babylon.module.d.ts 5.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * 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.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * 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).
  163. * 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.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @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.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Instrumentation/timeToken" {
  586. import { Nullable } from "babylonjs/types";
  587. /**
  588. * @hidden
  589. **/
  590. export class _TimeToken {
  591. _startTimeQuery: Nullable<WebGLQuery>;
  592. _endTimeQuery: Nullable<WebGLQuery>;
  593. _timeElapsedQuery: Nullable<WebGLQuery>;
  594. _timeElapsedQueryEnded: boolean;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** 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 */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** 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 */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** 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 */
  693. static readonly GEQUAL: number;
  694. /** 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 */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** Bilinear is mag = linear and min = linear and mip = nearest */
  779. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** nearest is mag = nearest and min = nearest and mip = linear */
  783. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  784. /** Bilinear is mag = linear and min = linear and mip = nearest */
  785. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** mag = nearest and min = nearest and mip = none */
  797. static readonly TEXTURE_NEAREST_NEAREST: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** mag = linear and min = linear and mip = none */
  803. static readonly TEXTURE_LINEAR_LINEAR: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * 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.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * 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.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1065. * @param fallback defines the fallback internal texture if any
  1066. * @param isBase64 defines whether the texture is encoded as a base64
  1067. * @param isBuffer defines whether the texture data are stored as a buffer
  1068. * @returns true if the loader can load the specified file
  1069. */
  1070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1071. /**
  1072. * Transform the url before loading if required.
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the transformed texture
  1076. */
  1077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1078. /**
  1079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1080. * @param rootUrl the url of the texture
  1081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1082. * @returns the fallback texture
  1083. */
  1084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1085. /**
  1086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param createPolynomials will be true if polynomials have been requested
  1090. * @param onLoad defines the callback to trigger once the texture is ready
  1091. * @param onError defines the callback to trigger in case of error
  1092. */
  1093. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1094. /**
  1095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1096. * @param data contains the texture data
  1097. * @param texture defines the BabylonJS internal texture
  1098. * @param callback defines the method to call once ready to upload
  1099. */
  1100. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1101. }
  1102. }
  1103. declare module "babylonjs/Engines/IPipelineContext" {
  1104. /**
  1105. * Class used to store and describe the pipeline context associated with an effect
  1106. */
  1107. export interface IPipelineContext {
  1108. /**
  1109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1110. */
  1111. isAsync: boolean;
  1112. /**
  1113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1114. */
  1115. isReady: boolean;
  1116. /** @hidden */
  1117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1118. }
  1119. }
  1120. declare module "babylonjs/Meshes/dataBuffer" {
  1121. /**
  1122. * Class used to store gfx data (like WebGLBuffer)
  1123. */
  1124. export class DataBuffer {
  1125. /**
  1126. * Gets or sets the number of objects referencing this buffer
  1127. */
  1128. references: number;
  1129. /** Gets or sets the size of the underlying buffer */
  1130. capacity: number;
  1131. /**
  1132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1133. */
  1134. is32Bits: boolean;
  1135. /**
  1136. * Gets the underlying buffer
  1137. */
  1138. get underlyingResource(): any;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1142. /** @hidden */
  1143. export interface IShaderProcessor {
  1144. attributeProcessor?: (attribute: string) => string;
  1145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1149. lineProcessor?: (line: string, isFragment: boolean) => string;
  1150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1156. /** @hidden */
  1157. export interface ProcessingOptions {
  1158. defines: string[];
  1159. indexParameters: any;
  1160. isFragment: boolean;
  1161. shouldUseHighPrecisionShader: boolean;
  1162. supportsUniformBuffers: boolean;
  1163. shadersRepository: string;
  1164. includesShadersStore: {
  1165. [key: string]: string;
  1166. };
  1167. processor?: IShaderProcessor;
  1168. version: string;
  1169. platformName: string;
  1170. lookForClosingBracketForUniformBuffer?: boolean;
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1174. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1175. /** @hidden */
  1176. export class ShaderCodeNode {
  1177. line: string;
  1178. children: ShaderCodeNode[];
  1179. additionalDefineKey?: string;
  1180. additionalDefineValue?: string;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. process(preprocessors: {
  1185. [key: string]: string;
  1186. }, options: ProcessingOptions): string;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1190. /** @hidden */
  1191. export class ShaderCodeCursor {
  1192. private _lines;
  1193. lineIndex: number;
  1194. get currentLine(): string;
  1195. get canRead(): boolean;
  1196. set lines(value: string[]);
  1197. }
  1198. }
  1199. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1200. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1201. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1202. /** @hidden */
  1203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1204. process(preprocessors: {
  1205. [key: string]: string;
  1206. }, options: ProcessingOptions): string;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1210. /** @hidden */
  1211. export class ShaderDefineExpression {
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1218. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderCodeTestNode extends ShaderCodeNode {
  1222. testExpression: ShaderDefineExpression;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1232. define: string;
  1233. not: boolean;
  1234. constructor(define: string, not?: boolean);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1241. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1242. /** @hidden */
  1243. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1244. leftOperand: ShaderDefineExpression;
  1245. rightOperand: ShaderDefineExpression;
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1252. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. operand: string;
  1268. testValue: string;
  1269. constructor(define: string, operand: string, testValue: string);
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Offline/IOfflineProvider" {
  1276. /**
  1277. * Class used to enable access to offline support
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. export interface IOfflineProvider {
  1281. /**
  1282. * Gets a boolean indicating if scene must be saved in the database
  1283. */
  1284. enableSceneOffline: boolean;
  1285. /**
  1286. * Gets a boolean indicating if textures must be saved in the database
  1287. */
  1288. enableTexturesOffline: boolean;
  1289. /**
  1290. * Open the offline support and make it available
  1291. * @param successCallback defines the callback to call on success
  1292. * @param errorCallback defines the callback to call on error
  1293. */
  1294. open(successCallback: () => void, errorCallback: () => void): void;
  1295. /**
  1296. * Loads an image from the offline support
  1297. * @param url defines the url to load from
  1298. * @param image defines the target DOM image
  1299. */
  1300. loadImage(url: string, image: HTMLImageElement): void;
  1301. /**
  1302. * Loads a file from offline support
  1303. * @param url defines the URL to load from
  1304. * @param sceneLoaded defines a callback to call on success
  1305. * @param progressCallBack defines a callback to call when progress changed
  1306. * @param errorCallback defines a callback to call on error
  1307. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1308. */
  1309. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1310. }
  1311. }
  1312. declare module "babylonjs/Misc/filesInputStore" {
  1313. /**
  1314. * Class used to help managing file picking and drag'n'drop
  1315. * File Storage
  1316. */
  1317. export class FilesInputStore {
  1318. /**
  1319. * List of files ready to be loaded
  1320. */
  1321. static FilesToLoad: {
  1322. [key: string]: File;
  1323. };
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/retryStrategy" {
  1327. import { WebRequest } from "babylonjs/Misc/webRequest";
  1328. /**
  1329. * Class used to define a retry strategy when error happens while loading assets
  1330. */
  1331. export class RetryStrategy {
  1332. /**
  1333. * Function used to defines an exponential back off strategy
  1334. * @param maxRetries defines the maximum number of retries (3 by default)
  1335. * @param baseInterval defines the interval between retries
  1336. * @returns the strategy function to use
  1337. */
  1338. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/baseError" {
  1342. /**
  1343. * @ignore
  1344. * Application error to support additional information when loading a file
  1345. */
  1346. export abstract class BaseError extends Error {
  1347. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/fileTools" {
  1351. import { WebRequest } from "babylonjs/Misc/webRequest";
  1352. import { Nullable } from "babylonjs/types";
  1353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1354. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1355. import { BaseError } from "babylonjs/Misc/baseError";
  1356. /** @ignore */
  1357. export class LoadFileError extends BaseError {
  1358. request?: WebRequest;
  1359. file?: File;
  1360. /**
  1361. * Creates a new LoadFileError
  1362. * @param message defines the message of the error
  1363. * @param request defines the optional web request
  1364. * @param file defines the optional file
  1365. */
  1366. constructor(message: string, object?: WebRequest | File);
  1367. }
  1368. /** @ignore */
  1369. export class RequestFileError extends BaseError {
  1370. request: WebRequest;
  1371. /**
  1372. * Creates a new LoadFileError
  1373. * @param message defines the message of the error
  1374. * @param request defines the optional web request
  1375. */
  1376. constructor(message: string, request: WebRequest);
  1377. }
  1378. /** @ignore */
  1379. export class ReadFileError extends BaseError {
  1380. file: File;
  1381. /**
  1382. * Creates a new ReadFileError
  1383. * @param message defines the message of the error
  1384. * @param file defines the optional file
  1385. */
  1386. constructor(message: string, file: File);
  1387. }
  1388. /**
  1389. * @hidden
  1390. */
  1391. export class FileTools {
  1392. /**
  1393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1394. */
  1395. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1396. /**
  1397. * Gets or sets the base URL to use to load assets
  1398. */
  1399. static BaseUrl: string;
  1400. /**
  1401. * Default behaviour for cors in the application.
  1402. * It can be a string if the expected behavior is identical in the entire app.
  1403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1404. */
  1405. static CorsBehavior: string | ((url: string | string[]) => string);
  1406. /**
  1407. * Gets or sets a function used to pre-process url before using them to load assets
  1408. */
  1409. static PreprocessUrl: (url: string) => string;
  1410. /**
  1411. * Removes unwanted characters from an url
  1412. * @param url defines the url to clean
  1413. * @returns the cleaned url
  1414. */
  1415. private static _CleanUrl;
  1416. /**
  1417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1418. * @param url define the url we are trying
  1419. * @param element define the dom element where to configure the cors policy
  1420. */
  1421. static SetCorsBehavior(url: string | string[], element: {
  1422. crossOrigin: string | null;
  1423. }): void;
  1424. /**
  1425. * Loads an image as an HTMLImageElement.
  1426. * @param input url string, ArrayBuffer, or Blob to load
  1427. * @param onLoad callback called when the image successfully loads
  1428. * @param onError callback called when the image fails to load
  1429. * @param offlineProvider offline provider for caching
  1430. * @param mimeType optional mime type
  1431. * @returns the HTMLImageElement of the loaded image
  1432. */
  1433. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1434. /**
  1435. * Reads a file from a File object
  1436. * @param file defines the file to load
  1437. * @param onSuccess defines the callback to call when data is loaded
  1438. * @param onProgress defines the callback to call during loading process
  1439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1440. * @param onError defines the callback to call when an error occurs
  1441. * @returns a file request object
  1442. */
  1443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1444. /**
  1445. * Loads a file from a url
  1446. * @param url url to load
  1447. * @param onSuccess callback called when the file successfully loads
  1448. * @param onProgress callback called while file is loading (if the server supports this mode)
  1449. * @param offlineProvider defines the offline provider for caching
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @returns a file request object
  1453. */
  1454. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1455. /**
  1456. * Loads a file
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1461. * @param onError callback called when the file fails to load
  1462. * @param onOpened callback called when the web request is opened
  1463. * @returns a file request object
  1464. */
  1465. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1466. /**
  1467. * Checks if the loaded document was accessed via `file:`-Protocol.
  1468. * @returns boolean
  1469. */
  1470. static IsFileURL(): boolean;
  1471. }
  1472. }
  1473. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1474. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1475. /** @hidden */
  1476. export class ShaderProcessor {
  1477. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1478. private static _ProcessPrecision;
  1479. private static _ExtractOperation;
  1480. private static _BuildSubExpression;
  1481. private static _BuildExpression;
  1482. private static _MoveCursorWithinIf;
  1483. private static _MoveCursor;
  1484. private static _EvaluatePreProcessors;
  1485. private static _PreparePreProcessors;
  1486. private static _ProcessShaderConversion;
  1487. private static _ProcessIncludes;
  1488. }
  1489. }
  1490. declare module "babylonjs/Maths/math.like" {
  1491. import { float, int, DeepImmutable } from "babylonjs/types";
  1492. /**
  1493. * @hidden
  1494. */
  1495. export interface IColor4Like {
  1496. r: float;
  1497. g: float;
  1498. b: float;
  1499. a: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IColor3Like {
  1505. r: float;
  1506. g: float;
  1507. b: float;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IVector4Like {
  1513. x: float;
  1514. y: float;
  1515. z: float;
  1516. w: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IVector3Like {
  1522. x: float;
  1523. y: float;
  1524. z: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IVector2Like {
  1530. x: float;
  1531. y: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IMatrixLike {
  1537. toArray(): DeepImmutable<Float32Array>;
  1538. updateFlag: int;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IViewportLike {
  1544. x: float;
  1545. y: float;
  1546. width: float;
  1547. height: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IPlaneLike {
  1553. normal: IVector3Like;
  1554. d: float;
  1555. normalize(): void;
  1556. }
  1557. }
  1558. declare module "babylonjs/Materials/iEffectFallbacks" {
  1559. import { Effect } from "babylonjs/Materials/effect";
  1560. /**
  1561. * Interface used to define common properties for effect fallbacks
  1562. */
  1563. export interface IEffectFallbacks {
  1564. /**
  1565. * Removes the defines that should be removed when falling back.
  1566. * @param currentDefines defines the current define statements for the shader.
  1567. * @param effect defines the current effect we try to compile
  1568. * @returns The resulting defines with defines of the current rank removed.
  1569. */
  1570. reduce(currentDefines: string, effect: Effect): string;
  1571. /**
  1572. * Removes the fallback from the bound mesh.
  1573. */
  1574. unBindMesh(): void;
  1575. /**
  1576. * Checks to see if more fallbacks are still availible.
  1577. */
  1578. hasMoreFallbacks: boolean;
  1579. }
  1580. }
  1581. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1582. /**
  1583. * Class used to evalaute queries containing `and` and `or` operators
  1584. */
  1585. export class AndOrNotEvaluator {
  1586. /**
  1587. * Evaluate a query
  1588. * @param query defines the query to evaluate
  1589. * @param evaluateCallback defines the callback used to filter result
  1590. * @returns true if the query matches
  1591. */
  1592. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1593. private static _HandleParenthesisContent;
  1594. private static _SimplifyNegation;
  1595. }
  1596. }
  1597. declare module "babylonjs/Misc/tags" {
  1598. /**
  1599. * Class used to store custom tags
  1600. */
  1601. export class Tags {
  1602. /**
  1603. * Adds support for tags on the given object
  1604. * @param obj defines the object to use
  1605. */
  1606. static EnableFor(obj: any): void;
  1607. /**
  1608. * Removes tags support
  1609. * @param obj defines the object to use
  1610. */
  1611. static DisableFor(obj: any): void;
  1612. /**
  1613. * Gets a boolean indicating if the given object has tags
  1614. * @param obj defines the object to use
  1615. * @returns a boolean
  1616. */
  1617. static HasTags(obj: any): boolean;
  1618. /**
  1619. * Gets the tags available on a given object
  1620. * @param obj defines the object to use
  1621. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1622. * @returns the tags
  1623. */
  1624. static GetTags(obj: any, asString?: boolean): any;
  1625. /**
  1626. * Adds tags to an object
  1627. * @param obj defines the object to use
  1628. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1629. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1630. */
  1631. static AddTagsTo(obj: any, tagsString: string): void;
  1632. /**
  1633. * @hidden
  1634. */
  1635. static _AddTagTo(obj: any, tag: string): void;
  1636. /**
  1637. * Removes specific tags from a specific object
  1638. * @param obj defines the object to use
  1639. * @param tagsString defines the tags to remove
  1640. */
  1641. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1642. /**
  1643. * @hidden
  1644. */
  1645. static _RemoveTagFrom(obj: any, tag: string): void;
  1646. /**
  1647. * Defines if tags hosted on an object match a given query
  1648. * @param obj defines the object to use
  1649. * @param tagsQuery defines the tag query
  1650. * @returns a boolean
  1651. */
  1652. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1653. }
  1654. }
  1655. declare module "babylonjs/Maths/math.scalar" {
  1656. /**
  1657. * Scalar computation library
  1658. */
  1659. export class Scalar {
  1660. /**
  1661. * Two pi constants convenient for computation.
  1662. */
  1663. static TwoPi: number;
  1664. /**
  1665. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1666. * @param a number
  1667. * @param b number
  1668. * @param epsilon (default = 1.401298E-45)
  1669. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1670. */
  1671. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1672. /**
  1673. * Returns a string : the upper case translation of the number i to hexadecimal.
  1674. * @param i number
  1675. * @returns the upper case translation of the number i to hexadecimal.
  1676. */
  1677. static ToHex(i: number): string;
  1678. /**
  1679. * Returns -1 if value is negative and +1 is value is positive.
  1680. * @param value the value
  1681. * @returns the value itself if it's equal to zero.
  1682. */
  1683. static Sign(value: number): number;
  1684. /**
  1685. * Returns the value itself if it's between min and max.
  1686. * Returns min if the value is lower than min.
  1687. * Returns max if the value is greater than max.
  1688. * @param value the value to clmap
  1689. * @param min the min value to clamp to (default: 0)
  1690. * @param max the max value to clamp to (default: 1)
  1691. * @returns the clamped value
  1692. */
  1693. static Clamp(value: number, min?: number, max?: number): number;
  1694. /**
  1695. * the log2 of value.
  1696. * @param value the value to compute log2 of
  1697. * @returns the log2 of value.
  1698. */
  1699. static Log2(value: number): number;
  1700. /**
  1701. * Loops the value, so that it is never larger than length and never smaller than 0.
  1702. *
  1703. * This is similar to the modulo operator but it works with floating point numbers.
  1704. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1705. * With t = 5 and length = 2.5, the result would be 0.0.
  1706. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1707. * @param value the value
  1708. * @param length the length
  1709. * @returns the looped value
  1710. */
  1711. static Repeat(value: number, length: number): number;
  1712. /**
  1713. * Normalize the value between 0.0 and 1.0 using min and max values
  1714. * @param value value to normalize
  1715. * @param min max to normalize between
  1716. * @param max min to normalize between
  1717. * @returns the normalized value
  1718. */
  1719. static Normalize(value: number, min: number, max: number): number;
  1720. /**
  1721. * Denormalize the value from 0.0 and 1.0 using min and max values
  1722. * @param normalized value to denormalize
  1723. * @param min max to denormalize between
  1724. * @param max min to denormalize between
  1725. * @returns the denormalized value
  1726. */
  1727. static Denormalize(normalized: number, min: number, max: number): number;
  1728. /**
  1729. * Calculates the shortest difference between two given angles given in degrees.
  1730. * @param current current angle in degrees
  1731. * @param target target angle in degrees
  1732. * @returns the delta
  1733. */
  1734. static DeltaAngle(current: number, target: number): number;
  1735. /**
  1736. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1737. * @param tx value
  1738. * @param length length
  1739. * @returns The returned value will move back and forth between 0 and length
  1740. */
  1741. static PingPong(tx: number, length: number): number;
  1742. /**
  1743. * Interpolates between min and max with smoothing at the limits.
  1744. *
  1745. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1746. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1747. * @param from from
  1748. * @param to to
  1749. * @param tx value
  1750. * @returns the smooth stepped value
  1751. */
  1752. static SmoothStep(from: number, to: number, tx: number): number;
  1753. /**
  1754. * Moves a value current towards target.
  1755. *
  1756. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1757. * Negative values of maxDelta pushes the value away from target.
  1758. * @param current current value
  1759. * @param target target value
  1760. * @param maxDelta max distance to move
  1761. * @returns resulting value
  1762. */
  1763. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1764. /**
  1765. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1766. *
  1767. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1768. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1769. * @param current current value
  1770. * @param target target value
  1771. * @param maxDelta max distance to move
  1772. * @returns resulting angle
  1773. */
  1774. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1775. /**
  1776. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1777. * @param start start value
  1778. * @param end target value
  1779. * @param amount amount to lerp between
  1780. * @returns the lerped value
  1781. */
  1782. static Lerp(start: number, end: number, amount: number): number;
  1783. /**
  1784. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1785. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1786. * @param start start value
  1787. * @param end target value
  1788. * @param amount amount to lerp between
  1789. * @returns the lerped value
  1790. */
  1791. static LerpAngle(start: number, end: number, amount: number): number;
  1792. /**
  1793. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1794. * @param a start value
  1795. * @param b target value
  1796. * @param value value between a and b
  1797. * @returns the inverseLerp value
  1798. */
  1799. static InverseLerp(a: number, b: number, value: number): number;
  1800. /**
  1801. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1802. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1803. * @param value1 spline value
  1804. * @param tangent1 spline value
  1805. * @param value2 spline value
  1806. * @param tangent2 spline value
  1807. * @param amount input value
  1808. * @returns hermite result
  1809. */
  1810. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1811. /**
  1812. * Returns a random float number between and min and max values
  1813. * @param min min value of random
  1814. * @param max max value of random
  1815. * @returns random value
  1816. */
  1817. static RandomRange(min: number, max: number): number;
  1818. /**
  1819. * This function returns percentage of a number in a given range.
  1820. *
  1821. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1822. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1823. * @param number to convert to percentage
  1824. * @param min min range
  1825. * @param max max range
  1826. * @returns the percentage
  1827. */
  1828. static RangeToPercent(number: number, min: number, max: number): number;
  1829. /**
  1830. * This function returns number that corresponds to the percentage in a given range.
  1831. *
  1832. * PercentToRange(0.34,0,100) will return 34.
  1833. * @param percent to convert to number
  1834. * @param min min range
  1835. * @param max max range
  1836. * @returns the number
  1837. */
  1838. static PercentToRange(percent: number, min: number, max: number): number;
  1839. /**
  1840. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1841. * @param angle The angle to normalize in radian.
  1842. * @return The converted angle.
  1843. */
  1844. static NormalizeRadians(angle: number): number;
  1845. }
  1846. }
  1847. declare module "babylonjs/Maths/math.constants" {
  1848. /**
  1849. * Constant used to convert a value to gamma space
  1850. * @ignorenaming
  1851. */
  1852. export const ToGammaSpace: number;
  1853. /**
  1854. * Constant used to convert a value to linear space
  1855. * @ignorenaming
  1856. */
  1857. export const ToLinearSpace = 2.2;
  1858. /**
  1859. * Constant used to define the minimal number value in Babylon.js
  1860. * @ignorenaming
  1861. */
  1862. let Epsilon: number;
  1863. export { Epsilon };
  1864. }
  1865. declare module "babylonjs/Maths/math.viewport" {
  1866. /**
  1867. * Class used to represent a viewport on screen
  1868. */
  1869. export class Viewport {
  1870. /** viewport left coordinate */
  1871. x: number;
  1872. /** viewport top coordinate */
  1873. y: number;
  1874. /**viewport width */
  1875. width: number;
  1876. /** viewport height */
  1877. height: number;
  1878. /**
  1879. * Creates a Viewport object located at (x, y) and sized (width, height)
  1880. * @param x defines viewport left coordinate
  1881. * @param y defines viewport top coordinate
  1882. * @param width defines the viewport width
  1883. * @param height defines the viewport height
  1884. */
  1885. constructor(
  1886. /** viewport left coordinate */
  1887. x: number,
  1888. /** viewport top coordinate */
  1889. y: number,
  1890. /**viewport width */
  1891. width: number,
  1892. /** viewport height */
  1893. height: number);
  1894. /**
  1895. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @returns a new Viewport
  1899. */
  1900. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1901. /**
  1902. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1903. * @param renderWidth defines the rendering width
  1904. * @param renderHeight defines the rendering height
  1905. * @param ref defines the target viewport
  1906. * @returns the current viewport
  1907. */
  1908. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1909. /**
  1910. * Returns a new Viewport copied from the current one
  1911. * @returns a new Viewport
  1912. */
  1913. clone(): Viewport;
  1914. }
  1915. }
  1916. declare module "babylonjs/Misc/arrayTools" {
  1917. /**
  1918. * Class containing a set of static utilities functions for arrays.
  1919. */
  1920. export class ArrayTools {
  1921. /**
  1922. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1923. * @param size the number of element to construct and put in the array
  1924. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1925. * @returns a new array filled with new objects
  1926. */
  1927. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1928. }
  1929. }
  1930. declare module "babylonjs/Maths/math.vector" {
  1931. import { Viewport } from "babylonjs/Maths/math.viewport";
  1932. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1933. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1934. /**
  1935. * Class representing a vector containing 2 coordinates
  1936. */
  1937. export class Vector2 {
  1938. /** defines the first coordinate */
  1939. x: number;
  1940. /** defines the second coordinate */
  1941. y: number;
  1942. /**
  1943. * Creates a new Vector2 from the given x and y coordinates
  1944. * @param x defines the first coordinate
  1945. * @param y defines the second coordinate
  1946. */
  1947. constructor(
  1948. /** defines the first coordinate */
  1949. x?: number,
  1950. /** defines the second coordinate */
  1951. y?: number);
  1952. /**
  1953. * Gets a string with the Vector2 coordinates
  1954. * @returns a string with the Vector2 coordinates
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Gets class name
  1959. * @returns the string "Vector2"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Gets current vector hash code
  1964. * @returns the Vector2 hash code as a number
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1969. * @param array defines the source array
  1970. * @param index defines the offset in source array
  1971. * @returns the current Vector2
  1972. */
  1973. toArray(array: FloatArray, index?: number): Vector2;
  1974. /**
  1975. * Copy the current vector to an array
  1976. * @returns a new array with 2 elements: the Vector2 coordinates.
  1977. */
  1978. asArray(): number[];
  1979. /**
  1980. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1981. * @param source defines the source Vector2
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. copyFromFloats(x: number, y: number): Vector2;
  1992. /**
  1993. * Sets the Vector2 coordinates with the given floats
  1994. * @param x defines the first coordinate
  1995. * @param y defines the second coordinate
  1996. * @returns the current updated Vector2
  1997. */
  1998. set(x: number, y: number): Vector2;
  1999. /**
  2000. * Add another vector with the current one
  2001. * @param otherVector defines the other vector
  2002. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2003. */
  2004. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2005. /**
  2006. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2007. * @param otherVector defines the other vector
  2008. * @param result defines the target vector
  2009. * @returns the unmodified current Vector2
  2010. */
  2011. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2012. /**
  2013. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2014. * @param otherVector defines the other vector
  2015. * @returns the current updated Vector2
  2016. */
  2017. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2018. /**
  2019. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2020. * @param otherVector defines the other vector
  2021. * @returns a new Vector2
  2022. */
  2023. addVector3(otherVector: Vector3): Vector2;
  2024. /**
  2025. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2026. * @param otherVector defines the other vector
  2027. * @returns a new Vector2
  2028. */
  2029. subtract(otherVector: Vector2): Vector2;
  2030. /**
  2031. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2032. * @param otherVector defines the other vector
  2033. * @param result defines the target vector
  2034. * @returns the unmodified current Vector2
  2035. */
  2036. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2037. /**
  2038. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @returns the current updated Vector2
  2041. */
  2042. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2043. /**
  2044. * Multiplies in place the current Vector2 coordinates by the given ones
  2045. * @param otherVector defines the other vector
  2046. * @returns the current updated Vector2
  2047. */
  2048. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2049. /**
  2050. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2051. * @param otherVector defines the other vector
  2052. * @returns a new Vector2
  2053. */
  2054. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2055. /**
  2056. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @param result defines the target vector
  2059. * @returns the unmodified current Vector2
  2060. */
  2061. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2062. /**
  2063. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2064. * @param x defines the first coordinate
  2065. * @param y defines the second coordinate
  2066. * @returns a new Vector2
  2067. */
  2068. multiplyByFloats(x: number, y: number): Vector2;
  2069. /**
  2070. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2071. * @param otherVector defines the other vector
  2072. * @returns a new Vector2
  2073. */
  2074. divide(otherVector: Vector2): Vector2;
  2075. /**
  2076. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2077. * @param otherVector defines the other vector
  2078. * @param result defines the target vector
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2082. /**
  2083. * Divides the current Vector2 coordinates by the given ones
  2084. * @param otherVector defines the other vector
  2085. * @returns the current updated Vector2
  2086. */
  2087. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2088. /**
  2089. * Gets a new Vector2 with current Vector2 negated coordinates
  2090. * @returns a new Vector2
  2091. */
  2092. negate(): Vector2;
  2093. /**
  2094. * Multiply the Vector2 coordinates by scale
  2095. * @param scale defines the scaling factor
  2096. * @returns the current updated Vector2
  2097. */
  2098. scaleInPlace(scale: number): Vector2;
  2099. /**
  2100. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2101. * @param scale defines the scaling factor
  2102. * @returns a new Vector2
  2103. */
  2104. scale(scale: number): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2114. * @param scale defines the scale factor
  2115. * @param result defines the Vector2 object where to store the result
  2116. * @returns the unmodified current Vector2
  2117. */
  2118. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2119. /**
  2120. * Gets a boolean if two vectors are equals
  2121. * @param otherVector defines the other vector
  2122. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2123. */
  2124. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2125. /**
  2126. * Gets a boolean if two vectors are equals (using an epsilon value)
  2127. * @param otherVector defines the other vector
  2128. * @param epsilon defines the minimal distance to consider equality
  2129. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2130. */
  2131. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2132. /**
  2133. * Gets a new Vector2 from current Vector2 floored values
  2134. * @returns a new Vector2
  2135. */
  2136. floor(): Vector2;
  2137. /**
  2138. * Gets a new Vector2 from current Vector2 floored values
  2139. * @returns a new Vector2
  2140. */
  2141. fract(): Vector2;
  2142. /**
  2143. * Gets the length of the vector
  2144. * @returns the vector length (float)
  2145. */
  2146. length(): number;
  2147. /**
  2148. * Gets the vector squared length
  2149. * @returns the vector squared length (float)
  2150. */
  2151. lengthSquared(): number;
  2152. /**
  2153. * Normalize the vector
  2154. * @returns the current updated Vector2
  2155. */
  2156. normalize(): Vector2;
  2157. /**
  2158. * Gets a new Vector2 copied from the Vector2
  2159. * @returns a new Vector2
  2160. */
  2161. clone(): Vector2;
  2162. /**
  2163. * Gets a new Vector2(0, 0)
  2164. * @returns a new Vector2
  2165. */
  2166. static Zero(): Vector2;
  2167. /**
  2168. * Gets a new Vector2(1, 1)
  2169. * @returns a new Vector2
  2170. */
  2171. static One(): Vector2;
  2172. /**
  2173. * Gets a new Vector2 set from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @returns a new Vector2
  2177. */
  2178. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2179. /**
  2180. * Sets "result" from the given index element of the given array
  2181. * @param array defines the data source
  2182. * @param offset defines the offset in the data source
  2183. * @param result defines the target vector
  2184. */
  2185. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2186. /**
  2187. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2188. * @param value1 defines 1st point of control
  2189. * @param value2 defines 2nd point of control
  2190. * @param value3 defines 3rd point of control
  2191. * @param value4 defines 4th point of control
  2192. * @param amount defines the interpolation factor
  2193. * @returns a new Vector2
  2194. */
  2195. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2196. /**
  2197. * 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".
  2198. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2199. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2200. * @param value defines the value to clamp
  2201. * @param min defines the lower limit
  2202. * @param max defines the upper limit
  2203. * @returns a new Vector2
  2204. */
  2205. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2208. * @param value1 defines the 1st control point
  2209. * @param tangent1 defines the outgoing tangent
  2210. * @param value2 defines the 2nd control point
  2211. * @param tangent2 defines the incoming tangent
  2212. * @param amount defines the interpolation factor
  2213. * @returns a new Vector2
  2214. */
  2215. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2216. /**
  2217. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2218. * @param start defines the start vector
  2219. * @param end defines the end vector
  2220. * @param amount defines the interpolation factor
  2221. * @returns a new Vector2
  2222. */
  2223. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2224. /**
  2225. * Gets the dot product of the vector "left" and the vector "right"
  2226. * @param left defines first vector
  2227. * @param right defines second vector
  2228. * @returns the dot product (float)
  2229. */
  2230. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2231. /**
  2232. * Returns a new Vector2 equal to the normalized given vector
  2233. * @param vector defines the vector to normalize
  2234. * @returns a new Vector2
  2235. */
  2236. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2246. * @param left defines 1st vector
  2247. * @param right defines 2nd vector
  2248. * @returns a new Vector2
  2249. */
  2250. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2251. /**
  2252. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @returns a new Vector2
  2256. */
  2257. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2258. /**
  2259. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2260. * @param vector defines the vector to transform
  2261. * @param transformation defines the matrix to apply
  2262. * @param result defines the target vector
  2263. */
  2264. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2265. /**
  2266. * Determines if a given vector is included in a triangle
  2267. * @param p defines the vector to test
  2268. * @param p0 defines 1st triangle point
  2269. * @param p1 defines 2nd triangle point
  2270. * @param p2 defines 3rd triangle point
  2271. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2272. */
  2273. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2274. /**
  2275. * Gets the distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the distance between vectors
  2279. */
  2280. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Returns the squared distance between the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns the squared distance between vectors
  2286. */
  2287. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2288. /**
  2289. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2290. * @param value1 defines first vector
  2291. * @param value2 defines second vector
  2292. * @returns a new Vector2
  2293. */
  2294. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2295. /**
  2296. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2297. * @param p defines the middle point
  2298. * @param segA defines one point of the segment
  2299. * @param segB defines the other point of the segment
  2300. * @returns the shortest distance
  2301. */
  2302. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2303. }
  2304. /**
  2305. * Class used to store (x,y,z) vector representation
  2306. * A Vector3 is the main object used in 3D geometry
  2307. * It can represent etiher the coordinates of a point the space, either a direction
  2308. * Reminder: js uses a left handed forward facing system
  2309. */
  2310. export class Vector3 {
  2311. /**
  2312. * Defines the first coordinates (on X axis)
  2313. */
  2314. x: number;
  2315. /**
  2316. * Defines the second coordinates (on Y axis)
  2317. */
  2318. y: number;
  2319. /**
  2320. * Defines the third coordinates (on Z axis)
  2321. */
  2322. z: number;
  2323. private static _UpReadOnly;
  2324. private static _ZeroReadOnly;
  2325. /**
  2326. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2327. * @param x defines the first coordinates (on X axis)
  2328. * @param y defines the second coordinates (on Y axis)
  2329. * @param z defines the third coordinates (on Z axis)
  2330. */
  2331. constructor(
  2332. /**
  2333. * Defines the first coordinates (on X axis)
  2334. */
  2335. x?: number,
  2336. /**
  2337. * Defines the second coordinates (on Y axis)
  2338. */
  2339. y?: number,
  2340. /**
  2341. * Defines the third coordinates (on Z axis)
  2342. */
  2343. z?: number);
  2344. /**
  2345. * Creates a string representation of the Vector3
  2346. * @returns a string with the Vector3 coordinates.
  2347. */
  2348. toString(): string;
  2349. /**
  2350. * Gets the class name
  2351. * @returns the string "Vector3"
  2352. */
  2353. getClassName(): string;
  2354. /**
  2355. * Creates the Vector3 hash code
  2356. * @returns a number which tends to be unique between Vector3 instances
  2357. */
  2358. getHashCode(): number;
  2359. /**
  2360. * Creates an array containing three elements : the coordinates of the Vector3
  2361. * @returns a new array of numbers
  2362. */
  2363. asArray(): number[];
  2364. /**
  2365. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2366. * @param array defines the destination array
  2367. * @param index defines the offset in the destination array
  2368. * @returns the current Vector3
  2369. */
  2370. toArray(array: FloatArray, index?: number): Vector3;
  2371. /**
  2372. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2373. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2374. */
  2375. toQuaternion(): Quaternion;
  2376. /**
  2377. * Adds the given vector to the current Vector3
  2378. * @param otherVector defines the second operand
  2379. * @returns the current updated Vector3
  2380. */
  2381. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2382. /**
  2383. * Adds the given coordinates to the current Vector3
  2384. * @param x defines the x coordinate of the operand
  2385. * @param y defines the y coordinate of the operand
  2386. * @param z defines the z coordinate of the operand
  2387. * @returns the current updated Vector3
  2388. */
  2389. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2390. /**
  2391. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2392. * @param otherVector defines the second operand
  2393. * @returns the resulting Vector3
  2394. */
  2395. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2396. /**
  2397. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2398. * @param otherVector defines the second operand
  2399. * @param result defines the Vector3 object where to store the result
  2400. * @returns the current Vector3
  2401. */
  2402. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2403. /**
  2404. * Subtract the given vector from the current Vector3
  2405. * @param otherVector defines the second operand
  2406. * @returns the current updated Vector3
  2407. */
  2408. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2409. /**
  2410. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2411. * @param otherVector defines the second operand
  2412. * @returns the resulting Vector3
  2413. */
  2414. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2415. /**
  2416. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2417. * @param otherVector defines the second operand
  2418. * @param result defines the Vector3 object where to store the result
  2419. * @returns the current Vector3
  2420. */
  2421. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2422. /**
  2423. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2424. * @param x defines the x coordinate of the operand
  2425. * @param y defines the y coordinate of the operand
  2426. * @param z defines the z coordinate of the operand
  2427. * @returns the resulting Vector3
  2428. */
  2429. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2430. /**
  2431. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2432. * @param x defines the x coordinate of the operand
  2433. * @param y defines the y coordinate of the operand
  2434. * @param z defines the z coordinate of the operand
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2439. /**
  2440. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2441. * @returns a new Vector3
  2442. */
  2443. negate(): Vector3;
  2444. /**
  2445. * Multiplies the Vector3 coordinates by the float "scale"
  2446. * @param scale defines the multiplier factor
  2447. * @returns the current updated Vector3
  2448. */
  2449. scaleInPlace(scale: number): Vector3;
  2450. /**
  2451. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2452. * @param scale defines the multiplier factor
  2453. * @returns a new Vector3
  2454. */
  2455. scale(scale: number): Vector3;
  2456. /**
  2457. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2458. * @param scale defines the multiplier factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the current Vector3
  2461. */
  2462. scaleToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2465. * @param scale defines the scale factor
  2466. * @param result defines the Vector3 object where to store the result
  2467. * @returns the unmodified current Vector3
  2468. */
  2469. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2470. /**
  2471. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2472. * @param otherVector defines the second operand
  2473. * @returns true if both vectors are equals
  2474. */
  2475. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2478. * @param otherVector defines the second operand
  2479. * @param epsilon defines the minimal distance to define values as equals
  2480. * @returns true if both vectors are distant less than epsilon
  2481. */
  2482. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2483. /**
  2484. * Returns true if the current Vector3 coordinates equals the given floats
  2485. * @param x defines the x coordinate of the operand
  2486. * @param y defines the y coordinate of the operand
  2487. * @param z defines the z coordinate of the operand
  2488. * @returns true if both vectors are equals
  2489. */
  2490. equalsToFloats(x: number, y: number, z: number): boolean;
  2491. /**
  2492. * Multiplies the current Vector3 coordinates by the given ones
  2493. * @param otherVector defines the second operand
  2494. * @returns the current updated Vector3
  2495. */
  2496. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2497. /**
  2498. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2499. * @param otherVector defines the second operand
  2500. * @returns the new Vector3
  2501. */
  2502. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2503. /**
  2504. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2505. * @param otherVector defines the second operand
  2506. * @param result defines the Vector3 object where to store the result
  2507. * @returns the current Vector3
  2508. */
  2509. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2510. /**
  2511. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2512. * @param x defines the x coordinate of the operand
  2513. * @param y defines the y coordinate of the operand
  2514. * @param z defines the z coordinate of the operand
  2515. * @returns the new Vector3
  2516. */
  2517. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2518. /**
  2519. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2520. * @param otherVector defines the second operand
  2521. * @returns the new Vector3
  2522. */
  2523. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Divides the current Vector3 coordinates by the given ones.
  2533. * @param otherVector defines the second operand
  2534. * @returns the current updated Vector3
  2535. */
  2536. divideInPlace(otherVector: Vector3): Vector3;
  2537. /**
  2538. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2539. * @param other defines the second operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2545. * @param other defines the second operand
  2546. * @returns the current updated Vector3
  2547. */
  2548. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2549. /**
  2550. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2551. * @param x defines the x coordinate of the operand
  2552. * @param y defines the y coordinate of the operand
  2553. * @param z defines the z coordinate of the operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2557. /**
  2558. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2567. * Check if is non uniform within a certain amount of decimal places to account for this
  2568. * @param epsilon the amount the values can differ
  2569. * @returns if the the vector is non uniform to a certain number of decimal places
  2570. */
  2571. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2572. /**
  2573. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2574. */
  2575. get isNonUniform(): boolean;
  2576. /**
  2577. * Gets a new Vector3 from current Vector3 floored values
  2578. * @returns a new Vector3
  2579. */
  2580. floor(): Vector3;
  2581. /**
  2582. * Gets a new Vector3 from current Vector3 floored values
  2583. * @returns a new Vector3
  2584. */
  2585. fract(): Vector3;
  2586. /**
  2587. * Gets the length of the Vector3
  2588. * @returns the length of the Vector3
  2589. */
  2590. length(): number;
  2591. /**
  2592. * Gets the squared length of the Vector3
  2593. * @returns squared length of the Vector3
  2594. */
  2595. lengthSquared(): number;
  2596. /**
  2597. * Normalize the current Vector3.
  2598. * Please note that this is an in place operation.
  2599. * @returns the current updated Vector3
  2600. */
  2601. normalize(): Vector3;
  2602. /**
  2603. * Reorders the x y z properties of the vector in place
  2604. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2605. * @returns the current updated vector
  2606. */
  2607. reorderInPlace(order: string): this;
  2608. /**
  2609. * Rotates the vector around 0,0,0 by a quaternion
  2610. * @param quaternion the rotation quaternion
  2611. * @param result vector to store the result
  2612. * @returns the resulting vector
  2613. */
  2614. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2615. /**
  2616. * Rotates a vector around a given point
  2617. * @param quaternion the rotation quaternion
  2618. * @param point the point to rotate around
  2619. * @param result vector to store the result
  2620. * @returns the resulting vector
  2621. */
  2622. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2623. /**
  2624. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2625. * The cross product is then orthogonal to both current and "other"
  2626. * @param other defines the right operand
  2627. * @returns the cross product
  2628. */
  2629. cross(other: Vector3): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 with the given input length.
  2632. * Please note that this is an in place operation.
  2633. * @param len the length of the vector
  2634. * @returns the current updated Vector3
  2635. */
  2636. normalizeFromLength(len: number): Vector3;
  2637. /**
  2638. * Normalize the current Vector3 to a new vector
  2639. * @returns the new Vector3
  2640. */
  2641. normalizeToNew(): Vector3;
  2642. /**
  2643. * Normalize the current Vector3 to the reference
  2644. * @param reference define the Vector3 to update
  2645. * @returns the updated Vector3
  2646. */
  2647. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2648. /**
  2649. * Creates a new Vector3 copied from the current Vector3
  2650. * @returns the new Vector3
  2651. */
  2652. clone(): Vector3;
  2653. /**
  2654. * Copies the given vector coordinates to the current Vector3 ones
  2655. * @param source defines the source Vector3
  2656. * @returns the current updated Vector3
  2657. */
  2658. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2659. /**
  2660. * Copies the given floats to the current Vector3 coordinates
  2661. * @param x defines the x coordinate of the operand
  2662. * @param y defines the y coordinate of the operand
  2663. * @param z defines the z coordinate of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. copyFromFloats(x: number, y: number, z: number): Vector3;
  2667. /**
  2668. * Copies the given floats to the current Vector3 coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. set(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Copies the given float to the current Vector3 coordinates
  2677. * @param v defines the x, y and z coordinates of the operand
  2678. * @returns the current updated Vector3
  2679. */
  2680. setAll(v: number): Vector3;
  2681. /**
  2682. * Get the clip factor between two vectors
  2683. * @param vector0 defines the first operand
  2684. * @param vector1 defines the second operand
  2685. * @param axis defines the axis to use
  2686. * @param size defines the size along the axis
  2687. * @returns the clip factor
  2688. */
  2689. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2690. /**
  2691. * Get angle between two vectors
  2692. * @param vector0 angle between vector0 and vector1
  2693. * @param vector1 angle between vector0 and vector1
  2694. * @param normal direction of the normal
  2695. * @return the angle between vector0 and vector1
  2696. */
  2697. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given array
  2700. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. */
  2704. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2707. * @param array defines the source array
  2708. * @param offset defines the offset in the source array
  2709. * @returns the new Vector3
  2710. * @deprecated Please use FromArray instead.
  2711. */
  2712. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. */
  2719. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2720. /**
  2721. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2722. * @param array defines the source array
  2723. * @param offset defines the offset in the source array
  2724. * @param result defines the Vector3 where to store the result
  2725. * @deprecated Please use FromArrayToRef instead.
  2726. */
  2727. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2728. /**
  2729. * Sets the given vector "result" with the given floats.
  2730. * @param x defines the x coordinate of the source
  2731. * @param y defines the y coordinate of the source
  2732. * @param z defines the z coordinate of the source
  2733. * @param result defines the Vector3 where to store the result
  2734. */
  2735. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2736. /**
  2737. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2738. * @returns a new empty Vector3
  2739. */
  2740. static Zero(): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2743. * @returns a new unit Vector3
  2744. */
  2745. static One(): Vector3;
  2746. /**
  2747. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2748. * @returns a new up Vector3
  2749. */
  2750. static Up(): Vector3;
  2751. /**
  2752. * Gets a up Vector3 that must not be updated
  2753. */
  2754. static get UpReadOnly(): DeepImmutable<Vector3>;
  2755. /**
  2756. * Gets a zero Vector3 that must not be updated
  2757. */
  2758. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2761. * @returns a new down Vector3
  2762. */
  2763. static Down(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2766. * @returns a new forward Vector3
  2767. */
  2768. static Forward(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2771. * @returns a new forward Vector3
  2772. */
  2773. static Backward(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2776. * @returns a new right Vector3
  2777. */
  2778. static Right(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2781. * @returns a new left Vector3
  2782. */
  2783. static Left(): Vector3;
  2784. /**
  2785. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2786. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2787. * @param vector defines the Vector3 to transform
  2788. * @param transformation defines the transformation matrix
  2789. * @returns the transformed Vector3
  2790. */
  2791. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2792. /**
  2793. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2795. * @param vector defines the Vector3 to transform
  2796. * @param transformation defines the transformation matrix
  2797. * @param result defines the Vector3 where to store the result
  2798. */
  2799. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2800. /**
  2801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2802. * This method computes tranformed coordinates only, not transformed direction vectors
  2803. * @param x define the x coordinate of the source vector
  2804. * @param y define the y coordinate of the source vector
  2805. * @param z define the z coordinate of the source vector
  2806. * @param transformation defines the transformation matrix
  2807. * @param result defines the Vector3 where to store the result
  2808. */
  2809. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2810. /**
  2811. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2812. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2813. * @param vector defines the Vector3 to transform
  2814. * @param transformation defines the transformation matrix
  2815. * @returns the new Vector3
  2816. */
  2817. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2818. /**
  2819. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2829. * @param x define the x coordinate of the source vector
  2830. * @param y define the y coordinate of the source vector
  2831. * @param z define the z coordinate of the source vector
  2832. * @param transformation defines the transformation matrix
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2838. * @param value1 defines the first control point
  2839. * @param value2 defines the second control point
  2840. * @param value3 defines the third control point
  2841. * @param value4 defines the fourth control point
  2842. * @param amount defines the amount on the spline to use
  2843. * @returns the new Vector3
  2844. */
  2845. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * 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"
  2848. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2849. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2850. * @param value defines the current value
  2851. * @param min defines the lower range value
  2852. * @param max defines the upper range value
  2853. * @returns the new Vector3
  2854. */
  2855. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2856. /**
  2857. * 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"
  2858. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2859. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2860. * @param value defines the current value
  2861. * @param min defines the lower range value
  2862. * @param max defines the upper range value
  2863. * @param result defines the Vector3 where to store the result
  2864. */
  2865. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2866. /**
  2867. * Checks if a given vector is inside a specific range
  2868. * @param v defines the vector to test
  2869. * @param min defines the minimum range
  2870. * @param max defines the maximum range
  2871. */
  2872. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2873. /**
  2874. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2875. * @param value1 defines the first control point
  2876. * @param tangent1 defines the first tangent vector
  2877. * @param value2 defines the second control point
  2878. * @param tangent2 defines the second tangent vector
  2879. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2880. * @returns the new Vector3
  2881. */
  2882. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2883. /**
  2884. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2885. * @param start defines the start value
  2886. * @param end defines the end value
  2887. * @param amount max defines amount between both (between 0 and 1)
  2888. * @returns the new Vector3
  2889. */
  2890. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2891. /**
  2892. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2893. * @param start defines the start value
  2894. * @param end defines the end value
  2895. * @param amount max defines amount between both (between 0 and 1)
  2896. * @param result defines the Vector3 where to store the result
  2897. */
  2898. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2899. /**
  2900. * Returns the dot product (float) between the vectors "left" and "right"
  2901. * @param left defines the left operand
  2902. * @param right defines the right operand
  2903. * @returns the dot product
  2904. */
  2905. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2906. /**
  2907. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2908. * The cross product is then orthogonal to both "left" and "right"
  2909. * @param left defines the left operand
  2910. * @param right defines the right operand
  2911. * @returns the cross product
  2912. */
  2913. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the cross product of "left" and "right"
  2916. * The cross product is then orthogonal to both "left" and "right"
  2917. * @param left defines the left operand
  2918. * @param right defines the right operand
  2919. * @param result defines the Vector3 where to store the result
  2920. */
  2921. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2922. /**
  2923. * Returns a new Vector3 as the normalization of the given vector
  2924. * @param vector defines the Vector3 to normalize
  2925. * @returns the new Vector3
  2926. */
  2927. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2928. /**
  2929. * Sets the given vector "result" with the normalization of the given first vector
  2930. * @param vector defines the Vector3 to normalize
  2931. * @param result defines the Vector3 where to store the result
  2932. */
  2933. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2934. /**
  2935. * Project a Vector3 onto screen space
  2936. * @param vector defines the Vector3 to project
  2937. * @param world defines the world matrix to use
  2938. * @param transform defines the transform (view x projection) matrix to use
  2939. * @param viewport defines the screen viewport to use
  2940. * @returns the new Vector3
  2941. */
  2942. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2943. /** @hidden */
  2944. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param source defines the screen space Vector3 to use
  2948. * @param viewportWidth defines the current width of the viewport
  2949. * @param viewportHeight defines the current height of the viewport
  2950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2951. * @param transform defines the transform (view x projection) matrix to use
  2952. * @returns the new Vector3
  2953. */
  2954. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2955. /**
  2956. * Unproject from screen space to object space
  2957. * @param source defines the screen space Vector3 to use
  2958. * @param viewportWidth defines the current width of the viewport
  2959. * @param viewportHeight defines the current height of the viewport
  2960. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2961. * @param view defines the view matrix to use
  2962. * @param projection defines the projection matrix to use
  2963. * @returns the new Vector3
  2964. */
  2965. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2966. /**
  2967. * Unproject from screen space to object space
  2968. * @param source defines the screen space Vector3 to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param view defines the view matrix to use
  2973. * @param projection defines the projection matrix to use
  2974. * @param result defines the Vector3 where to store the result
  2975. */
  2976. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2977. /**
  2978. * Unproject from screen space to object space
  2979. * @param sourceX defines the screen space x coordinate to use
  2980. * @param sourceY defines the screen space y coordinate to use
  2981. * @param sourceZ defines the screen space z coordinate to use
  2982. * @param viewportWidth defines the current width of the viewport
  2983. * @param viewportHeight defines the current height of the viewport
  2984. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2985. * @param view defines the view matrix to use
  2986. * @param projection defines the projection matrix to use
  2987. * @param result defines the Vector3 where to store the result
  2988. */
  2989. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2990. /**
  2991. * Gets the minimal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Gets the maximal coordinate values between two Vector3
  2999. * @param left defines the first operand
  3000. * @param right defines the second operand
  3001. * @returns the new Vector3
  3002. */
  3003. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3004. /**
  3005. * Returns the distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the distance
  3009. */
  3010. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns the squared distance between the vectors "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the squared distance
  3016. */
  3017. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3018. /**
  3019. * Returns a new Vector3 located at the center between "value1" and "value2"
  3020. * @param value1 defines the first operand
  3021. * @param value2 defines the second operand
  3022. * @returns the new Vector3
  3023. */
  3024. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3025. /**
  3026. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3027. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3028. * to something in order to rotate it from its local system to the given target system
  3029. * Note: axis1, axis2 and axis3 are normalized during this operation
  3030. * @param axis1 defines the first axis
  3031. * @param axis2 defines the second axis
  3032. * @param axis3 defines the third axis
  3033. * @returns a new Vector3
  3034. */
  3035. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3036. /**
  3037. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3038. * @param axis1 defines the first axis
  3039. * @param axis2 defines the second axis
  3040. * @param axis3 defines the third axis
  3041. * @param ref defines the Vector3 where to store the result
  3042. */
  3043. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3044. }
  3045. /**
  3046. * Vector4 class created for EulerAngle class conversion to Quaternion
  3047. */
  3048. export class Vector4 {
  3049. /** x value of the vector */
  3050. x: number;
  3051. /** y value of the vector */
  3052. y: number;
  3053. /** z value of the vector */
  3054. z: number;
  3055. /** w value of the vector */
  3056. w: number;
  3057. /**
  3058. * Creates a Vector4 object from the given floats.
  3059. * @param x x value of the vector
  3060. * @param y y value of the vector
  3061. * @param z z value of the vector
  3062. * @param w w value of the vector
  3063. */
  3064. constructor(
  3065. /** x value of the vector */
  3066. x: number,
  3067. /** y value of the vector */
  3068. y: number,
  3069. /** z value of the vector */
  3070. z: number,
  3071. /** w value of the vector */
  3072. w: number);
  3073. /**
  3074. * Returns the string with the Vector4 coordinates.
  3075. * @returns a string containing all the vector values
  3076. */
  3077. toString(): string;
  3078. /**
  3079. * Returns the string "Vector4".
  3080. * @returns "Vector4"
  3081. */
  3082. getClassName(): string;
  3083. /**
  3084. * Returns the Vector4 hash code.
  3085. * @returns a unique hash code
  3086. */
  3087. getHashCode(): number;
  3088. /**
  3089. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3090. * @returns the resulting array
  3091. */
  3092. asArray(): number[];
  3093. /**
  3094. * Populates the given array from the given index with the Vector4 coordinates.
  3095. * @param array array to populate
  3096. * @param index index of the array to start at (default: 0)
  3097. * @returns the Vector4.
  3098. */
  3099. toArray(array: FloatArray, index?: number): Vector4;
  3100. /**
  3101. * Adds the given vector to the current Vector4.
  3102. * @param otherVector the vector to add
  3103. * @returns the updated Vector4.
  3104. */
  3105. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3106. /**
  3107. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3108. * @param otherVector the vector to add
  3109. * @returns the resulting vector
  3110. */
  3111. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3112. /**
  3113. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3114. * @param otherVector the vector to add
  3115. * @param result the vector to store the result
  3116. * @returns the current Vector4.
  3117. */
  3118. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3119. /**
  3120. * Subtract in place the given vector from the current Vector4.
  3121. * @param otherVector the vector to subtract
  3122. * @returns the updated Vector4.
  3123. */
  3124. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3125. /**
  3126. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3127. * @param otherVector the vector to add
  3128. * @returns the new vector with the result
  3129. */
  3130. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3131. /**
  3132. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3133. * @param otherVector the vector to subtract
  3134. * @param result the vector to store the result
  3135. * @returns the current Vector4.
  3136. */
  3137. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3138. /**
  3139. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3140. */
  3141. /**
  3142. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3143. * @param x value to subtract
  3144. * @param y value to subtract
  3145. * @param z value to subtract
  3146. * @param w value to subtract
  3147. * @returns new vector containing the result
  3148. */
  3149. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3150. /**
  3151. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3152. * @param x value to subtract
  3153. * @param y value to subtract
  3154. * @param z value to subtract
  3155. * @param w value to subtract
  3156. * @param result the vector to store the result in
  3157. * @returns the current Vector4.
  3158. */
  3159. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3160. /**
  3161. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3162. * @returns a new vector with the negated values
  3163. */
  3164. negate(): Vector4;
  3165. /**
  3166. * Multiplies the current Vector4 coordinates by scale (float).
  3167. * @param scale the number to scale with
  3168. * @returns the updated Vector4.
  3169. */
  3170. scaleInPlace(scale: number): Vector4;
  3171. /**
  3172. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3173. * @param scale the number to scale with
  3174. * @returns a new vector with the result
  3175. */
  3176. scale(scale: number): Vector4;
  3177. /**
  3178. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3179. * @param scale the number to scale with
  3180. * @param result a vector to store the result in
  3181. * @returns the current Vector4.
  3182. */
  3183. scaleToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3186. * @param scale defines the scale factor
  3187. * @param result defines the Vector4 object where to store the result
  3188. * @returns the unmodified current Vector4
  3189. */
  3190. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3191. /**
  3192. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3193. * @param otherVector the vector to compare against
  3194. * @returns true if they are equal
  3195. */
  3196. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3197. /**
  3198. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3199. * @param otherVector vector to compare against
  3200. * @param epsilon (Default: very small number)
  3201. * @returns true if they are equal
  3202. */
  3203. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3204. /**
  3205. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3206. * @param x x value to compare against
  3207. * @param y y value to compare against
  3208. * @param z z value to compare against
  3209. * @param w w value to compare against
  3210. * @returns true if equal
  3211. */
  3212. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3213. /**
  3214. * Multiplies in place the current Vector4 by the given one.
  3215. * @param otherVector vector to multiple with
  3216. * @returns the updated Vector4.
  3217. */
  3218. multiplyInPlace(otherVector: Vector4): Vector4;
  3219. /**
  3220. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3221. * @param otherVector vector to multiple with
  3222. * @returns resulting new vector
  3223. */
  3224. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3225. /**
  3226. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3227. * @param otherVector vector to multiple with
  3228. * @param result vector to store the result
  3229. * @returns the current Vector4.
  3230. */
  3231. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3232. /**
  3233. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3234. * @param x x value multiply with
  3235. * @param y y value multiply with
  3236. * @param z z value multiply with
  3237. * @param w w value multiply with
  3238. * @returns resulting new vector
  3239. */
  3240. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3241. /**
  3242. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3243. * @param otherVector vector to devide with
  3244. * @returns resulting new vector
  3245. */
  3246. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3247. /**
  3248. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3249. * @param otherVector vector to devide with
  3250. * @param result vector to store the result
  3251. * @returns the current Vector4.
  3252. */
  3253. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3254. /**
  3255. * Divides the current Vector3 coordinates by the given ones.
  3256. * @param otherVector vector to devide with
  3257. * @returns the updated Vector3.
  3258. */
  3259. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3260. /**
  3261. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3262. * @param other defines the second operand
  3263. * @returns the current updated Vector4
  3264. */
  3265. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3268. * @param other defines the second operand
  3269. * @returns the current updated Vector4
  3270. */
  3271. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3272. /**
  3273. * Gets a new Vector4 from current Vector4 floored values
  3274. * @returns a new Vector4
  3275. */
  3276. floor(): Vector4;
  3277. /**
  3278. * Gets a new Vector4 from current Vector3 floored values
  3279. * @returns a new Vector4
  3280. */
  3281. fract(): Vector4;
  3282. /**
  3283. * Returns the Vector4 length (float).
  3284. * @returns the length
  3285. */
  3286. length(): number;
  3287. /**
  3288. * Returns the Vector4 squared length (float).
  3289. * @returns the length squared
  3290. */
  3291. lengthSquared(): number;
  3292. /**
  3293. * Normalizes in place the Vector4.
  3294. * @returns the updated Vector4.
  3295. */
  3296. normalize(): Vector4;
  3297. /**
  3298. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3299. * @returns this converted to a new vector3
  3300. */
  3301. toVector3(): Vector3;
  3302. /**
  3303. * Returns a new Vector4 copied from the current one.
  3304. * @returns the new cloned vector
  3305. */
  3306. clone(): Vector4;
  3307. /**
  3308. * Updates the current Vector4 with the given one coordinates.
  3309. * @param source the source vector to copy from
  3310. * @returns the updated Vector4.
  3311. */
  3312. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3313. /**
  3314. * Updates the current Vector4 coordinates with the given floats.
  3315. * @param x float to copy from
  3316. * @param y float to copy from
  3317. * @param z float to copy from
  3318. * @param w float to copy from
  3319. * @returns the updated Vector4.
  3320. */
  3321. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3322. /**
  3323. * Updates the current Vector4 coordinates with the given floats.
  3324. * @param x float to set from
  3325. * @param y float to set from
  3326. * @param z float to set from
  3327. * @param w float to set from
  3328. * @returns the updated Vector4.
  3329. */
  3330. set(x: number, y: number, z: number, w: number): Vector4;
  3331. /**
  3332. * Copies the given float to the current Vector3 coordinates
  3333. * @param v defines the x, y, z and w coordinates of the operand
  3334. * @returns the current updated Vector3
  3335. */
  3336. setAll(v: number): Vector4;
  3337. /**
  3338. * Returns a new Vector4 set from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @returns the new vector
  3342. */
  3343. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" from the starting index of the given Float32Array.
  3353. * @param array the array to pull values from
  3354. * @param offset the offset into the array to start at
  3355. * @param result the vector to store the result in
  3356. */
  3357. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3358. /**
  3359. * Updates the given vector "result" coordinates from the given floats.
  3360. * @param x float to set from
  3361. * @param y float to set from
  3362. * @param z float to set from
  3363. * @param w float to set from
  3364. * @param result the vector to the floats in
  3365. */
  3366. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3367. /**
  3368. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3369. * @returns the new vector
  3370. */
  3371. static Zero(): Vector4;
  3372. /**
  3373. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3374. * @returns the new vector
  3375. */
  3376. static One(): Vector4;
  3377. /**
  3378. * Returns a new normalized Vector4 from the given one.
  3379. * @param vector the vector to normalize
  3380. * @returns the vector
  3381. */
  3382. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Updates the given vector "result" from the normalization of the given one.
  3385. * @param vector the vector to normalize
  3386. * @param result the vector to store the result in
  3387. */
  3388. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3389. /**
  3390. * Returns a vector with the minimum values from the left and right vectors
  3391. * @param left left vector to minimize
  3392. * @param right right vector to minimize
  3393. * @returns a new vector with the minimum of the left and right vector values
  3394. */
  3395. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns a vector with the maximum values from the left and right vectors
  3398. * @param left left vector to maximize
  3399. * @param right right vector to maximize
  3400. * @returns a new vector with the maximum of the left and right vector values
  3401. */
  3402. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3403. /**
  3404. * Returns the distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors
  3408. */
  3409. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the distance between
  3413. * @param value2 value to calulate the distance between
  3414. * @return the distance between the two vectors squared
  3415. */
  3416. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3417. /**
  3418. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3419. * @param value1 value to calulate the center between
  3420. * @param value2 value to calulate the center between
  3421. * @return the center between the two vectors
  3422. */
  3423. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3426. * This methods computes transformed normalized direction vectors only.
  3427. * @param vector the vector to transform
  3428. * @param transformation the transformation matrix to apply
  3429. * @returns the new vector
  3430. */
  3431. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3432. /**
  3433. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3434. * This methods computes transformed normalized direction vectors only.
  3435. * @param vector the vector to transform
  3436. * @param transformation the transformation matrix to apply
  3437. * @param result the vector to store the result in
  3438. */
  3439. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3440. /**
  3441. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3442. * This methods computes transformed normalized direction vectors only.
  3443. * @param x value to transform
  3444. * @param y value to transform
  3445. * @param z value to transform
  3446. * @param w value to transform
  3447. * @param transformation the transformation matrix to apply
  3448. * @param result the vector to store the results in
  3449. */
  3450. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3451. /**
  3452. * Creates a new Vector4 from a Vector3
  3453. * @param source defines the source data
  3454. * @param w defines the 4th component (default is 0)
  3455. * @returns a new Vector4
  3456. */
  3457. static FromVector3(source: Vector3, w?: number): Vector4;
  3458. }
  3459. /**
  3460. * Class used to store quaternion data
  3461. * @see https://en.wikipedia.org/wiki/Quaternion
  3462. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3463. */
  3464. export class Quaternion {
  3465. /** defines the first component (0 by default) */
  3466. x: number;
  3467. /** defines the second component (0 by default) */
  3468. y: number;
  3469. /** defines the third component (0 by default) */
  3470. z: number;
  3471. /** defines the fourth component (1.0 by default) */
  3472. w: number;
  3473. /**
  3474. * Creates a new Quaternion from the given floats
  3475. * @param x defines the first component (0 by default)
  3476. * @param y defines the second component (0 by default)
  3477. * @param z defines the third component (0 by default)
  3478. * @param w defines the fourth component (1.0 by default)
  3479. */
  3480. constructor(
  3481. /** defines the first component (0 by default) */
  3482. x?: number,
  3483. /** defines the second component (0 by default) */
  3484. y?: number,
  3485. /** defines the third component (0 by default) */
  3486. z?: number,
  3487. /** defines the fourth component (1.0 by default) */
  3488. w?: number);
  3489. /**
  3490. * Gets a string representation for the current quaternion
  3491. * @returns a string with the Quaternion coordinates
  3492. */
  3493. toString(): string;
  3494. /**
  3495. * Gets the class name of the quaternion
  3496. * @returns the string "Quaternion"
  3497. */
  3498. getClassName(): string;
  3499. /**
  3500. * Gets a hash code for this quaternion
  3501. * @returns the quaternion hash code
  3502. */
  3503. getHashCode(): number;
  3504. /**
  3505. * Copy the quaternion to an array
  3506. * @returns a new array populated with 4 elements from the quaternion coordinates
  3507. */
  3508. asArray(): number[];
  3509. /**
  3510. * Check if two quaternions are equals
  3511. * @param otherQuaternion defines the second operand
  3512. * @return true if the current quaternion and the given one coordinates are strictly equals
  3513. */
  3514. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3515. /**
  3516. * Clone the current quaternion
  3517. * @returns a new quaternion copied from the current one
  3518. */
  3519. clone(): Quaternion;
  3520. /**
  3521. * Copy a quaternion to the current one
  3522. * @param other defines the other quaternion
  3523. * @returns the updated current quaternion
  3524. */
  3525. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3526. /**
  3527. * Updates the current quaternion with the given float coordinates
  3528. * @param x defines the x coordinate
  3529. * @param y defines the y coordinate
  3530. * @param z defines the z coordinate
  3531. * @param w defines the w coordinate
  3532. * @returns the updated current quaternion
  3533. */
  3534. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3535. /**
  3536. * Updates the current quaternion from the given float coordinates
  3537. * @param x defines the x coordinate
  3538. * @param y defines the y coordinate
  3539. * @param z defines the z coordinate
  3540. * @param w defines the w coordinate
  3541. * @returns the updated current quaternion
  3542. */
  3543. set(x: number, y: number, z: number, w: number): Quaternion;
  3544. /**
  3545. * Adds two quaternions
  3546. * @param other defines the second operand
  3547. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3548. */
  3549. add(other: DeepImmutable<Quaternion>): Quaternion;
  3550. /**
  3551. * Add a quaternion to the current one
  3552. * @param other defines the quaternion to add
  3553. * @returns the current quaternion
  3554. */
  3555. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3556. /**
  3557. * Subtract two quaternions
  3558. * @param other defines the second operand
  3559. * @returns a new quaternion as the subtraction result of the given one from the current one
  3560. */
  3561. subtract(other: Quaternion): Quaternion;
  3562. /**
  3563. * Multiplies the current quaternion by a scale factor
  3564. * @param value defines the scale factor
  3565. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3566. */
  3567. scale(value: number): Quaternion;
  3568. /**
  3569. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3570. * @param scale defines the scale factor
  3571. * @param result defines the Quaternion object where to store the result
  3572. * @returns the unmodified current quaternion
  3573. */
  3574. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3575. /**
  3576. * Multiplies in place the current quaternion by a scale factor
  3577. * @param value defines the scale factor
  3578. * @returns the current modified quaternion
  3579. */
  3580. scaleInPlace(value: number): Quaternion;
  3581. /**
  3582. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3583. * @param scale defines the scale factor
  3584. * @param result defines the Quaternion object where to store the result
  3585. * @returns the unmodified current quaternion
  3586. */
  3587. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies two quaternions
  3590. * @param q1 defines the second operand
  3591. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3592. */
  3593. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3594. /**
  3595. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @param result defines the target quaternion
  3598. * @returns the current quaternion
  3599. */
  3600. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3601. /**
  3602. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3603. * @param q1 defines the second operand
  3604. * @returns the currentupdated quaternion
  3605. */
  3606. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3607. /**
  3608. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3609. * @param ref defines the target quaternion
  3610. * @returns the current quaternion
  3611. */
  3612. conjugateToRef(ref: Quaternion): Quaternion;
  3613. /**
  3614. * Conjugates in place (1-q) the current quaternion
  3615. * @returns the current updated quaternion
  3616. */
  3617. conjugateInPlace(): Quaternion;
  3618. /**
  3619. * Conjugates in place (1-q) the current quaternion
  3620. * @returns a new quaternion
  3621. */
  3622. conjugate(): Quaternion;
  3623. /**
  3624. * Gets length of current quaternion
  3625. * @returns the quaternion length (float)
  3626. */
  3627. length(): number;
  3628. /**
  3629. * Normalize in place the current quaternion
  3630. * @returns the current updated quaternion
  3631. */
  3632. normalize(): Quaternion;
  3633. /**
  3634. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns a new Vector3 containing the Euler angles
  3637. */
  3638. toEulerAngles(order?: string): Vector3;
  3639. /**
  3640. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3641. * @param result defines the vector which will be filled with the Euler angles
  3642. * @param order is a reserved parameter and is ignore for now
  3643. * @returns the current unchanged quaternion
  3644. */
  3645. toEulerAnglesToRef(result: Vector3): Quaternion;
  3646. /**
  3647. * Updates the given rotation matrix with the current quaternion values
  3648. * @param result defines the target matrix
  3649. * @returns the current unchanged quaternion
  3650. */
  3651. toRotationMatrix(result: Matrix): Quaternion;
  3652. /**
  3653. * Updates the current quaternion from the given rotation matrix values
  3654. * @param matrix defines the source matrix
  3655. * @returns the current updated quaternion
  3656. */
  3657. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3658. /**
  3659. * Creates a new quaternion from a rotation matrix
  3660. * @param matrix defines the source matrix
  3661. * @returns a new quaternion created from the given rotation matrix values
  3662. */
  3663. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3664. /**
  3665. * Updates the given quaternion with the given rotation matrix values
  3666. * @param matrix defines the source matrix
  3667. * @param result defines the target quaternion
  3668. */
  3669. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3670. /**
  3671. * Returns the dot product (float) between the quaternions "left" and "right"
  3672. * @param left defines the left operand
  3673. * @param right defines the right operand
  3674. * @returns the dot product
  3675. */
  3676. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3677. /**
  3678. * Checks if the two quaternions are close to each other
  3679. * @param quat0 defines the first quaternion to check
  3680. * @param quat1 defines the second quaternion to check
  3681. * @returns true if the two quaternions are close to each other
  3682. */
  3683. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3684. /**
  3685. * Creates an empty quaternion
  3686. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3687. */
  3688. static Zero(): Quaternion;
  3689. /**
  3690. * Inverse a given quaternion
  3691. * @param q defines the source quaternion
  3692. * @returns a new quaternion as the inverted current quaternion
  3693. */
  3694. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Inverse a given quaternion
  3697. * @param q defines the source quaternion
  3698. * @param result the quaternion the result will be stored in
  3699. * @returns the result quaternion
  3700. */
  3701. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3702. /**
  3703. * Creates an identity quaternion
  3704. * @returns the identity quaternion
  3705. */
  3706. static Identity(): Quaternion;
  3707. /**
  3708. * Gets a boolean indicating if the given quaternion is identity
  3709. * @param quaternion defines the quaternion to check
  3710. * @returns true if the quaternion is identity
  3711. */
  3712. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3713. /**
  3714. * Creates a quaternion from a rotation around an axis
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3718. */
  3719. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3720. /**
  3721. * Creates a rotation around an axis and stores it into the given quaternion
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle to use
  3724. * @param result defines the target quaternion
  3725. * @returns the target quaternion
  3726. */
  3727. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from data stored into an array
  3730. * @param array defines the data source
  3731. * @param offset defines the offset in the source array where the data starts
  3732. * @returns a new quaternion
  3733. */
  3734. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3735. /**
  3736. * Create a quaternion from Euler rotation angles
  3737. * @param x Pitch
  3738. * @param y Yaw
  3739. * @param z Roll
  3740. * @returns the new Quaternion
  3741. */
  3742. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3743. /**
  3744. * Updates a quaternion from Euler rotation angles
  3745. * @param x Pitch
  3746. * @param y Yaw
  3747. * @param z Roll
  3748. * @param result the quaternion to store the result
  3749. * @returns the updated quaternion
  3750. */
  3751. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3752. /**
  3753. * Create a quaternion from Euler rotation vector
  3754. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3755. * @returns the new Quaternion
  3756. */
  3757. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3758. /**
  3759. * Updates a quaternion from Euler rotation vector
  3760. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3761. * @param result the quaternion to store the result
  3762. * @returns the updated quaternion
  3763. */
  3764. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3765. /**
  3766. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3767. * @param yaw defines the rotation around Y axis
  3768. * @param pitch defines the rotation around X axis
  3769. * @param roll defines the rotation around Z axis
  3770. * @returns the new quaternion
  3771. */
  3772. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3773. /**
  3774. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3775. * @param yaw defines the rotation around Y axis
  3776. * @param pitch defines the rotation around X axis
  3777. * @param roll defines the rotation around Z axis
  3778. * @param result defines the target quaternion
  3779. */
  3780. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3781. /**
  3782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3783. * @param alpha defines the rotation around first axis
  3784. * @param beta defines the rotation around second axis
  3785. * @param gamma defines the rotation around third axis
  3786. * @returns the new quaternion
  3787. */
  3788. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3789. /**
  3790. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3791. * @param alpha defines the rotation around first axis
  3792. * @param beta defines the rotation around second axis
  3793. * @param gamma defines the rotation around third axis
  3794. * @param result defines the target quaternion
  3795. */
  3796. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3797. /**
  3798. * 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)
  3799. * @param axis1 defines the first axis
  3800. * @param axis2 defines the second axis
  3801. * @param axis3 defines the third axis
  3802. * @returns the new quaternion
  3803. */
  3804. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3805. /**
  3806. * 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
  3807. * @param axis1 defines the first axis
  3808. * @param axis2 defines the second axis
  3809. * @param axis3 defines the third axis
  3810. * @param ref defines the target quaternion
  3811. */
  3812. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3813. /**
  3814. * Interpolates between two quaternions
  3815. * @param left defines first quaternion
  3816. * @param right defines second quaternion
  3817. * @param amount defines the gradient to use
  3818. * @returns the new interpolated quaternion
  3819. */
  3820. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3821. /**
  3822. * Interpolates between two quaternions and stores it into a target quaternion
  3823. * @param left defines first quaternion
  3824. * @param right defines second quaternion
  3825. * @param amount defines the gradient to use
  3826. * @param result defines the target quaternion
  3827. */
  3828. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3829. /**
  3830. * Interpolate between two quaternions using Hermite interpolation
  3831. * @param value1 defines first quaternion
  3832. * @param tangent1 defines the incoming tangent
  3833. * @param value2 defines second quaternion
  3834. * @param tangent2 defines the outgoing tangent
  3835. * @param amount defines the target quaternion
  3836. * @returns the new interpolated quaternion
  3837. */
  3838. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3839. }
  3840. /**
  3841. * Class used to store matrix data (4x4)
  3842. */
  3843. export class Matrix {
  3844. private static _updateFlagSeed;
  3845. private static _identityReadOnly;
  3846. private _isIdentity;
  3847. private _isIdentityDirty;
  3848. private _isIdentity3x2;
  3849. private _isIdentity3x2Dirty;
  3850. /**
  3851. * Gets the update flag of the matrix which is an unique number for the matrix.
  3852. * It will be incremented every time the matrix data change.
  3853. * You can use it to speed the comparison between two versions of the same matrix.
  3854. */
  3855. updateFlag: number;
  3856. private readonly _m;
  3857. /**
  3858. * Gets the internal data of the matrix
  3859. */
  3860. get m(): DeepImmutable<Float32Array>;
  3861. /** @hidden */
  3862. _markAsUpdated(): void;
  3863. /** @hidden */
  3864. private _updateIdentityStatus;
  3865. /**
  3866. * Creates an empty matrix (filled with zeros)
  3867. */
  3868. constructor();
  3869. /**
  3870. * Check if the current matrix is identity
  3871. * @returns true is the matrix is the identity matrix
  3872. */
  3873. isIdentity(): boolean;
  3874. /**
  3875. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3876. * @returns true is the matrix is the identity matrix
  3877. */
  3878. isIdentityAs3x2(): boolean;
  3879. /**
  3880. * Gets the determinant of the matrix
  3881. * @returns the matrix determinant
  3882. */
  3883. determinant(): number;
  3884. /**
  3885. * Returns the matrix as a Float32Array
  3886. * @returns the matrix underlying array
  3887. */
  3888. toArray(): DeepImmutable<Float32Array>;
  3889. /**
  3890. * Returns the matrix as a Float32Array
  3891. * @returns the matrix underlying array.
  3892. */
  3893. asArray(): DeepImmutable<Float32Array>;
  3894. /**
  3895. * Inverts the current matrix in place
  3896. * @returns the current inverted matrix
  3897. */
  3898. invert(): Matrix;
  3899. /**
  3900. * Sets all the matrix elements to zero
  3901. * @returns the current matrix
  3902. */
  3903. reset(): Matrix;
  3904. /**
  3905. * Adds the current matrix with a second one
  3906. * @param other defines the matrix to add
  3907. * @returns a new matrix as the addition of the current matrix and the given one
  3908. */
  3909. add(other: DeepImmutable<Matrix>): Matrix;
  3910. /**
  3911. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3912. * @param other defines the matrix to add
  3913. * @param result defines the target matrix
  3914. * @returns the current matrix
  3915. */
  3916. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3917. /**
  3918. * Adds in place the given matrix to the current matrix
  3919. * @param other defines the second operand
  3920. * @returns the current updated matrix
  3921. */
  3922. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3923. /**
  3924. * Sets the given matrix to the current inverted Matrix
  3925. * @param other defines the target matrix
  3926. * @returns the unmodified current matrix
  3927. */
  3928. invertToRef(other: Matrix): Matrix;
  3929. /**
  3930. * add a value at the specified position in the current Matrix
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. addAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * mutiply the specified position in the current Matrix by a value
  3938. * @param index the index of the value within the matrix. between 0 and 15.
  3939. * @param value the value to be added
  3940. * @returns the current updated matrix
  3941. */
  3942. multiplyAtIndex(index: number, value: number): Matrix;
  3943. /**
  3944. * Inserts the translation vector (using 3 floats) in the current matrix
  3945. * @param x defines the 1st component of the translation
  3946. * @param y defines the 2nd component of the translation
  3947. * @param z defines the 3rd component of the translation
  3948. * @returns the current updated matrix
  3949. */
  3950. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3951. /**
  3952. * Adds the translation vector (using 3 floats) in the current matrix
  3953. * @param x defines the 1st component of the translation
  3954. * @param y defines the 2nd component of the translation
  3955. * @param z defines the 3rd component of the translation
  3956. * @returns the current updated matrix
  3957. */
  3958. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3959. /**
  3960. * Inserts the translation vector in the current matrix
  3961. * @param vector3 defines the translation to insert
  3962. * @returns the current updated matrix
  3963. */
  3964. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3965. /**
  3966. * Gets the translation value of the current matrix
  3967. * @returns a new Vector3 as the extracted translation from the matrix
  3968. */
  3969. getTranslation(): Vector3;
  3970. /**
  3971. * Fill a Vector3 with the extracted translation from the matrix
  3972. * @param result defines the Vector3 where to store the translation
  3973. * @returns the current matrix
  3974. */
  3975. getTranslationToRef(result: Vector3): Matrix;
  3976. /**
  3977. * Remove rotation and scaling part from the matrix
  3978. * @returns the updated matrix
  3979. */
  3980. removeRotationAndScaling(): Matrix;
  3981. /**
  3982. * Multiply two matrices
  3983. * @param other defines the second operand
  3984. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3985. */
  3986. multiply(other: DeepImmutable<Matrix>): Matrix;
  3987. /**
  3988. * Copy the current matrix from the given one
  3989. * @param other defines the source matrix
  3990. * @returns the current updated matrix
  3991. */
  3992. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3993. /**
  3994. * Populates the given array from the starting index with the current matrix values
  3995. * @param array defines the target array
  3996. * @param offset defines the offset in the target array where to start storing values
  3997. * @returns the current matrix
  3998. */
  3999. copyToArray(array: Float32Array, offset?: number): Matrix;
  4000. /**
  4001. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the matrix where to store the multiplication
  4004. * @returns the current matrix
  4005. */
  4006. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4007. /**
  4008. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4009. * @param other defines the second operand
  4010. * @param result defines the array where to store the multiplication
  4011. * @param offset defines the offset in the target array where to start storing values
  4012. * @returns the current matrix
  4013. */
  4014. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4015. /**
  4016. * Check equality between this matrix and a second one
  4017. * @param value defines the second matrix to compare
  4018. * @returns true is the current matrix and the given one values are strictly equal
  4019. */
  4020. equals(value: DeepImmutable<Matrix>): boolean;
  4021. /**
  4022. * Clone the current matrix
  4023. * @returns a new matrix from the current matrix
  4024. */
  4025. clone(): Matrix;
  4026. /**
  4027. * Returns the name of the current matrix class
  4028. * @returns the string "Matrix"
  4029. */
  4030. getClassName(): string;
  4031. /**
  4032. * Gets the hash code of the current matrix
  4033. * @returns the hash code
  4034. */
  4035. getHashCode(): number;
  4036. /**
  4037. * Decomposes the current Matrix into a translation, rotation and scaling components
  4038. * @param scale defines the scale vector3 given as a reference to update
  4039. * @param rotation defines the rotation quaternion given as a reference to update
  4040. * @param translation defines the translation vector3 given as a reference to update
  4041. * @returns true if operation was successful
  4042. */
  4043. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4044. /**
  4045. * Gets specific row of the matrix
  4046. * @param index defines the number of the row to get
  4047. * @returns the index-th row of the current matrix as a new Vector4
  4048. */
  4049. getRow(index: number): Nullable<Vector4>;
  4050. /**
  4051. * Sets the index-th row of the current matrix to the vector4 values
  4052. * @param index defines the number of the row to set
  4053. * @param row defines the target vector4
  4054. * @returns the updated current matrix
  4055. */
  4056. setRow(index: number, row: Vector4): Matrix;
  4057. /**
  4058. * Compute the transpose of the matrix
  4059. * @returns the new transposed matrix
  4060. */
  4061. transpose(): Matrix;
  4062. /**
  4063. * Compute the transpose of the matrix and store it in a given matrix
  4064. * @param result defines the target matrix
  4065. * @returns the current matrix
  4066. */
  4067. transposeToRef(result: Matrix): Matrix;
  4068. /**
  4069. * Sets the index-th row of the current matrix with the given 4 x float values
  4070. * @param index defines the row index
  4071. * @param x defines the x component to set
  4072. * @param y defines the y component to set
  4073. * @param z defines the z component to set
  4074. * @param w defines the w component to set
  4075. * @returns the updated current matrix
  4076. */
  4077. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4078. /**
  4079. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4080. * @param scale defines the scale factor
  4081. * @returns a new matrix
  4082. */
  4083. scale(scale: number): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor to a given result matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Scale the current matrix values by a factor and add the result to a given matrix
  4093. * @param scale defines the scale factor
  4094. * @param result defines the Matrix to store the result
  4095. * @returns the current matrix
  4096. */
  4097. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4098. /**
  4099. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4100. * @param ref matrix to store the result
  4101. */
  4102. toNormalMatrix(ref: Matrix): void;
  4103. /**
  4104. * Gets only rotation part of the current matrix
  4105. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4106. */
  4107. getRotationMatrix(): Matrix;
  4108. /**
  4109. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4110. * @param result defines the target matrix to store data to
  4111. * @returns the current matrix
  4112. */
  4113. getRotationMatrixToRef(result: Matrix): Matrix;
  4114. /**
  4115. * Toggles model matrix from being right handed to left handed in place and vice versa
  4116. */
  4117. toggleModelMatrixHandInPlace(): void;
  4118. /**
  4119. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4120. */
  4121. toggleProjectionMatrixHandInPlace(): void;
  4122. /**
  4123. * Creates a matrix from an array
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @returns a new Matrix set from the starting index of the given array
  4127. */
  4128. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4129. /**
  4130. * Copy the content of an array into a given matrix
  4131. * @param array defines the source array
  4132. * @param offset defines an offset in the source array
  4133. * @param result defines the target matrix
  4134. */
  4135. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4136. /**
  4137. * Stores an array into a matrix after having multiplied each component by a given factor
  4138. * @param array defines the source array
  4139. * @param offset defines the offset in the source array
  4140. * @param scale defines the scaling factor
  4141. * @param result defines the target matrix
  4142. */
  4143. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4144. /**
  4145. * Gets an identity matrix that must not be updated
  4146. */
  4147. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4148. /**
  4149. * Stores a list of values (16) inside a given matrix
  4150. * @param initialM11 defines 1st value of 1st row
  4151. * @param initialM12 defines 2nd value of 1st row
  4152. * @param initialM13 defines 3rd value of 1st row
  4153. * @param initialM14 defines 4th value of 1st row
  4154. * @param initialM21 defines 1st value of 2nd row
  4155. * @param initialM22 defines 2nd value of 2nd row
  4156. * @param initialM23 defines 3rd value of 2nd row
  4157. * @param initialM24 defines 4th value of 2nd row
  4158. * @param initialM31 defines 1st value of 3rd row
  4159. * @param initialM32 defines 2nd value of 3rd row
  4160. * @param initialM33 defines 3rd value of 3rd row
  4161. * @param initialM34 defines 4th value of 3rd row
  4162. * @param initialM41 defines 1st value of 4th row
  4163. * @param initialM42 defines 2nd value of 4th row
  4164. * @param initialM43 defines 3rd value of 4th row
  4165. * @param initialM44 defines 4th value of 4th row
  4166. * @param result defines the target matrix
  4167. */
  4168. 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;
  4169. /**
  4170. * Creates new matrix from a list of values (16)
  4171. * @param initialM11 defines 1st value of 1st row
  4172. * @param initialM12 defines 2nd value of 1st row
  4173. * @param initialM13 defines 3rd value of 1st row
  4174. * @param initialM14 defines 4th value of 1st row
  4175. * @param initialM21 defines 1st value of 2nd row
  4176. * @param initialM22 defines 2nd value of 2nd row
  4177. * @param initialM23 defines 3rd value of 2nd row
  4178. * @param initialM24 defines 4th value of 2nd row
  4179. * @param initialM31 defines 1st value of 3rd row
  4180. * @param initialM32 defines 2nd value of 3rd row
  4181. * @param initialM33 defines 3rd value of 3rd row
  4182. * @param initialM34 defines 4th value of 3rd row
  4183. * @param initialM41 defines 1st value of 4th row
  4184. * @param initialM42 defines 2nd value of 4th row
  4185. * @param initialM43 defines 3rd value of 4th row
  4186. * @param initialM44 defines 4th value of 4th row
  4187. * @returns the new matrix
  4188. */
  4189. 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;
  4190. /**
  4191. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4192. * @param scale defines the scale vector3
  4193. * @param rotation defines the rotation quaternion
  4194. * @param translation defines the translation vector3
  4195. * @returns a new matrix
  4196. */
  4197. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4198. /**
  4199. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4200. * @param scale defines the scale vector3
  4201. * @param rotation defines the rotation quaternion
  4202. * @param translation defines the translation vector3
  4203. * @param result defines the target matrix
  4204. */
  4205. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4206. /**
  4207. * Creates a new identity matrix
  4208. * @returns a new identity matrix
  4209. */
  4210. static Identity(): Matrix;
  4211. /**
  4212. * Creates a new identity matrix and stores the result in a given matrix
  4213. * @param result defines the target matrix
  4214. */
  4215. static IdentityToRef(result: Matrix): void;
  4216. /**
  4217. * Creates a new zero matrix
  4218. * @returns a new zero matrix
  4219. */
  4220. static Zero(): Matrix;
  4221. /**
  4222. * Creates a new rotation matrix for "angle" radians around the X axis
  4223. * @param angle defines the angle (in radians) to use
  4224. * @return the new matrix
  4225. */
  4226. static RotationX(angle: number): Matrix;
  4227. /**
  4228. * Creates a new matrix as the invert of a given matrix
  4229. * @param source defines the source matrix
  4230. * @returns the new matrix
  4231. */
  4232. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4235. * @param angle defines the angle (in radians) to use
  4236. * @param result defines the target matrix
  4237. */
  4238. static RotationXToRef(angle: number, result: Matrix): void;
  4239. /**
  4240. * Creates a new rotation matrix for "angle" radians around the Y axis
  4241. * @param angle defines the angle (in radians) to use
  4242. * @return the new matrix
  4243. */
  4244. static RotationY(angle: number): Matrix;
  4245. /**
  4246. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4247. * @param angle defines the angle (in radians) to use
  4248. * @param result defines the target matrix
  4249. */
  4250. static RotationYToRef(angle: number, result: Matrix): void;
  4251. /**
  4252. * Creates a new rotation matrix for "angle" radians around the Z axis
  4253. * @param angle defines the angle (in radians) to use
  4254. * @return the new matrix
  4255. */
  4256. static RotationZ(angle: number): Matrix;
  4257. /**
  4258. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4259. * @param angle defines the angle (in radians) to use
  4260. * @param result defines the target matrix
  4261. */
  4262. static RotationZToRef(angle: number, result: Matrix): void;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @return the new matrix
  4268. */
  4269. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4270. /**
  4271. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4272. * @param axis defines the axis to use
  4273. * @param angle defines the angle (in radians) to use
  4274. * @param result defines the target matrix
  4275. */
  4276. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4277. /**
  4278. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4279. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4280. * @param from defines the vector to align
  4281. * @param to defines the vector to align to
  4282. * @param result defines the target matrix
  4283. */
  4284. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4285. /**
  4286. * Creates a rotation matrix
  4287. * @param yaw defines the yaw angle in radians (Y axis)
  4288. * @param pitch defines the pitch angle in radians (X axis)
  4289. * @param roll defines the roll angle in radians (X axis)
  4290. * @returns the new rotation matrix
  4291. */
  4292. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4293. /**
  4294. * Creates a rotation matrix and stores it in a given matrix
  4295. * @param yaw defines the yaw angle in radians (Y axis)
  4296. * @param pitch defines the pitch angle in radians (X axis)
  4297. * @param roll defines the roll angle in radians (X axis)
  4298. * @param result defines the target matrix
  4299. */
  4300. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4301. /**
  4302. * Creates a scaling matrix
  4303. * @param x defines the scale factor on X axis
  4304. * @param y defines the scale factor on Y axis
  4305. * @param z defines the scale factor on Z axis
  4306. * @returns the new matrix
  4307. */
  4308. static Scaling(x: number, y: number, z: number): Matrix;
  4309. /**
  4310. * Creates a scaling matrix and stores it in a given matrix
  4311. * @param x defines the scale factor on X axis
  4312. * @param y defines the scale factor on Y axis
  4313. * @param z defines the scale factor on Z axis
  4314. * @param result defines the target matrix
  4315. */
  4316. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4317. /**
  4318. * Creates a translation matrix
  4319. * @param x defines the translation on X axis
  4320. * @param y defines the translation on Y axis
  4321. * @param z defines the translationon Z axis
  4322. * @returns the new matrix
  4323. */
  4324. static Translation(x: number, y: number, z: number): Matrix;
  4325. /**
  4326. * Creates a translation matrix and stores it in a given matrix
  4327. * @param x defines the translation on X axis
  4328. * @param y defines the translation on Y axis
  4329. * @param z defines the translationon Z axis
  4330. * @param result defines the target matrix
  4331. */
  4332. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4333. /**
  4334. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4335. * @param startValue defines the start value
  4336. * @param endValue defines the end value
  4337. * @param gradient defines the gradient factor
  4338. * @returns the new matrix
  4339. */
  4340. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4341. /**
  4342. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4343. * @param startValue defines the start value
  4344. * @param endValue defines the end value
  4345. * @param gradient defines the gradient factor
  4346. * @param result defines the Matrix object where to store data
  4347. */
  4348. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4349. /**
  4350. * Builds a new matrix whose values are computed by:
  4351. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4352. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4353. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4354. * @param startValue defines the first matrix
  4355. * @param endValue defines the second matrix
  4356. * @param gradient defines the gradient between the two matrices
  4357. * @returns the new matrix
  4358. */
  4359. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4360. /**
  4361. * Update a matrix to values which are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @param result defines the target matrix
  4369. */
  4370. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4371. /**
  4372. * 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"
  4373. * This function works in left handed mode
  4374. * @param eye defines the final position of the entity
  4375. * @param target defines where the entity should look at
  4376. * @param up defines the up vector for the entity
  4377. * @returns the new matrix
  4378. */
  4379. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4380. /**
  4381. * 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".
  4382. * This function works in left handed mode
  4383. * @param eye defines the final position of the entity
  4384. * @param target defines where the entity should look at
  4385. * @param up defines the up vector for the entity
  4386. * @param result defines the target matrix
  4387. */
  4388. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4389. /**
  4390. * 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"
  4391. * This function works in right handed mode
  4392. * @param eye defines the final position of the entity
  4393. * @param target defines where the entity should look at
  4394. * @param up defines the up vector for the entity
  4395. * @returns the new matrix
  4396. */
  4397. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4398. /**
  4399. * 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".
  4400. * This function works in right handed mode
  4401. * @param eye defines the final position of the entity
  4402. * @param target defines where the entity should look at
  4403. * @param up defines the up vector for the entity
  4404. * @param result defines the target matrix
  4405. */
  4406. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4407. /**
  4408. * Create a left-handed orthographic projection matrix
  4409. * @param width defines the viewport width
  4410. * @param height defines the viewport height
  4411. * @param znear defines the near clip plane
  4412. * @param zfar defines the far clip plane
  4413. * @returns a new matrix as a left-handed orthographic projection matrix
  4414. */
  4415. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4416. /**
  4417. * Store a left-handed orthographic projection to a given matrix
  4418. * @param width defines the viewport width
  4419. * @param height defines the viewport height
  4420. * @param znear defines the near clip plane
  4421. * @param zfar defines the far clip plane
  4422. * @param result defines the target matrix
  4423. */
  4424. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4425. /**
  4426. * Create a left-handed orthographic projection matrix
  4427. * @param left defines the viewport left coordinate
  4428. * @param right defines the viewport right coordinate
  4429. * @param bottom defines the viewport bottom coordinate
  4430. * @param top defines the viewport top coordinate
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @returns a new matrix as a left-handed orthographic projection matrix
  4434. */
  4435. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4436. /**
  4437. * Stores a left-handed orthographic projection into a given matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @param result defines the target matrix
  4445. */
  4446. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4447. /**
  4448. * Creates a right-handed orthographic projection matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @returns a new matrix as a right-handed orthographic projection matrix
  4456. */
  4457. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4458. /**
  4459. * Stores a right-handed orthographic projection into a given matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Creates a left-handed perspective projection matrix
  4471. * @param width defines the viewport width
  4472. * @param height defines the viewport height
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @returns a new matrix as a left-handed perspective projection matrix
  4476. */
  4477. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4478. /**
  4479. * Creates a left-handed perspective projection matrix
  4480. * @param fov defines the horizontal field of view
  4481. * @param aspect defines the aspect ratio
  4482. * @param znear defines the near clip plane
  4483. * @param zfar defines the far clip plane
  4484. * @returns a new matrix as a left-handed perspective projection matrix
  4485. */
  4486. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4487. /**
  4488. * Stores a left-handed perspective projection into a given matrix
  4489. * @param fov defines the horizontal field of view
  4490. * @param aspect defines the aspect ratio
  4491. * @param znear defines the near clip plane
  4492. * @param zfar defines the far clip plane
  4493. * @param result defines the target matrix
  4494. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4495. */
  4496. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4497. /**
  4498. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4499. * @param fov defines the horizontal field of view
  4500. * @param aspect defines the aspect ratio
  4501. * @param znear defines the near clip plane
  4502. * @param zfar not used as infinity is used as far clip
  4503. * @param result defines the target matrix
  4504. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4505. */
  4506. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4507. /**
  4508. * Creates a right-handed perspective projection matrix
  4509. * @param fov defines the horizontal field of view
  4510. * @param aspect defines the aspect ratio
  4511. * @param znear defines the near clip plane
  4512. * @param zfar defines the far clip plane
  4513. * @returns a new matrix as a right-handed perspective projection matrix
  4514. */
  4515. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4516. /**
  4517. * Stores a right-handed perspective projection into a given matrix
  4518. * @param fov defines the horizontal field of view
  4519. * @param aspect defines the aspect ratio
  4520. * @param znear defines the near clip plane
  4521. * @param zfar defines the far clip plane
  4522. * @param result defines the target matrix
  4523. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4524. */
  4525. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4526. /**
  4527. * Stores a right-handed perspective projection into a given matrix
  4528. * @param fov defines the horizontal field of view
  4529. * @param aspect defines the aspect ratio
  4530. * @param znear defines the near clip plane
  4531. * @param zfar not used as infinity is used as far clip
  4532. * @param result defines the target matrix
  4533. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4534. */
  4535. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4536. /**
  4537. * Stores a perspective projection for WebVR info a given matrix
  4538. * @param fov defines the field of view
  4539. * @param znear defines the near clip plane
  4540. * @param zfar defines the far clip plane
  4541. * @param result defines the target matrix
  4542. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4543. */
  4544. static PerspectiveFovWebVRToRef(fov: {
  4545. upDegrees: number;
  4546. downDegrees: number;
  4547. leftDegrees: number;
  4548. rightDegrees: number;
  4549. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4550. /**
  4551. * Computes a complete transformation matrix
  4552. * @param viewport defines the viewport to use
  4553. * @param world defines the world matrix
  4554. * @param view defines the view matrix
  4555. * @param projection defines the projection matrix
  4556. * @param zmin defines the near clip plane
  4557. * @param zmax defines the far clip plane
  4558. * @returns the transformation matrix
  4559. */
  4560. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4561. /**
  4562. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4563. * @param matrix defines the matrix to use
  4564. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4565. */
  4566. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4567. /**
  4568. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4569. * @param matrix defines the matrix to use
  4570. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4571. */
  4572. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4573. /**
  4574. * Compute the transpose of a given matrix
  4575. * @param matrix defines the matrix to transpose
  4576. * @returns the new matrix
  4577. */
  4578. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4579. /**
  4580. * Compute the transpose of a matrix and store it in a target matrix
  4581. * @param matrix defines the matrix to transpose
  4582. * @param result defines the target matrix
  4583. */
  4584. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4585. /**
  4586. * Computes a reflection matrix from a plane
  4587. * @param plane defines the reflection plane
  4588. * @returns a new matrix
  4589. */
  4590. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4591. /**
  4592. * Computes a reflection matrix from a plane
  4593. * @param plane defines the reflection plane
  4594. * @param result defines the target matrix
  4595. */
  4596. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4597. /**
  4598. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4599. * @param xaxis defines the value of the 1st axis
  4600. * @param yaxis defines the value of the 2nd axis
  4601. * @param zaxis defines the value of the 3rd axis
  4602. * @param result defines the target matrix
  4603. */
  4604. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4605. /**
  4606. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4607. * @param quat defines the quaternion to use
  4608. * @param result defines the target matrix
  4609. */
  4610. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4611. }
  4612. /**
  4613. * @hidden
  4614. */
  4615. export class TmpVectors {
  4616. static Vector2: Vector2[];
  4617. static Vector3: Vector3[];
  4618. static Vector4: Vector4[];
  4619. static Quaternion: Quaternion[];
  4620. static Matrix: Matrix[];
  4621. }
  4622. }
  4623. declare module "babylonjs/Maths/math.path" {
  4624. import { DeepImmutable, Nullable } from "babylonjs/types";
  4625. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4626. /**
  4627. * Defines potential orientation for back face culling
  4628. */
  4629. export enum Orientation {
  4630. /**
  4631. * Clockwise
  4632. */
  4633. CW = 0,
  4634. /** Counter clockwise */
  4635. CCW = 1
  4636. }
  4637. /** Class used to represent a Bezier curve */
  4638. export class BezierCurve {
  4639. /**
  4640. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4641. * @param t defines the time
  4642. * @param x1 defines the left coordinate on X axis
  4643. * @param y1 defines the left coordinate on Y axis
  4644. * @param x2 defines the right coordinate on X axis
  4645. * @param y2 defines the right coordinate on Y axis
  4646. * @returns the interpolated value
  4647. */
  4648. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4649. }
  4650. /**
  4651. * Defines angle representation
  4652. */
  4653. export class Angle {
  4654. private _radians;
  4655. /**
  4656. * Creates an Angle object of "radians" radians (float).
  4657. * @param radians the angle in radians
  4658. */
  4659. constructor(radians: number);
  4660. /**
  4661. * Get value in degrees
  4662. * @returns the Angle value in degrees (float)
  4663. */
  4664. degrees(): number;
  4665. /**
  4666. * Get value in radians
  4667. * @returns the Angle value in radians (float)
  4668. */
  4669. radians(): number;
  4670. /**
  4671. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4672. * @param a defines first vector
  4673. * @param b defines second vector
  4674. * @returns a new Angle
  4675. */
  4676. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4677. /**
  4678. * Gets a new Angle object from the given float in radians
  4679. * @param radians defines the angle value in radians
  4680. * @returns a new Angle
  4681. */
  4682. static FromRadians(radians: number): Angle;
  4683. /**
  4684. * Gets a new Angle object from the given float in degrees
  4685. * @param degrees defines the angle value in degrees
  4686. * @returns a new Angle
  4687. */
  4688. static FromDegrees(degrees: number): Angle;
  4689. }
  4690. /**
  4691. * This represents an arc in a 2d space.
  4692. */
  4693. export class Arc2 {
  4694. /** Defines the start point of the arc */
  4695. startPoint: Vector2;
  4696. /** Defines the mid point of the arc */
  4697. midPoint: Vector2;
  4698. /** Defines the end point of the arc */
  4699. endPoint: Vector2;
  4700. /**
  4701. * Defines the center point of the arc.
  4702. */
  4703. centerPoint: Vector2;
  4704. /**
  4705. * Defines the radius of the arc.
  4706. */
  4707. radius: number;
  4708. /**
  4709. * Defines the angle of the arc (from mid point to end point).
  4710. */
  4711. angle: Angle;
  4712. /**
  4713. * Defines the start angle of the arc (from start point to middle point).
  4714. */
  4715. startAngle: Angle;
  4716. /**
  4717. * Defines the orientation of the arc (clock wise/counter clock wise).
  4718. */
  4719. orientation: Orientation;
  4720. /**
  4721. * Creates an Arc object from the three given points : start, middle and end.
  4722. * @param startPoint Defines the start point of the arc
  4723. * @param midPoint Defines the midlle point of the arc
  4724. * @param endPoint Defines the end point of the arc
  4725. */
  4726. constructor(
  4727. /** Defines the start point of the arc */
  4728. startPoint: Vector2,
  4729. /** Defines the mid point of the arc */
  4730. midPoint: Vector2,
  4731. /** Defines the end point of the arc */
  4732. endPoint: Vector2);
  4733. }
  4734. /**
  4735. * Represents a 2D path made up of multiple 2D points
  4736. */
  4737. export class Path2 {
  4738. private _points;
  4739. private _length;
  4740. /**
  4741. * If the path start and end point are the same
  4742. */
  4743. closed: boolean;
  4744. /**
  4745. * Creates a Path2 object from the starting 2D coordinates x and y.
  4746. * @param x the starting points x value
  4747. * @param y the starting points y value
  4748. */
  4749. constructor(x: number, y: number);
  4750. /**
  4751. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4752. * @param x the added points x value
  4753. * @param y the added points y value
  4754. * @returns the updated Path2.
  4755. */
  4756. addLineTo(x: number, y: number): Path2;
  4757. /**
  4758. * 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.
  4759. * @param midX middle point x value
  4760. * @param midY middle point y value
  4761. * @param endX end point x value
  4762. * @param endY end point y value
  4763. * @param numberOfSegments (default: 36)
  4764. * @returns the updated Path2.
  4765. */
  4766. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4767. /**
  4768. * Closes the Path2.
  4769. * @returns the Path2.
  4770. */
  4771. close(): Path2;
  4772. /**
  4773. * Gets the sum of the distance between each sequential point in the path
  4774. * @returns the Path2 total length (float).
  4775. */
  4776. length(): number;
  4777. /**
  4778. * Gets the points which construct the path
  4779. * @returns the Path2 internal array of points.
  4780. */
  4781. getPoints(): Vector2[];
  4782. /**
  4783. * Retreives the point at the distance aways from the starting point
  4784. * @param normalizedLengthPosition the length along the path to retreive the point from
  4785. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4786. */
  4787. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4788. /**
  4789. * Creates a new path starting from an x and y position
  4790. * @param x starting x value
  4791. * @param y starting y value
  4792. * @returns a new Path2 starting at the coordinates (x, y).
  4793. */
  4794. static StartingAt(x: number, y: number): Path2;
  4795. }
  4796. /**
  4797. * Represents a 3D path made up of multiple 3D points
  4798. */
  4799. export class Path3D {
  4800. /**
  4801. * an array of Vector3, the curve axis of the Path3D
  4802. */
  4803. path: Vector3[];
  4804. private _curve;
  4805. private _distances;
  4806. private _tangents;
  4807. private _normals;
  4808. private _binormals;
  4809. private _raw;
  4810. private _alignTangentsWithPath;
  4811. private readonly _pointAtData;
  4812. /**
  4813. * new Path3D(path, normal, raw)
  4814. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4815. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4816. * @param path an array of Vector3, the curve axis of the Path3D
  4817. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4818. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4819. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4820. */
  4821. constructor(
  4822. /**
  4823. * an array of Vector3, the curve axis of the Path3D
  4824. */
  4825. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4826. /**
  4827. * Returns the Path3D array of successive Vector3 designing its curve.
  4828. * @returns the Path3D array of successive Vector3 designing its curve.
  4829. */
  4830. getCurve(): Vector3[];
  4831. /**
  4832. * Returns the Path3D array of successive Vector3 designing its curve.
  4833. * @returns the Path3D array of successive Vector3 designing its curve.
  4834. */
  4835. getPoints(): Vector3[];
  4836. /**
  4837. * @returns the computed length (float) of the path.
  4838. */
  4839. length(): number;
  4840. /**
  4841. * Returns an array populated with tangent vectors on each Path3D curve point.
  4842. * @returns an array populated with tangent vectors on each Path3D curve point.
  4843. */
  4844. getTangents(): Vector3[];
  4845. /**
  4846. * Returns an array populated with normal vectors on each Path3D curve point.
  4847. * @returns an array populated with normal vectors on each Path3D curve point.
  4848. */
  4849. getNormals(): Vector3[];
  4850. /**
  4851. * Returns an array populated with binormal vectors on each Path3D curve point.
  4852. * @returns an array populated with binormal vectors on each Path3D curve point.
  4853. */
  4854. getBinormals(): Vector3[];
  4855. /**
  4856. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4857. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4858. */
  4859. getDistances(): number[];
  4860. /**
  4861. * Returns an interpolated point along this path
  4862. * @param position the position of the point along this path, from 0.0 to 1.0
  4863. * @returns a new Vector3 as the point
  4864. */
  4865. getPointAt(position: number): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4870. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4871. */
  4872. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4877. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4878. */
  4879. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4884. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4885. */
  4886. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4887. /**
  4888. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4889. * @param position the position of the point along this path, from 0.0 to 1.0
  4890. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4891. */
  4892. getDistanceAt(position: number): number;
  4893. /**
  4894. * Returns the array index of the previous point of an interpolated point along this path
  4895. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4896. * @returns the array index
  4897. */
  4898. getPreviousPointIndexAt(position: number): number;
  4899. /**
  4900. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4901. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4902. * @returns the sub position
  4903. */
  4904. getSubPositionAt(position: number): number;
  4905. /**
  4906. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4907. * @param target the vector of which to get the closest position to
  4908. * @returns the position of the closest virtual point on this path to the target vector
  4909. */
  4910. getClosestPositionTo(target: Vector3): number;
  4911. /**
  4912. * Returns a sub path (slice) of this path
  4913. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4914. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4915. * @returns a sub path (slice) of this path
  4916. */
  4917. slice(start?: number, end?: number): Path3D;
  4918. /**
  4919. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4920. * @param path path which all values are copied into the curves points
  4921. * @param firstNormal which should be projected onto the curve
  4922. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4923. * @returns the same object updated.
  4924. */
  4925. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4926. private _compute;
  4927. private _getFirstNonNullVector;
  4928. private _getLastNonNullVector;
  4929. private _normalVector;
  4930. /**
  4931. * Updates the point at data for an interpolated point along this curve
  4932. * @param position the position of the point along this curve, from 0.0 to 1.0
  4933. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4934. * @returns the (updated) point at data
  4935. */
  4936. private _updatePointAtData;
  4937. /**
  4938. * Updates the point at data from the specified parameters
  4939. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4940. * @param point the interpolated point
  4941. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4942. */
  4943. private _setPointAtData;
  4944. /**
  4945. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4946. */
  4947. private _updateInterpolationMatrix;
  4948. }
  4949. /**
  4950. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4951. * A Curve3 is designed from a series of successive Vector3.
  4952. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4953. */
  4954. export class Curve3 {
  4955. private _points;
  4956. private _length;
  4957. /**
  4958. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4959. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4960. * @param v1 (Vector3) the control point
  4961. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4962. * @param nbPoints (integer) the wanted number of points in the curve
  4963. * @returns the created Curve3
  4964. */
  4965. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4966. /**
  4967. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4969. * @param v1 (Vector3) the first control point
  4970. * @param v2 (Vector3) the second control point
  4971. * @param v3 (Vector3) the end point of the Cubic Bezier
  4972. * @param nbPoints (integer) the wanted number of points in the curve
  4973. * @returns the created Curve3
  4974. */
  4975. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4976. /**
  4977. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4978. * @param p1 (Vector3) the origin point of the Hermite Spline
  4979. * @param t1 (Vector3) the tangent vector at the origin point
  4980. * @param p2 (Vector3) the end point of the Hermite Spline
  4981. * @param t2 (Vector3) the tangent vector at the end point
  4982. * @param nbPoints (integer) the wanted number of points in the curve
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4986. /**
  4987. * Returns a Curve3 object along a CatmullRom Spline curve :
  4988. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4989. * @param nbPoints (integer) the wanted number of points between each curve control points
  4990. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4994. /**
  4995. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4996. * A Curve3 is designed from a series of successive Vector3.
  4997. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4998. * @param points points which make up the curve
  4999. */
  5000. constructor(points: Vector3[]);
  5001. /**
  5002. * @returns the Curve3 stored array of successive Vector3
  5003. */
  5004. getPoints(): Vector3[];
  5005. /**
  5006. * @returns the computed length (float) of the curve.
  5007. */
  5008. length(): number;
  5009. /**
  5010. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5011. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5012. * curveA and curveB keep unchanged.
  5013. * @param curve the curve to continue from this curve
  5014. * @returns the newly constructed curve
  5015. */
  5016. continue(curve: DeepImmutable<Curve3>): Curve3;
  5017. private _computeLength;
  5018. }
  5019. }
  5020. declare module "babylonjs/Animations/easing" {
  5021. /**
  5022. * This represents the main contract an easing function should follow.
  5023. * Easing functions are used throughout the animation system.
  5024. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5025. */
  5026. export interface IEasingFunction {
  5027. /**
  5028. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5029. * of the easing function.
  5030. * The link below provides some of the most common examples of easing functions.
  5031. * @see https://easings.net/
  5032. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5033. * @returns the corresponding value on the curve defined by the easing function
  5034. */
  5035. ease(gradient: number): number;
  5036. }
  5037. /**
  5038. * Base class used for every default easing function.
  5039. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5040. */
  5041. export class EasingFunction implements IEasingFunction {
  5042. /**
  5043. * Interpolation follows the mathematical formula associated with the easing function.
  5044. */
  5045. static readonly EASINGMODE_EASEIN: number;
  5046. /**
  5047. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5048. */
  5049. static readonly EASINGMODE_EASEOUT: number;
  5050. /**
  5051. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5052. */
  5053. static readonly EASINGMODE_EASEINOUT: number;
  5054. private _easingMode;
  5055. /**
  5056. * Sets the easing mode of the current function.
  5057. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5058. */
  5059. setEasingMode(easingMode: number): void;
  5060. /**
  5061. * Gets the current easing mode.
  5062. * @returns the easing mode
  5063. */
  5064. getEasingMode(): number;
  5065. /**
  5066. * @hidden
  5067. */
  5068. easeInCore(gradient: number): number;
  5069. /**
  5070. * Given an input gradient between 0 and 1, this returns the corresponding value
  5071. * of the easing function.
  5072. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5073. * @returns the corresponding value on the curve defined by the easing function
  5074. */
  5075. ease(gradient: number): number;
  5076. }
  5077. /**
  5078. * Easing function with a circle shape (see link below).
  5079. * @see https://easings.net/#easeInCirc
  5080. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5081. */
  5082. export class CircleEase extends EasingFunction implements IEasingFunction {
  5083. /** @hidden */
  5084. easeInCore(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a ease back shape (see link below).
  5088. * @see https://easings.net/#easeInBack
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class BackEase extends EasingFunction implements IEasingFunction {
  5092. /** Defines the amplitude of the function */
  5093. amplitude: number;
  5094. /**
  5095. * Instantiates a back ease easing
  5096. * @see https://easings.net/#easeInBack
  5097. * @param amplitude Defines the amplitude of the function
  5098. */
  5099. constructor(
  5100. /** Defines the amplitude of the function */
  5101. amplitude?: number);
  5102. /** @hidden */
  5103. easeInCore(gradient: number): number;
  5104. }
  5105. /**
  5106. * Easing function with a bouncing shape (see link below).
  5107. * @see https://easings.net/#easeInBounce
  5108. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5109. */
  5110. export class BounceEase extends EasingFunction implements IEasingFunction {
  5111. /** Defines the number of bounces */
  5112. bounces: number;
  5113. /** Defines the amplitude of the bounce */
  5114. bounciness: number;
  5115. /**
  5116. * Instantiates a bounce easing
  5117. * @see https://easings.net/#easeInBounce
  5118. * @param bounces Defines the number of bounces
  5119. * @param bounciness Defines the amplitude of the bounce
  5120. */
  5121. constructor(
  5122. /** Defines the number of bounces */
  5123. bounces?: number,
  5124. /** Defines the amplitude of the bounce */
  5125. bounciness?: number);
  5126. /** @hidden */
  5127. easeInCore(gradient: number): number;
  5128. }
  5129. /**
  5130. * Easing function with a power of 3 shape (see link below).
  5131. * @see https://easings.net/#easeInCubic
  5132. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5133. */
  5134. export class CubicEase extends EasingFunction implements IEasingFunction {
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with an elastic shape (see link below).
  5140. * @see https://easings.net/#easeInElastic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5144. /** Defines the number of oscillations*/
  5145. oscillations: number;
  5146. /** Defines the amplitude of the oscillations*/
  5147. springiness: number;
  5148. /**
  5149. * Instantiates an elastic easing function
  5150. * @see https://easings.net/#easeInElastic
  5151. * @param oscillations Defines the number of oscillations
  5152. * @param springiness Defines the amplitude of the oscillations
  5153. */
  5154. constructor(
  5155. /** Defines the number of oscillations*/
  5156. oscillations?: number,
  5157. /** Defines the amplitude of the oscillations*/
  5158. springiness?: number);
  5159. /** @hidden */
  5160. easeInCore(gradient: number): number;
  5161. }
  5162. /**
  5163. * Easing function with an exponential shape (see link below).
  5164. * @see https://easings.net/#easeInExpo
  5165. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5166. */
  5167. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5168. /** Defines the exponent of the function */
  5169. exponent: number;
  5170. /**
  5171. * Instantiates an exponential easing function
  5172. * @see https://easings.net/#easeInExpo
  5173. * @param exponent Defines the exponent of the function
  5174. */
  5175. constructor(
  5176. /** Defines the exponent of the function */
  5177. exponent?: number);
  5178. /** @hidden */
  5179. easeInCore(gradient: number): number;
  5180. }
  5181. /**
  5182. * Easing function with a power shape (see link below).
  5183. * @see https://easings.net/#easeInQuad
  5184. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5185. */
  5186. export class PowerEase extends EasingFunction implements IEasingFunction {
  5187. /** Defines the power of the function */
  5188. power: number;
  5189. /**
  5190. * Instantiates an power base easing function
  5191. * @see https://easings.net/#easeInQuad
  5192. * @param power Defines the power of the function
  5193. */
  5194. constructor(
  5195. /** Defines the power of the function */
  5196. power?: number);
  5197. /** @hidden */
  5198. easeInCore(gradient: number): number;
  5199. }
  5200. /**
  5201. * Easing function with a power of 2 shape (see link below).
  5202. * @see https://easings.net/#easeInQuad
  5203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5204. */
  5205. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 4 shape (see link below).
  5211. * @see https://easings.net/#easeInQuart
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 5 shape (see link below).
  5220. * @see https://easings.net/#easeInQuint
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a sin shape (see link below).
  5229. * @see https://easings.net/#easeInSine
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class SineEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a bezier shape (see link below).
  5238. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the x component of the start tangent in the bezier curve */
  5243. x1: number;
  5244. /** Defines the y component of the start tangent in the bezier curve */
  5245. y1: number;
  5246. /** Defines the x component of the end tangent in the bezier curve */
  5247. x2: number;
  5248. /** Defines the y component of the end tangent in the bezier curve */
  5249. y2: number;
  5250. /**
  5251. * Instantiates a bezier function
  5252. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5253. * @param x1 Defines the x component of the start tangent in the bezier curve
  5254. * @param y1 Defines the y component of the start tangent in the bezier curve
  5255. * @param x2 Defines the x component of the end tangent in the bezier curve
  5256. * @param y2 Defines the y component of the end tangent in the bezier curve
  5257. */
  5258. constructor(
  5259. /** Defines the x component of the start tangent in the bezier curve */
  5260. x1?: number,
  5261. /** Defines the y component of the start tangent in the bezier curve */
  5262. y1?: number,
  5263. /** Defines the x component of the end tangent in the bezier curve */
  5264. x2?: number,
  5265. /** Defines the y component of the end tangent in the bezier curve */
  5266. y2?: number);
  5267. /** @hidden */
  5268. easeInCore(gradient: number): number;
  5269. }
  5270. }
  5271. declare module "babylonjs/Maths/math.color" {
  5272. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5273. /**
  5274. * Class used to hold a RBG color
  5275. */
  5276. export class Color3 {
  5277. /**
  5278. * Defines the red component (between 0 and 1, default is 0)
  5279. */
  5280. r: number;
  5281. /**
  5282. * Defines the green component (between 0 and 1, default is 0)
  5283. */
  5284. g: number;
  5285. /**
  5286. * Defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. b: number;
  5289. /**
  5290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5291. * @param r defines the red component (between 0 and 1, default is 0)
  5292. * @param g defines the green component (between 0 and 1, default is 0)
  5293. * @param b defines the blue component (between 0 and 1, default is 0)
  5294. */
  5295. constructor(
  5296. /**
  5297. * Defines the red component (between 0 and 1, default is 0)
  5298. */
  5299. r?: number,
  5300. /**
  5301. * Defines the green component (between 0 and 1, default is 0)
  5302. */
  5303. g?: number,
  5304. /**
  5305. * Defines the blue component (between 0 and 1, default is 0)
  5306. */
  5307. b?: number);
  5308. /**
  5309. * Creates a string with the Color3 current values
  5310. * @returns the string representation of the Color3 object
  5311. */
  5312. toString(): string;
  5313. /**
  5314. * Returns the string "Color3"
  5315. * @returns "Color3"
  5316. */
  5317. getClassName(): string;
  5318. /**
  5319. * Compute the Color3 hash code
  5320. * @returns an unique number that can be used to hash Color3 objects
  5321. */
  5322. getHashCode(): number;
  5323. /**
  5324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5325. * @param array defines the array where to store the r,g,b components
  5326. * @param index defines an optional index in the target array to define where to start storing values
  5327. * @returns the current Color3 object
  5328. */
  5329. toArray(array: FloatArray, index?: number): Color3;
  5330. /**
  5331. * Returns a new Color4 object from the current Color3 and the given alpha
  5332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5333. * @returns a new Color4 object
  5334. */
  5335. toColor4(alpha?: number): Color4;
  5336. /**
  5337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5338. * @returns the new array
  5339. */
  5340. asArray(): number[];
  5341. /**
  5342. * Returns the luminance value
  5343. * @returns a float value
  5344. */
  5345. toLuminance(): number;
  5346. /**
  5347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5348. * @param otherColor defines the second operand
  5349. * @returns the new Color3 object
  5350. */
  5351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5352. /**
  5353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5354. * @param otherColor defines the second operand
  5355. * @param result defines the Color3 object where to store the result
  5356. * @returns the current Color3
  5357. */
  5358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5359. /**
  5360. * Determines equality between Color3 objects
  5361. * @param otherColor defines the second operand
  5362. * @returns true if the rgb values are equal to the given ones
  5363. */
  5364. equals(otherColor: DeepImmutable<Color3>): boolean;
  5365. /**
  5366. * Determines equality between the current Color3 object and a set of r,b,g values
  5367. * @param r defines the red component to check
  5368. * @param g defines the green component to check
  5369. * @param b defines the blue component to check
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equalsFloats(r: number, g: number, b: number): boolean;
  5373. /**
  5374. * Multiplies in place each rgb value by scale
  5375. * @param scale defines the scaling factor
  5376. * @returns the updated Color3
  5377. */
  5378. scale(scale: number): Color3;
  5379. /**
  5380. * Multiplies the rgb values by scale and stores the result into "result"
  5381. * @param scale defines the scaling factor
  5382. * @param result defines the Color3 object where to store the result
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Scale the current Color3 values by a factor and add the result to a given Color3
  5388. * @param scale defines the scale factor
  5389. * @param result defines color to store the result into
  5390. * @returns the unmodified current Color3
  5391. */
  5392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5393. /**
  5394. * Clamps the rgb values by the min and max values and stores the result into "result"
  5395. * @param min defines minimum clamping value (default is 0)
  5396. * @param max defines maximum clamping value (default is 1)
  5397. * @param result defines color to store the result into
  5398. * @returns the original Color3
  5399. */
  5400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5401. /**
  5402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5403. * @param otherColor defines the second operand
  5404. * @returns the new Color3
  5405. */
  5406. add(otherColor: DeepImmutable<Color3>): Color3;
  5407. /**
  5408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5409. * @param otherColor defines the second operand
  5410. * @param result defines Color3 object to store the result into
  5411. * @returns the unmodified current Color3
  5412. */
  5413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5414. /**
  5415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5416. * @param otherColor defines the second operand
  5417. * @returns the new Color3
  5418. */
  5419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5420. /**
  5421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5422. * @param otherColor defines the second operand
  5423. * @param result defines Color3 object to store the result into
  5424. * @returns the unmodified current Color3
  5425. */
  5426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5427. /**
  5428. * Copy the current object
  5429. * @returns a new Color3 copied the current one
  5430. */
  5431. clone(): Color3;
  5432. /**
  5433. * Copies the rgb values from the source in the current Color3
  5434. * @param source defines the source Color3 object
  5435. * @returns the updated Color3 object
  5436. */
  5437. copyFrom(source: DeepImmutable<Color3>): Color3;
  5438. /**
  5439. * Updates the Color3 rgb values from the given floats
  5440. * @param r defines the red component to read from
  5441. * @param g defines the green component to read from
  5442. * @param b defines the blue component to read from
  5443. * @returns the current Color3 object
  5444. */
  5445. copyFromFloats(r: number, g: number, b: number): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. set(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Compute the Color3 hexadecimal code as a string
  5456. * @returns a string containing the hexadecimal representation of the Color3 object
  5457. */
  5458. toHexString(): string;
  5459. /**
  5460. * Computes a new Color3 converted from the current one to linear space
  5461. * @returns a new Color3 object
  5462. */
  5463. toLinearSpace(): Color3;
  5464. /**
  5465. * Converts current color in rgb space to HSV values
  5466. * @returns a new color3 representing the HSV values
  5467. */
  5468. toHSV(): Color3;
  5469. /**
  5470. * Converts current color in rgb space to HSV values
  5471. * @param result defines the Color3 where to store the HSV values
  5472. */
  5473. toHSVToRef(result: Color3): void;
  5474. /**
  5475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5476. * @param convertedColor defines the Color3 object where to store the linear space version
  5477. * @returns the unmodified Color3
  5478. */
  5479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5480. /**
  5481. * Computes a new Color3 converted from the current one to gamma space
  5482. * @returns a new Color3 object
  5483. */
  5484. toGammaSpace(): Color3;
  5485. /**
  5486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5487. * @param convertedColor defines the Color3 object where to store the gamma space version
  5488. * @returns the unmodified Color3
  5489. */
  5490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5491. private static _BlackReadOnly;
  5492. /**
  5493. * Convert Hue, saturation and value to a Color3 (RGB)
  5494. * @param hue defines the hue
  5495. * @param saturation defines the saturation
  5496. * @param value defines the value
  5497. * @param result defines the Color3 where to store the RGB values
  5498. */
  5499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5500. /**
  5501. * Creates a new Color3 from the string containing valid hexadecimal values
  5502. * @param hex defines a string containing valid hexadecimal values
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromHexString(hex: string): Color3;
  5506. /**
  5507. * Creates a new Color3 from the starting index of the given array
  5508. * @param array defines the source array
  5509. * @param offset defines an offset in the source array
  5510. * @returns a new Color3 object
  5511. */
  5512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5513. /**
  5514. * Creates a new Color3 from integer values (< 256)
  5515. * @param r defines the red component to read from (value between 0 and 255)
  5516. * @param g defines the green component to read from (value between 0 and 255)
  5517. * @param b defines the blue component to read from (value between 0 and 255)
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromInts(r: number, g: number, b: number): Color3;
  5521. /**
  5522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5523. * @param start defines the start Color3 value
  5524. * @param end defines the end Color3 value
  5525. * @param amount defines the gradient value between start and end
  5526. * @returns a new Color3 object
  5527. */
  5528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param left defines the start value
  5532. * @param right defines the end value
  5533. * @param amount defines the gradient factor
  5534. * @param result defines the Color3 object where to store the result
  5535. */
  5536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5537. /**
  5538. * Returns a Color3 value containing a red color
  5539. * @returns a new Color3 object
  5540. */
  5541. static Red(): Color3;
  5542. /**
  5543. * Returns a Color3 value containing a green color
  5544. * @returns a new Color3 object
  5545. */
  5546. static Green(): Color3;
  5547. /**
  5548. * Returns a Color3 value containing a blue color
  5549. * @returns a new Color3 object
  5550. */
  5551. static Blue(): Color3;
  5552. /**
  5553. * Returns a Color3 value containing a black color
  5554. * @returns a new Color3 object
  5555. */
  5556. static Black(): Color3;
  5557. /**
  5558. * Gets a Color3 value containing a black color that must not be updated
  5559. */
  5560. static get BlackReadOnly(): DeepImmutable<Color3>;
  5561. /**
  5562. * Returns a Color3 value containing a white color
  5563. * @returns a new Color3 object
  5564. */
  5565. static White(): Color3;
  5566. /**
  5567. * Returns a Color3 value containing a purple color
  5568. * @returns a new Color3 object
  5569. */
  5570. static Purple(): Color3;
  5571. /**
  5572. * Returns a Color3 value containing a magenta color
  5573. * @returns a new Color3 object
  5574. */
  5575. static Magenta(): Color3;
  5576. /**
  5577. * Returns a Color3 value containing a yellow color
  5578. * @returns a new Color3 object
  5579. */
  5580. static Yellow(): Color3;
  5581. /**
  5582. * Returns a Color3 value containing a gray color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Gray(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a teal color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Teal(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a random color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Random(): Color3;
  5596. }
  5597. /**
  5598. * Class used to hold a RBGA color
  5599. */
  5600. export class Color4 {
  5601. /**
  5602. * Defines the red component (between 0 and 1, default is 0)
  5603. */
  5604. r: number;
  5605. /**
  5606. * Defines the green component (between 0 and 1, default is 0)
  5607. */
  5608. g: number;
  5609. /**
  5610. * Defines the blue component (between 0 and 1, default is 0)
  5611. */
  5612. b: number;
  5613. /**
  5614. * Defines the alpha component (between 0 and 1, default is 1)
  5615. */
  5616. a: number;
  5617. /**
  5618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5619. * @param r defines the red component (between 0 and 1, default is 0)
  5620. * @param g defines the green component (between 0 and 1, default is 0)
  5621. * @param b defines the blue component (between 0 and 1, default is 0)
  5622. * @param a defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. constructor(
  5625. /**
  5626. * Defines the red component (between 0 and 1, default is 0)
  5627. */
  5628. r?: number,
  5629. /**
  5630. * Defines the green component (between 0 and 1, default is 0)
  5631. */
  5632. g?: number,
  5633. /**
  5634. * Defines the blue component (between 0 and 1, default is 0)
  5635. */
  5636. b?: number,
  5637. /**
  5638. * Defines the alpha component (between 0 and 1, default is 1)
  5639. */
  5640. a?: number);
  5641. /**
  5642. * Adds in place the given Color4 values to the current Color4 object
  5643. * @param right defines the second operand
  5644. * @returns the current updated Color4 object
  5645. */
  5646. addInPlace(right: DeepImmutable<Color4>): Color4;
  5647. /**
  5648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5649. * @returns the new array
  5650. */
  5651. asArray(): number[];
  5652. /**
  5653. * Stores from the starting index in the given array the Color4 successive values
  5654. * @param array defines the array where to store the r,g,b components
  5655. * @param index defines an optional index in the target array to define where to start storing values
  5656. * @returns the current Color4 object
  5657. */
  5658. toArray(array: number[], index?: number): Color4;
  5659. /**
  5660. * Determines equality between Color4 objects
  5661. * @param otherColor defines the second operand
  5662. * @returns true if the rgba values are equal to the given ones
  5663. */
  5664. equals(otherColor: DeepImmutable<Color4>): boolean;
  5665. /**
  5666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5667. * @param right defines the second operand
  5668. * @returns a new Color4 object
  5669. */
  5670. add(right: DeepImmutable<Color4>): Color4;
  5671. /**
  5672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5673. * @param right defines the second operand
  5674. * @returns a new Color4 object
  5675. */
  5676. subtract(right: DeepImmutable<Color4>): Color4;
  5677. /**
  5678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5679. * @param right defines the second operand
  5680. * @param result defines the Color4 object where to store the result
  5681. * @returns the current Color4 object
  5682. */
  5683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5684. /**
  5685. * Creates a new Color4 with the current Color4 values multiplied by scale
  5686. * @param scale defines the scaling factor to apply
  5687. * @returns a new Color4 object
  5688. */
  5689. scale(scale: number): Color4;
  5690. /**
  5691. * Multiplies the current Color4 values by scale and stores the result in "result"
  5692. * @param scale defines the scaling factor to apply
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the current unmodified Color4
  5695. */
  5696. scaleToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Scale the current Color4 values by a factor and add the result to a given Color4
  5699. * @param scale defines the scale factor
  5700. * @param result defines the Color4 object where to store the result
  5701. * @returns the unmodified current Color4
  5702. */
  5703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5704. /**
  5705. * Clamps the rgb values by the min and max values and stores the result into "result"
  5706. * @param min defines minimum clamping value (default is 0)
  5707. * @param max defines maximum clamping value (default is 1)
  5708. * @param result defines color to store the result into.
  5709. * @returns the cuurent Color4
  5710. */
  5711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5712. /**
  5713. * Multipy an Color4 value by another and return a new Color4 object
  5714. * @param color defines the Color4 value to multiply by
  5715. * @returns a new Color4 object
  5716. */
  5717. multiply(color: Color4): Color4;
  5718. /**
  5719. * Multipy a Color4 value by another and push the result in a reference value
  5720. * @param color defines the Color4 value to multiply by
  5721. * @param result defines the Color4 to fill the result in
  5722. * @returns the result Color4
  5723. */
  5724. multiplyToRef(color: Color4, result: Color4): Color4;
  5725. /**
  5726. * Creates a string with the Color4 current values
  5727. * @returns the string representation of the Color4 object
  5728. */
  5729. toString(): string;
  5730. /**
  5731. * Returns the string "Color4"
  5732. * @returns "Color4"
  5733. */
  5734. getClassName(): string;
  5735. /**
  5736. * Compute the Color4 hash code
  5737. * @returns an unique number that can be used to hash Color4 objects
  5738. */
  5739. getHashCode(): number;
  5740. /**
  5741. * Creates a new Color4 copied from the current one
  5742. * @returns a new Color4 object
  5743. */
  5744. clone(): Color4;
  5745. /**
  5746. * Copies the given Color4 values into the current one
  5747. * @param source defines the source Color4 object
  5748. * @returns the current updated Color4 object
  5749. */
  5750. copyFrom(source: Color4): Color4;
  5751. /**
  5752. * Copies the given float values into the current one
  5753. * @param r defines the red component to read from
  5754. * @param g defines the green component to read from
  5755. * @param b defines the blue component to read from
  5756. * @param a defines the alpha component to read from
  5757. * @returns the current updated Color4 object
  5758. */
  5759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5760. /**
  5761. * Copies the given float values into the current one
  5762. * @param r defines the red component to read from
  5763. * @param g defines the green component to read from
  5764. * @param b defines the blue component to read from
  5765. * @param a defines the alpha component to read from
  5766. * @returns the current updated Color4 object
  5767. */
  5768. set(r: number, g: number, b: number, a: number): Color4;
  5769. /**
  5770. * Compute the Color4 hexadecimal code as a string
  5771. * @returns a string containing the hexadecimal representation of the Color4 object
  5772. */
  5773. toHexString(): string;
  5774. /**
  5775. * Computes a new Color4 converted from the current one to linear space
  5776. * @returns a new Color4 object
  5777. */
  5778. toLinearSpace(): Color4;
  5779. /**
  5780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5781. * @param convertedColor defines the Color4 object where to store the linear space version
  5782. * @returns the unmodified Color4
  5783. */
  5784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5785. /**
  5786. * Computes a new Color4 converted from the current one to gamma space
  5787. * @returns a new Color4 object
  5788. */
  5789. toGammaSpace(): Color4;
  5790. /**
  5791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5792. * @param convertedColor defines the Color4 object where to store the gamma space version
  5793. * @returns the unmodified Color4
  5794. */
  5795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5796. /**
  5797. * Creates a new Color4 from the string containing valid hexadecimal values
  5798. * @param hex defines a string containing valid hexadecimal values
  5799. * @returns a new Color4 object
  5800. */
  5801. static FromHexString(hex: string): Color4;
  5802. /**
  5803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5804. * @param left defines the start value
  5805. * @param right defines the end value
  5806. * @param amount defines the gradient factor
  5807. * @returns a new Color4 object
  5808. */
  5809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5810. /**
  5811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @param result defines the Color4 object where to store data
  5816. */
  5817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5818. /**
  5819. * Creates a new Color4 from a Color3 and an alpha value
  5820. * @param color3 defines the source Color3 to read from
  5821. * @param alpha defines the alpha component (1.0 by default)
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5825. /**
  5826. * Creates a new Color4 from the starting index element of the given array
  5827. * @param array defines the source array to read from
  5828. * @param offset defines the offset in the source array
  5829. * @returns a new Color4 object
  5830. */
  5831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5832. /**
  5833. * Creates a new Color3 from integer values (< 256)
  5834. * @param r defines the red component to read from (value between 0 and 255)
  5835. * @param g defines the green component to read from (value between 0 and 255)
  5836. * @param b defines the blue component to read from (value between 0 and 255)
  5837. * @param a defines the alpha component to read from (value between 0 and 255)
  5838. * @returns a new Color3 object
  5839. */
  5840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5841. /**
  5842. * Check the content of a given array and convert it to an array containing RGBA data
  5843. * If the original array was already containing count * 4 values then it is returned directly
  5844. * @param colors defines the array to check
  5845. * @param count defines the number of RGBA data to expect
  5846. * @returns an array containing count * 4 values (RGBA)
  5847. */
  5848. static CheckColors4(colors: number[], count: number): number[];
  5849. }
  5850. /**
  5851. * @hidden
  5852. */
  5853. export class TmpColors {
  5854. static Color3: Color3[];
  5855. static Color4: Color4[];
  5856. }
  5857. }
  5858. declare module "babylonjs/Animations/animationKey" {
  5859. /**
  5860. * Defines an interface which represents an animation key frame
  5861. */
  5862. export interface IAnimationKey {
  5863. /**
  5864. * Frame of the key frame
  5865. */
  5866. frame: number;
  5867. /**
  5868. * Value at the specifies key frame
  5869. */
  5870. value: any;
  5871. /**
  5872. * The input tangent for the cubic hermite spline
  5873. */
  5874. inTangent?: any;
  5875. /**
  5876. * The output tangent for the cubic hermite spline
  5877. */
  5878. outTangent?: any;
  5879. /**
  5880. * The animation interpolation type
  5881. */
  5882. interpolation?: AnimationKeyInterpolation;
  5883. }
  5884. /**
  5885. * Enum for the animation key frame interpolation type
  5886. */
  5887. export enum AnimationKeyInterpolation {
  5888. /**
  5889. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5890. */
  5891. STEP = 1
  5892. }
  5893. }
  5894. declare module "babylonjs/Animations/animationRange" {
  5895. /**
  5896. * Represents the range of an animation
  5897. */
  5898. export class AnimationRange {
  5899. /**The name of the animation range**/
  5900. name: string;
  5901. /**The starting frame of the animation */
  5902. from: number;
  5903. /**The ending frame of the animation*/
  5904. to: number;
  5905. /**
  5906. * Initializes the range of an animation
  5907. * @param name The name of the animation range
  5908. * @param from The starting frame of the animation
  5909. * @param to The ending frame of the animation
  5910. */
  5911. constructor(
  5912. /**The name of the animation range**/
  5913. name: string,
  5914. /**The starting frame of the animation */
  5915. from: number,
  5916. /**The ending frame of the animation*/
  5917. to: number);
  5918. /**
  5919. * Makes a copy of the animation range
  5920. * @returns A copy of the animation range
  5921. */
  5922. clone(): AnimationRange;
  5923. }
  5924. }
  5925. declare module "babylonjs/Animations/animationEvent" {
  5926. /**
  5927. * Composed of a frame, and an action function
  5928. */
  5929. export class AnimationEvent {
  5930. /** The frame for which the event is triggered **/
  5931. frame: number;
  5932. /** The event to perform when triggered **/
  5933. action: (currentFrame: number) => void;
  5934. /** Specifies if the event should be triggered only once**/
  5935. onlyOnce?: boolean | undefined;
  5936. /**
  5937. * Specifies if the animation event is done
  5938. */
  5939. isDone: boolean;
  5940. /**
  5941. * Initializes the animation event
  5942. * @param frame The frame for which the event is triggered
  5943. * @param action The event to perform when triggered
  5944. * @param onlyOnce Specifies if the event should be triggered only once
  5945. */
  5946. constructor(
  5947. /** The frame for which the event is triggered **/
  5948. frame: number,
  5949. /** The event to perform when triggered **/
  5950. action: (currentFrame: number) => void,
  5951. /** Specifies if the event should be triggered only once**/
  5952. onlyOnce?: boolean | undefined);
  5953. /** @hidden */
  5954. _clone(): AnimationEvent;
  5955. }
  5956. }
  5957. declare module "babylonjs/Behaviors/behavior" {
  5958. import { Nullable } from "babylonjs/types";
  5959. /**
  5960. * Interface used to define a behavior
  5961. */
  5962. export interface Behavior<T> {
  5963. /** gets or sets behavior's name */
  5964. name: string;
  5965. /**
  5966. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5967. */
  5968. init(): void;
  5969. /**
  5970. * Called when the behavior is attached to a target
  5971. * @param target defines the target where the behavior is attached to
  5972. */
  5973. attach(target: T): void;
  5974. /**
  5975. * Called when the behavior is detached from its target
  5976. */
  5977. detach(): void;
  5978. }
  5979. /**
  5980. * Interface implemented by classes supporting behaviors
  5981. */
  5982. export interface IBehaviorAware<T> {
  5983. /**
  5984. * Attach a behavior
  5985. * @param behavior defines the behavior to attach
  5986. * @returns the current host
  5987. */
  5988. addBehavior(behavior: Behavior<T>): T;
  5989. /**
  5990. * Remove a behavior from the current object
  5991. * @param behavior defines the behavior to detach
  5992. * @returns the current host
  5993. */
  5994. removeBehavior(behavior: Behavior<T>): T;
  5995. /**
  5996. * Gets a behavior using its name to search
  5997. * @param name defines the name to search
  5998. * @returns the behavior or null if not found
  5999. */
  6000. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6001. }
  6002. }
  6003. declare module "babylonjs/Misc/smartArray" {
  6004. /**
  6005. * Defines an array and its length.
  6006. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6007. */
  6008. export interface ISmartArrayLike<T> {
  6009. /**
  6010. * The data of the array.
  6011. */
  6012. data: Array<T>;
  6013. /**
  6014. * The active length of the array.
  6015. */
  6016. length: number;
  6017. }
  6018. /**
  6019. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6020. */
  6021. export class SmartArray<T> implements ISmartArrayLike<T> {
  6022. /**
  6023. * The full set of data from the array.
  6024. */
  6025. data: Array<T>;
  6026. /**
  6027. * The active length of the array.
  6028. */
  6029. length: number;
  6030. protected _id: number;
  6031. /**
  6032. * Instantiates a Smart Array.
  6033. * @param capacity defines the default capacity of the array.
  6034. */
  6035. constructor(capacity: number);
  6036. /**
  6037. * Pushes a value at the end of the active data.
  6038. * @param value defines the object to push in the array.
  6039. */
  6040. push(value: T): void;
  6041. /**
  6042. * Iterates over the active data and apply the lambda to them.
  6043. * @param func defines the action to apply on each value.
  6044. */
  6045. forEach(func: (content: T) => void): void;
  6046. /**
  6047. * Sorts the full sets of data.
  6048. * @param compareFn defines the comparison function to apply.
  6049. */
  6050. sort(compareFn: (a: T, b: T) => number): void;
  6051. /**
  6052. * Resets the active data to an empty array.
  6053. */
  6054. reset(): void;
  6055. /**
  6056. * Releases all the data from the array as well as the array.
  6057. */
  6058. dispose(): void;
  6059. /**
  6060. * Concats the active data with a given array.
  6061. * @param array defines the data to concatenate with.
  6062. */
  6063. concat(array: any): void;
  6064. /**
  6065. * Returns the position of a value in the active data.
  6066. * @param value defines the value to find the index for
  6067. * @returns the index if found in the active data otherwise -1
  6068. */
  6069. indexOf(value: T): number;
  6070. /**
  6071. * Returns whether an element is part of the active data.
  6072. * @param value defines the value to look for
  6073. * @returns true if found in the active data otherwise false
  6074. */
  6075. contains(value: T): boolean;
  6076. private static _GlobalId;
  6077. }
  6078. /**
  6079. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6080. * The data in this array can only be present once
  6081. */
  6082. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6083. private _duplicateId;
  6084. /**
  6085. * Pushes a value at the end of the active data.
  6086. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6087. * @param value defines the object to push in the array.
  6088. */
  6089. push(value: T): void;
  6090. /**
  6091. * Pushes a value at the end of the active data.
  6092. * If the data is already present, it won t be added again
  6093. * @param value defines the object to push in the array.
  6094. * @returns true if added false if it was already present
  6095. */
  6096. pushNoDuplicate(value: T): boolean;
  6097. /**
  6098. * Resets the active data to an empty array.
  6099. */
  6100. reset(): void;
  6101. /**
  6102. * Concats the active data with a given array.
  6103. * This ensures no dupplicate will be present in the result.
  6104. * @param array defines the data to concatenate with.
  6105. */
  6106. concatWithNoDuplicate(array: any): void;
  6107. }
  6108. }
  6109. declare module "babylonjs/Cameras/cameraInputsManager" {
  6110. import { Nullable } from "babylonjs/types";
  6111. import { Camera } from "babylonjs/Cameras/camera";
  6112. /**
  6113. * @ignore
  6114. * This is a list of all the different input types that are available in the application.
  6115. * Fo instance: ArcRotateCameraGamepadInput...
  6116. */
  6117. export var CameraInputTypes: {};
  6118. /**
  6119. * This is the contract to implement in order to create a new input class.
  6120. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6121. */
  6122. export interface ICameraInput<TCamera extends Camera> {
  6123. /**
  6124. * Defines the camera the input is attached to.
  6125. */
  6126. camera: Nullable<TCamera>;
  6127. /**
  6128. * Gets the class name of the current intput.
  6129. * @returns the class name
  6130. */
  6131. getClassName(): string;
  6132. /**
  6133. * Get the friendly name associated with the input class.
  6134. * @returns the input friendly name
  6135. */
  6136. getSimpleName(): string;
  6137. /**
  6138. * Attach the input controls to a specific dom element to get the input from.
  6139. * @param element Defines the element the controls should be listened from
  6140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6141. */
  6142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6143. /**
  6144. * Detach the current controls from the specified dom element.
  6145. * @param element Defines the element to stop listening the inputs from
  6146. */
  6147. detachControl(element: Nullable<HTMLElement>): void;
  6148. /**
  6149. * Update the current camera state depending on the inputs that have been used this frame.
  6150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6151. */
  6152. checkInputs?: () => void;
  6153. }
  6154. /**
  6155. * Represents a map of input types to input instance or input index to input instance.
  6156. */
  6157. export interface CameraInputsMap<TCamera extends Camera> {
  6158. /**
  6159. * Accessor to the input by input type.
  6160. */
  6161. [name: string]: ICameraInput<TCamera>;
  6162. /**
  6163. * Accessor to the input by input index.
  6164. */
  6165. [idx: number]: ICameraInput<TCamera>;
  6166. }
  6167. /**
  6168. * This represents the input manager used within a camera.
  6169. * It helps dealing with all the different kind of input attached to a camera.
  6170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6171. */
  6172. export class CameraInputsManager<TCamera extends Camera> {
  6173. /**
  6174. * Defines the list of inputs attahed to the camera.
  6175. */
  6176. attached: CameraInputsMap<TCamera>;
  6177. /**
  6178. * Defines the dom element the camera is collecting inputs from.
  6179. * This is null if the controls have not been attached.
  6180. */
  6181. attachedElement: Nullable<HTMLElement>;
  6182. /**
  6183. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6184. */
  6185. noPreventDefault: boolean;
  6186. /**
  6187. * Defined the camera the input manager belongs to.
  6188. */
  6189. camera: TCamera;
  6190. /**
  6191. * Update the current camera state depending on the inputs that have been used this frame.
  6192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6193. */
  6194. checkInputs: () => void;
  6195. /**
  6196. * Instantiate a new Camera Input Manager.
  6197. * @param camera Defines the camera the input manager blongs to
  6198. */
  6199. constructor(camera: TCamera);
  6200. /**
  6201. * Add an input method to a camera
  6202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6203. * @param input camera input method
  6204. */
  6205. add(input: ICameraInput<TCamera>): void;
  6206. /**
  6207. * Remove a specific input method from a camera
  6208. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6209. * @param inputToRemove camera input method
  6210. */
  6211. remove(inputToRemove: ICameraInput<TCamera>): void;
  6212. /**
  6213. * Remove a specific input type from a camera
  6214. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6215. * @param inputType the type of the input to remove
  6216. */
  6217. removeByType(inputType: string): void;
  6218. private _addCheckInputs;
  6219. /**
  6220. * Attach the input controls to the currently attached dom element to listen the events from.
  6221. * @param input Defines the input to attach
  6222. */
  6223. attachInput(input: ICameraInput<TCamera>): void;
  6224. /**
  6225. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6226. * @param element Defines the dom element to collect the events from
  6227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6230. /**
  6231. * Detach the current manager inputs controls from a specific dom element.
  6232. * @param element Defines the dom element to collect the events from
  6233. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6234. */
  6235. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6236. /**
  6237. * Rebuild the dynamic inputCheck function from the current list of
  6238. * defined inputs in the manager.
  6239. */
  6240. rebuildInputCheck(): void;
  6241. /**
  6242. * Remove all attached input methods from a camera
  6243. */
  6244. clear(): void;
  6245. /**
  6246. * Serialize the current input manager attached to a camera.
  6247. * This ensures than once parsed,
  6248. * the input associated to the camera will be identical to the current ones
  6249. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6250. */
  6251. serialize(serializedCamera: any): void;
  6252. /**
  6253. * Parses an input manager serialized JSON to restore the previous list of inputs
  6254. * and states associated to a camera.
  6255. * @param parsedCamera Defines the JSON to parse
  6256. */
  6257. parse(parsedCamera: any): void;
  6258. }
  6259. }
  6260. declare module "babylonjs/Meshes/buffer" {
  6261. import { Nullable, DataArray } from "babylonjs/types";
  6262. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6263. /**
  6264. * Class used to store data that will be store in GPU memory
  6265. */
  6266. export class Buffer {
  6267. private _engine;
  6268. private _buffer;
  6269. /** @hidden */
  6270. _data: Nullable<DataArray>;
  6271. private _updatable;
  6272. private _instanced;
  6273. private _divisor;
  6274. /**
  6275. * Gets the byte stride.
  6276. */
  6277. readonly byteStride: number;
  6278. /**
  6279. * Constructor
  6280. * @param engine the engine
  6281. * @param data the data to use for this buffer
  6282. * @param updatable whether the data is updatable
  6283. * @param stride the stride (optional)
  6284. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6285. * @param instanced whether the buffer is instanced (optional)
  6286. * @param useBytes set to true if the stride in in bytes (optional)
  6287. * @param divisor sets an optional divisor for instances (1 by default)
  6288. */
  6289. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6290. /**
  6291. * Create a new VertexBuffer based on the current buffer
  6292. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6293. * @param offset defines offset in the buffer (0 by default)
  6294. * @param size defines the size in floats of attributes (position is 3 for instance)
  6295. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6296. * @param instanced defines if the vertex buffer contains indexed data
  6297. * @param useBytes defines if the offset and stride are in bytes *
  6298. * @param divisor sets an optional divisor for instances (1 by default)
  6299. * @returns the new vertex buffer
  6300. */
  6301. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6302. /**
  6303. * Gets a boolean indicating if the Buffer is updatable?
  6304. * @returns true if the buffer is updatable
  6305. */
  6306. isUpdatable(): boolean;
  6307. /**
  6308. * Gets current buffer's data
  6309. * @returns a DataArray or null
  6310. */
  6311. getData(): Nullable<DataArray>;
  6312. /**
  6313. * Gets underlying native buffer
  6314. * @returns underlying native buffer
  6315. */
  6316. getBuffer(): Nullable<DataBuffer>;
  6317. /**
  6318. * Gets the stride in float32 units (i.e. byte stride / 4).
  6319. * May not be an integer if the byte stride is not divisible by 4.
  6320. * @returns the stride in float32 units
  6321. * @deprecated Please use byteStride instead.
  6322. */
  6323. getStrideSize(): number;
  6324. /**
  6325. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6326. * @param data defines the data to store
  6327. */
  6328. create(data?: Nullable<DataArray>): void;
  6329. /** @hidden */
  6330. _rebuild(): void;
  6331. /**
  6332. * Update current buffer data
  6333. * @param data defines the data to store
  6334. */
  6335. update(data: DataArray): void;
  6336. /**
  6337. * Updates the data directly.
  6338. * @param data the new data
  6339. * @param offset the new offset
  6340. * @param vertexCount the vertex count (optional)
  6341. * @param useBytes set to true if the offset is in bytes
  6342. */
  6343. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6344. /**
  6345. * Release all resources
  6346. */
  6347. dispose(): void;
  6348. }
  6349. /**
  6350. * Specialized buffer used to store vertex data
  6351. */
  6352. export class VertexBuffer {
  6353. /** @hidden */
  6354. _buffer: Buffer;
  6355. private _kind;
  6356. private _size;
  6357. private _ownsBuffer;
  6358. private _instanced;
  6359. private _instanceDivisor;
  6360. /**
  6361. * The byte type.
  6362. */
  6363. static readonly BYTE: number;
  6364. /**
  6365. * The unsigned byte type.
  6366. */
  6367. static readonly UNSIGNED_BYTE: number;
  6368. /**
  6369. * The short type.
  6370. */
  6371. static readonly SHORT: number;
  6372. /**
  6373. * The unsigned short type.
  6374. */
  6375. static readonly UNSIGNED_SHORT: number;
  6376. /**
  6377. * The integer type.
  6378. */
  6379. static readonly INT: number;
  6380. /**
  6381. * The unsigned integer type.
  6382. */
  6383. static readonly UNSIGNED_INT: number;
  6384. /**
  6385. * The float type.
  6386. */
  6387. static readonly FLOAT: number;
  6388. /**
  6389. * Gets or sets the instance divisor when in instanced mode
  6390. */
  6391. get instanceDivisor(): number;
  6392. set instanceDivisor(value: number);
  6393. /**
  6394. * Gets the byte stride.
  6395. */
  6396. readonly byteStride: number;
  6397. /**
  6398. * Gets the byte offset.
  6399. */
  6400. readonly byteOffset: number;
  6401. /**
  6402. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6403. */
  6404. readonly normalized: boolean;
  6405. /**
  6406. * Gets the data type of each component in the array.
  6407. */
  6408. readonly type: number;
  6409. /**
  6410. * Constructor
  6411. * @param engine the engine
  6412. * @param data the data to use for this vertex buffer
  6413. * @param kind the vertex buffer kind
  6414. * @param updatable whether the data is updatable
  6415. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6416. * @param stride the stride (optional)
  6417. * @param instanced whether the buffer is instanced (optional)
  6418. * @param offset the offset of the data (optional)
  6419. * @param size the number of components (optional)
  6420. * @param type the type of the component (optional)
  6421. * @param normalized whether the data contains normalized data (optional)
  6422. * @param useBytes set to true if stride and offset are in bytes (optional)
  6423. * @param divisor defines the instance divisor to use (1 by default)
  6424. */
  6425. 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, divisor?: number);
  6426. /** @hidden */
  6427. _rebuild(): void;
  6428. /**
  6429. * Returns the kind of the VertexBuffer (string)
  6430. * @returns a string
  6431. */
  6432. getKind(): string;
  6433. /**
  6434. * Gets a boolean indicating if the VertexBuffer is updatable?
  6435. * @returns true if the buffer is updatable
  6436. */
  6437. isUpdatable(): boolean;
  6438. /**
  6439. * Gets current buffer's data
  6440. * @returns a DataArray or null
  6441. */
  6442. getData(): Nullable<DataArray>;
  6443. /**
  6444. * Gets underlying native buffer
  6445. * @returns underlying native buffer
  6446. */
  6447. getBuffer(): Nullable<DataBuffer>;
  6448. /**
  6449. * Gets the stride in float32 units (i.e. byte stride / 4).
  6450. * May not be an integer if the byte stride is not divisible by 4.
  6451. * @returns the stride in float32 units
  6452. * @deprecated Please use byteStride instead.
  6453. */
  6454. getStrideSize(): number;
  6455. /**
  6456. * Returns the offset as a multiple of the type byte length.
  6457. * @returns the offset in bytes
  6458. * @deprecated Please use byteOffset instead.
  6459. */
  6460. getOffset(): number;
  6461. /**
  6462. * Returns the number of components per vertex attribute (integer)
  6463. * @returns the size in float
  6464. */
  6465. getSize(): number;
  6466. /**
  6467. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6468. * @returns true if this buffer is instanced
  6469. */
  6470. getIsInstanced(): boolean;
  6471. /**
  6472. * Returns the instancing divisor, zero for non-instanced (integer).
  6473. * @returns a number
  6474. */
  6475. getInstanceDivisor(): number;
  6476. /**
  6477. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6478. * @param data defines the data to store
  6479. */
  6480. create(data?: DataArray): void;
  6481. /**
  6482. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6483. * This function will create a new buffer if the current one is not updatable
  6484. * @param data defines the data to store
  6485. */
  6486. update(data: DataArray): void;
  6487. /**
  6488. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6489. * Returns the directly updated WebGLBuffer.
  6490. * @param data the new data
  6491. * @param offset the new offset
  6492. * @param useBytes set to true if the offset is in bytes
  6493. */
  6494. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6495. /**
  6496. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6497. */
  6498. dispose(): void;
  6499. /**
  6500. * Enumerates each value of this vertex buffer as numbers.
  6501. * @param count the number of values to enumerate
  6502. * @param callback the callback function called for each value
  6503. */
  6504. forEach(count: number, callback: (value: number, index: number) => void): void;
  6505. /**
  6506. * Positions
  6507. */
  6508. static readonly PositionKind: string;
  6509. /**
  6510. * Normals
  6511. */
  6512. static readonly NormalKind: string;
  6513. /**
  6514. * Tangents
  6515. */
  6516. static readonly TangentKind: string;
  6517. /**
  6518. * Texture coordinates
  6519. */
  6520. static readonly UVKind: string;
  6521. /**
  6522. * Texture coordinates 2
  6523. */
  6524. static readonly UV2Kind: string;
  6525. /**
  6526. * Texture coordinates 3
  6527. */
  6528. static readonly UV3Kind: string;
  6529. /**
  6530. * Texture coordinates 4
  6531. */
  6532. static readonly UV4Kind: string;
  6533. /**
  6534. * Texture coordinates 5
  6535. */
  6536. static readonly UV5Kind: string;
  6537. /**
  6538. * Texture coordinates 6
  6539. */
  6540. static readonly UV6Kind: string;
  6541. /**
  6542. * Colors
  6543. */
  6544. static readonly ColorKind: string;
  6545. /**
  6546. * Matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesKind: string;
  6549. /**
  6550. * Matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsKind: string;
  6553. /**
  6554. * Additional matrix indices (for bones)
  6555. */
  6556. static readonly MatricesIndicesExtraKind: string;
  6557. /**
  6558. * Additional matrix weights (for bones)
  6559. */
  6560. static readonly MatricesWeightsExtraKind: string;
  6561. /**
  6562. * Deduces the stride given a kind.
  6563. * @param kind The kind string to deduce
  6564. * @returns The deduced stride
  6565. */
  6566. static DeduceStride(kind: string): number;
  6567. /**
  6568. * Gets the byte length of the given type.
  6569. * @param type the type
  6570. * @returns the number of bytes
  6571. */
  6572. static GetTypeByteLength(type: number): number;
  6573. /**
  6574. * Enumerates each value of the given parameters as numbers.
  6575. * @param data the data to enumerate
  6576. * @param byteOffset the byte offset of the data
  6577. * @param byteStride the byte stride of the data
  6578. * @param componentCount the number of components per element
  6579. * @param componentType the type of the component
  6580. * @param count the number of values to enumerate
  6581. * @param normalized whether the data is normalized
  6582. * @param callback the callback function called for each value
  6583. */
  6584. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6585. private static _GetFloatValue;
  6586. }
  6587. }
  6588. declare module "babylonjs/Collisions/intersectionInfo" {
  6589. import { Nullable } from "babylonjs/types";
  6590. /**
  6591. * @hidden
  6592. */
  6593. export class IntersectionInfo {
  6594. bu: Nullable<number>;
  6595. bv: Nullable<number>;
  6596. distance: number;
  6597. faceId: number;
  6598. subMeshId: number;
  6599. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6600. }
  6601. }
  6602. declare module "babylonjs/Maths/math.plane" {
  6603. import { DeepImmutable } from "babylonjs/types";
  6604. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module "babylonjs/Culling/boundingSphere" {
  6713. import { DeepImmutable } from "babylonjs/types";
  6714. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6715. import { Plane } from "babylonjs/Maths/math.plane";
  6716. /**
  6717. * Class used to store bounding sphere information
  6718. */
  6719. export class BoundingSphere {
  6720. /**
  6721. * Gets the center of the bounding sphere in local space
  6722. */
  6723. readonly center: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in local space
  6726. */
  6727. radius: number;
  6728. /**
  6729. * Gets the center of the bounding sphere in world space
  6730. */
  6731. readonly centerWorld: Vector3;
  6732. /**
  6733. * Radius of the bounding sphere in world space
  6734. */
  6735. radiusWorld: number;
  6736. /**
  6737. * Gets the minimum vector in local space
  6738. */
  6739. readonly minimum: Vector3;
  6740. /**
  6741. * Gets the maximum vector in local space
  6742. */
  6743. readonly maximum: Vector3;
  6744. private _worldMatrix;
  6745. private static readonly TmpVector3;
  6746. /**
  6747. * Creates a new bounding sphere
  6748. * @param min defines the minimum vector (in local space)
  6749. * @param max defines the maximum vector (in local space)
  6750. * @param worldMatrix defines the new world matrix
  6751. */
  6752. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6753. /**
  6754. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6755. * @param min defines the new minimum vector (in local space)
  6756. * @param max defines the new maximum vector (in local space)
  6757. * @param worldMatrix defines the new world matrix
  6758. */
  6759. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6760. /**
  6761. * Scale the current bounding sphere by applying a scale factor
  6762. * @param factor defines the scale factor to apply
  6763. * @returns the current bounding box
  6764. */
  6765. scale(factor: number): BoundingSphere;
  6766. /**
  6767. * Gets the world matrix of the bounding box
  6768. * @returns a matrix
  6769. */
  6770. getWorldMatrix(): DeepImmutable<Matrix>;
  6771. /** @hidden */
  6772. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6773. /**
  6774. * Tests if the bounding sphere is intersecting the frustum planes
  6775. * @param frustumPlanes defines the frustum planes to test
  6776. * @returns true if there is an intersection
  6777. */
  6778. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6779. /**
  6780. * Tests if the bounding sphere center is in between the frustum planes.
  6781. * Used for optimistic fast inclusion.
  6782. * @param frustumPlanes defines the frustum planes to test
  6783. * @returns true if the sphere center is in between the frustum planes
  6784. */
  6785. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6786. /**
  6787. * Tests if a point is inside the bounding sphere
  6788. * @param point defines the point to test
  6789. * @returns true if the point is inside the bounding sphere
  6790. */
  6791. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6792. /**
  6793. * Checks if two sphere intersct
  6794. * @param sphere0 sphere 0
  6795. * @param sphere1 sphere 1
  6796. * @returns true if the speres intersect
  6797. */
  6798. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6799. }
  6800. }
  6801. declare module "babylonjs/Culling/boundingBox" {
  6802. import { DeepImmutable } from "babylonjs/types";
  6803. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6804. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6805. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6806. import { Plane } from "babylonjs/Maths/math.plane";
  6807. /**
  6808. * Class used to store bounding box information
  6809. */
  6810. export class BoundingBox implements ICullable {
  6811. /**
  6812. * Gets the 8 vectors representing the bounding box in local space
  6813. */
  6814. readonly vectors: Vector3[];
  6815. /**
  6816. * Gets the center of the bounding box in local space
  6817. */
  6818. readonly center: Vector3;
  6819. /**
  6820. * Gets the center of the bounding box in world space
  6821. */
  6822. readonly centerWorld: Vector3;
  6823. /**
  6824. * Gets the extend size in local space
  6825. */
  6826. readonly extendSize: Vector3;
  6827. /**
  6828. * Gets the extend size in world space
  6829. */
  6830. readonly extendSizeWorld: Vector3;
  6831. /**
  6832. * Gets the OBB (object bounding box) directions
  6833. */
  6834. readonly directions: Vector3[];
  6835. /**
  6836. * Gets the 8 vectors representing the bounding box in world space
  6837. */
  6838. readonly vectorsWorld: Vector3[];
  6839. /**
  6840. * Gets the minimum vector in world space
  6841. */
  6842. readonly minimumWorld: Vector3;
  6843. /**
  6844. * Gets the maximum vector in world space
  6845. */
  6846. readonly maximumWorld: Vector3;
  6847. /**
  6848. * Gets the minimum vector in local space
  6849. */
  6850. readonly minimum: Vector3;
  6851. /**
  6852. * Gets the maximum vector in local space
  6853. */
  6854. readonly maximum: Vector3;
  6855. private _worldMatrix;
  6856. private static readonly TmpVector3;
  6857. /**
  6858. * @hidden
  6859. */
  6860. _tag: number;
  6861. /**
  6862. * Creates a new bounding box
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding box by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingBox;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(world: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding box is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding box is entirely inside the frustum planes
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @returns true if there is an inclusion
  6898. */
  6899. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. /**
  6901. * Tests if a point is inside the bounding box
  6902. * @param point defines the point to test
  6903. * @returns true if the point is inside the bounding box
  6904. */
  6905. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6906. /**
  6907. * Tests if the bounding box intersects with a bounding sphere
  6908. * @param sphere defines the sphere to test
  6909. * @returns true if there is an intersection
  6910. */
  6911. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6912. /**
  6913. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6914. * @param min defines the min vector to use
  6915. * @param max defines the max vector to use
  6916. * @returns true if there is an intersection
  6917. */
  6918. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6919. /**
  6920. * Tests if two bounding boxes are intersections
  6921. * @param box0 defines the first box to test
  6922. * @param box1 defines the second box to test
  6923. * @returns true if there is an intersection
  6924. */
  6925. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6926. /**
  6927. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6928. * @param minPoint defines the minimum vector of the bounding box
  6929. * @param maxPoint defines the maximum vector of the bounding box
  6930. * @param sphereCenter defines the sphere center
  6931. * @param sphereRadius defines the sphere radius
  6932. * @returns true if there is an intersection
  6933. */
  6934. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6935. /**
  6936. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6937. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @return true if there is an inclusion
  6940. */
  6941. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6944. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @return true if there is an intersection
  6947. */
  6948. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. }
  6950. }
  6951. declare module "babylonjs/Collisions/collider" {
  6952. import { Nullable, IndicesArray } from "babylonjs/types";
  6953. import { Vector3 } from "babylonjs/Maths/math.vector";
  6954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6955. import { Plane } from "babylonjs/Maths/math.plane";
  6956. /** @hidden */
  6957. export class Collider {
  6958. /** Define if a collision was found */
  6959. collisionFound: boolean;
  6960. /**
  6961. * Define last intersection point in local space
  6962. */
  6963. intersectionPoint: Vector3;
  6964. /**
  6965. * Define last collided mesh
  6966. */
  6967. collidedMesh: Nullable<AbstractMesh>;
  6968. private _collisionPoint;
  6969. private _planeIntersectionPoint;
  6970. private _tempVector;
  6971. private _tempVector2;
  6972. private _tempVector3;
  6973. private _tempVector4;
  6974. private _edge;
  6975. private _baseToVertex;
  6976. private _destinationPoint;
  6977. private _slidePlaneNormal;
  6978. private _displacementVector;
  6979. /** @hidden */
  6980. _radius: Vector3;
  6981. /** @hidden */
  6982. _retry: number;
  6983. private _velocity;
  6984. private _basePoint;
  6985. private _epsilon;
  6986. /** @hidden */
  6987. _velocityWorldLength: number;
  6988. /** @hidden */
  6989. _basePointWorld: Vector3;
  6990. private _velocityWorld;
  6991. private _normalizedVelocity;
  6992. /** @hidden */
  6993. _initialVelocity: Vector3;
  6994. /** @hidden */
  6995. _initialPosition: Vector3;
  6996. private _nearestDistance;
  6997. private _collisionMask;
  6998. get collisionMask(): number;
  6999. set collisionMask(mask: number);
  7000. /**
  7001. * Gets the plane normal used to compute the sliding response (in local space)
  7002. */
  7003. get slidePlaneNormal(): Vector3;
  7004. /** @hidden */
  7005. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7006. /** @hidden */
  7007. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7008. /** @hidden */
  7009. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7010. /** @hidden */
  7011. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7014. /** @hidden */
  7015. _getResponse(pos: Vector3, vel: Vector3): void;
  7016. }
  7017. }
  7018. declare module "babylonjs/Culling/boundingInfo" {
  7019. import { DeepImmutable } from "babylonjs/types";
  7020. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7021. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7022. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7023. import { Plane } from "babylonjs/Maths/math.plane";
  7024. import { Collider } from "babylonjs/Collisions/collider";
  7025. /**
  7026. * Interface for cullable objects
  7027. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7028. */
  7029. export interface ICullable {
  7030. /**
  7031. * Checks if the object or part of the object is in the frustum
  7032. * @param frustumPlanes Camera near/planes
  7033. * @returns true if the object is in frustum otherwise false
  7034. */
  7035. isInFrustum(frustumPlanes: Plane[]): boolean;
  7036. /**
  7037. * Checks if a cullable object (mesh...) is in the camera frustum
  7038. * Unlike isInFrustum this cheks the full bounding box
  7039. * @param frustumPlanes Camera near/planes
  7040. * @returns true if the object is in frustum otherwise false
  7041. */
  7042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7043. }
  7044. /**
  7045. * Info for a bounding data of a mesh
  7046. */
  7047. export class BoundingInfo implements ICullable {
  7048. /**
  7049. * Bounding box for the mesh
  7050. */
  7051. readonly boundingBox: BoundingBox;
  7052. /**
  7053. * Bounding sphere for the mesh
  7054. */
  7055. readonly boundingSphere: BoundingSphere;
  7056. private _isLocked;
  7057. private static readonly TmpVector3;
  7058. /**
  7059. * Constructs bounding info
  7060. * @param minimum min vector of the bounding box/sphere
  7061. * @param maximum max vector of the bounding box/sphere
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7065. /**
  7066. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7067. * @param min defines the new minimum vector (in local space)
  7068. * @param max defines the new maximum vector (in local space)
  7069. * @param worldMatrix defines the new world matrix
  7070. */
  7071. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * min vector of the bounding box/sphere
  7074. */
  7075. get minimum(): Vector3;
  7076. /**
  7077. * max vector of the bounding box/sphere
  7078. */
  7079. get maximum(): Vector3;
  7080. /**
  7081. * If the info is locked and won't be updated to avoid perf overhead
  7082. */
  7083. get isLocked(): boolean;
  7084. set isLocked(value: boolean);
  7085. /**
  7086. * Updates the bounding sphere and box
  7087. * @param world world matrix to be used to update
  7088. */
  7089. update(world: DeepImmutable<Matrix>): void;
  7090. /**
  7091. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7092. * @param center New center of the bounding info
  7093. * @param extend New extend of the bounding info
  7094. * @returns the current bounding info
  7095. */
  7096. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7097. /**
  7098. * Scale the current bounding info by applying a scale factor
  7099. * @param factor defines the scale factor to apply
  7100. * @returns the current bounding info
  7101. */
  7102. scale(factor: number): BoundingInfo;
  7103. /**
  7104. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7105. * @param frustumPlanes defines the frustum to test
  7106. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7107. * @returns true if the bounding info is in the frustum planes
  7108. */
  7109. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7110. /**
  7111. * Gets the world distance between the min and max points of the bounding box
  7112. */
  7113. get diagonalLength(): number;
  7114. /**
  7115. * Checks if a cullable object (mesh...) is in the camera frustum
  7116. * Unlike isInFrustum this cheks the full bounding box
  7117. * @param frustumPlanes Camera near/planes
  7118. * @returns true if the object is in frustum otherwise false
  7119. */
  7120. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. /** @hidden */
  7122. _checkCollision(collider: Collider): boolean;
  7123. /**
  7124. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7125. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7126. * @param point the point to check intersection with
  7127. * @returns if the point intersects
  7128. */
  7129. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7130. /**
  7131. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7132. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7133. * @param boundingInfo the bounding info to check intersection with
  7134. * @param precise if the intersection should be done using OBB
  7135. * @returns if the bounding info intersects
  7136. */
  7137. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7138. }
  7139. }
  7140. declare module "babylonjs/Maths/math.functions" {
  7141. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7142. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7143. /**
  7144. * Extracts minimum and maximum values from a list of indexed positions
  7145. * @param positions defines the positions to use
  7146. * @param indices defines the indices to the positions
  7147. * @param indexStart defines the start index
  7148. * @param indexCount defines the end index
  7149. * @param bias defines bias value to add to the result
  7150. * @return minimum and maximum values
  7151. */
  7152. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7153. minimum: Vector3;
  7154. maximum: Vector3;
  7155. };
  7156. /**
  7157. * Extracts minimum and maximum values from a list of positions
  7158. * @param positions defines the positions to use
  7159. * @param start defines the start index in the positions array
  7160. * @param count defines the number of positions to handle
  7161. * @param bias defines bias value to add to the result
  7162. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7163. * @return minimum and maximum values
  7164. */
  7165. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7166. minimum: Vector3;
  7167. maximum: Vector3;
  7168. };
  7169. }
  7170. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7171. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7172. /** @hidden */
  7173. export class WebGLDataBuffer extends DataBuffer {
  7174. private _buffer;
  7175. constructor(resource: WebGLBuffer);
  7176. get underlyingResource(): any;
  7177. }
  7178. }
  7179. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7180. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7181. import { Nullable } from "babylonjs/types";
  7182. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7183. /** @hidden */
  7184. export class WebGLPipelineContext implements IPipelineContext {
  7185. engine: ThinEngine;
  7186. program: Nullable<WebGLProgram>;
  7187. context?: WebGLRenderingContext;
  7188. vertexShader?: WebGLShader;
  7189. fragmentShader?: WebGLShader;
  7190. isParallelCompiled: boolean;
  7191. onCompiled?: () => void;
  7192. transformFeedback?: WebGLTransformFeedback | null;
  7193. vertexCompilationError: Nullable<string>;
  7194. fragmentCompilationError: Nullable<string>;
  7195. programLinkError: Nullable<string>;
  7196. programValidationError: Nullable<string>;
  7197. get isAsync(): boolean;
  7198. get isReady(): boolean;
  7199. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7200. }
  7201. }
  7202. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7203. import { FloatArray, Nullable } from "babylonjs/types";
  7204. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7205. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7206. module "babylonjs/Engines/thinEngine" {
  7207. interface ThinEngine {
  7208. /**
  7209. * Create an uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param elements defines the content of the uniform buffer
  7212. * @returns the webGL uniform buffer
  7213. */
  7214. createUniformBuffer(elements: FloatArray): DataBuffer;
  7215. /**
  7216. * Create a dynamic uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Update an existing uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param uniformBuffer defines the target uniform buffer
  7226. * @param elements defines the content to update
  7227. * @param offset defines the offset in the uniform buffer where update should start
  7228. * @param count defines the size of the data to update
  7229. */
  7230. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7231. /**
  7232. * Bind an uniform buffer to the current webGL context
  7233. * @param buffer defines the buffer to bind
  7234. */
  7235. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7236. /**
  7237. * Bind a buffer to the current webGL context at a given location
  7238. * @param buffer defines the buffer to bind
  7239. * @param location defines the index where to bind the buffer
  7240. */
  7241. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7242. /**
  7243. * Bind a specific block at a given index in a specific shader program
  7244. * @param pipelineContext defines the pipeline context to use
  7245. * @param blockName defines the block name
  7246. * @param index defines the index where to bind the block
  7247. */
  7248. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7249. }
  7250. }
  7251. }
  7252. declare module "babylonjs/Materials/uniformBuffer" {
  7253. import { Nullable, FloatArray } from "babylonjs/types";
  7254. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7255. import { Engine } from "babylonjs/Engines/engine";
  7256. import { Effect } from "babylonjs/Materials/effect";
  7257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7258. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7259. import { Color3 } from "babylonjs/Maths/math.color";
  7260. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7261. /**
  7262. * Uniform buffer objects.
  7263. *
  7264. * Handles blocks of uniform on the GPU.
  7265. *
  7266. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7267. *
  7268. * For more information, please refer to :
  7269. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7270. */
  7271. export class UniformBuffer {
  7272. private _engine;
  7273. private _buffer;
  7274. private _data;
  7275. private _bufferData;
  7276. private _dynamic?;
  7277. private _uniformLocations;
  7278. private _uniformSizes;
  7279. private _uniformLocationPointer;
  7280. private _needSync;
  7281. private _noUBO;
  7282. private _currentEffect;
  7283. /** @hidden */
  7284. _alreadyBound: boolean;
  7285. private static _MAX_UNIFORM_SIZE;
  7286. private static _tempBuffer;
  7287. /**
  7288. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7289. * This is dynamic to allow compat with webgl 1 and 2.
  7290. * You will need to pass the name of the uniform as well as the value.
  7291. */
  7292. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7293. /**
  7294. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7295. * This is dynamic to allow compat with webgl 1 and 2.
  7296. * You will need to pass the name of the uniform as well as the value.
  7297. */
  7298. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7299. /**
  7300. * Lambda to Update a single float in a uniform buffer.
  7301. * This is dynamic to allow compat with webgl 1 and 2.
  7302. * You will need to pass the name of the uniform as well as the value.
  7303. */
  7304. updateFloat: (name: string, x: number) => void;
  7305. /**
  7306. * Lambda to Update a vec2 of float in a uniform buffer.
  7307. * This is dynamic to allow compat with webgl 1 and 2.
  7308. * You will need to pass the name of the uniform as well as the value.
  7309. */
  7310. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7311. /**
  7312. * Lambda to Update a vec3 of float in a uniform buffer.
  7313. * This is dynamic to allow compat with webgl 1 and 2.
  7314. * You will need to pass the name of the uniform as well as the value.
  7315. */
  7316. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7317. /**
  7318. * Lambda to Update a vec4 of float in a uniform buffer.
  7319. * This is dynamic to allow compat with webgl 1 and 2.
  7320. * You will need to pass the name of the uniform as well as the value.
  7321. */
  7322. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7323. /**
  7324. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7325. * This is dynamic to allow compat with webgl 1 and 2.
  7326. * You will need to pass the name of the uniform as well as the value.
  7327. */
  7328. updateMatrix: (name: string, mat: Matrix) => void;
  7329. /**
  7330. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7331. * This is dynamic to allow compat with webgl 1 and 2.
  7332. * You will need to pass the name of the uniform as well as the value.
  7333. */
  7334. updateVector3: (name: string, vector: Vector3) => void;
  7335. /**
  7336. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7337. * This is dynamic to allow compat with webgl 1 and 2.
  7338. * You will need to pass the name of the uniform as well as the value.
  7339. */
  7340. updateVector4: (name: string, vector: Vector4) => void;
  7341. /**
  7342. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7343. * This is dynamic to allow compat with webgl 1 and 2.
  7344. * You will need to pass the name of the uniform as well as the value.
  7345. */
  7346. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7347. /**
  7348. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7349. * This is dynamic to allow compat with webgl 1 and 2.
  7350. * You will need to pass the name of the uniform as well as the value.
  7351. */
  7352. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7353. /**
  7354. * Instantiates a new Uniform buffer objects.
  7355. *
  7356. * Handles blocks of uniform on the GPU.
  7357. *
  7358. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7359. *
  7360. * For more information, please refer to :
  7361. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7362. * @param engine Define the engine the buffer is associated with
  7363. * @param data Define the data contained in the buffer
  7364. * @param dynamic Define if the buffer is updatable
  7365. */
  7366. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7367. /**
  7368. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7369. * or just falling back on setUniformXXX calls.
  7370. */
  7371. get useUbo(): boolean;
  7372. /**
  7373. * Indicates if the WebGL underlying uniform buffer is in sync
  7374. * with the javascript cache data.
  7375. */
  7376. get isSync(): boolean;
  7377. /**
  7378. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7379. * Also, a dynamic UniformBuffer will disable cache verification and always
  7380. * update the underlying WebGL uniform buffer to the GPU.
  7381. * @returns if Dynamic, otherwise false
  7382. */
  7383. isDynamic(): boolean;
  7384. /**
  7385. * The data cache on JS side.
  7386. * @returns the underlying data as a float array
  7387. */
  7388. getData(): Float32Array;
  7389. /**
  7390. * The underlying WebGL Uniform buffer.
  7391. * @returns the webgl buffer
  7392. */
  7393. getBuffer(): Nullable<DataBuffer>;
  7394. /**
  7395. * std140 layout specifies how to align data within an UBO structure.
  7396. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7397. * for specs.
  7398. */
  7399. private _fillAlignment;
  7400. /**
  7401. * Adds an uniform in the buffer.
  7402. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7403. * for the layout to be correct !
  7404. * @param name Name of the uniform, as used in the uniform block in the shader.
  7405. * @param size Data size, or data directly.
  7406. */
  7407. addUniform(name: string, size: number | number[]): void;
  7408. /**
  7409. * Adds a Matrix 4x4 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param mat A 4x4 matrix.
  7412. */
  7413. addMatrix(name: string, mat: Matrix): void;
  7414. /**
  7415. * Adds a vec2 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. * @param x Define the x component value of the vec2
  7418. * @param y Define the y component value of the vec2
  7419. */
  7420. addFloat2(name: string, x: number, y: number): void;
  7421. /**
  7422. * Adds a vec3 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param x Define the x component value of the vec3
  7425. * @param y Define the y component value of the vec3
  7426. * @param z Define the z component value of the vec3
  7427. */
  7428. addFloat3(name: string, x: number, y: number, z: number): void;
  7429. /**
  7430. * Adds a vec3 to the uniform buffer.
  7431. * @param name Name of the uniform, as used in the uniform block in the shader.
  7432. * @param color Define the vec3 from a Color
  7433. */
  7434. addColor3(name: string, color: Color3): void;
  7435. /**
  7436. * Adds a vec4 to the uniform buffer.
  7437. * @param name Name of the uniform, as used in the uniform block in the shader.
  7438. * @param color Define the rgb components from a Color
  7439. * @param alpha Define the a component of the vec4
  7440. */
  7441. addColor4(name: string, color: Color3, alpha: number): void;
  7442. /**
  7443. * Adds a vec3 to the uniform buffer.
  7444. * @param name Name of the uniform, as used in the uniform block in the shader.
  7445. * @param vector Define the vec3 components from a Vector
  7446. */
  7447. addVector3(name: string, vector: Vector3): void;
  7448. /**
  7449. * Adds a Matrix 3x3 to the uniform buffer.
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. */
  7452. addMatrix3x3(name: string): void;
  7453. /**
  7454. * Adds a Matrix 2x2 to the uniform buffer.
  7455. * @param name Name of the uniform, as used in the uniform block in the shader.
  7456. */
  7457. addMatrix2x2(name: string): void;
  7458. /**
  7459. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7460. */
  7461. create(): void;
  7462. /** @hidden */
  7463. _rebuild(): void;
  7464. /**
  7465. * Updates the WebGL Uniform Buffer on the GPU.
  7466. * If the `dynamic` flag is set to true, no cache comparison is done.
  7467. * Otherwise, the buffer will be updated only if the cache differs.
  7468. */
  7469. update(): void;
  7470. /**
  7471. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7472. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7473. * @param data Define the flattened data
  7474. * @param size Define the size of the data.
  7475. */
  7476. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7477. private _valueCache;
  7478. private _cacheMatrix;
  7479. private _updateMatrix3x3ForUniform;
  7480. private _updateMatrix3x3ForEffect;
  7481. private _updateMatrix2x2ForEffect;
  7482. private _updateMatrix2x2ForUniform;
  7483. private _updateFloatForEffect;
  7484. private _updateFloatForUniform;
  7485. private _updateFloat2ForEffect;
  7486. private _updateFloat2ForUniform;
  7487. private _updateFloat3ForEffect;
  7488. private _updateFloat3ForUniform;
  7489. private _updateFloat4ForEffect;
  7490. private _updateFloat4ForUniform;
  7491. private _updateMatrixForEffect;
  7492. private _updateMatrixForUniform;
  7493. private _updateVector3ForEffect;
  7494. private _updateVector3ForUniform;
  7495. private _updateVector4ForEffect;
  7496. private _updateVector4ForUniform;
  7497. private _updateColor3ForEffect;
  7498. private _updateColor3ForUniform;
  7499. private _updateColor4ForEffect;
  7500. private _updateColor4ForUniform;
  7501. /**
  7502. * Sets a sampler uniform on the effect.
  7503. * @param name Define the name of the sampler.
  7504. * @param texture Define the texture to set in the sampler
  7505. */
  7506. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7507. /**
  7508. * Directly updates the value of the uniform in the cache AND on the GPU.
  7509. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7510. * @param data Define the flattened data
  7511. */
  7512. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7513. /**
  7514. * Binds this uniform buffer to an effect.
  7515. * @param effect Define the effect to bind the buffer to
  7516. * @param name Name of the uniform block in the shader.
  7517. */
  7518. bindToEffect(effect: Effect, name: string): void;
  7519. /**
  7520. * Disposes the uniform buffer.
  7521. */
  7522. dispose(): void;
  7523. }
  7524. }
  7525. declare module "babylonjs/Misc/iInspectable" {
  7526. /**
  7527. * Enum that determines the text-wrapping mode to use.
  7528. */
  7529. export enum InspectableType {
  7530. /**
  7531. * Checkbox for booleans
  7532. */
  7533. Checkbox = 0,
  7534. /**
  7535. * Sliders for numbers
  7536. */
  7537. Slider = 1,
  7538. /**
  7539. * Vector3
  7540. */
  7541. Vector3 = 2,
  7542. /**
  7543. * Quaternions
  7544. */
  7545. Quaternion = 3,
  7546. /**
  7547. * Color3
  7548. */
  7549. Color3 = 4,
  7550. /**
  7551. * String
  7552. */
  7553. String = 5
  7554. }
  7555. /**
  7556. * Interface used to define custom inspectable properties.
  7557. * This interface is used by the inspector to display custom property grids
  7558. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7559. */
  7560. export interface IInspectable {
  7561. /**
  7562. * Gets the label to display
  7563. */
  7564. label: string;
  7565. /**
  7566. * Gets the name of the property to edit
  7567. */
  7568. propertyName: string;
  7569. /**
  7570. * Gets the type of the editor to use
  7571. */
  7572. type: InspectableType;
  7573. /**
  7574. * Gets the minimum value of the property when using in "slider" mode
  7575. */
  7576. min?: number;
  7577. /**
  7578. * Gets the maximum value of the property when using in "slider" mode
  7579. */
  7580. max?: number;
  7581. /**
  7582. * Gets the setp to use when using in "slider" mode
  7583. */
  7584. step?: number;
  7585. }
  7586. }
  7587. declare module "babylonjs/Misc/timingTools" {
  7588. /**
  7589. * Class used to provide helper for timing
  7590. */
  7591. export class TimingTools {
  7592. /**
  7593. * Polyfill for setImmediate
  7594. * @param action defines the action to execute after the current execution block
  7595. */
  7596. static SetImmediate(action: () => void): void;
  7597. }
  7598. }
  7599. declare module "babylonjs/Misc/instantiationTools" {
  7600. /**
  7601. * Class used to enable instatition of objects by class name
  7602. */
  7603. export class InstantiationTools {
  7604. /**
  7605. * Use this object to register external classes like custom textures or material
  7606. * to allow the laoders to instantiate them
  7607. */
  7608. static RegisteredExternalClasses: {
  7609. [key: string]: Object;
  7610. };
  7611. /**
  7612. * Tries to instantiate a new object from a given class name
  7613. * @param className defines the class name to instantiate
  7614. * @returns the new object or null if the system was not able to do the instantiation
  7615. */
  7616. static Instantiate(className: string): any;
  7617. }
  7618. }
  7619. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7620. /**
  7621. * Define options used to create a depth texture
  7622. */
  7623. export class DepthTextureCreationOptions {
  7624. /** Specifies whether or not a stencil should be allocated in the texture */
  7625. generateStencil?: boolean;
  7626. /** Specifies whether or not bilinear filtering is enable on the texture */
  7627. bilinearFiltering?: boolean;
  7628. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7629. comparisonFunction?: number;
  7630. /** Specifies if the created texture is a cube texture */
  7631. isCube?: boolean;
  7632. }
  7633. }
  7634. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7635. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7636. import { Nullable } from "babylonjs/types";
  7637. import { Scene } from "babylonjs/scene";
  7638. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7639. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7640. module "babylonjs/Engines/thinEngine" {
  7641. interface ThinEngine {
  7642. /**
  7643. * Creates a depth stencil cube texture.
  7644. * This is only available in WebGL 2.
  7645. * @param size The size of face edge in the cube texture.
  7646. * @param options The options defining the cube texture.
  7647. * @returns The cube texture
  7648. */
  7649. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7650. /**
  7651. * Creates a cube texture
  7652. * @param rootUrl defines the url where the files to load is located
  7653. * @param scene defines the current scene
  7654. * @param files defines the list of files to load (1 per face)
  7655. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7656. * @param onLoad defines an optional callback raised when the texture is loaded
  7657. * @param onError defines an optional callback raised if there is an issue to load the texture
  7658. * @param format defines the format of the data
  7659. * @param forcedExtension defines the extension to use to pick the right loader
  7660. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7661. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7662. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7663. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7664. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7665. * @returns the cube texture as an InternalTexture
  7666. */
  7667. 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;
  7668. /**
  7669. * Creates a cube texture
  7670. * @param rootUrl defines the url where the files to load is located
  7671. * @param scene defines the current scene
  7672. * @param files defines the list of files to load (1 per face)
  7673. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7674. * @param onLoad defines an optional callback raised when the texture is loaded
  7675. * @param onError defines an optional callback raised if there is an issue to load the texture
  7676. * @param format defines the format of the data
  7677. * @param forcedExtension defines the extension to use to pick the right loader
  7678. * @returns the cube texture as an InternalTexture
  7679. */
  7680. 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;
  7681. /**
  7682. * Creates a cube texture
  7683. * @param rootUrl defines the url where the files to load is located
  7684. * @param scene defines the current scene
  7685. * @param files defines the list of files to load (1 per face)
  7686. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7687. * @param onLoad defines an optional callback raised when the texture is loaded
  7688. * @param onError defines an optional callback raised if there is an issue to load the texture
  7689. * @param format defines the format of the data
  7690. * @param forcedExtension defines the extension to use to pick the right loader
  7691. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7692. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7693. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7694. * @returns the cube texture as an InternalTexture
  7695. */
  7696. 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;
  7697. /** @hidden */
  7698. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7699. /** @hidden */
  7700. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7701. /** @hidden */
  7702. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7703. /** @hidden */
  7704. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7705. /**
  7706. * @hidden
  7707. */
  7708. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7709. }
  7710. }
  7711. }
  7712. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7713. import { Nullable } from "babylonjs/types";
  7714. import { Scene } from "babylonjs/scene";
  7715. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7716. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7717. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7718. /**
  7719. * Class for creating a cube texture
  7720. */
  7721. export class CubeTexture extends BaseTexture {
  7722. private _delayedOnLoad;
  7723. /**
  7724. * The url of the texture
  7725. */
  7726. url: string;
  7727. /**
  7728. * Gets or sets the center of the bounding box associated with the cube texture.
  7729. * It must define where the camera used to render the texture was set
  7730. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7731. */
  7732. boundingBoxPosition: Vector3;
  7733. private _boundingBoxSize;
  7734. /**
  7735. * Gets or sets the size of the bounding box associated with the cube texture
  7736. * When defined, the cubemap will switch to local mode
  7737. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7738. * @example https://www.babylonjs-playground.com/#RNASML
  7739. */
  7740. set boundingBoxSize(value: Vector3);
  7741. /**
  7742. * Returns the bounding box size
  7743. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7744. */
  7745. get boundingBoxSize(): Vector3;
  7746. protected _rotationY: number;
  7747. /**
  7748. * Sets texture matrix rotation angle around Y axis in radians.
  7749. */
  7750. set rotationY(value: number);
  7751. /**
  7752. * Gets texture matrix rotation angle around Y axis radians.
  7753. */
  7754. get rotationY(): number;
  7755. /**
  7756. * Are mip maps generated for this texture or not.
  7757. */
  7758. get noMipmap(): boolean;
  7759. private _noMipmap;
  7760. private _files;
  7761. protected _forcedExtension: Nullable<string>;
  7762. private _extensions;
  7763. private _textureMatrix;
  7764. private _format;
  7765. private _createPolynomials;
  7766. /** @hidden */
  7767. _prefiltered: boolean;
  7768. /**
  7769. * Creates a cube texture from an array of image urls
  7770. * @param files defines an array of image urls
  7771. * @param scene defines the hosting scene
  7772. * @param noMipmap specifies if mip maps are not used
  7773. * @returns a cube texture
  7774. */
  7775. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7776. /**
  7777. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7778. * @param url defines the url of the prefiltered texture
  7779. * @param scene defines the scene the texture is attached to
  7780. * @param forcedExtension defines the extension of the file if different from the url
  7781. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7782. * @return the prefiltered texture
  7783. */
  7784. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7785. /**
  7786. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7787. * as prefiltered data.
  7788. * @param rootUrl defines the url of the texture or the root name of the six images
  7789. * @param scene defines the scene the texture is attached to
  7790. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7791. * @param noMipmap defines if mipmaps should be created or not
  7792. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7793. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7794. * @param onError defines a callback triggered in case of error during load
  7795. * @param format defines the internal format to use for the texture once loaded
  7796. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7797. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7798. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7799. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7800. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7801. * @return the cube texture
  7802. */
  7803. 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);
  7804. /**
  7805. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7806. */
  7807. get isPrefiltered(): boolean;
  7808. /**
  7809. * Get the current class name of the texture useful for serialization or dynamic coding.
  7810. * @returns "CubeTexture"
  7811. */
  7812. getClassName(): string;
  7813. /**
  7814. * Update the url (and optional buffer) of this texture if url was null during construction.
  7815. * @param url the url of the texture
  7816. * @param forcedExtension defines the extension to use
  7817. * @param onLoad callback called when the texture is loaded (defaults to null)
  7818. */
  7819. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7820. /**
  7821. * Delays loading of the cube texture
  7822. * @param forcedExtension defines the extension to use
  7823. */
  7824. delayLoad(forcedExtension?: string): void;
  7825. /**
  7826. * Returns the reflection texture matrix
  7827. * @returns the reflection texture matrix
  7828. */
  7829. getReflectionTextureMatrix(): Matrix;
  7830. /**
  7831. * Sets the reflection texture matrix
  7832. * @param value Reflection texture matrix
  7833. */
  7834. setReflectionTextureMatrix(value: Matrix): void;
  7835. /**
  7836. * Parses text to create a cube texture
  7837. * @param parsedTexture define the serialized text to read from
  7838. * @param scene defines the hosting scene
  7839. * @param rootUrl defines the root url of the cube texture
  7840. * @returns a cube texture
  7841. */
  7842. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7843. /**
  7844. * Makes a clone, or deep copy, of the cube texture
  7845. * @returns a new cube texture
  7846. */
  7847. clone(): CubeTexture;
  7848. }
  7849. }
  7850. declare module "babylonjs/Materials/materialDefines" {
  7851. /**
  7852. * Manages the defines for the Material
  7853. */
  7854. export class MaterialDefines {
  7855. /** @hidden */
  7856. protected _keys: string[];
  7857. private _isDirty;
  7858. /** @hidden */
  7859. _renderId: number;
  7860. /** @hidden */
  7861. _areLightsDirty: boolean;
  7862. /** @hidden */
  7863. _areLightsDisposed: boolean;
  7864. /** @hidden */
  7865. _areAttributesDirty: boolean;
  7866. /** @hidden */
  7867. _areTexturesDirty: boolean;
  7868. /** @hidden */
  7869. _areFresnelDirty: boolean;
  7870. /** @hidden */
  7871. _areMiscDirty: boolean;
  7872. /** @hidden */
  7873. _areImageProcessingDirty: boolean;
  7874. /** @hidden */
  7875. _normals: boolean;
  7876. /** @hidden */
  7877. _uvs: boolean;
  7878. /** @hidden */
  7879. _needNormals: boolean;
  7880. /** @hidden */
  7881. _needUVs: boolean;
  7882. [id: string]: any;
  7883. /**
  7884. * Specifies if the material needs to be re-calculated
  7885. */
  7886. get isDirty(): boolean;
  7887. /**
  7888. * Marks the material to indicate that it has been re-calculated
  7889. */
  7890. markAsProcessed(): void;
  7891. /**
  7892. * Marks the material to indicate that it needs to be re-calculated
  7893. */
  7894. markAsUnprocessed(): void;
  7895. /**
  7896. * Marks the material to indicate all of its defines need to be re-calculated
  7897. */
  7898. markAllAsDirty(): void;
  7899. /**
  7900. * Marks the material to indicate that image processing needs to be re-calculated
  7901. */
  7902. markAsImageProcessingDirty(): void;
  7903. /**
  7904. * Marks the material to indicate the lights need to be re-calculated
  7905. * @param disposed Defines whether the light is dirty due to dispose or not
  7906. */
  7907. markAsLightDirty(disposed?: boolean): void;
  7908. /**
  7909. * Marks the attribute state as changed
  7910. */
  7911. markAsAttributesDirty(): void;
  7912. /**
  7913. * Marks the texture state as changed
  7914. */
  7915. markAsTexturesDirty(): void;
  7916. /**
  7917. * Marks the fresnel state as changed
  7918. */
  7919. markAsFresnelDirty(): void;
  7920. /**
  7921. * Marks the misc state as changed
  7922. */
  7923. markAsMiscDirty(): void;
  7924. /**
  7925. * Rebuilds the material defines
  7926. */
  7927. rebuild(): void;
  7928. /**
  7929. * Specifies if two material defines are equal
  7930. * @param other - A material define instance to compare to
  7931. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7932. */
  7933. isEqual(other: MaterialDefines): boolean;
  7934. /**
  7935. * Clones this instance's defines to another instance
  7936. * @param other - material defines to clone values to
  7937. */
  7938. cloneTo(other: MaterialDefines): void;
  7939. /**
  7940. * Resets the material define values
  7941. */
  7942. reset(): void;
  7943. /**
  7944. * Converts the material define values to a string
  7945. * @returns - String of material define information
  7946. */
  7947. toString(): string;
  7948. }
  7949. }
  7950. declare module "babylonjs/Materials/colorCurves" {
  7951. import { Effect } from "babylonjs/Materials/effect";
  7952. /**
  7953. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7954. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7955. * 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;
  7956. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7957. */
  7958. export class ColorCurves {
  7959. private _dirty;
  7960. private _tempColor;
  7961. private _globalCurve;
  7962. private _highlightsCurve;
  7963. private _midtonesCurve;
  7964. private _shadowsCurve;
  7965. private _positiveCurve;
  7966. private _negativeCurve;
  7967. private _globalHue;
  7968. private _globalDensity;
  7969. private _globalSaturation;
  7970. private _globalExposure;
  7971. /**
  7972. * Gets the global Hue value.
  7973. * 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).
  7974. */
  7975. get globalHue(): number;
  7976. /**
  7977. * Sets the global Hue value.
  7978. * 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).
  7979. */
  7980. set globalHue(value: number);
  7981. /**
  7982. * Gets the global Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. get globalDensity(): number;
  7987. /**
  7988. * Sets the global Density value.
  7989. * 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.
  7990. * Values less than zero provide a filter of opposite hue.
  7991. */
  7992. set globalDensity(value: number);
  7993. /**
  7994. * Gets the global Saturation value.
  7995. * 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.
  7996. */
  7997. get globalSaturation(): number;
  7998. /**
  7999. * Sets the global Saturation value.
  8000. * 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.
  8001. */
  8002. set globalSaturation(value: number);
  8003. /**
  8004. * Gets the global Exposure value.
  8005. * 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.
  8006. */
  8007. get globalExposure(): number;
  8008. /**
  8009. * Sets the global Exposure value.
  8010. * 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.
  8011. */
  8012. set globalExposure(value: number);
  8013. private _highlightsHue;
  8014. private _highlightsDensity;
  8015. private _highlightsSaturation;
  8016. private _highlightsExposure;
  8017. /**
  8018. * Gets the highlights Hue value.
  8019. * 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).
  8020. */
  8021. get highlightsHue(): number;
  8022. /**
  8023. * Sets the highlights Hue value.
  8024. * 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).
  8025. */
  8026. set highlightsHue(value: number);
  8027. /**
  8028. * Gets the highlights Density value.
  8029. * 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.
  8030. * Values less than zero provide a filter of opposite hue.
  8031. */
  8032. get highlightsDensity(): number;
  8033. /**
  8034. * Sets the highlights Density value.
  8035. * 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.
  8036. * Values less than zero provide a filter of opposite hue.
  8037. */
  8038. set highlightsDensity(value: number);
  8039. /**
  8040. * Gets the highlights Saturation value.
  8041. * 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.
  8042. */
  8043. get highlightsSaturation(): number;
  8044. /**
  8045. * Sets the highlights Saturation value.
  8046. * 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.
  8047. */
  8048. set highlightsSaturation(value: number);
  8049. /**
  8050. * Gets the highlights Exposure value.
  8051. * 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.
  8052. */
  8053. get highlightsExposure(): number;
  8054. /**
  8055. * Sets the highlights Exposure value.
  8056. * 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.
  8057. */
  8058. set highlightsExposure(value: number);
  8059. private _midtonesHue;
  8060. private _midtonesDensity;
  8061. private _midtonesSaturation;
  8062. private _midtonesExposure;
  8063. /**
  8064. * Gets the midtones Hue value.
  8065. * 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).
  8066. */
  8067. get midtonesHue(): number;
  8068. /**
  8069. * Sets the midtones Hue value.
  8070. * 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).
  8071. */
  8072. set midtonesHue(value: number);
  8073. /**
  8074. * Gets the midtones Density value.
  8075. * 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.
  8076. * Values less than zero provide a filter of opposite hue.
  8077. */
  8078. get midtonesDensity(): number;
  8079. /**
  8080. * Sets the midtones Density value.
  8081. * 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.
  8082. * Values less than zero provide a filter of opposite hue.
  8083. */
  8084. set midtonesDensity(value: number);
  8085. /**
  8086. * Gets the midtones Saturation value.
  8087. * 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.
  8088. */
  8089. get midtonesSaturation(): number;
  8090. /**
  8091. * Sets the midtones Saturation value.
  8092. * 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.
  8093. */
  8094. set midtonesSaturation(value: number);
  8095. /**
  8096. * Gets the midtones Exposure value.
  8097. * 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.
  8098. */
  8099. get midtonesExposure(): number;
  8100. /**
  8101. * Sets the midtones Exposure value.
  8102. * 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.
  8103. */
  8104. set midtonesExposure(value: number);
  8105. private _shadowsHue;
  8106. private _shadowsDensity;
  8107. private _shadowsSaturation;
  8108. private _shadowsExposure;
  8109. /**
  8110. * Gets the shadows Hue value.
  8111. * 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).
  8112. */
  8113. get shadowsHue(): number;
  8114. /**
  8115. * Sets the shadows Hue value.
  8116. * 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).
  8117. */
  8118. set shadowsHue(value: number);
  8119. /**
  8120. * Gets the shadows Density value.
  8121. * 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.
  8122. * Values less than zero provide a filter of opposite hue.
  8123. */
  8124. get shadowsDensity(): number;
  8125. /**
  8126. * Sets the shadows Density value.
  8127. * 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.
  8128. * Values less than zero provide a filter of opposite hue.
  8129. */
  8130. set shadowsDensity(value: number);
  8131. /**
  8132. * Gets the shadows Saturation value.
  8133. * 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.
  8134. */
  8135. get shadowsSaturation(): number;
  8136. /**
  8137. * Sets the shadows Saturation value.
  8138. * 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.
  8139. */
  8140. set shadowsSaturation(value: number);
  8141. /**
  8142. * Gets the shadows Exposure value.
  8143. * 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.
  8144. */
  8145. get shadowsExposure(): number;
  8146. /**
  8147. * Sets the shadows Exposure value.
  8148. * 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.
  8149. */
  8150. set shadowsExposure(value: number);
  8151. /**
  8152. * Returns the class name
  8153. * @returns The class name
  8154. */
  8155. getClassName(): string;
  8156. /**
  8157. * Binds the color curves to the shader.
  8158. * @param colorCurves The color curve to bind
  8159. * @param effect The effect to bind to
  8160. * @param positiveUniform The positive uniform shader parameter
  8161. * @param neutralUniform The neutral uniform shader parameter
  8162. * @param negativeUniform The negative uniform shader parameter
  8163. */
  8164. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8165. /**
  8166. * Prepare the list of uniforms associated with the ColorCurves effects.
  8167. * @param uniformsList The list of uniforms used in the effect
  8168. */
  8169. static PrepareUniforms(uniformsList: string[]): void;
  8170. /**
  8171. * Returns color grading data based on a hue, density, saturation and exposure value.
  8172. * @param filterHue The hue of the color filter.
  8173. * @param filterDensity The density of the color filter.
  8174. * @param saturation The saturation.
  8175. * @param exposure The exposure.
  8176. * @param result The result data container.
  8177. */
  8178. private getColorGradingDataToRef;
  8179. /**
  8180. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8181. * @param value The input slider value in range [-100,100].
  8182. * @returns Adjusted value.
  8183. */
  8184. private static applyColorGradingSliderNonlinear;
  8185. /**
  8186. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8187. * @param hue The hue (H) input.
  8188. * @param saturation The saturation (S) input.
  8189. * @param brightness The brightness (B) input.
  8190. * @result An RGBA color represented as Vector4.
  8191. */
  8192. private static fromHSBToRef;
  8193. /**
  8194. * Returns a value clamped between min and max
  8195. * @param value The value to clamp
  8196. * @param min The minimum of value
  8197. * @param max The maximum of value
  8198. * @returns The clamped value.
  8199. */
  8200. private static clamp;
  8201. /**
  8202. * Clones the current color curve instance.
  8203. * @return The cloned curves
  8204. */
  8205. clone(): ColorCurves;
  8206. /**
  8207. * Serializes the current color curve instance to a json representation.
  8208. * @return a JSON representation
  8209. */
  8210. serialize(): any;
  8211. /**
  8212. * Parses the color curve from a json representation.
  8213. * @param source the JSON source to parse
  8214. * @return The parsed curves
  8215. */
  8216. static Parse(source: any): ColorCurves;
  8217. }
  8218. }
  8219. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8220. import { Observable } from "babylonjs/Misc/observable";
  8221. import { Nullable } from "babylonjs/types";
  8222. import { Color4 } from "babylonjs/Maths/math.color";
  8223. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8224. import { Effect } from "babylonjs/Materials/effect";
  8225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8226. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8227. /**
  8228. * Interface to follow in your material defines to integrate easily the
  8229. * Image proccessing functions.
  8230. * @hidden
  8231. */
  8232. export interface IImageProcessingConfigurationDefines {
  8233. IMAGEPROCESSING: boolean;
  8234. VIGNETTE: boolean;
  8235. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8236. VIGNETTEBLENDMODEOPAQUE: boolean;
  8237. TONEMAPPING: boolean;
  8238. TONEMAPPING_ACES: boolean;
  8239. CONTRAST: boolean;
  8240. EXPOSURE: boolean;
  8241. COLORCURVES: boolean;
  8242. COLORGRADING: boolean;
  8243. COLORGRADING3D: boolean;
  8244. SAMPLER3DGREENDEPTH: boolean;
  8245. SAMPLER3DBGRMAP: boolean;
  8246. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8247. }
  8248. /**
  8249. * @hidden
  8250. */
  8251. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8252. IMAGEPROCESSING: boolean;
  8253. VIGNETTE: boolean;
  8254. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8255. VIGNETTEBLENDMODEOPAQUE: boolean;
  8256. TONEMAPPING: boolean;
  8257. TONEMAPPING_ACES: boolean;
  8258. CONTRAST: boolean;
  8259. COLORCURVES: boolean;
  8260. COLORGRADING: boolean;
  8261. COLORGRADING3D: boolean;
  8262. SAMPLER3DGREENDEPTH: boolean;
  8263. SAMPLER3DBGRMAP: boolean;
  8264. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8265. EXPOSURE: boolean;
  8266. constructor();
  8267. }
  8268. /**
  8269. * This groups together the common properties used for image processing either in direct forward pass
  8270. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8271. * or not.
  8272. */
  8273. export class ImageProcessingConfiguration {
  8274. /**
  8275. * Default tone mapping applied in BabylonJS.
  8276. */
  8277. static readonly TONEMAPPING_STANDARD: number;
  8278. /**
  8279. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8280. * to other engines rendering to increase portability.
  8281. */
  8282. static readonly TONEMAPPING_ACES: number;
  8283. /**
  8284. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8285. */
  8286. colorCurves: Nullable<ColorCurves>;
  8287. private _colorCurvesEnabled;
  8288. /**
  8289. * Gets wether the color curves effect is enabled.
  8290. */
  8291. get colorCurvesEnabled(): boolean;
  8292. /**
  8293. * Sets wether the color curves effect is enabled.
  8294. */
  8295. set colorCurvesEnabled(value: boolean);
  8296. private _colorGradingTexture;
  8297. /**
  8298. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8299. */
  8300. get colorGradingTexture(): Nullable<BaseTexture>;
  8301. /**
  8302. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8303. */
  8304. set colorGradingTexture(value: Nullable<BaseTexture>);
  8305. private _colorGradingEnabled;
  8306. /**
  8307. * Gets wether the color grading effect is enabled.
  8308. */
  8309. get colorGradingEnabled(): boolean;
  8310. /**
  8311. * Sets wether the color grading effect is enabled.
  8312. */
  8313. set colorGradingEnabled(value: boolean);
  8314. private _colorGradingWithGreenDepth;
  8315. /**
  8316. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8317. */
  8318. get colorGradingWithGreenDepth(): boolean;
  8319. /**
  8320. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8321. */
  8322. set colorGradingWithGreenDepth(value: boolean);
  8323. private _colorGradingBGR;
  8324. /**
  8325. * Gets wether the color grading texture contains BGR values.
  8326. */
  8327. get colorGradingBGR(): boolean;
  8328. /**
  8329. * Sets wether the color grading texture contains BGR values.
  8330. */
  8331. set colorGradingBGR(value: boolean);
  8332. /** @hidden */
  8333. _exposure: number;
  8334. /**
  8335. * Gets the Exposure used in the effect.
  8336. */
  8337. get exposure(): number;
  8338. /**
  8339. * Sets the Exposure used in the effect.
  8340. */
  8341. set exposure(value: number);
  8342. private _toneMappingEnabled;
  8343. /**
  8344. * Gets wether the tone mapping effect is enabled.
  8345. */
  8346. get toneMappingEnabled(): boolean;
  8347. /**
  8348. * Sets wether the tone mapping effect is enabled.
  8349. */
  8350. set toneMappingEnabled(value: boolean);
  8351. private _toneMappingType;
  8352. /**
  8353. * Gets the type of tone mapping effect.
  8354. */
  8355. get toneMappingType(): number;
  8356. /**
  8357. * Sets the type of tone mapping effect used in BabylonJS.
  8358. */
  8359. set toneMappingType(value: number);
  8360. protected _contrast: number;
  8361. /**
  8362. * Gets the contrast used in the effect.
  8363. */
  8364. get contrast(): number;
  8365. /**
  8366. * Sets the contrast used in the effect.
  8367. */
  8368. set contrast(value: number);
  8369. /**
  8370. * Vignette stretch size.
  8371. */
  8372. vignetteStretch: number;
  8373. /**
  8374. * Vignette centre X Offset.
  8375. */
  8376. vignetteCentreX: number;
  8377. /**
  8378. * Vignette centre Y Offset.
  8379. */
  8380. vignetteCentreY: number;
  8381. /**
  8382. * Vignette weight or intensity of the vignette effect.
  8383. */
  8384. vignetteWeight: number;
  8385. /**
  8386. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8387. * if vignetteEnabled is set to true.
  8388. */
  8389. vignetteColor: Color4;
  8390. /**
  8391. * Camera field of view used by the Vignette effect.
  8392. */
  8393. vignetteCameraFov: number;
  8394. private _vignetteBlendMode;
  8395. /**
  8396. * Gets the vignette blend mode allowing different kind of effect.
  8397. */
  8398. get vignetteBlendMode(): number;
  8399. /**
  8400. * Sets the vignette blend mode allowing different kind of effect.
  8401. */
  8402. set vignetteBlendMode(value: number);
  8403. private _vignetteEnabled;
  8404. /**
  8405. * Gets wether the vignette effect is enabled.
  8406. */
  8407. get vignetteEnabled(): boolean;
  8408. /**
  8409. * Sets wether the vignette effect is enabled.
  8410. */
  8411. set vignetteEnabled(value: boolean);
  8412. private _applyByPostProcess;
  8413. /**
  8414. * Gets wether the image processing is applied through a post process or not.
  8415. */
  8416. get applyByPostProcess(): boolean;
  8417. /**
  8418. * Sets wether the image processing is applied through a post process or not.
  8419. */
  8420. set applyByPostProcess(value: boolean);
  8421. private _isEnabled;
  8422. /**
  8423. * Gets wether the image processing is enabled or not.
  8424. */
  8425. get isEnabled(): boolean;
  8426. /**
  8427. * Sets wether the image processing is enabled or not.
  8428. */
  8429. set isEnabled(value: boolean);
  8430. /**
  8431. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8432. */
  8433. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8434. /**
  8435. * Method called each time the image processing information changes requires to recompile the effect.
  8436. */
  8437. protected _updateParameters(): void;
  8438. /**
  8439. * Gets the current class name.
  8440. * @return "ImageProcessingConfiguration"
  8441. */
  8442. getClassName(): string;
  8443. /**
  8444. * Prepare the list of uniforms associated with the Image Processing effects.
  8445. * @param uniforms The list of uniforms used in the effect
  8446. * @param defines the list of defines currently in use
  8447. */
  8448. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8449. /**
  8450. * Prepare the list of samplers associated with the Image Processing effects.
  8451. * @param samplersList The list of uniforms used in the effect
  8452. * @param defines the list of defines currently in use
  8453. */
  8454. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8455. /**
  8456. * Prepare the list of defines associated to the shader.
  8457. * @param defines the list of defines to complete
  8458. * @param forPostProcess Define if we are currently in post process mode or not
  8459. */
  8460. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8461. /**
  8462. * Returns true if all the image processing information are ready.
  8463. * @returns True if ready, otherwise, false
  8464. */
  8465. isReady(): boolean;
  8466. /**
  8467. * Binds the image processing to the shader.
  8468. * @param effect The effect to bind to
  8469. * @param overrideAspectRatio Override the aspect ratio of the effect
  8470. */
  8471. bind(effect: Effect, overrideAspectRatio?: number): void;
  8472. /**
  8473. * Clones the current image processing instance.
  8474. * @return The cloned image processing
  8475. */
  8476. clone(): ImageProcessingConfiguration;
  8477. /**
  8478. * Serializes the current image processing instance to a json representation.
  8479. * @return a JSON representation
  8480. */
  8481. serialize(): any;
  8482. /**
  8483. * Parses the image processing from a json representation.
  8484. * @param source the JSON source to parse
  8485. * @return The parsed image processing
  8486. */
  8487. static Parse(source: any): ImageProcessingConfiguration;
  8488. private static _VIGNETTEMODE_MULTIPLY;
  8489. private static _VIGNETTEMODE_OPAQUE;
  8490. /**
  8491. * Used to apply the vignette as a mix with the pixel color.
  8492. */
  8493. static get VIGNETTEMODE_MULTIPLY(): number;
  8494. /**
  8495. * Used to apply the vignette as a replacement of the pixel color.
  8496. */
  8497. static get VIGNETTEMODE_OPAQUE(): number;
  8498. }
  8499. }
  8500. declare module "babylonjs/Shaders/postprocess.vertex" {
  8501. /** @hidden */
  8502. export var postprocessVertexShader: {
  8503. name: string;
  8504. shader: string;
  8505. };
  8506. }
  8507. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8508. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8509. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8510. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8511. module "babylonjs/Engines/thinEngine" {
  8512. interface ThinEngine {
  8513. /**
  8514. * Creates a new render target texture
  8515. * @param size defines the size of the texture
  8516. * @param options defines the options used to create the texture
  8517. * @returns a new render target texture stored in an InternalTexture
  8518. */
  8519. createRenderTargetTexture(size: number | {
  8520. width: number;
  8521. height: number;
  8522. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8523. /**
  8524. * Creates a depth stencil texture.
  8525. * This is only available in WebGL 2 or with the depth texture extension available.
  8526. * @param size The size of face edge in the texture.
  8527. * @param options The options defining the texture.
  8528. * @returns The texture
  8529. */
  8530. createDepthStencilTexture(size: number | {
  8531. width: number;
  8532. height: number;
  8533. }, options: DepthTextureCreationOptions): InternalTexture;
  8534. /** @hidden */
  8535. _createDepthStencilTexture(size: number | {
  8536. width: number;
  8537. height: number;
  8538. }, options: DepthTextureCreationOptions): InternalTexture;
  8539. }
  8540. }
  8541. }
  8542. declare module "babylonjs/Maths/math.axis" {
  8543. import { Vector3 } from "babylonjs/Maths/math.vector";
  8544. /** Defines supported spaces */
  8545. export enum Space {
  8546. /** Local (object) space */
  8547. LOCAL = 0,
  8548. /** World space */
  8549. WORLD = 1,
  8550. /** Bone space */
  8551. BONE = 2
  8552. }
  8553. /** Defines the 3 main axes */
  8554. export class Axis {
  8555. /** X axis */
  8556. static X: Vector3;
  8557. /** Y axis */
  8558. static Y: Vector3;
  8559. /** Z axis */
  8560. static Z: Vector3;
  8561. }
  8562. }
  8563. declare module "babylonjs/Cameras/targetCamera" {
  8564. import { Nullable } from "babylonjs/types";
  8565. import { Camera } from "babylonjs/Cameras/camera";
  8566. import { Scene } from "babylonjs/scene";
  8567. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8568. /**
  8569. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8570. * This is the base of the follow, arc rotate cameras and Free camera
  8571. * @see http://doc.babylonjs.com/features/cameras
  8572. */
  8573. export class TargetCamera extends Camera {
  8574. private static _RigCamTransformMatrix;
  8575. private static _TargetTransformMatrix;
  8576. private static _TargetFocalPoint;
  8577. /**
  8578. * Define the current direction the camera is moving to
  8579. */
  8580. cameraDirection: Vector3;
  8581. /**
  8582. * Define the current rotation the camera is rotating to
  8583. */
  8584. cameraRotation: Vector2;
  8585. /**
  8586. * When set, the up vector of the camera will be updated by the rotation of the camera
  8587. */
  8588. updateUpVectorFromRotation: boolean;
  8589. private _tmpQuaternion;
  8590. /**
  8591. * Define the current rotation of the camera
  8592. */
  8593. rotation: Vector3;
  8594. /**
  8595. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8596. */
  8597. rotationQuaternion: Quaternion;
  8598. /**
  8599. * Define the current speed of the camera
  8600. */
  8601. speed: number;
  8602. /**
  8603. * Add constraint to the camera to prevent it to move freely in all directions and
  8604. * around all axis.
  8605. */
  8606. noRotationConstraint: boolean;
  8607. /**
  8608. * Define the current target of the camera as an object or a position.
  8609. */
  8610. lockedTarget: any;
  8611. /** @hidden */
  8612. _currentTarget: Vector3;
  8613. /** @hidden */
  8614. _initialFocalDistance: number;
  8615. /** @hidden */
  8616. _viewMatrix: Matrix;
  8617. /** @hidden */
  8618. _camMatrix: Matrix;
  8619. /** @hidden */
  8620. _cameraTransformMatrix: Matrix;
  8621. /** @hidden */
  8622. _cameraRotationMatrix: Matrix;
  8623. /** @hidden */
  8624. _referencePoint: Vector3;
  8625. /** @hidden */
  8626. _transformedReferencePoint: Vector3;
  8627. protected _globalCurrentTarget: Vector3;
  8628. protected _globalCurrentUpVector: Vector3;
  8629. /** @hidden */
  8630. _reset: () => void;
  8631. private _defaultUp;
  8632. /**
  8633. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8634. * This is the base of the follow, arc rotate cameras and Free camera
  8635. * @see http://doc.babylonjs.com/features/cameras
  8636. * @param name Defines the name of the camera in the scene
  8637. * @param position Defines the start position of the camera in the scene
  8638. * @param scene Defines the scene the camera belongs to
  8639. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8640. */
  8641. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8642. /**
  8643. * Gets the position in front of the camera at a given distance.
  8644. * @param distance The distance from the camera we want the position to be
  8645. * @returns the position
  8646. */
  8647. getFrontPosition(distance: number): Vector3;
  8648. /** @hidden */
  8649. _getLockedTargetPosition(): Nullable<Vector3>;
  8650. private _storedPosition;
  8651. private _storedRotation;
  8652. private _storedRotationQuaternion;
  8653. /**
  8654. * Store current camera state of the camera (fov, position, rotation, etc..)
  8655. * @returns the camera
  8656. */
  8657. storeState(): Camera;
  8658. /**
  8659. * Restored camera state. You must call storeState() first
  8660. * @returns whether it was successful or not
  8661. * @hidden
  8662. */
  8663. _restoreStateValues(): boolean;
  8664. /** @hidden */
  8665. _initCache(): void;
  8666. /** @hidden */
  8667. _updateCache(ignoreParentClass?: boolean): void;
  8668. /** @hidden */
  8669. _isSynchronizedViewMatrix(): boolean;
  8670. /** @hidden */
  8671. _computeLocalCameraSpeed(): number;
  8672. /**
  8673. * Defines the target the camera should look at.
  8674. * @param target Defines the new target as a Vector or a mesh
  8675. */
  8676. setTarget(target: Vector3): void;
  8677. /**
  8678. * Return the current target position of the camera. This value is expressed in local space.
  8679. * @returns the target position
  8680. */
  8681. getTarget(): Vector3;
  8682. /** @hidden */
  8683. _decideIfNeedsToMove(): boolean;
  8684. /** @hidden */
  8685. _updatePosition(): void;
  8686. /** @hidden */
  8687. _checkInputs(): void;
  8688. protected _updateCameraRotationMatrix(): void;
  8689. /**
  8690. * 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)
  8691. * @returns the current camera
  8692. */
  8693. private _rotateUpVectorWithCameraRotationMatrix;
  8694. private _cachedRotationZ;
  8695. private _cachedQuaternionRotationZ;
  8696. /** @hidden */
  8697. _getViewMatrix(): Matrix;
  8698. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8699. /**
  8700. * @hidden
  8701. */
  8702. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8703. /**
  8704. * @hidden
  8705. */
  8706. _updateRigCameras(): void;
  8707. private _getRigCamPositionAndTarget;
  8708. /**
  8709. * Gets the current object class name.
  8710. * @return the class name
  8711. */
  8712. getClassName(): string;
  8713. }
  8714. }
  8715. declare module "babylonjs/Events/keyboardEvents" {
  8716. /**
  8717. * Gather the list of keyboard event types as constants.
  8718. */
  8719. export class KeyboardEventTypes {
  8720. /**
  8721. * The keydown event is fired when a key becomes active (pressed).
  8722. */
  8723. static readonly KEYDOWN: number;
  8724. /**
  8725. * The keyup event is fired when a key has been released.
  8726. */
  8727. static readonly KEYUP: number;
  8728. }
  8729. /**
  8730. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8731. */
  8732. export class KeyboardInfo {
  8733. /**
  8734. * Defines the type of event (KeyboardEventTypes)
  8735. */
  8736. type: number;
  8737. /**
  8738. * Defines the related dom event
  8739. */
  8740. event: KeyboardEvent;
  8741. /**
  8742. * Instantiates a new keyboard info.
  8743. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8744. * @param type Defines the type of event (KeyboardEventTypes)
  8745. * @param event Defines the related dom event
  8746. */
  8747. constructor(
  8748. /**
  8749. * Defines the type of event (KeyboardEventTypes)
  8750. */
  8751. type: number,
  8752. /**
  8753. * Defines the related dom event
  8754. */
  8755. event: KeyboardEvent);
  8756. }
  8757. /**
  8758. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8759. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8760. */
  8761. export class KeyboardInfoPre extends KeyboardInfo {
  8762. /**
  8763. * Defines the type of event (KeyboardEventTypes)
  8764. */
  8765. type: number;
  8766. /**
  8767. * Defines the related dom event
  8768. */
  8769. event: KeyboardEvent;
  8770. /**
  8771. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8772. */
  8773. skipOnPointerObservable: boolean;
  8774. /**
  8775. * Instantiates a new keyboard pre info.
  8776. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8777. * @param type Defines the type of event (KeyboardEventTypes)
  8778. * @param event Defines the related dom event
  8779. */
  8780. constructor(
  8781. /**
  8782. * Defines the type of event (KeyboardEventTypes)
  8783. */
  8784. type: number,
  8785. /**
  8786. * Defines the related dom event
  8787. */
  8788. event: KeyboardEvent);
  8789. }
  8790. }
  8791. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8792. import { Nullable } from "babylonjs/types";
  8793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8794. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8795. /**
  8796. * Manage the keyboard inputs to control the movement of a free camera.
  8797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8798. */
  8799. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8800. /**
  8801. * Defines the camera the input is attached to.
  8802. */
  8803. camera: FreeCamera;
  8804. /**
  8805. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8806. */
  8807. keysUp: number[];
  8808. /**
  8809. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8810. */
  8811. keysDown: number[];
  8812. /**
  8813. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8814. */
  8815. keysLeft: number[];
  8816. /**
  8817. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8818. */
  8819. keysRight: number[];
  8820. private _keys;
  8821. private _onCanvasBlurObserver;
  8822. private _onKeyboardObserver;
  8823. private _engine;
  8824. private _scene;
  8825. /**
  8826. * Attach the input controls to a specific dom element to get the input from.
  8827. * @param element Defines the element the controls should be listened from
  8828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8829. */
  8830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8831. /**
  8832. * Detach the current controls from the specified dom element.
  8833. * @param element Defines the element to stop listening the inputs from
  8834. */
  8835. detachControl(element: Nullable<HTMLElement>): void;
  8836. /**
  8837. * Update the current camera state depending on the inputs that have been used this frame.
  8838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8839. */
  8840. checkInputs(): void;
  8841. /**
  8842. * Gets the class name of the current intput.
  8843. * @returns the class name
  8844. */
  8845. getClassName(): string;
  8846. /** @hidden */
  8847. _onLostFocus(): void;
  8848. /**
  8849. * Get the friendly name associated with the input class.
  8850. * @returns the input friendly name
  8851. */
  8852. getSimpleName(): string;
  8853. }
  8854. }
  8855. declare module "babylonjs/Lights/shadowLight" {
  8856. import { Camera } from "babylonjs/Cameras/camera";
  8857. import { Scene } from "babylonjs/scene";
  8858. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8860. import { Light } from "babylonjs/Lights/light";
  8861. /**
  8862. * Interface describing all the common properties and methods a shadow light needs to implement.
  8863. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8864. * as well as binding the different shadow properties to the effects.
  8865. */
  8866. export interface IShadowLight extends Light {
  8867. /**
  8868. * The light id in the scene (used in scene.findLighById for instance)
  8869. */
  8870. id: string;
  8871. /**
  8872. * The position the shdow will be casted from.
  8873. */
  8874. position: Vector3;
  8875. /**
  8876. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8877. */
  8878. direction: Vector3;
  8879. /**
  8880. * The transformed position. Position of the light in world space taking parenting in account.
  8881. */
  8882. transformedPosition: Vector3;
  8883. /**
  8884. * The transformed direction. Direction of the light in world space taking parenting in account.
  8885. */
  8886. transformedDirection: Vector3;
  8887. /**
  8888. * The friendly name of the light in the scene.
  8889. */
  8890. name: string;
  8891. /**
  8892. * Defines the shadow projection clipping minimum z value.
  8893. */
  8894. shadowMinZ: number;
  8895. /**
  8896. * Defines the shadow projection clipping maximum z value.
  8897. */
  8898. shadowMaxZ: number;
  8899. /**
  8900. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8901. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8902. */
  8903. computeTransformedInformation(): boolean;
  8904. /**
  8905. * Gets the scene the light belongs to.
  8906. * @returns The scene
  8907. */
  8908. getScene(): Scene;
  8909. /**
  8910. * Callback defining a custom Projection Matrix Builder.
  8911. * This can be used to override the default projection matrix computation.
  8912. */
  8913. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8914. /**
  8915. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8916. * @param matrix The materix to updated with the projection information
  8917. * @param viewMatrix The transform matrix of the light
  8918. * @param renderList The list of mesh to render in the map
  8919. * @returns The current light
  8920. */
  8921. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8922. /**
  8923. * Gets the current depth scale used in ESM.
  8924. * @returns The scale
  8925. */
  8926. getDepthScale(): number;
  8927. /**
  8928. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8929. * @returns true if a cube texture needs to be use
  8930. */
  8931. needCube(): boolean;
  8932. /**
  8933. * Detects if the projection matrix requires to be recomputed this frame.
  8934. * @returns true if it requires to be recomputed otherwise, false.
  8935. */
  8936. needProjectionMatrixCompute(): boolean;
  8937. /**
  8938. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8939. */
  8940. forceProjectionMatrixCompute(): void;
  8941. /**
  8942. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8943. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8944. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8945. */
  8946. getShadowDirection(faceIndex?: number): Vector3;
  8947. /**
  8948. * Gets the minZ used for shadow according to both the scene and the light.
  8949. * @param activeCamera The camera we are returning the min for
  8950. * @returns the depth min z
  8951. */
  8952. getDepthMinZ(activeCamera: Camera): number;
  8953. /**
  8954. * Gets the maxZ used for shadow according to both the scene and the light.
  8955. * @param activeCamera The camera we are returning the max for
  8956. * @returns the depth max z
  8957. */
  8958. getDepthMaxZ(activeCamera: Camera): number;
  8959. }
  8960. /**
  8961. * Base implementation IShadowLight
  8962. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8963. */
  8964. export abstract class ShadowLight extends Light implements IShadowLight {
  8965. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8966. protected _position: Vector3;
  8967. protected _setPosition(value: Vector3): void;
  8968. /**
  8969. * Sets the position the shadow will be casted from. Also use as the light position for both
  8970. * point and spot lights.
  8971. */
  8972. get position(): Vector3;
  8973. /**
  8974. * Sets the position the shadow will be casted from. Also use as the light position for both
  8975. * point and spot lights.
  8976. */
  8977. set position(value: Vector3);
  8978. protected _direction: Vector3;
  8979. protected _setDirection(value: Vector3): void;
  8980. /**
  8981. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8982. * Also use as the light direction on spot and directional lights.
  8983. */
  8984. get direction(): Vector3;
  8985. /**
  8986. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8987. * Also use as the light direction on spot and directional lights.
  8988. */
  8989. set direction(value: Vector3);
  8990. private _shadowMinZ;
  8991. /**
  8992. * Gets the shadow projection clipping minimum z value.
  8993. */
  8994. get shadowMinZ(): number;
  8995. /**
  8996. * Sets the shadow projection clipping minimum z value.
  8997. */
  8998. set shadowMinZ(value: number);
  8999. private _shadowMaxZ;
  9000. /**
  9001. * Sets the shadow projection clipping maximum z value.
  9002. */
  9003. get shadowMaxZ(): number;
  9004. /**
  9005. * Gets the shadow projection clipping maximum z value.
  9006. */
  9007. set shadowMaxZ(value: number);
  9008. /**
  9009. * Callback defining a custom Projection Matrix Builder.
  9010. * This can be used to override the default projection matrix computation.
  9011. */
  9012. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9013. /**
  9014. * The transformed position. Position of the light in world space taking parenting in account.
  9015. */
  9016. transformedPosition: Vector3;
  9017. /**
  9018. * The transformed direction. Direction of the light in world space taking parenting in account.
  9019. */
  9020. transformedDirection: Vector3;
  9021. private _needProjectionMatrixCompute;
  9022. /**
  9023. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9024. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9025. */
  9026. computeTransformedInformation(): boolean;
  9027. /**
  9028. * Return the depth scale used for the shadow map.
  9029. * @returns the depth scale.
  9030. */
  9031. getDepthScale(): number;
  9032. /**
  9033. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9034. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9035. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9036. */
  9037. getShadowDirection(faceIndex?: number): Vector3;
  9038. /**
  9039. * Returns the ShadowLight absolute position in the World.
  9040. * @returns the position vector in world space
  9041. */
  9042. getAbsolutePosition(): Vector3;
  9043. /**
  9044. * Sets the ShadowLight direction toward the passed target.
  9045. * @param target The point to target in local space
  9046. * @returns the updated ShadowLight direction
  9047. */
  9048. setDirectionToTarget(target: Vector3): Vector3;
  9049. /**
  9050. * Returns the light rotation in euler definition.
  9051. * @returns the x y z rotation in local space.
  9052. */
  9053. getRotation(): Vector3;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /** @hidden */
  9069. _initCache(): void;
  9070. /** @hidden */
  9071. _isSynchronized(): boolean;
  9072. /**
  9073. * Computes the world matrix of the node
  9074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9075. * @returns the world matrix
  9076. */
  9077. computeWorldMatrix(force?: boolean): Matrix;
  9078. /**
  9079. * Gets the minZ used for shadow according to both the scene and the light.
  9080. * @param activeCamera The camera we are returning the min for
  9081. * @returns the depth min z
  9082. */
  9083. getDepthMinZ(activeCamera: Camera): number;
  9084. /**
  9085. * Gets the maxZ used for shadow according to both the scene and the light.
  9086. * @param activeCamera The camera we are returning the max for
  9087. * @returns the depth max z
  9088. */
  9089. getDepthMaxZ(activeCamera: Camera): number;
  9090. /**
  9091. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9092. * @param matrix The materix to updated with the projection information
  9093. * @param viewMatrix The transform matrix of the light
  9094. * @param renderList The list of mesh to render in the map
  9095. * @returns The current light
  9096. */
  9097. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9098. }
  9099. }
  9100. declare module "babylonjs/Materials/effectFallbacks" {
  9101. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9102. import { Effect } from "babylonjs/Materials/effect";
  9103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9104. /**
  9105. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9106. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9107. */
  9108. export class EffectFallbacks implements IEffectFallbacks {
  9109. private _defines;
  9110. private _currentRank;
  9111. private _maxRank;
  9112. private _mesh;
  9113. /**
  9114. * Removes the fallback from the bound mesh.
  9115. */
  9116. unBindMesh(): void;
  9117. /**
  9118. * Adds a fallback on the specified property.
  9119. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9120. * @param define The name of the define in the shader
  9121. */
  9122. addFallback(rank: number, define: string): void;
  9123. /**
  9124. * Sets the mesh to use CPU skinning when needing to fallback.
  9125. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9126. * @param mesh The mesh to use the fallbacks.
  9127. */
  9128. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9129. /**
  9130. * Checks to see if more fallbacks are still availible.
  9131. */
  9132. get hasMoreFallbacks(): boolean;
  9133. /**
  9134. * Removes the defines that should be removed when falling back.
  9135. * @param currentDefines defines the current define statements for the shader.
  9136. * @param effect defines the current effect we try to compile
  9137. * @returns The resulting defines with defines of the current rank removed.
  9138. */
  9139. reduce(currentDefines: string, effect: Effect): string;
  9140. }
  9141. }
  9142. declare module "babylonjs/Materials/materialHelper" {
  9143. import { Nullable } from "babylonjs/types";
  9144. import { Scene } from "babylonjs/scene";
  9145. import { Engine } from "babylonjs/Engines/engine";
  9146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9147. import { Light } from "babylonjs/Lights/light";
  9148. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9149. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9150. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9151. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9152. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9153. /**
  9154. * "Static Class" containing the most commonly used helper while dealing with material for
  9155. * rendering purpose.
  9156. *
  9157. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9158. *
  9159. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9160. */
  9161. export class MaterialHelper {
  9162. /**
  9163. * Bind the current view position to an effect.
  9164. * @param effect The effect to be bound
  9165. * @param scene The scene the eyes position is used from
  9166. */
  9167. static BindEyePosition(effect: Effect, scene: Scene): void;
  9168. /**
  9169. * Helps preparing the defines values about the UVs in used in the effect.
  9170. * UVs are shared as much as we can accross channels in the shaders.
  9171. * @param texture The texture we are preparing the UVs for
  9172. * @param defines The defines to update
  9173. * @param key The channel key "diffuse", "specular"... used in the shader
  9174. */
  9175. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9176. /**
  9177. * Binds a texture matrix value to its corrsponding uniform
  9178. * @param texture The texture to bind the matrix for
  9179. * @param uniformBuffer The uniform buffer receivin the data
  9180. * @param key The channel key "diffuse", "specular"... used in the shader
  9181. */
  9182. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9183. /**
  9184. * Gets the current status of the fog (should it be enabled?)
  9185. * @param mesh defines the mesh to evaluate for fog support
  9186. * @param scene defines the hosting scene
  9187. * @returns true if fog must be enabled
  9188. */
  9189. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9190. /**
  9191. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9192. * @param mesh defines the current mesh
  9193. * @param scene defines the current scene
  9194. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9195. * @param pointsCloud defines if point cloud rendering has to be turned on
  9196. * @param fogEnabled defines if fog has to be turned on
  9197. * @param alphaTest defines if alpha testing has to be turned on
  9198. * @param defines defines the current list of defines
  9199. */
  9200. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9201. /**
  9202. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9203. * @param scene defines the current scene
  9204. * @param engine defines the current engine
  9205. * @param defines specifies the list of active defines
  9206. * @param useInstances defines if instances have to be turned on
  9207. * @param useClipPlane defines if clip plane have to be turned on
  9208. */
  9209. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9210. /**
  9211. * Prepares the defines for bones
  9212. * @param mesh The mesh containing the geometry data we will draw
  9213. * @param defines The defines to update
  9214. */
  9215. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9216. /**
  9217. * Prepares the defines for morph targets
  9218. * @param mesh The mesh containing the geometry data we will draw
  9219. * @param defines The defines to update
  9220. */
  9221. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9222. /**
  9223. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9224. * @param mesh The mesh containing the geometry data we will draw
  9225. * @param defines The defines to update
  9226. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9227. * @param useBones Precise whether bones should be used or not (override mesh info)
  9228. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9229. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9230. * @returns false if defines are considered not dirty and have not been checked
  9231. */
  9232. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9233. /**
  9234. * Prepares the defines related to multiview
  9235. * @param scene The scene we are intending to draw
  9236. * @param defines The defines to update
  9237. */
  9238. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9239. /**
  9240. * Prepares the defines related to the light information passed in parameter
  9241. * @param scene The scene we are intending to draw
  9242. * @param mesh The mesh the effect is compiling for
  9243. * @param light The light the effect is compiling for
  9244. * @param lightIndex The index of the light
  9245. * @param defines The defines to update
  9246. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9247. * @param state Defines the current state regarding what is needed (normals, etc...)
  9248. */
  9249. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9250. needNormals: boolean;
  9251. needRebuild: boolean;
  9252. shadowEnabled: boolean;
  9253. specularEnabled: boolean;
  9254. lightmapMode: boolean;
  9255. }): void;
  9256. /**
  9257. * Prepares the defines related to the light information passed in parameter
  9258. * @param scene The scene we are intending to draw
  9259. * @param mesh The mesh the effect is compiling for
  9260. * @param defines The defines to update
  9261. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9262. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9263. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9264. * @returns true if normals will be required for the rest of the effect
  9265. */
  9266. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9267. /**
  9268. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9269. * @param lightIndex defines the light index
  9270. * @param uniformsList The uniform list
  9271. * @param samplersList The sampler list
  9272. * @param projectedLightTexture defines if projected texture must be used
  9273. * @param uniformBuffersList defines an optional list of uniform buffers
  9274. */
  9275. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9276. /**
  9277. * Prepares the uniforms and samplers list to be used in the effect
  9278. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9279. * @param samplersList The sampler list
  9280. * @param defines The defines helping in the list generation
  9281. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9282. */
  9283. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9284. /**
  9285. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9286. * @param defines The defines to update while falling back
  9287. * @param fallbacks The authorized effect fallbacks
  9288. * @param maxSimultaneousLights The maximum number of lights allowed
  9289. * @param rank the current rank of the Effect
  9290. * @returns The newly affected rank
  9291. */
  9292. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9293. private static _TmpMorphInfluencers;
  9294. /**
  9295. * Prepares the list of attributes required for morph targets according to the effect defines.
  9296. * @param attribs The current list of supported attribs
  9297. * @param mesh The mesh to prepare the morph targets attributes for
  9298. * @param influencers The number of influencers
  9299. */
  9300. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9301. /**
  9302. * Prepares the list of attributes required for morph targets according to the effect defines.
  9303. * @param attribs The current list of supported attribs
  9304. * @param mesh The mesh to prepare the morph targets attributes for
  9305. * @param defines The current Defines of the effect
  9306. */
  9307. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9308. /**
  9309. * Prepares the list of attributes required for bones according to the effect defines.
  9310. * @param attribs The current list of supported attribs
  9311. * @param mesh The mesh to prepare the bones attributes for
  9312. * @param defines The current Defines of the effect
  9313. * @param fallbacks The current efffect fallback strategy
  9314. */
  9315. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9316. /**
  9317. * Check and prepare the list of attributes required for instances according to the effect defines.
  9318. * @param attribs The current list of supported attribs
  9319. * @param defines The current MaterialDefines of the effect
  9320. */
  9321. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9322. /**
  9323. * Add the list of attributes required for instances to the attribs array.
  9324. * @param attribs The current list of supported attribs
  9325. */
  9326. static PushAttributesForInstances(attribs: string[]): void;
  9327. /**
  9328. * Binds the light information to the effect.
  9329. * @param light The light containing the generator
  9330. * @param effect The effect we are binding the data to
  9331. * @param lightIndex The light index in the effect used to render
  9332. */
  9333. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9334. /**
  9335. * Binds the lights information from the scene to the effect for the given mesh.
  9336. * @param light Light to bind
  9337. * @param lightIndex Light index
  9338. * @param scene The scene where the light belongs to
  9339. * @param effect The effect we are binding the data to
  9340. * @param useSpecular Defines if specular is supported
  9341. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9342. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9343. */
  9344. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9345. /**
  9346. * Binds the lights information from the scene to the effect for the given mesh.
  9347. * @param scene The scene the lights belongs to
  9348. * @param mesh The mesh we are binding the information to render
  9349. * @param effect The effect we are binding the data to
  9350. * @param defines The generated defines for the effect
  9351. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9352. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9353. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9354. */
  9355. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9356. private static _tempFogColor;
  9357. /**
  9358. * Binds the fog information from the scene to the effect for the given mesh.
  9359. * @param scene The scene the lights belongs to
  9360. * @param mesh The mesh we are binding the information to render
  9361. * @param effect The effect we are binding the data to
  9362. * @param linearSpace Defines if the fog effect is applied in linear space
  9363. */
  9364. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9365. /**
  9366. * Binds the bones information from the mesh to the effect.
  9367. * @param mesh The mesh we are binding the information to render
  9368. * @param effect The effect we are binding the data to
  9369. */
  9370. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9371. /**
  9372. * Binds the morph targets information from the mesh to the effect.
  9373. * @param abstractMesh The mesh we are binding the information to render
  9374. * @param effect The effect we are binding the data to
  9375. */
  9376. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9377. /**
  9378. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9379. * @param defines The generated defines used in the effect
  9380. * @param effect The effect we are binding the data to
  9381. * @param scene The scene we are willing to render with logarithmic scale for
  9382. */
  9383. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9384. /**
  9385. * Binds the clip plane information from the scene to the effect.
  9386. * @param scene The scene the clip plane information are extracted from
  9387. * @param effect The effect we are binding the data to
  9388. */
  9389. static BindClipPlane(effect: Effect, scene: Scene): void;
  9390. }
  9391. }
  9392. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9393. /** @hidden */
  9394. export var packingFunctions: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9400. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9401. /** @hidden */
  9402. export var shadowMapPixelShader: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9408. /** @hidden */
  9409. export var bonesDeclaration: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9415. /** @hidden */
  9416. export var morphTargetsVertexGlobalDeclaration: {
  9417. name: string;
  9418. shader: string;
  9419. };
  9420. }
  9421. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9422. /** @hidden */
  9423. export var morphTargetsVertexDeclaration: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9429. /** @hidden */
  9430. export var instancesDeclaration: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9436. /** @hidden */
  9437. export var helperFunctions: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9443. /** @hidden */
  9444. export var morphTargetsVertex: {
  9445. name: string;
  9446. shader: string;
  9447. };
  9448. }
  9449. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9450. /** @hidden */
  9451. export var instancesVertex: {
  9452. name: string;
  9453. shader: string;
  9454. };
  9455. }
  9456. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9457. /** @hidden */
  9458. export var bonesVertex: {
  9459. name: string;
  9460. shader: string;
  9461. };
  9462. }
  9463. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9464. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9467. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9468. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9469. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9470. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9471. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9472. /** @hidden */
  9473. export var shadowMapVertexShader: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9479. /** @hidden */
  9480. export var depthBoxBlurPixelShader: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9486. import { Nullable } from "babylonjs/types";
  9487. import { Scene } from "babylonjs/scene";
  9488. import { Matrix } from "babylonjs/Maths/math.vector";
  9489. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9491. import { Mesh } from "babylonjs/Meshes/mesh";
  9492. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9493. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9494. import { Effect } from "babylonjs/Materials/effect";
  9495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9496. import "babylonjs/Shaders/shadowMap.fragment";
  9497. import "babylonjs/Shaders/shadowMap.vertex";
  9498. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9499. import { Observable } from "babylonjs/Misc/observable";
  9500. /**
  9501. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9502. */
  9503. export interface ICustomShaderOptions {
  9504. /**
  9505. * Gets or sets the custom shader name to use
  9506. */
  9507. shaderName: string;
  9508. /**
  9509. * The list of attribute names used in the shader
  9510. */
  9511. attributes?: string[];
  9512. /**
  9513. * The list of unifrom names used in the shader
  9514. */
  9515. uniforms?: string[];
  9516. /**
  9517. * The list of sampler names used in the shader
  9518. */
  9519. samplers?: string[];
  9520. /**
  9521. * The list of defines used in the shader
  9522. */
  9523. defines?: string[];
  9524. }
  9525. /**
  9526. * Interface to implement to create a shadow generator compatible with BJS.
  9527. */
  9528. export interface IShadowGenerator {
  9529. /**
  9530. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9531. * @returns The render target texture if present otherwise, null
  9532. */
  9533. getShadowMap(): Nullable<RenderTargetTexture>;
  9534. /**
  9535. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9536. * @returns The render target texture if the shadow map is present otherwise, null
  9537. */
  9538. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9539. /**
  9540. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9541. * @param subMesh The submesh we want to render in the shadow map
  9542. * @param useInstances Defines wether will draw in the map using instances
  9543. * @returns true if ready otherwise, false
  9544. */
  9545. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9546. /**
  9547. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9548. * @param defines Defines of the material we want to update
  9549. * @param lightIndex Index of the light in the enabled light list of the material
  9550. */
  9551. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9552. /**
  9553. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9554. * defined in the generator but impacting the effect).
  9555. * It implies the unifroms available on the materials are the standard BJS ones.
  9556. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9557. * @param effect The effect we are binfing the information for
  9558. */
  9559. bindShadowLight(lightIndex: string, effect: Effect): void;
  9560. /**
  9561. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9562. * (eq to shadow prjection matrix * light transform matrix)
  9563. * @returns The transform matrix used to create the shadow map
  9564. */
  9565. getTransformMatrix(): Matrix;
  9566. /**
  9567. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9568. * Cube and 2D textures for instance.
  9569. */
  9570. recreateShadowMap(): void;
  9571. /**
  9572. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9573. * @param onCompiled Callback triggered at the and of the effects compilation
  9574. * @param options Sets of optional options forcing the compilation with different modes
  9575. */
  9576. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9577. useInstances: boolean;
  9578. }>): void;
  9579. /**
  9580. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9581. * @param options Sets of optional options forcing the compilation with different modes
  9582. * @returns A promise that resolves when the compilation completes
  9583. */
  9584. forceCompilationAsync(options?: Partial<{
  9585. useInstances: boolean;
  9586. }>): Promise<void>;
  9587. /**
  9588. * Serializes the shadow generator setup to a json object.
  9589. * @returns The serialized JSON object
  9590. */
  9591. serialize(): any;
  9592. /**
  9593. * Disposes the Shadow map and related Textures and effects.
  9594. */
  9595. dispose(): void;
  9596. }
  9597. /**
  9598. * Default implementation IShadowGenerator.
  9599. * This is the main object responsible of generating shadows in the framework.
  9600. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9601. */
  9602. export class ShadowGenerator implements IShadowGenerator {
  9603. /**
  9604. * Shadow generator mode None: no filtering applied.
  9605. */
  9606. static readonly FILTER_NONE: number;
  9607. /**
  9608. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9609. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9610. */
  9611. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9612. /**
  9613. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9614. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9615. */
  9616. static readonly FILTER_POISSONSAMPLING: number;
  9617. /**
  9618. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9619. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9620. */
  9621. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9622. /**
  9623. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9624. * edge artifacts on steep falloff.
  9625. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9626. */
  9627. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9628. /**
  9629. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9630. * edge artifacts on steep falloff.
  9631. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9632. */
  9633. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9634. /**
  9635. * Shadow generator mode PCF: Percentage Closer Filtering
  9636. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9637. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9638. */
  9639. static readonly FILTER_PCF: number;
  9640. /**
  9641. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9642. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9643. * Contact Hardening
  9644. */
  9645. static readonly FILTER_PCSS: number;
  9646. /**
  9647. * Reserved for PCF and PCSS
  9648. * Highest Quality.
  9649. *
  9650. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9651. *
  9652. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9653. */
  9654. static readonly QUALITY_HIGH: number;
  9655. /**
  9656. * Reserved for PCF and PCSS
  9657. * Good tradeoff for quality/perf cross devices
  9658. *
  9659. * Execute PCF on a 3*3 kernel.
  9660. *
  9661. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9662. */
  9663. static readonly QUALITY_MEDIUM: number;
  9664. /**
  9665. * Reserved for PCF and PCSS
  9666. * The lowest quality but the fastest.
  9667. *
  9668. * Execute PCF on a 1*1 kernel.
  9669. *
  9670. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9671. */
  9672. static readonly QUALITY_LOW: number;
  9673. /** Gets or sets the custom shader name to use */
  9674. customShaderOptions: ICustomShaderOptions;
  9675. /**
  9676. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9677. */
  9678. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9679. /**
  9680. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9681. */
  9682. onAfterShadowMapRenderObservable: Observable<Effect>;
  9683. /**
  9684. * Observable triggered before a mesh is rendered in the shadow map.
  9685. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9686. */
  9687. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9688. /**
  9689. * Observable triggered after a mesh is rendered in the shadow map.
  9690. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9691. */
  9692. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9693. private _bias;
  9694. /**
  9695. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9696. */
  9697. get bias(): number;
  9698. /**
  9699. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9700. */
  9701. set bias(bias: number);
  9702. private _normalBias;
  9703. /**
  9704. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9705. */
  9706. get normalBias(): number;
  9707. /**
  9708. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9709. */
  9710. set normalBias(normalBias: number);
  9711. private _blurBoxOffset;
  9712. /**
  9713. * Gets the blur box offset: offset applied during the blur pass.
  9714. * Only useful if useKernelBlur = false
  9715. */
  9716. get blurBoxOffset(): number;
  9717. /**
  9718. * Sets the blur box offset: offset applied during the blur pass.
  9719. * Only useful if useKernelBlur = false
  9720. */
  9721. set blurBoxOffset(value: number);
  9722. private _blurScale;
  9723. /**
  9724. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9725. * 2 means half of the size.
  9726. */
  9727. get blurScale(): number;
  9728. /**
  9729. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9730. * 2 means half of the size.
  9731. */
  9732. set blurScale(value: number);
  9733. private _blurKernel;
  9734. /**
  9735. * Gets the blur kernel: kernel size of the blur pass.
  9736. * Only useful if useKernelBlur = true
  9737. */
  9738. get blurKernel(): number;
  9739. /**
  9740. * Sets the blur kernel: kernel size of the blur pass.
  9741. * Only useful if useKernelBlur = true
  9742. */
  9743. set blurKernel(value: number);
  9744. private _useKernelBlur;
  9745. /**
  9746. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9747. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9748. */
  9749. get useKernelBlur(): boolean;
  9750. /**
  9751. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9752. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9753. */
  9754. set useKernelBlur(value: boolean);
  9755. private _depthScale;
  9756. /**
  9757. * Gets the depth scale used in ESM mode.
  9758. */
  9759. get depthScale(): number;
  9760. /**
  9761. * Sets the depth scale used in ESM mode.
  9762. * This can override the scale stored on the light.
  9763. */
  9764. set depthScale(value: number);
  9765. private _filter;
  9766. /**
  9767. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9768. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9769. */
  9770. get filter(): number;
  9771. /**
  9772. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9773. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9774. */
  9775. set filter(value: number);
  9776. /**
  9777. * Gets if the current filter is set to Poisson Sampling.
  9778. */
  9779. get usePoissonSampling(): boolean;
  9780. /**
  9781. * Sets the current filter to Poisson Sampling.
  9782. */
  9783. set usePoissonSampling(value: boolean);
  9784. /**
  9785. * Gets if the current filter is set to ESM.
  9786. */
  9787. get useExponentialShadowMap(): boolean;
  9788. /**
  9789. * Sets the current filter is to ESM.
  9790. */
  9791. set useExponentialShadowMap(value: boolean);
  9792. /**
  9793. * Gets if the current filter is set to filtered ESM.
  9794. */
  9795. get useBlurExponentialShadowMap(): boolean;
  9796. /**
  9797. * Gets if the current filter is set to filtered ESM.
  9798. */
  9799. set useBlurExponentialShadowMap(value: boolean);
  9800. /**
  9801. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9802. * exponential to prevent steep falloff artifacts).
  9803. */
  9804. get useCloseExponentialShadowMap(): boolean;
  9805. /**
  9806. * Sets the current filter to "close ESM" (using the inverse of the
  9807. * exponential to prevent steep falloff artifacts).
  9808. */
  9809. set useCloseExponentialShadowMap(value: boolean);
  9810. /**
  9811. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9812. * exponential to prevent steep falloff artifacts).
  9813. */
  9814. get useBlurCloseExponentialShadowMap(): boolean;
  9815. /**
  9816. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9817. * exponential to prevent steep falloff artifacts).
  9818. */
  9819. set useBlurCloseExponentialShadowMap(value: boolean);
  9820. /**
  9821. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9822. */
  9823. get usePercentageCloserFiltering(): boolean;
  9824. /**
  9825. * Sets the current filter to "PCF" (percentage closer filtering).
  9826. */
  9827. set usePercentageCloserFiltering(value: boolean);
  9828. private _filteringQuality;
  9829. /**
  9830. * Gets the PCF or PCSS Quality.
  9831. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9832. */
  9833. get filteringQuality(): number;
  9834. /**
  9835. * Sets the PCF or PCSS Quality.
  9836. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9837. */
  9838. set filteringQuality(filteringQuality: number);
  9839. /**
  9840. * Gets if the current filter is set to "PCSS" (contact hardening).
  9841. */
  9842. get useContactHardeningShadow(): boolean;
  9843. /**
  9844. * Sets the current filter to "PCSS" (contact hardening).
  9845. */
  9846. set useContactHardeningShadow(value: boolean);
  9847. private _contactHardeningLightSizeUVRatio;
  9848. /**
  9849. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9850. * Using a ratio helps keeping shape stability independently of the map size.
  9851. *
  9852. * It does not account for the light projection as it was having too much
  9853. * instability during the light setup or during light position changes.
  9854. *
  9855. * Only valid if useContactHardeningShadow is true.
  9856. */
  9857. get contactHardeningLightSizeUVRatio(): number;
  9858. /**
  9859. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9860. * Using a ratio helps keeping shape stability independently of the map size.
  9861. *
  9862. * It does not account for the light projection as it was having too much
  9863. * instability during the light setup or during light position changes.
  9864. *
  9865. * Only valid if useContactHardeningShadow is true.
  9866. */
  9867. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9868. private _darkness;
  9869. /** Gets or sets the actual darkness of a shadow */
  9870. get darkness(): number;
  9871. set darkness(value: number);
  9872. /**
  9873. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9874. * 0 means strongest and 1 would means no shadow.
  9875. * @returns the darkness.
  9876. */
  9877. getDarkness(): number;
  9878. /**
  9879. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9880. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9881. * @returns the shadow generator allowing fluent coding.
  9882. */
  9883. setDarkness(darkness: number): ShadowGenerator;
  9884. private _transparencyShadow;
  9885. /** Gets or sets the ability to have transparent shadow */
  9886. get transparencyShadow(): boolean;
  9887. set transparencyShadow(value: boolean);
  9888. /**
  9889. * Sets the ability to have transparent shadow (boolean).
  9890. * @param transparent True if transparent else False
  9891. * @returns the shadow generator allowing fluent coding
  9892. */
  9893. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9894. private _shadowMap;
  9895. private _shadowMap2;
  9896. /**
  9897. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9898. * @returns The render target texture if present otherwise, null
  9899. */
  9900. getShadowMap(): Nullable<RenderTargetTexture>;
  9901. /**
  9902. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9903. * @returns The render target texture if the shadow map is present otherwise, null
  9904. */
  9905. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9906. /**
  9907. * Gets the class name of that object
  9908. * @returns "ShadowGenerator"
  9909. */
  9910. getClassName(): string;
  9911. /**
  9912. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9913. * @param mesh Mesh to add
  9914. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9915. * @returns the Shadow Generator itself
  9916. */
  9917. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9918. /**
  9919. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9920. * @param mesh Mesh to remove
  9921. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9922. * @returns the Shadow Generator itself
  9923. */
  9924. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9925. /**
  9926. * Controls the extent to which the shadows fade out at the edge of the frustum
  9927. * Used only by directionals and spots
  9928. */
  9929. frustumEdgeFalloff: number;
  9930. private _light;
  9931. /**
  9932. * Returns the associated light object.
  9933. * @returns the light generating the shadow
  9934. */
  9935. getLight(): IShadowLight;
  9936. /**
  9937. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9938. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9939. * It might on the other hand introduce peter panning.
  9940. */
  9941. forceBackFacesOnly: boolean;
  9942. private _scene;
  9943. private _lightDirection;
  9944. private _effect;
  9945. private _viewMatrix;
  9946. private _projectionMatrix;
  9947. private _transformMatrix;
  9948. private _cachedPosition;
  9949. private _cachedDirection;
  9950. private _cachedDefines;
  9951. private _currentRenderID;
  9952. private _boxBlurPostprocess;
  9953. private _kernelBlurXPostprocess;
  9954. private _kernelBlurYPostprocess;
  9955. private _blurPostProcesses;
  9956. private _mapSize;
  9957. private _currentFaceIndex;
  9958. private _currentFaceIndexCache;
  9959. private _textureType;
  9960. private _defaultTextureMatrix;
  9961. private _storedUniqueId;
  9962. /** @hidden */
  9963. static _SceneComponentInitialization: (scene: Scene) => void;
  9964. /**
  9965. * Creates a ShadowGenerator object.
  9966. * A ShadowGenerator is the required tool to use the shadows.
  9967. * Each light casting shadows needs to use its own ShadowGenerator.
  9968. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9969. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9970. * @param light The light object generating the shadows.
  9971. * @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.
  9972. */
  9973. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9974. private _initializeGenerator;
  9975. private _initializeShadowMap;
  9976. private _initializeBlurRTTAndPostProcesses;
  9977. private _renderForShadowMap;
  9978. private _renderSubMeshForShadowMap;
  9979. private _applyFilterValues;
  9980. /**
  9981. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9982. * @param onCompiled Callback triggered at the and of the effects compilation
  9983. * @param options Sets of optional options forcing the compilation with different modes
  9984. */
  9985. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9986. useInstances: boolean;
  9987. }>): void;
  9988. /**
  9989. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9990. * @param options Sets of optional options forcing the compilation with different modes
  9991. * @returns A promise that resolves when the compilation completes
  9992. */
  9993. forceCompilationAsync(options?: Partial<{
  9994. useInstances: boolean;
  9995. }>): Promise<void>;
  9996. /**
  9997. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9998. * @param subMesh The submesh we want to render in the shadow map
  9999. * @param useInstances Defines wether will draw in the map using instances
  10000. * @returns true if ready otherwise, false
  10001. */
  10002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10003. /**
  10004. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10005. * @param defines Defines of the material we want to update
  10006. * @param lightIndex Index of the light in the enabled light list of the material
  10007. */
  10008. prepareDefines(defines: any, lightIndex: number): void;
  10009. /**
  10010. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10011. * defined in the generator but impacting the effect).
  10012. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10013. * @param effect The effect we are binfing the information for
  10014. */
  10015. bindShadowLight(lightIndex: string, effect: Effect): void;
  10016. /**
  10017. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10018. * (eq to shadow prjection matrix * light transform matrix)
  10019. * @returns The transform matrix used to create the shadow map
  10020. */
  10021. getTransformMatrix(): Matrix;
  10022. /**
  10023. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10024. * Cube and 2D textures for instance.
  10025. */
  10026. recreateShadowMap(): void;
  10027. private _disposeBlurPostProcesses;
  10028. private _disposeRTTandPostProcesses;
  10029. /**
  10030. * Disposes the ShadowGenerator.
  10031. * Returns nothing.
  10032. */
  10033. dispose(): void;
  10034. /**
  10035. * Serializes the shadow generator setup to a json object.
  10036. * @returns The serialized JSON object
  10037. */
  10038. serialize(): any;
  10039. /**
  10040. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10041. * @param parsedShadowGenerator The JSON object to parse
  10042. * @param scene The scene to create the shadow map for
  10043. * @returns The parsed shadow generator
  10044. */
  10045. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10046. }
  10047. }
  10048. declare module "babylonjs/Lights/light" {
  10049. import { Nullable } from "babylonjs/types";
  10050. import { Scene } from "babylonjs/scene";
  10051. import { Vector3 } from "babylonjs/Maths/math.vector";
  10052. import { Color3 } from "babylonjs/Maths/math.color";
  10053. import { Node } from "babylonjs/node";
  10054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10055. import { Effect } from "babylonjs/Materials/effect";
  10056. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10057. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10058. /**
  10059. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10060. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10061. * 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.
  10062. */
  10063. export abstract class Light extends Node {
  10064. /**
  10065. * Falloff Default: light is falling off following the material specification:
  10066. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10067. */
  10068. static readonly FALLOFF_DEFAULT: number;
  10069. /**
  10070. * Falloff Physical: light is falling off following the inverse squared distance law.
  10071. */
  10072. static readonly FALLOFF_PHYSICAL: number;
  10073. /**
  10074. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10075. * to enhance interoperability with other engines.
  10076. */
  10077. static readonly FALLOFF_GLTF: number;
  10078. /**
  10079. * Falloff Standard: light is falling off like in the standard material
  10080. * to enhance interoperability with other materials.
  10081. */
  10082. static readonly FALLOFF_STANDARD: number;
  10083. /**
  10084. * If every light affecting the material is in this lightmapMode,
  10085. * material.lightmapTexture adds or multiplies
  10086. * (depends on material.useLightmapAsShadowmap)
  10087. * after every other light calculations.
  10088. */
  10089. static readonly LIGHTMAP_DEFAULT: number;
  10090. /**
  10091. * material.lightmapTexture as only diffuse lighting from this light
  10092. * adds only specular lighting from this light
  10093. * adds dynamic shadows
  10094. */
  10095. static readonly LIGHTMAP_SPECULAR: number;
  10096. /**
  10097. * material.lightmapTexture as only lighting
  10098. * no light calculation from this light
  10099. * only adds dynamic shadows from this light
  10100. */
  10101. static readonly LIGHTMAP_SHADOWSONLY: number;
  10102. /**
  10103. * Each light type uses the default quantity according to its type:
  10104. * point/spot lights use luminous intensity
  10105. * directional lights use illuminance
  10106. */
  10107. static readonly INTENSITYMODE_AUTOMATIC: number;
  10108. /**
  10109. * lumen (lm)
  10110. */
  10111. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10112. /**
  10113. * candela (lm/sr)
  10114. */
  10115. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10116. /**
  10117. * lux (lm/m^2)
  10118. */
  10119. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10120. /**
  10121. * nit (cd/m^2)
  10122. */
  10123. static readonly INTENSITYMODE_LUMINANCE: number;
  10124. /**
  10125. * Light type const id of the point light.
  10126. */
  10127. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10128. /**
  10129. * Light type const id of the directional light.
  10130. */
  10131. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10132. /**
  10133. * Light type const id of the spot light.
  10134. */
  10135. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10136. /**
  10137. * Light type const id of the hemispheric light.
  10138. */
  10139. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10140. /**
  10141. * Diffuse gives the basic color to an object.
  10142. */
  10143. diffuse: Color3;
  10144. /**
  10145. * Specular produces a highlight color on an object.
  10146. * Note: This is note affecting PBR materials.
  10147. */
  10148. specular: Color3;
  10149. /**
  10150. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10151. * falling off base on range or angle.
  10152. * This can be set to any values in Light.FALLOFF_x.
  10153. *
  10154. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10155. * other types of materials.
  10156. */
  10157. falloffType: number;
  10158. /**
  10159. * Strength of the light.
  10160. * Note: By default it is define in the framework own unit.
  10161. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10162. */
  10163. intensity: number;
  10164. private _range;
  10165. protected _inverseSquaredRange: number;
  10166. /**
  10167. * Defines how far from the source the light is impacting in scene units.
  10168. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10169. */
  10170. get range(): number;
  10171. /**
  10172. * Defines how far from the source the light is impacting in scene units.
  10173. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10174. */
  10175. set range(value: number);
  10176. /**
  10177. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10178. * of light.
  10179. */
  10180. private _photometricScale;
  10181. private _intensityMode;
  10182. /**
  10183. * Gets the photometric scale used to interpret the intensity.
  10184. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10185. */
  10186. get intensityMode(): number;
  10187. /**
  10188. * Sets the photometric scale used to interpret the intensity.
  10189. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10190. */
  10191. set intensityMode(value: number);
  10192. private _radius;
  10193. /**
  10194. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10195. */
  10196. get radius(): number;
  10197. /**
  10198. * sets the light radius used by PBR Materials to simulate soft area lights.
  10199. */
  10200. set radius(value: number);
  10201. private _renderPriority;
  10202. /**
  10203. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10204. * exceeding the number allowed of the materials.
  10205. */
  10206. renderPriority: number;
  10207. private _shadowEnabled;
  10208. /**
  10209. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10210. * the current shadow generator.
  10211. */
  10212. get shadowEnabled(): boolean;
  10213. /**
  10214. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10215. * the current shadow generator.
  10216. */
  10217. set shadowEnabled(value: boolean);
  10218. private _includedOnlyMeshes;
  10219. /**
  10220. * Gets the only meshes impacted by this light.
  10221. */
  10222. get includedOnlyMeshes(): AbstractMesh[];
  10223. /**
  10224. * Sets the only meshes impacted by this light.
  10225. */
  10226. set includedOnlyMeshes(value: AbstractMesh[]);
  10227. private _excludedMeshes;
  10228. /**
  10229. * Gets the meshes not impacted by this light.
  10230. */
  10231. get excludedMeshes(): AbstractMesh[];
  10232. /**
  10233. * Sets the meshes not impacted by this light.
  10234. */
  10235. set excludedMeshes(value: AbstractMesh[]);
  10236. private _excludeWithLayerMask;
  10237. /**
  10238. * Gets the layer id use to find what meshes are not impacted by the light.
  10239. * Inactive if 0
  10240. */
  10241. get excludeWithLayerMask(): number;
  10242. /**
  10243. * Sets the layer id use to find what meshes are not impacted by the light.
  10244. * Inactive if 0
  10245. */
  10246. set excludeWithLayerMask(value: number);
  10247. private _includeOnlyWithLayerMask;
  10248. /**
  10249. * Gets the layer id use to find what meshes are impacted by the light.
  10250. * Inactive if 0
  10251. */
  10252. get includeOnlyWithLayerMask(): number;
  10253. /**
  10254. * Sets the layer id use to find what meshes are impacted by the light.
  10255. * Inactive if 0
  10256. */
  10257. set includeOnlyWithLayerMask(value: number);
  10258. private _lightmapMode;
  10259. /**
  10260. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10261. */
  10262. get lightmapMode(): number;
  10263. /**
  10264. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10265. */
  10266. set lightmapMode(value: number);
  10267. /**
  10268. * Shadow generator associted to the light.
  10269. * @hidden Internal use only.
  10270. */
  10271. _shadowGenerator: Nullable<IShadowGenerator>;
  10272. /**
  10273. * @hidden Internal use only.
  10274. */
  10275. _excludedMeshesIds: string[];
  10276. /**
  10277. * @hidden Internal use only.
  10278. */
  10279. _includedOnlyMeshesIds: string[];
  10280. /**
  10281. * The current light unifom buffer.
  10282. * @hidden Internal use only.
  10283. */
  10284. _uniformBuffer: UniformBuffer;
  10285. /** @hidden */
  10286. _renderId: number;
  10287. /**
  10288. * Creates a Light object in the scene.
  10289. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10290. * @param name The firendly name of the light
  10291. * @param scene The scene the light belongs too
  10292. */
  10293. constructor(name: string, scene: Scene);
  10294. protected abstract _buildUniformLayout(): void;
  10295. /**
  10296. * Sets the passed Effect "effect" with the Light information.
  10297. * @param effect The effect to update
  10298. * @param lightIndex The index of the light in the effect to update
  10299. * @returns The light
  10300. */
  10301. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10302. /**
  10303. * Sets the passed Effect "effect" with the Light textures.
  10304. * @param effect The effect to update
  10305. * @param lightIndex The index of the light in the effect to update
  10306. * @returns The light
  10307. */
  10308. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10309. /**
  10310. * Binds the lights information from the scene to the effect for the given mesh.
  10311. * @param lightIndex Light index
  10312. * @param scene The scene where the light belongs to
  10313. * @param effect The effect we are binding the data to
  10314. * @param useSpecular Defines if specular is supported
  10315. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10316. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10317. */
  10318. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10319. /**
  10320. * Sets the passed Effect "effect" with the Light information.
  10321. * @param effect The effect to update
  10322. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10323. * @returns The light
  10324. */
  10325. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10326. /**
  10327. * Returns the string "Light".
  10328. * @returns the class name
  10329. */
  10330. getClassName(): string;
  10331. /** @hidden */
  10332. readonly _isLight: boolean;
  10333. /**
  10334. * Converts the light information to a readable string for debug purpose.
  10335. * @param fullDetails Supports for multiple levels of logging within scene loading
  10336. * @returns the human readable light info
  10337. */
  10338. toString(fullDetails?: boolean): string;
  10339. /** @hidden */
  10340. protected _syncParentEnabledState(): void;
  10341. /**
  10342. * Set the enabled state of this node.
  10343. * @param value - the new enabled state
  10344. */
  10345. setEnabled(value: boolean): void;
  10346. /**
  10347. * Returns the Light associated shadow generator if any.
  10348. * @return the associated shadow generator.
  10349. */
  10350. getShadowGenerator(): Nullable<IShadowGenerator>;
  10351. /**
  10352. * Returns a Vector3, the absolute light position in the World.
  10353. * @returns the world space position of the light
  10354. */
  10355. getAbsolutePosition(): Vector3;
  10356. /**
  10357. * Specifies if the light will affect the passed mesh.
  10358. * @param mesh The mesh to test against the light
  10359. * @return true the mesh is affected otherwise, false.
  10360. */
  10361. canAffectMesh(mesh: AbstractMesh): boolean;
  10362. /**
  10363. * Sort function to order lights for rendering.
  10364. * @param a First Light object to compare to second.
  10365. * @param b Second Light object to compare first.
  10366. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10367. */
  10368. static CompareLightsPriority(a: Light, b: Light): number;
  10369. /**
  10370. * Releases resources associated with this node.
  10371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10373. */
  10374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10375. /**
  10376. * Returns the light type ID (integer).
  10377. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10378. */
  10379. getTypeID(): number;
  10380. /**
  10381. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10382. * @returns the scaled intensity in intensity mode unit
  10383. */
  10384. getScaledIntensity(): number;
  10385. /**
  10386. * Returns a new Light object, named "name", from the current one.
  10387. * @param name The name of the cloned light
  10388. * @returns the new created light
  10389. */
  10390. clone(name: string): Nullable<Light>;
  10391. /**
  10392. * Serializes the current light into a Serialization object.
  10393. * @returns the serialized object.
  10394. */
  10395. serialize(): any;
  10396. /**
  10397. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10398. * This new light is named "name" and added to the passed scene.
  10399. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10400. * @param name The friendly name of the light
  10401. * @param scene The scene the new light will belong to
  10402. * @returns the constructor function
  10403. */
  10404. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10405. /**
  10406. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10407. * @param parsedLight The JSON representation of the light
  10408. * @param scene The scene to create the parsed light in
  10409. * @returns the created light after parsing
  10410. */
  10411. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10412. private _hookArrayForExcluded;
  10413. private _hookArrayForIncludedOnly;
  10414. private _resyncMeshes;
  10415. /**
  10416. * Forces the meshes to update their light related information in their rendering used effects
  10417. * @hidden Internal Use Only
  10418. */
  10419. _markMeshesAsLightDirty(): void;
  10420. /**
  10421. * Recomputes the cached photometric scale if needed.
  10422. */
  10423. private _computePhotometricScale;
  10424. /**
  10425. * Returns the Photometric Scale according to the light type and intensity mode.
  10426. */
  10427. private _getPhotometricScale;
  10428. /**
  10429. * Reorder the light in the scene according to their defined priority.
  10430. * @hidden Internal Use Only
  10431. */
  10432. _reorderLightsInScene(): void;
  10433. /**
  10434. * Prepares the list of defines specific to the light type.
  10435. * @param defines the list of defines
  10436. * @param lightIndex defines the index of the light for the effect
  10437. */
  10438. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10439. }
  10440. }
  10441. declare module "babylonjs/Actions/action" {
  10442. import { Observable } from "babylonjs/Misc/observable";
  10443. import { Condition } from "babylonjs/Actions/condition";
  10444. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10445. import { ActionManager } from "babylonjs/Actions/actionManager";
  10446. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10447. /**
  10448. * Interface used to define Action
  10449. */
  10450. export interface IAction {
  10451. /**
  10452. * Trigger for the action
  10453. */
  10454. trigger: number;
  10455. /** Options of the trigger */
  10456. triggerOptions: any;
  10457. /**
  10458. * Gets the trigger parameters
  10459. * @returns the trigger parameters
  10460. */
  10461. getTriggerParameter(): any;
  10462. /**
  10463. * Internal only - executes current action event
  10464. * @hidden
  10465. */
  10466. _executeCurrent(evt?: ActionEvent): void;
  10467. /**
  10468. * Serialize placeholder for child classes
  10469. * @param parent of child
  10470. * @returns the serialized object
  10471. */
  10472. serialize(parent: any): any;
  10473. /**
  10474. * Internal only
  10475. * @hidden
  10476. */
  10477. _prepare(): void;
  10478. /**
  10479. * Internal only - manager for action
  10480. * @hidden
  10481. */
  10482. _actionManager: AbstractActionManager;
  10483. /**
  10484. * Adds action to chain of actions, may be a DoNothingAction
  10485. * @param action defines the next action to execute
  10486. * @returns The action passed in
  10487. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10488. */
  10489. then(action: IAction): IAction;
  10490. }
  10491. /**
  10492. * The action to be carried out following a trigger
  10493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10494. */
  10495. export class Action implements IAction {
  10496. /** the trigger, with or without parameters, for the action */
  10497. triggerOptions: any;
  10498. /**
  10499. * Trigger for the action
  10500. */
  10501. trigger: number;
  10502. /**
  10503. * Internal only - manager for action
  10504. * @hidden
  10505. */
  10506. _actionManager: ActionManager;
  10507. private _nextActiveAction;
  10508. private _child;
  10509. private _condition?;
  10510. private _triggerParameter;
  10511. /**
  10512. * An event triggered prior to action being executed.
  10513. */
  10514. onBeforeExecuteObservable: Observable<Action>;
  10515. /**
  10516. * Creates a new Action
  10517. * @param triggerOptions the trigger, with or without parameters, for the action
  10518. * @param condition an optional determinant of action
  10519. */
  10520. constructor(
  10521. /** the trigger, with or without parameters, for the action */
  10522. triggerOptions: any, condition?: Condition);
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. _prepare(): void;
  10528. /**
  10529. * Gets the trigger parameters
  10530. * @returns the trigger parameters
  10531. */
  10532. getTriggerParameter(): any;
  10533. /**
  10534. * Internal only - executes current action event
  10535. * @hidden
  10536. */
  10537. _executeCurrent(evt?: ActionEvent): void;
  10538. /**
  10539. * Execute placeholder for child classes
  10540. * @param evt optional action event
  10541. */
  10542. execute(evt?: ActionEvent): void;
  10543. /**
  10544. * Skips to next active action
  10545. */
  10546. skipToNextActiveAction(): void;
  10547. /**
  10548. * Adds action to chain of actions, may be a DoNothingAction
  10549. * @param action defines the next action to execute
  10550. * @returns The action passed in
  10551. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10552. */
  10553. then(action: Action): Action;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. _getProperty(propertyPath: string): string;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. _getEffectiveTarget(target: any, propertyPath: string): any;
  10564. /**
  10565. * Serialize placeholder for child classes
  10566. * @param parent of child
  10567. * @returns the serialized object
  10568. */
  10569. serialize(parent: any): any;
  10570. /**
  10571. * Internal only called by serialize
  10572. * @hidden
  10573. */
  10574. protected _serialize(serializedAction: any, parent?: any): any;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. static _SerializeValueAsString: (value: any) => string;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10585. name: string;
  10586. targetType: string;
  10587. value: string;
  10588. };
  10589. }
  10590. }
  10591. declare module "babylonjs/Actions/condition" {
  10592. import { ActionManager } from "babylonjs/Actions/actionManager";
  10593. /**
  10594. * A Condition applied to an Action
  10595. */
  10596. export class Condition {
  10597. /**
  10598. * Internal only - manager for action
  10599. * @hidden
  10600. */
  10601. _actionManager: ActionManager;
  10602. /**
  10603. * Internal only
  10604. * @hidden
  10605. */
  10606. _evaluationId: number;
  10607. /**
  10608. * Internal only
  10609. * @hidden
  10610. */
  10611. _currentResult: boolean;
  10612. /**
  10613. * Creates a new Condition
  10614. * @param actionManager the manager of the action the condition is applied to
  10615. */
  10616. constructor(actionManager: ActionManager);
  10617. /**
  10618. * Check if the current condition is valid
  10619. * @returns a boolean
  10620. */
  10621. isValid(): boolean;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. _getProperty(propertyPath: string): string;
  10627. /**
  10628. * Internal only
  10629. * @hidden
  10630. */
  10631. _getEffectiveTarget(target: any, propertyPath: string): any;
  10632. /**
  10633. * Serialize placeholder for child classes
  10634. * @returns the serialized object
  10635. */
  10636. serialize(): any;
  10637. /**
  10638. * Internal only
  10639. * @hidden
  10640. */
  10641. protected _serialize(serializedCondition: any): any;
  10642. }
  10643. /**
  10644. * Defines specific conditional operators as extensions of Condition
  10645. */
  10646. export class ValueCondition extends Condition {
  10647. /** path to specify the property of the target the conditional operator uses */
  10648. propertyPath: string;
  10649. /** the value compared by the conditional operator against the current value of the property */
  10650. value: any;
  10651. /** the conditional operator, default ValueCondition.IsEqual */
  10652. operator: number;
  10653. /**
  10654. * Internal only
  10655. * @hidden
  10656. */
  10657. private static _IsEqual;
  10658. /**
  10659. * Internal only
  10660. * @hidden
  10661. */
  10662. private static _IsDifferent;
  10663. /**
  10664. * Internal only
  10665. * @hidden
  10666. */
  10667. private static _IsGreater;
  10668. /**
  10669. * Internal only
  10670. * @hidden
  10671. */
  10672. private static _IsLesser;
  10673. /**
  10674. * returns the number for IsEqual
  10675. */
  10676. static get IsEqual(): number;
  10677. /**
  10678. * Returns the number for IsDifferent
  10679. */
  10680. static get IsDifferent(): number;
  10681. /**
  10682. * Returns the number for IsGreater
  10683. */
  10684. static get IsGreater(): number;
  10685. /**
  10686. * Returns the number for IsLesser
  10687. */
  10688. static get IsLesser(): number;
  10689. /**
  10690. * Internal only The action manager for the condition
  10691. * @hidden
  10692. */
  10693. _actionManager: ActionManager;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. private _target;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. private _effectiveTarget;
  10704. /**
  10705. * Internal only
  10706. * @hidden
  10707. */
  10708. private _property;
  10709. /**
  10710. * Creates a new ValueCondition
  10711. * @param actionManager manager for the action the condition applies to
  10712. * @param target for the action
  10713. * @param propertyPath path to specify the property of the target the conditional operator uses
  10714. * @param value the value compared by the conditional operator against the current value of the property
  10715. * @param operator the conditional operator, default ValueCondition.IsEqual
  10716. */
  10717. constructor(actionManager: ActionManager, target: any,
  10718. /** path to specify the property of the target the conditional operator uses */
  10719. propertyPath: string,
  10720. /** the value compared by the conditional operator against the current value of the property */
  10721. value: any,
  10722. /** the conditional operator, default ValueCondition.IsEqual */
  10723. operator?: number);
  10724. /**
  10725. * Compares the given value with the property value for the specified conditional operator
  10726. * @returns the result of the comparison
  10727. */
  10728. isValid(): boolean;
  10729. /**
  10730. * Serialize the ValueCondition into a JSON compatible object
  10731. * @returns serialization object
  10732. */
  10733. serialize(): any;
  10734. /**
  10735. * Gets the name of the conditional operator for the ValueCondition
  10736. * @param operator the conditional operator
  10737. * @returns the name
  10738. */
  10739. static GetOperatorName(operator: number): string;
  10740. }
  10741. /**
  10742. * Defines a predicate condition as an extension of Condition
  10743. */
  10744. export class PredicateCondition extends Condition {
  10745. /** defines the predicate function used to validate the condition */
  10746. predicate: () => boolean;
  10747. /**
  10748. * Internal only - manager for action
  10749. * @hidden
  10750. */
  10751. _actionManager: ActionManager;
  10752. /**
  10753. * Creates a new PredicateCondition
  10754. * @param actionManager manager for the action the condition applies to
  10755. * @param predicate defines the predicate function used to validate the condition
  10756. */
  10757. constructor(actionManager: ActionManager,
  10758. /** defines the predicate function used to validate the condition */
  10759. predicate: () => boolean);
  10760. /**
  10761. * @returns the validity of the predicate condition
  10762. */
  10763. isValid(): boolean;
  10764. }
  10765. /**
  10766. * Defines a state condition as an extension of Condition
  10767. */
  10768. export class StateCondition extends Condition {
  10769. /** Value to compare with target state */
  10770. value: string;
  10771. /**
  10772. * Internal only - manager for action
  10773. * @hidden
  10774. */
  10775. _actionManager: ActionManager;
  10776. /**
  10777. * Internal only
  10778. * @hidden
  10779. */
  10780. private _target;
  10781. /**
  10782. * Creates a new StateCondition
  10783. * @param actionManager manager for the action the condition applies to
  10784. * @param target of the condition
  10785. * @param value to compare with target state
  10786. */
  10787. constructor(actionManager: ActionManager, target: any,
  10788. /** Value to compare with target state */
  10789. value: string);
  10790. /**
  10791. * Gets a boolean indicating if the current condition is met
  10792. * @returns the validity of the state
  10793. */
  10794. isValid(): boolean;
  10795. /**
  10796. * Serialize the StateCondition into a JSON compatible object
  10797. * @returns serialization object
  10798. */
  10799. serialize(): any;
  10800. }
  10801. }
  10802. declare module "babylonjs/Actions/directActions" {
  10803. import { Action } from "babylonjs/Actions/action";
  10804. import { Condition } from "babylonjs/Actions/condition";
  10805. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10806. /**
  10807. * This defines an action responsible to toggle a boolean once triggered.
  10808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10809. */
  10810. export class SwitchBooleanAction extends Action {
  10811. /**
  10812. * The path to the boolean property in the target object
  10813. */
  10814. propertyPath: string;
  10815. private _target;
  10816. private _effectiveTarget;
  10817. private _property;
  10818. /**
  10819. * Instantiate the action
  10820. * @param triggerOptions defines the trigger options
  10821. * @param target defines the object containing the boolean
  10822. * @param propertyPath defines the path to the boolean property in the target object
  10823. * @param condition defines the trigger related conditions
  10824. */
  10825. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10826. /** @hidden */
  10827. _prepare(): void;
  10828. /**
  10829. * Execute the action toggle the boolean value.
  10830. */
  10831. execute(): void;
  10832. /**
  10833. * Serializes the actions and its related information.
  10834. * @param parent defines the object to serialize in
  10835. * @returns the serialized object
  10836. */
  10837. serialize(parent: any): any;
  10838. }
  10839. /**
  10840. * This defines an action responsible to set a the state field of the target
  10841. * to a desired value once triggered.
  10842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10843. */
  10844. export class SetStateAction extends Action {
  10845. /**
  10846. * The value to store in the state field.
  10847. */
  10848. value: string;
  10849. private _target;
  10850. /**
  10851. * Instantiate the action
  10852. * @param triggerOptions defines the trigger options
  10853. * @param target defines the object containing the state property
  10854. * @param value defines the value to store in the state field
  10855. * @param condition defines the trigger related conditions
  10856. */
  10857. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10858. /**
  10859. * Execute the action and store the value on the target state property.
  10860. */
  10861. execute(): void;
  10862. /**
  10863. * Serializes the actions and its related information.
  10864. * @param parent defines the object to serialize in
  10865. * @returns the serialized object
  10866. */
  10867. serialize(parent: any): any;
  10868. }
  10869. /**
  10870. * This defines an action responsible to set a property of the target
  10871. * to a desired value once triggered.
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10873. */
  10874. export class SetValueAction extends Action {
  10875. /**
  10876. * The path of the property to set in the target.
  10877. */
  10878. propertyPath: string;
  10879. /**
  10880. * The value to set in the property
  10881. */
  10882. value: any;
  10883. private _target;
  10884. private _effectiveTarget;
  10885. private _property;
  10886. /**
  10887. * Instantiate the action
  10888. * @param triggerOptions defines the trigger options
  10889. * @param target defines the object containing the property
  10890. * @param propertyPath defines the path of the property to set in the target
  10891. * @param value defines the value to set in the property
  10892. * @param condition defines the trigger related conditions
  10893. */
  10894. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10895. /** @hidden */
  10896. _prepare(): void;
  10897. /**
  10898. * Execute the action and set the targetted property to the desired value.
  10899. */
  10900. execute(): void;
  10901. /**
  10902. * Serializes the actions and its related information.
  10903. * @param parent defines the object to serialize in
  10904. * @returns the serialized object
  10905. */
  10906. serialize(parent: any): any;
  10907. }
  10908. /**
  10909. * This defines an action responsible to increment the target value
  10910. * to a desired value once triggered.
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10912. */
  10913. export class IncrementValueAction extends Action {
  10914. /**
  10915. * The path of the property to increment in the target.
  10916. */
  10917. propertyPath: string;
  10918. /**
  10919. * The value we should increment the property by.
  10920. */
  10921. value: any;
  10922. private _target;
  10923. private _effectiveTarget;
  10924. private _property;
  10925. /**
  10926. * Instantiate the action
  10927. * @param triggerOptions defines the trigger options
  10928. * @param target defines the object containing the property
  10929. * @param propertyPath defines the path of the property to increment in the target
  10930. * @param value defines the value value we should increment the property by
  10931. * @param condition defines the trigger related conditions
  10932. */
  10933. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10934. /** @hidden */
  10935. _prepare(): void;
  10936. /**
  10937. * Execute the action and increment the target of the value amount.
  10938. */
  10939. execute(): void;
  10940. /**
  10941. * Serializes the actions and its related information.
  10942. * @param parent defines the object to serialize in
  10943. * @returns the serialized object
  10944. */
  10945. serialize(parent: any): any;
  10946. }
  10947. /**
  10948. * This defines an action responsible to start an animation once triggered.
  10949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10950. */
  10951. export class PlayAnimationAction extends Action {
  10952. /**
  10953. * Where the animation should start (animation frame)
  10954. */
  10955. from: number;
  10956. /**
  10957. * Where the animation should stop (animation frame)
  10958. */
  10959. to: number;
  10960. /**
  10961. * Define if the animation should loop or stop after the first play.
  10962. */
  10963. loop?: boolean;
  10964. private _target;
  10965. /**
  10966. * Instantiate the action
  10967. * @param triggerOptions defines the trigger options
  10968. * @param target defines the target animation or animation name
  10969. * @param from defines from where the animation should start (animation frame)
  10970. * @param end defines where the animation should stop (animation frame)
  10971. * @param loop defines if the animation should loop or stop after the first play
  10972. * @param condition defines the trigger related conditions
  10973. */
  10974. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10975. /** @hidden */
  10976. _prepare(): void;
  10977. /**
  10978. * Execute the action and play the animation.
  10979. */
  10980. execute(): void;
  10981. /**
  10982. * Serializes the actions and its related information.
  10983. * @param parent defines the object to serialize in
  10984. * @returns the serialized object
  10985. */
  10986. serialize(parent: any): any;
  10987. }
  10988. /**
  10989. * This defines an action responsible to stop an animation once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class StopAnimationAction extends Action {
  10993. private _target;
  10994. /**
  10995. * Instantiate the action
  10996. * @param triggerOptions defines the trigger options
  10997. * @param target defines the target animation or animation name
  10998. * @param condition defines the trigger related conditions
  10999. */
  11000. constructor(triggerOptions: any, target: any, condition?: Condition);
  11001. /** @hidden */
  11002. _prepare(): void;
  11003. /**
  11004. * Execute the action and stop the animation.
  11005. */
  11006. execute(): void;
  11007. /**
  11008. * Serializes the actions and its related information.
  11009. * @param parent defines the object to serialize in
  11010. * @returns the serialized object
  11011. */
  11012. serialize(parent: any): any;
  11013. }
  11014. /**
  11015. * This defines an action responsible that does nothing once triggered.
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11017. */
  11018. export class DoNothingAction extends Action {
  11019. /**
  11020. * Instantiate the action
  11021. * @param triggerOptions defines the trigger options
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions?: any, condition?: Condition);
  11025. /**
  11026. * Execute the action and do nothing.
  11027. */
  11028. execute(): void;
  11029. /**
  11030. * Serializes the actions and its related information.
  11031. * @param parent defines the object to serialize in
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. }
  11036. /**
  11037. * This defines an action responsible to trigger several actions once triggered.
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11039. */
  11040. export class CombineAction extends Action {
  11041. /**
  11042. * The list of aggregated animations to run.
  11043. */
  11044. children: Action[];
  11045. /**
  11046. * Instantiate the action
  11047. * @param triggerOptions defines the trigger options
  11048. * @param children defines the list of aggregated animations to run
  11049. * @param condition defines the trigger related conditions
  11050. */
  11051. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11052. /** @hidden */
  11053. _prepare(): void;
  11054. /**
  11055. * Execute the action and executes all the aggregated actions.
  11056. */
  11057. execute(evt: ActionEvent): void;
  11058. /**
  11059. * Serializes the actions and its related information.
  11060. * @param parent defines the object to serialize in
  11061. * @returns the serialized object
  11062. */
  11063. serialize(parent: any): any;
  11064. }
  11065. /**
  11066. * This defines an action responsible to run code (external event) once triggered.
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11068. */
  11069. export class ExecuteCodeAction extends Action {
  11070. /**
  11071. * The callback function to run.
  11072. */
  11073. func: (evt: ActionEvent) => void;
  11074. /**
  11075. * Instantiate the action
  11076. * @param triggerOptions defines the trigger options
  11077. * @param func defines the callback function to run
  11078. * @param condition defines the trigger related conditions
  11079. */
  11080. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11081. /**
  11082. * Execute the action and run the attached code.
  11083. */
  11084. execute(evt: ActionEvent): void;
  11085. }
  11086. /**
  11087. * This defines an action responsible to set the parent property of the target once triggered.
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11089. */
  11090. export class SetParentAction extends Action {
  11091. private _parent;
  11092. private _target;
  11093. /**
  11094. * Instantiate the action
  11095. * @param triggerOptions defines the trigger options
  11096. * @param target defines the target containing the parent property
  11097. * @param parent defines from where the animation should start (animation frame)
  11098. * @param condition defines the trigger related conditions
  11099. */
  11100. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11101. /** @hidden */
  11102. _prepare(): void;
  11103. /**
  11104. * Execute the action and set the parent property.
  11105. */
  11106. execute(): void;
  11107. /**
  11108. * Serializes the actions and its related information.
  11109. * @param parent defines the object to serialize in
  11110. * @returns the serialized object
  11111. */
  11112. serialize(parent: any): any;
  11113. }
  11114. }
  11115. declare module "babylonjs/Actions/actionManager" {
  11116. import { Nullable } from "babylonjs/types";
  11117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11118. import { Scene } from "babylonjs/scene";
  11119. import { IAction } from "babylonjs/Actions/action";
  11120. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11121. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11122. /**
  11123. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11124. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11126. */
  11127. export class ActionManager extends AbstractActionManager {
  11128. /**
  11129. * Nothing
  11130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11131. */
  11132. static readonly NothingTrigger: number;
  11133. /**
  11134. * On pick
  11135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11136. */
  11137. static readonly OnPickTrigger: number;
  11138. /**
  11139. * On left pick
  11140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11141. */
  11142. static readonly OnLeftPickTrigger: number;
  11143. /**
  11144. * On right pick
  11145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11146. */
  11147. static readonly OnRightPickTrigger: number;
  11148. /**
  11149. * On center pick
  11150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11151. */
  11152. static readonly OnCenterPickTrigger: number;
  11153. /**
  11154. * On pick down
  11155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11156. */
  11157. static readonly OnPickDownTrigger: number;
  11158. /**
  11159. * On double pick
  11160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11161. */
  11162. static readonly OnDoublePickTrigger: number;
  11163. /**
  11164. * On pick up
  11165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11166. */
  11167. static readonly OnPickUpTrigger: number;
  11168. /**
  11169. * On pick out.
  11170. * This trigger will only be raised if you also declared a OnPickDown
  11171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11172. */
  11173. static readonly OnPickOutTrigger: number;
  11174. /**
  11175. * On long press
  11176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11177. */
  11178. static readonly OnLongPressTrigger: number;
  11179. /**
  11180. * On pointer over
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11182. */
  11183. static readonly OnPointerOverTrigger: number;
  11184. /**
  11185. * On pointer out
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly OnPointerOutTrigger: number;
  11189. /**
  11190. * On every frame
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnEveryFrameTrigger: number;
  11194. /**
  11195. * On intersection enter
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnIntersectionEnterTrigger: number;
  11199. /**
  11200. * On intersection exit
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnIntersectionExitTrigger: number;
  11204. /**
  11205. * On key down
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnKeyDownTrigger: number;
  11209. /**
  11210. * On key up
  11211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11212. */
  11213. static readonly OnKeyUpTrigger: number;
  11214. private _scene;
  11215. /**
  11216. * Creates a new action manager
  11217. * @param scene defines the hosting scene
  11218. */
  11219. constructor(scene: Scene);
  11220. /**
  11221. * Releases all associated resources
  11222. */
  11223. dispose(): void;
  11224. /**
  11225. * Gets hosting scene
  11226. * @returns the hosting scene
  11227. */
  11228. getScene(): Scene;
  11229. /**
  11230. * Does this action manager handles actions of any of the given triggers
  11231. * @param triggers defines the triggers to be tested
  11232. * @return a boolean indicating whether one (or more) of the triggers is handled
  11233. */
  11234. hasSpecificTriggers(triggers: number[]): boolean;
  11235. /**
  11236. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11237. * speed.
  11238. * @param triggerA defines the trigger to be tested
  11239. * @param triggerB defines the trigger to be tested
  11240. * @return a boolean indicating whether one (or more) of the triggers is handled
  11241. */
  11242. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11243. /**
  11244. * Does this action manager handles actions of a given trigger
  11245. * @param trigger defines the trigger to be tested
  11246. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11247. * @return whether the trigger is handled
  11248. */
  11249. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11250. /**
  11251. * Does this action manager has pointer triggers
  11252. */
  11253. get hasPointerTriggers(): boolean;
  11254. /**
  11255. * Does this action manager has pick triggers
  11256. */
  11257. get hasPickTriggers(): boolean;
  11258. /**
  11259. * Registers an action to this action manager
  11260. * @param action defines the action to be registered
  11261. * @return the action amended (prepared) after registration
  11262. */
  11263. registerAction(action: IAction): Nullable<IAction>;
  11264. /**
  11265. * Unregisters an action to this action manager
  11266. * @param action defines the action to be unregistered
  11267. * @return a boolean indicating whether the action has been unregistered
  11268. */
  11269. unregisterAction(action: IAction): Boolean;
  11270. /**
  11271. * Process a specific trigger
  11272. * @param trigger defines the trigger to process
  11273. * @param evt defines the event details to be processed
  11274. */
  11275. processTrigger(trigger: number, evt?: IActionEvent): void;
  11276. /** @hidden */
  11277. _getEffectiveTarget(target: any, propertyPath: string): any;
  11278. /** @hidden */
  11279. _getProperty(propertyPath: string): string;
  11280. /**
  11281. * Serialize this manager to a JSON object
  11282. * @param name defines the property name to store this manager
  11283. * @returns a JSON representation of this manager
  11284. */
  11285. serialize(name: string): any;
  11286. /**
  11287. * Creates a new ActionManager from a JSON data
  11288. * @param parsedActions defines the JSON data to read from
  11289. * @param object defines the hosting mesh
  11290. * @param scene defines the hosting scene
  11291. */
  11292. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11293. /**
  11294. * Get a trigger name by index
  11295. * @param trigger defines the trigger index
  11296. * @returns a trigger name
  11297. */
  11298. static GetTriggerName(trigger: number): string;
  11299. }
  11300. }
  11301. declare module "babylonjs/Culling/ray" {
  11302. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11303. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11305. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11306. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11307. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11308. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11309. import { Plane } from "babylonjs/Maths/math.plane";
  11310. /**
  11311. * Class representing a ray with position and direction
  11312. */
  11313. export class Ray {
  11314. /** origin point */
  11315. origin: Vector3;
  11316. /** direction */
  11317. direction: Vector3;
  11318. /** length of the ray */
  11319. length: number;
  11320. private static readonly TmpVector3;
  11321. private _tmpRay;
  11322. /**
  11323. * Creates a new ray
  11324. * @param origin origin point
  11325. * @param direction direction
  11326. * @param length length of the ray
  11327. */
  11328. constructor(
  11329. /** origin point */
  11330. origin: Vector3,
  11331. /** direction */
  11332. direction: Vector3,
  11333. /** length of the ray */
  11334. length?: number);
  11335. /**
  11336. * Checks if the ray intersects a box
  11337. * @param minimum bound of the box
  11338. * @param maximum bound of the box
  11339. * @param intersectionTreshold extra extend to be added to the box in all direction
  11340. * @returns if the box was hit
  11341. */
  11342. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11343. /**
  11344. * Checks if the ray intersects a box
  11345. * @param box the bounding box to check
  11346. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11347. * @returns if the box was hit
  11348. */
  11349. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11350. /**
  11351. * If the ray hits a sphere
  11352. * @param sphere the bounding sphere to check
  11353. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11354. * @returns true if it hits the sphere
  11355. */
  11356. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11357. /**
  11358. * If the ray hits a triange
  11359. * @param vertex0 triangle vertex
  11360. * @param vertex1 triangle vertex
  11361. * @param vertex2 triangle vertex
  11362. * @returns intersection information if hit
  11363. */
  11364. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11365. /**
  11366. * Checks if ray intersects a plane
  11367. * @param plane the plane to check
  11368. * @returns the distance away it was hit
  11369. */
  11370. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11371. /**
  11372. * Calculate the intercept of a ray on a given axis
  11373. * @param axis to check 'x' | 'y' | 'z'
  11374. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11375. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11376. */
  11377. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11378. /**
  11379. * Checks if ray intersects a mesh
  11380. * @param mesh the mesh to check
  11381. * @param fastCheck if only the bounding box should checked
  11382. * @returns picking info of the intersecton
  11383. */
  11384. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11385. /**
  11386. * Checks if ray intersects a mesh
  11387. * @param meshes the meshes to check
  11388. * @param fastCheck if only the bounding box should checked
  11389. * @param results array to store result in
  11390. * @returns Array of picking infos
  11391. */
  11392. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11393. private _comparePickingInfo;
  11394. private static smallnum;
  11395. private static rayl;
  11396. /**
  11397. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11398. * @param sega the first point of the segment to test the intersection against
  11399. * @param segb the second point of the segment to test the intersection against
  11400. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11401. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11402. */
  11403. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11404. /**
  11405. * Update the ray from viewport position
  11406. * @param x position
  11407. * @param y y position
  11408. * @param viewportWidth viewport width
  11409. * @param viewportHeight viewport height
  11410. * @param world world matrix
  11411. * @param view view matrix
  11412. * @param projection projection matrix
  11413. * @returns this ray updated
  11414. */
  11415. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11416. /**
  11417. * Creates a ray with origin and direction of 0,0,0
  11418. * @returns the new ray
  11419. */
  11420. static Zero(): Ray;
  11421. /**
  11422. * Creates a new ray from screen space and viewport
  11423. * @param x position
  11424. * @param y y position
  11425. * @param viewportWidth viewport width
  11426. * @param viewportHeight viewport height
  11427. * @param world world matrix
  11428. * @param view view matrix
  11429. * @param projection projection matrix
  11430. * @returns new ray
  11431. */
  11432. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11433. /**
  11434. * 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
  11435. * transformed to the given world matrix.
  11436. * @param origin The origin point
  11437. * @param end The end point
  11438. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11439. * @returns the new ray
  11440. */
  11441. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11442. /**
  11443. * Transforms a ray by a matrix
  11444. * @param ray ray to transform
  11445. * @param matrix matrix to apply
  11446. * @returns the resulting new ray
  11447. */
  11448. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11449. /**
  11450. * Transforms a ray by a matrix
  11451. * @param ray ray to transform
  11452. * @param matrix matrix to apply
  11453. * @param result ray to store result in
  11454. */
  11455. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11456. /**
  11457. * Unproject a ray from screen space to object space
  11458. * @param sourceX defines the screen space x coordinate to use
  11459. * @param sourceY defines the screen space y coordinate to use
  11460. * @param viewportWidth defines the current width of the viewport
  11461. * @param viewportHeight defines the current height of the viewport
  11462. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11463. * @param view defines the view matrix to use
  11464. * @param projection defines the projection matrix to use
  11465. */
  11466. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11467. }
  11468. /**
  11469. * Type used to define predicate used to select faces when a mesh intersection is detected
  11470. */
  11471. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11472. module "babylonjs/scene" {
  11473. interface Scene {
  11474. /** @hidden */
  11475. _tempPickingRay: Nullable<Ray>;
  11476. /** @hidden */
  11477. _cachedRayForTransform: Ray;
  11478. /** @hidden */
  11479. _pickWithRayInverseMatrix: Matrix;
  11480. /** @hidden */
  11481. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11482. /** @hidden */
  11483. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11484. }
  11485. }
  11486. }
  11487. declare module "babylonjs/sceneComponent" {
  11488. import { Scene } from "babylonjs/scene";
  11489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11491. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11492. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11493. import { Nullable } from "babylonjs/types";
  11494. import { Camera } from "babylonjs/Cameras/camera";
  11495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11496. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11497. import { AbstractScene } from "babylonjs/abstractScene";
  11498. import { Mesh } from "babylonjs/Meshes/mesh";
  11499. /**
  11500. * Groups all the scene component constants in one place to ease maintenance.
  11501. * @hidden
  11502. */
  11503. export class SceneComponentConstants {
  11504. static readonly NAME_EFFECTLAYER: string;
  11505. static readonly NAME_LAYER: string;
  11506. static readonly NAME_LENSFLARESYSTEM: string;
  11507. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11508. static readonly NAME_PARTICLESYSTEM: string;
  11509. static readonly NAME_GAMEPAD: string;
  11510. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11511. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11512. static readonly NAME_DEPTHRENDERER: string;
  11513. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11514. static readonly NAME_SPRITE: string;
  11515. static readonly NAME_OUTLINERENDERER: string;
  11516. static readonly NAME_PROCEDURALTEXTURE: string;
  11517. static readonly NAME_SHADOWGENERATOR: string;
  11518. static readonly NAME_OCTREE: string;
  11519. static readonly NAME_PHYSICSENGINE: string;
  11520. static readonly NAME_AUDIO: string;
  11521. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11522. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11523. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11524. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11525. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11526. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11527. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11528. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11529. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11530. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11531. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11532. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11533. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11534. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11535. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11536. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11537. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11538. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11539. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11540. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11541. static readonly STEP_AFTERRENDER_AUDIO: number;
  11542. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11543. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11544. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11545. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11546. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11547. static readonly STEP_POINTERMOVE_SPRITE: number;
  11548. static readonly STEP_POINTERDOWN_SPRITE: number;
  11549. static readonly STEP_POINTERUP_SPRITE: number;
  11550. }
  11551. /**
  11552. * This represents a scene component.
  11553. *
  11554. * This is used to decouple the dependency the scene is having on the different workloads like
  11555. * layers, post processes...
  11556. */
  11557. export interface ISceneComponent {
  11558. /**
  11559. * The name of the component. Each component must have a unique name.
  11560. */
  11561. name: string;
  11562. /**
  11563. * The scene the component belongs to.
  11564. */
  11565. scene: Scene;
  11566. /**
  11567. * Register the component to one instance of a scene.
  11568. */
  11569. register(): void;
  11570. /**
  11571. * Rebuilds the elements related to this component in case of
  11572. * context lost for instance.
  11573. */
  11574. rebuild(): void;
  11575. /**
  11576. * Disposes the component and the associated ressources.
  11577. */
  11578. dispose(): void;
  11579. }
  11580. /**
  11581. * This represents a SERIALIZABLE scene component.
  11582. *
  11583. * This extends Scene Component to add Serialization methods on top.
  11584. */
  11585. export interface ISceneSerializableComponent extends ISceneComponent {
  11586. /**
  11587. * Adds all the elements from the container to the scene
  11588. * @param container the container holding the elements
  11589. */
  11590. addFromContainer(container: AbstractScene): void;
  11591. /**
  11592. * Removes all the elements in the container from the scene
  11593. * @param container contains the elements to remove
  11594. * @param dispose if the removed element should be disposed (default: false)
  11595. */
  11596. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11597. /**
  11598. * Serializes the component data to the specified json object
  11599. * @param serializationObject The object to serialize to
  11600. */
  11601. serialize(serializationObject: any): void;
  11602. }
  11603. /**
  11604. * Strong typing of a Mesh related stage step action
  11605. */
  11606. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11607. /**
  11608. * Strong typing of a Evaluate Sub Mesh related stage step action
  11609. */
  11610. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11611. /**
  11612. * Strong typing of a Active Mesh related stage step action
  11613. */
  11614. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11615. /**
  11616. * Strong typing of a Camera related stage step action
  11617. */
  11618. export type CameraStageAction = (camera: Camera) => void;
  11619. /**
  11620. * Strong typing of a Camera Frame buffer related stage step action
  11621. */
  11622. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11623. /**
  11624. * Strong typing of a Render Target related stage step action
  11625. */
  11626. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11627. /**
  11628. * Strong typing of a RenderingGroup related stage step action
  11629. */
  11630. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11631. /**
  11632. * Strong typing of a Mesh Render related stage step action
  11633. */
  11634. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11635. /**
  11636. * Strong typing of a simple stage step action
  11637. */
  11638. export type SimpleStageAction = () => void;
  11639. /**
  11640. * Strong typing of a render target action.
  11641. */
  11642. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11643. /**
  11644. * Strong typing of a pointer move action.
  11645. */
  11646. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11647. /**
  11648. * Strong typing of a pointer up/down action.
  11649. */
  11650. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11651. /**
  11652. * Representation of a stage in the scene (Basically a list of ordered steps)
  11653. * @hidden
  11654. */
  11655. export class Stage<T extends Function> extends Array<{
  11656. index: number;
  11657. component: ISceneComponent;
  11658. action: T;
  11659. }> {
  11660. /**
  11661. * Hide ctor from the rest of the world.
  11662. * @param items The items to add.
  11663. */
  11664. private constructor();
  11665. /**
  11666. * Creates a new Stage.
  11667. * @returns A new instance of a Stage
  11668. */
  11669. static Create<T extends Function>(): Stage<T>;
  11670. /**
  11671. * Registers a step in an ordered way in the targeted stage.
  11672. * @param index Defines the position to register the step in
  11673. * @param component Defines the component attached to the step
  11674. * @param action Defines the action to launch during the step
  11675. */
  11676. registerStep(index: number, component: ISceneComponent, action: T): void;
  11677. /**
  11678. * Clears all the steps from the stage.
  11679. */
  11680. clear(): void;
  11681. }
  11682. }
  11683. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11684. import { Nullable } from "babylonjs/types";
  11685. import { Observable } from "babylonjs/Misc/observable";
  11686. import { Scene } from "babylonjs/scene";
  11687. import { Sprite } from "babylonjs/Sprites/sprite";
  11688. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11689. import { Ray } from "babylonjs/Culling/ray";
  11690. import { Camera } from "babylonjs/Cameras/camera";
  11691. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11692. import { ISceneComponent } from "babylonjs/sceneComponent";
  11693. module "babylonjs/scene" {
  11694. interface Scene {
  11695. /** @hidden */
  11696. _pointerOverSprite: Nullable<Sprite>;
  11697. /** @hidden */
  11698. _pickedDownSprite: Nullable<Sprite>;
  11699. /** @hidden */
  11700. _tempSpritePickingRay: Nullable<Ray>;
  11701. /**
  11702. * All of the sprite managers added to this scene
  11703. * @see http://doc.babylonjs.com/babylon101/sprites
  11704. */
  11705. spriteManagers: Array<ISpriteManager>;
  11706. /**
  11707. * An event triggered when sprites rendering is about to start
  11708. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11709. */
  11710. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11711. /**
  11712. * An event triggered when sprites rendering is done
  11713. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11714. */
  11715. onAfterSpritesRenderingObservable: Observable<Scene>;
  11716. /** @hidden */
  11717. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11718. /** Launch a ray to try to pick a sprite in the scene
  11719. * @param x position on screen
  11720. * @param y position on screen
  11721. * @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
  11722. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11723. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11724. * @returns a PickingInfo
  11725. */
  11726. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11727. /** Use the given ray to pick a sprite in the scene
  11728. * @param ray The ray (in world space) to use to pick meshes
  11729. * @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
  11730. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11731. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11732. * @returns a PickingInfo
  11733. */
  11734. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11735. /** @hidden */
  11736. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11737. /** Launch a ray to try to pick sprites in the scene
  11738. * @param x position on screen
  11739. * @param y position on screen
  11740. * @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
  11741. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11742. * @returns a PickingInfo array
  11743. */
  11744. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11745. /** Use the given ray to pick sprites in the scene
  11746. * @param ray The ray (in world space) to use to pick meshes
  11747. * @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
  11748. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11749. * @returns a PickingInfo array
  11750. */
  11751. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11752. /**
  11753. * Force the sprite under the pointer
  11754. * @param sprite defines the sprite to use
  11755. */
  11756. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11757. /**
  11758. * Gets the sprite under the pointer
  11759. * @returns a Sprite or null if no sprite is under the pointer
  11760. */
  11761. getPointerOverSprite(): Nullable<Sprite>;
  11762. }
  11763. }
  11764. /**
  11765. * Defines the sprite scene component responsible to manage sprites
  11766. * in a given scene.
  11767. */
  11768. export class SpriteSceneComponent implements ISceneComponent {
  11769. /**
  11770. * The component name helpfull to identify the component in the list of scene components.
  11771. */
  11772. readonly name: string;
  11773. /**
  11774. * The scene the component belongs to.
  11775. */
  11776. scene: Scene;
  11777. /** @hidden */
  11778. private _spritePredicate;
  11779. /**
  11780. * Creates a new instance of the component for the given scene
  11781. * @param scene Defines the scene to register the component in
  11782. */
  11783. constructor(scene: Scene);
  11784. /**
  11785. * Registers the component in a given scene
  11786. */
  11787. register(): void;
  11788. /**
  11789. * Rebuilds the elements related to this component in case of
  11790. * context lost for instance.
  11791. */
  11792. rebuild(): void;
  11793. /**
  11794. * Disposes the component and the associated ressources.
  11795. */
  11796. dispose(): void;
  11797. private _pickSpriteButKeepRay;
  11798. private _pointerMove;
  11799. private _pointerDown;
  11800. private _pointerUp;
  11801. }
  11802. }
  11803. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11804. /** @hidden */
  11805. export var fogFragmentDeclaration: {
  11806. name: string;
  11807. shader: string;
  11808. };
  11809. }
  11810. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11811. /** @hidden */
  11812. export var fogFragment: {
  11813. name: string;
  11814. shader: string;
  11815. };
  11816. }
  11817. declare module "babylonjs/Shaders/sprites.fragment" {
  11818. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11819. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11820. /** @hidden */
  11821. export var spritesPixelShader: {
  11822. name: string;
  11823. shader: string;
  11824. };
  11825. }
  11826. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11827. /** @hidden */
  11828. export var fogVertexDeclaration: {
  11829. name: string;
  11830. shader: string;
  11831. };
  11832. }
  11833. declare module "babylonjs/Shaders/sprites.vertex" {
  11834. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11835. /** @hidden */
  11836. export var spritesVertexShader: {
  11837. name: string;
  11838. shader: string;
  11839. };
  11840. }
  11841. declare module "babylonjs/Sprites/spriteManager" {
  11842. import { IDisposable, Scene } from "babylonjs/scene";
  11843. import { Nullable } from "babylonjs/types";
  11844. import { Observable } from "babylonjs/Misc/observable";
  11845. import { Sprite } from "babylonjs/Sprites/sprite";
  11846. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11847. import { Camera } from "babylonjs/Cameras/camera";
  11848. import { Texture } from "babylonjs/Materials/Textures/texture";
  11849. import "babylonjs/Shaders/sprites.fragment";
  11850. import "babylonjs/Shaders/sprites.vertex";
  11851. import { Ray } from "babylonjs/Culling/ray";
  11852. /**
  11853. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11854. */
  11855. export interface ISpriteManager extends IDisposable {
  11856. /**
  11857. * Restricts the camera to viewing objects with the same layerMask.
  11858. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11859. */
  11860. layerMask: number;
  11861. /**
  11862. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11863. */
  11864. isPickable: boolean;
  11865. /**
  11866. * Specifies the rendering group id for this mesh (0 by default)
  11867. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11868. */
  11869. renderingGroupId: number;
  11870. /**
  11871. * Defines the list of sprites managed by the manager.
  11872. */
  11873. sprites: Array<Sprite>;
  11874. /**
  11875. * Tests the intersection of a sprite with a specific ray.
  11876. * @param ray The ray we are sending to test the collision
  11877. * @param camera The camera space we are sending rays in
  11878. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11879. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11880. * @returns picking info or null.
  11881. */
  11882. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11883. /**
  11884. * Intersects the sprites with a ray
  11885. * @param ray defines the ray to intersect with
  11886. * @param camera defines the current active camera
  11887. * @param predicate defines a predicate used to select candidate sprites
  11888. * @returns null if no hit or a PickingInfo array
  11889. */
  11890. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11891. /**
  11892. * Renders the list of sprites on screen.
  11893. */
  11894. render(): void;
  11895. }
  11896. /**
  11897. * Class used to manage multiple sprites on the same spritesheet
  11898. * @see http://doc.babylonjs.com/babylon101/sprites
  11899. */
  11900. export class SpriteManager implements ISpriteManager {
  11901. /** defines the manager's name */
  11902. name: string;
  11903. /** Gets the list of sprites */
  11904. sprites: Sprite[];
  11905. /** Gets or sets the rendering group id (0 by default) */
  11906. renderingGroupId: number;
  11907. /** Gets or sets camera layer mask */
  11908. layerMask: number;
  11909. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11910. fogEnabled: boolean;
  11911. /** Gets or sets a boolean indicating if the sprites are pickable */
  11912. isPickable: boolean;
  11913. /** Defines the default width of a cell in the spritesheet */
  11914. cellWidth: number;
  11915. /** Defines the default height of a cell in the spritesheet */
  11916. cellHeight: number;
  11917. /** Associative array from JSON sprite data file */
  11918. private _cellData;
  11919. /** Array of sprite names from JSON sprite data file */
  11920. private _spriteMap;
  11921. /** True when packed cell data from JSON file is ready*/
  11922. private _packedAndReady;
  11923. /**
  11924. * An event triggered when the manager is disposed.
  11925. */
  11926. onDisposeObservable: Observable<SpriteManager>;
  11927. private _onDisposeObserver;
  11928. /**
  11929. * Callback called when the manager is disposed
  11930. */
  11931. set onDispose(callback: () => void);
  11932. private _capacity;
  11933. private _fromPacked;
  11934. private _spriteTexture;
  11935. private _epsilon;
  11936. private _scene;
  11937. private _vertexData;
  11938. private _buffer;
  11939. private _vertexBuffers;
  11940. private _indexBuffer;
  11941. private _effectBase;
  11942. private _effectFog;
  11943. /**
  11944. * Gets or sets the spritesheet texture
  11945. */
  11946. get texture(): Texture;
  11947. set texture(value: Texture);
  11948. /**
  11949. * Creates a new sprite manager
  11950. * @param name defines the manager's name
  11951. * @param imgUrl defines the sprite sheet url
  11952. * @param capacity defines the maximum allowed number of sprites
  11953. * @param cellSize defines the size of a sprite cell
  11954. * @param scene defines the hosting scene
  11955. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11956. * @param samplingMode defines the smapling mode to use with spritesheet
  11957. * @param fromPacked set to false; do not alter
  11958. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11959. */
  11960. constructor(
  11961. /** defines the manager's name */
  11962. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11963. private _makePacked;
  11964. private _appendSpriteVertex;
  11965. /**
  11966. * Intersects the sprites with a ray
  11967. * @param ray defines the ray to intersect with
  11968. * @param camera defines the current active camera
  11969. * @param predicate defines a predicate used to select candidate sprites
  11970. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11971. * @returns null if no hit or a PickingInfo
  11972. */
  11973. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11974. /**
  11975. * Intersects the sprites with a ray
  11976. * @param ray defines the ray to intersect with
  11977. * @param camera defines the current active camera
  11978. * @param predicate defines a predicate used to select candidate sprites
  11979. * @returns null if no hit or a PickingInfo array
  11980. */
  11981. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11982. /**
  11983. * Render all child sprites
  11984. */
  11985. render(): void;
  11986. /**
  11987. * Release associated resources
  11988. */
  11989. dispose(): void;
  11990. }
  11991. }
  11992. declare module "babylonjs/Sprites/sprite" {
  11993. import { Vector3 } from "babylonjs/Maths/math.vector";
  11994. import { Nullable } from "babylonjs/types";
  11995. import { ActionManager } from "babylonjs/Actions/actionManager";
  11996. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11997. import { Color4 } from "babylonjs/Maths/math.color";
  11998. /**
  11999. * Class used to represent a sprite
  12000. * @see http://doc.babylonjs.com/babylon101/sprites
  12001. */
  12002. export class Sprite {
  12003. /** defines the name */
  12004. name: string;
  12005. /** Gets or sets the current world position */
  12006. position: Vector3;
  12007. /** Gets or sets the main color */
  12008. color: Color4;
  12009. /** Gets or sets the width */
  12010. width: number;
  12011. /** Gets or sets the height */
  12012. height: number;
  12013. /** Gets or sets rotation angle */
  12014. angle: number;
  12015. /** Gets or sets the cell index in the sprite sheet */
  12016. cellIndex: number;
  12017. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12018. cellRef: string;
  12019. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12020. invertU: number;
  12021. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12022. invertV: number;
  12023. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12024. disposeWhenFinishedAnimating: boolean;
  12025. /** Gets the list of attached animations */
  12026. animations: Animation[];
  12027. /** Gets or sets a boolean indicating if the sprite can be picked */
  12028. isPickable: boolean;
  12029. /**
  12030. * Gets or sets the associated action manager
  12031. */
  12032. actionManager: Nullable<ActionManager>;
  12033. private _animationStarted;
  12034. private _loopAnimation;
  12035. private _fromIndex;
  12036. private _toIndex;
  12037. private _delay;
  12038. private _direction;
  12039. private _manager;
  12040. private _time;
  12041. private _onAnimationEnd;
  12042. /**
  12043. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12044. */
  12045. isVisible: boolean;
  12046. /**
  12047. * Gets or sets the sprite size
  12048. */
  12049. get size(): number;
  12050. set size(value: number);
  12051. /**
  12052. * Creates a new Sprite
  12053. * @param name defines the name
  12054. * @param manager defines the manager
  12055. */
  12056. constructor(
  12057. /** defines the name */
  12058. name: string, manager: ISpriteManager);
  12059. /**
  12060. * Starts an animation
  12061. * @param from defines the initial key
  12062. * @param to defines the end key
  12063. * @param loop defines if the animation must loop
  12064. * @param delay defines the start delay (in ms)
  12065. * @param onAnimationEnd defines a callback to call when animation ends
  12066. */
  12067. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12068. /** Stops current animation (if any) */
  12069. stopAnimation(): void;
  12070. /** @hidden */
  12071. _animate(deltaTime: number): void;
  12072. /** Release associated resources */
  12073. dispose(): void;
  12074. }
  12075. }
  12076. declare module "babylonjs/Collisions/pickingInfo" {
  12077. import { Nullable } from "babylonjs/types";
  12078. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12080. import { Sprite } from "babylonjs/Sprites/sprite";
  12081. import { Ray } from "babylonjs/Culling/ray";
  12082. /**
  12083. * Information about the result of picking within a scene
  12084. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12085. */
  12086. export class PickingInfo {
  12087. /** @hidden */
  12088. _pickingUnavailable: boolean;
  12089. /**
  12090. * If the pick collided with an object
  12091. */
  12092. hit: boolean;
  12093. /**
  12094. * Distance away where the pick collided
  12095. */
  12096. distance: number;
  12097. /**
  12098. * The location of pick collision
  12099. */
  12100. pickedPoint: Nullable<Vector3>;
  12101. /**
  12102. * The mesh corresponding the the pick collision
  12103. */
  12104. pickedMesh: Nullable<AbstractMesh>;
  12105. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12106. bu: number;
  12107. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12108. bv: number;
  12109. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12110. faceId: number;
  12111. /** Id of the the submesh that was picked */
  12112. subMeshId: number;
  12113. /** If a sprite was picked, this will be the sprite the pick collided with */
  12114. pickedSprite: Nullable<Sprite>;
  12115. /**
  12116. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12117. */
  12118. originMesh: Nullable<AbstractMesh>;
  12119. /**
  12120. * The ray that was used to perform the picking.
  12121. */
  12122. ray: Nullable<Ray>;
  12123. /**
  12124. * Gets the normal correspodning to the face the pick collided with
  12125. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12126. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12127. * @returns The normal correspodning to the face the pick collided with
  12128. */
  12129. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12130. /**
  12131. * Gets the texture coordinates of where the pick occured
  12132. * @returns the vector containing the coordnates of the texture
  12133. */
  12134. getTextureCoordinates(): Nullable<Vector2>;
  12135. }
  12136. }
  12137. declare module "babylonjs/Events/pointerEvents" {
  12138. import { Nullable } from "babylonjs/types";
  12139. import { Vector2 } from "babylonjs/Maths/math.vector";
  12140. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12141. import { Ray } from "babylonjs/Culling/ray";
  12142. /**
  12143. * Gather the list of pointer event types as constants.
  12144. */
  12145. export class PointerEventTypes {
  12146. /**
  12147. * 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.
  12148. */
  12149. static readonly POINTERDOWN: number;
  12150. /**
  12151. * The pointerup event is fired when a pointer is no longer active.
  12152. */
  12153. static readonly POINTERUP: number;
  12154. /**
  12155. * The pointermove event is fired when a pointer changes coordinates.
  12156. */
  12157. static readonly POINTERMOVE: number;
  12158. /**
  12159. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12160. */
  12161. static readonly POINTERWHEEL: number;
  12162. /**
  12163. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12164. */
  12165. static readonly POINTERPICK: number;
  12166. /**
  12167. * The pointertap event is fired when a the object has been touched and released without drag.
  12168. */
  12169. static readonly POINTERTAP: number;
  12170. /**
  12171. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12172. */
  12173. static readonly POINTERDOUBLETAP: number;
  12174. }
  12175. /**
  12176. * Base class of pointer info types.
  12177. */
  12178. export class PointerInfoBase {
  12179. /**
  12180. * Defines the type of event (PointerEventTypes)
  12181. */
  12182. type: number;
  12183. /**
  12184. * Defines the related dom event
  12185. */
  12186. event: PointerEvent | MouseWheelEvent;
  12187. /**
  12188. * Instantiates the base class of pointers info.
  12189. * @param type Defines the type of event (PointerEventTypes)
  12190. * @param event Defines the related dom event
  12191. */
  12192. constructor(
  12193. /**
  12194. * Defines the type of event (PointerEventTypes)
  12195. */
  12196. type: number,
  12197. /**
  12198. * Defines the related dom event
  12199. */
  12200. event: PointerEvent | MouseWheelEvent);
  12201. }
  12202. /**
  12203. * This class is used to store pointer related info for the onPrePointerObservable event.
  12204. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12205. */
  12206. export class PointerInfoPre extends PointerInfoBase {
  12207. /**
  12208. * Ray from a pointer if availible (eg. 6dof controller)
  12209. */
  12210. ray: Nullable<Ray>;
  12211. /**
  12212. * Defines the local position of the pointer on the canvas.
  12213. */
  12214. localPosition: Vector2;
  12215. /**
  12216. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12217. */
  12218. skipOnPointerObservable: boolean;
  12219. /**
  12220. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12221. * @param type Defines the type of event (PointerEventTypes)
  12222. * @param event Defines the related dom event
  12223. * @param localX Defines the local x coordinates of the pointer when the event occured
  12224. * @param localY Defines the local y coordinates of the pointer when the event occured
  12225. */
  12226. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12227. }
  12228. /**
  12229. * This type contains all the data related to a pointer event in Babylon.js.
  12230. * 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.
  12231. */
  12232. export class PointerInfo extends PointerInfoBase {
  12233. /**
  12234. * Defines the picking info associated to the info (if any)\
  12235. */
  12236. pickInfo: Nullable<PickingInfo>;
  12237. /**
  12238. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12239. * @param type Defines the type of event (PointerEventTypes)
  12240. * @param event Defines the related dom event
  12241. * @param pickInfo Defines the picking info associated to the info (if any)\
  12242. */
  12243. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12244. /**
  12245. * Defines the picking info associated to the info (if any)\
  12246. */
  12247. pickInfo: Nullable<PickingInfo>);
  12248. }
  12249. /**
  12250. * Data relating to a touch event on the screen.
  12251. */
  12252. export interface PointerTouch {
  12253. /**
  12254. * X coordinate of touch.
  12255. */
  12256. x: number;
  12257. /**
  12258. * Y coordinate of touch.
  12259. */
  12260. y: number;
  12261. /**
  12262. * Id of touch. Unique for each finger.
  12263. */
  12264. pointerId: number;
  12265. /**
  12266. * Event type passed from DOM.
  12267. */
  12268. type: any;
  12269. }
  12270. }
  12271. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12272. import { Observable } from "babylonjs/Misc/observable";
  12273. import { Nullable } from "babylonjs/types";
  12274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12276. /**
  12277. * Manage the mouse inputs to control the movement of a free camera.
  12278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12279. */
  12280. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12281. /**
  12282. * Define if touch is enabled in the mouse input
  12283. */
  12284. touchEnabled: boolean;
  12285. /**
  12286. * Defines the camera the input is attached to.
  12287. */
  12288. camera: FreeCamera;
  12289. /**
  12290. * Defines the buttons associated with the input to handle camera move.
  12291. */
  12292. buttons: number[];
  12293. /**
  12294. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12295. */
  12296. angularSensibility: number;
  12297. private _pointerInput;
  12298. private _onMouseMove;
  12299. private _observer;
  12300. private previousPosition;
  12301. /**
  12302. * Observable for when a pointer move event occurs containing the move offset
  12303. */
  12304. onPointerMovedObservable: Observable<{
  12305. offsetX: number;
  12306. offsetY: number;
  12307. }>;
  12308. /**
  12309. * @hidden
  12310. * If the camera should be rotated automatically based on pointer movement
  12311. */
  12312. _allowCameraRotation: boolean;
  12313. /**
  12314. * Manage the mouse inputs to control the movement of a free camera.
  12315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12316. * @param touchEnabled Defines if touch is enabled or not
  12317. */
  12318. constructor(
  12319. /**
  12320. * Define if touch is enabled in the mouse input
  12321. */
  12322. touchEnabled?: boolean);
  12323. /**
  12324. * Attach the input controls to a specific dom element to get the input from.
  12325. * @param element Defines the element the controls should be listened from
  12326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12327. */
  12328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12329. /**
  12330. * Called on JS contextmenu event.
  12331. * Override this method to provide functionality.
  12332. */
  12333. protected onContextMenu(evt: PointerEvent): void;
  12334. /**
  12335. * Detach the current controls from the specified dom element.
  12336. * @param element Defines the element to stop listening the inputs from
  12337. */
  12338. detachControl(element: Nullable<HTMLElement>): void;
  12339. /**
  12340. * Gets the class name of the current intput.
  12341. * @returns the class name
  12342. */
  12343. getClassName(): string;
  12344. /**
  12345. * Get the friendly name associated with the input class.
  12346. * @returns the input friendly name
  12347. */
  12348. getSimpleName(): string;
  12349. }
  12350. }
  12351. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12352. import { Nullable } from "babylonjs/types";
  12353. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12354. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12355. /**
  12356. * Manage the touch inputs to control the movement of a free camera.
  12357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12358. */
  12359. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12360. /**
  12361. * Defines the camera the input is attached to.
  12362. */
  12363. camera: FreeCamera;
  12364. /**
  12365. * Defines the touch sensibility for rotation.
  12366. * The higher the faster.
  12367. */
  12368. touchAngularSensibility: number;
  12369. /**
  12370. * Defines the touch sensibility for move.
  12371. * The higher the faster.
  12372. */
  12373. touchMoveSensibility: number;
  12374. private _offsetX;
  12375. private _offsetY;
  12376. private _pointerPressed;
  12377. private _pointerInput;
  12378. private _observer;
  12379. private _onLostFocus;
  12380. /**
  12381. * Attach the input controls to a specific dom element to get the input from.
  12382. * @param element Defines the element the controls should be listened from
  12383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12384. */
  12385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12386. /**
  12387. * Detach the current controls from the specified dom element.
  12388. * @param element Defines the element to stop listening the inputs from
  12389. */
  12390. detachControl(element: Nullable<HTMLElement>): void;
  12391. /**
  12392. * Update the current camera state depending on the inputs that have been used this frame.
  12393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12394. */
  12395. checkInputs(): void;
  12396. /**
  12397. * Gets the class name of the current intput.
  12398. * @returns the class name
  12399. */
  12400. getClassName(): string;
  12401. /**
  12402. * Get the friendly name associated with the input class.
  12403. * @returns the input friendly name
  12404. */
  12405. getSimpleName(): string;
  12406. }
  12407. }
  12408. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12409. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12410. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12411. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12412. import { Nullable } from "babylonjs/types";
  12413. /**
  12414. * Default Inputs manager for the FreeCamera.
  12415. * It groups all the default supported inputs for ease of use.
  12416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12417. */
  12418. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12419. /**
  12420. * @hidden
  12421. */
  12422. _mouseInput: Nullable<FreeCameraMouseInput>;
  12423. /**
  12424. * Instantiates a new FreeCameraInputsManager.
  12425. * @param camera Defines the camera the inputs belong to
  12426. */
  12427. constructor(camera: FreeCamera);
  12428. /**
  12429. * Add keyboard input support to the input manager.
  12430. * @returns the current input manager
  12431. */
  12432. addKeyboard(): FreeCameraInputsManager;
  12433. /**
  12434. * Add mouse input support to the input manager.
  12435. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12436. * @returns the current input manager
  12437. */
  12438. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12439. /**
  12440. * Removes the mouse input support from the manager
  12441. * @returns the current input manager
  12442. */
  12443. removeMouse(): FreeCameraInputsManager;
  12444. /**
  12445. * Add touch input support to the input manager.
  12446. * @returns the current input manager
  12447. */
  12448. addTouch(): FreeCameraInputsManager;
  12449. /**
  12450. * Remove all attached input methods from a camera
  12451. */
  12452. clear(): void;
  12453. }
  12454. }
  12455. declare module "babylonjs/Cameras/freeCamera" {
  12456. import { Vector3 } from "babylonjs/Maths/math.vector";
  12457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12458. import { Scene } from "babylonjs/scene";
  12459. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12460. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12461. /**
  12462. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12463. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12464. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12465. */
  12466. export class FreeCamera extends TargetCamera {
  12467. /**
  12468. * Define the collision ellipsoid of the camera.
  12469. * This is helpful to simulate a camera body like the player body around the camera
  12470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12471. */
  12472. ellipsoid: Vector3;
  12473. /**
  12474. * Define an offset for the position of the ellipsoid around the camera.
  12475. * This can be helpful to determine the center of the body near the gravity center of the body
  12476. * instead of its head.
  12477. */
  12478. ellipsoidOffset: Vector3;
  12479. /**
  12480. * Enable or disable collisions of the camera with the rest of the scene objects.
  12481. */
  12482. checkCollisions: boolean;
  12483. /**
  12484. * Enable or disable gravity on the camera.
  12485. */
  12486. applyGravity: boolean;
  12487. /**
  12488. * Define the input manager associated to the camera.
  12489. */
  12490. inputs: FreeCameraInputsManager;
  12491. /**
  12492. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12493. * Higher values reduce sensitivity.
  12494. */
  12495. get angularSensibility(): number;
  12496. /**
  12497. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12498. * Higher values reduce sensitivity.
  12499. */
  12500. set angularSensibility(value: number);
  12501. /**
  12502. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12503. */
  12504. get keysUp(): number[];
  12505. set keysUp(value: number[]);
  12506. /**
  12507. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12508. */
  12509. get keysDown(): number[];
  12510. set keysDown(value: number[]);
  12511. /**
  12512. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12513. */
  12514. get keysLeft(): number[];
  12515. set keysLeft(value: number[]);
  12516. /**
  12517. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12518. */
  12519. get keysRight(): number[];
  12520. set keysRight(value: number[]);
  12521. /**
  12522. * Event raised when the camera collide with a mesh in the scene.
  12523. */
  12524. onCollide: (collidedMesh: AbstractMesh) => void;
  12525. private _collider;
  12526. private _needMoveForGravity;
  12527. private _oldPosition;
  12528. private _diffPosition;
  12529. private _newPosition;
  12530. /** @hidden */
  12531. _localDirection: Vector3;
  12532. /** @hidden */
  12533. _transformedDirection: Vector3;
  12534. /**
  12535. * Instantiates a Free Camera.
  12536. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12537. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12538. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12539. * @param name Define the name of the camera in the scene
  12540. * @param position Define the start position of the camera in the scene
  12541. * @param scene Define the scene the camera belongs to
  12542. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12543. */
  12544. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12545. /**
  12546. * Attached controls to the current camera.
  12547. * @param element Defines the element the controls should be listened from
  12548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12549. */
  12550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12551. /**
  12552. * Detach the current controls from the camera.
  12553. * The camera will stop reacting to inputs.
  12554. * @param element Defines the element to stop listening the inputs from
  12555. */
  12556. detachControl(element: HTMLElement): void;
  12557. private _collisionMask;
  12558. /**
  12559. * Define a collision mask to limit the list of object the camera can collide with
  12560. */
  12561. get collisionMask(): number;
  12562. set collisionMask(mask: number);
  12563. /** @hidden */
  12564. _collideWithWorld(displacement: Vector3): void;
  12565. private _onCollisionPositionChange;
  12566. /** @hidden */
  12567. _checkInputs(): void;
  12568. /** @hidden */
  12569. _decideIfNeedsToMove(): boolean;
  12570. /** @hidden */
  12571. _updatePosition(): void;
  12572. /**
  12573. * Destroy the camera and release the current resources hold by it.
  12574. */
  12575. dispose(): void;
  12576. /**
  12577. * Gets the current object class name.
  12578. * @return the class name
  12579. */
  12580. getClassName(): string;
  12581. }
  12582. }
  12583. declare module "babylonjs/Gamepads/gamepad" {
  12584. import { Observable } from "babylonjs/Misc/observable";
  12585. /**
  12586. * Represents a gamepad control stick position
  12587. */
  12588. export class StickValues {
  12589. /**
  12590. * The x component of the control stick
  12591. */
  12592. x: number;
  12593. /**
  12594. * The y component of the control stick
  12595. */
  12596. y: number;
  12597. /**
  12598. * Initializes the gamepad x and y control stick values
  12599. * @param x The x component of the gamepad control stick value
  12600. * @param y The y component of the gamepad control stick value
  12601. */
  12602. constructor(
  12603. /**
  12604. * The x component of the control stick
  12605. */
  12606. x: number,
  12607. /**
  12608. * The y component of the control stick
  12609. */
  12610. y: number);
  12611. }
  12612. /**
  12613. * An interface which manages callbacks for gamepad button changes
  12614. */
  12615. export interface GamepadButtonChanges {
  12616. /**
  12617. * Called when a gamepad has been changed
  12618. */
  12619. changed: boolean;
  12620. /**
  12621. * Called when a gamepad press event has been triggered
  12622. */
  12623. pressChanged: boolean;
  12624. /**
  12625. * Called when a touch event has been triggered
  12626. */
  12627. touchChanged: boolean;
  12628. /**
  12629. * Called when a value has changed
  12630. */
  12631. valueChanged: boolean;
  12632. }
  12633. /**
  12634. * Represents a gamepad
  12635. */
  12636. export class Gamepad {
  12637. /**
  12638. * The id of the gamepad
  12639. */
  12640. id: string;
  12641. /**
  12642. * The index of the gamepad
  12643. */
  12644. index: number;
  12645. /**
  12646. * The browser gamepad
  12647. */
  12648. browserGamepad: any;
  12649. /**
  12650. * Specifies what type of gamepad this represents
  12651. */
  12652. type: number;
  12653. private _leftStick;
  12654. private _rightStick;
  12655. /** @hidden */
  12656. _isConnected: boolean;
  12657. private _leftStickAxisX;
  12658. private _leftStickAxisY;
  12659. private _rightStickAxisX;
  12660. private _rightStickAxisY;
  12661. /**
  12662. * Triggered when the left control stick has been changed
  12663. */
  12664. private _onleftstickchanged;
  12665. /**
  12666. * Triggered when the right control stick has been changed
  12667. */
  12668. private _onrightstickchanged;
  12669. /**
  12670. * Represents a gamepad controller
  12671. */
  12672. static GAMEPAD: number;
  12673. /**
  12674. * Represents a generic controller
  12675. */
  12676. static GENERIC: number;
  12677. /**
  12678. * Represents an XBox controller
  12679. */
  12680. static XBOX: number;
  12681. /**
  12682. * Represents a pose-enabled controller
  12683. */
  12684. static POSE_ENABLED: number;
  12685. /**
  12686. * Represents an Dual Shock controller
  12687. */
  12688. static DUALSHOCK: number;
  12689. /**
  12690. * Specifies whether the left control stick should be Y-inverted
  12691. */
  12692. protected _invertLeftStickY: boolean;
  12693. /**
  12694. * Specifies if the gamepad has been connected
  12695. */
  12696. get isConnected(): boolean;
  12697. /**
  12698. * Initializes the gamepad
  12699. * @param id The id of the gamepad
  12700. * @param index The index of the gamepad
  12701. * @param browserGamepad The browser gamepad
  12702. * @param leftStickX The x component of the left joystick
  12703. * @param leftStickY The y component of the left joystick
  12704. * @param rightStickX The x component of the right joystick
  12705. * @param rightStickY The y component of the right joystick
  12706. */
  12707. constructor(
  12708. /**
  12709. * The id of the gamepad
  12710. */
  12711. id: string,
  12712. /**
  12713. * The index of the gamepad
  12714. */
  12715. index: number,
  12716. /**
  12717. * The browser gamepad
  12718. */
  12719. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12720. /**
  12721. * Callback triggered when the left joystick has changed
  12722. * @param callback
  12723. */
  12724. onleftstickchanged(callback: (values: StickValues) => void): void;
  12725. /**
  12726. * Callback triggered when the right joystick has changed
  12727. * @param callback
  12728. */
  12729. onrightstickchanged(callback: (values: StickValues) => void): void;
  12730. /**
  12731. * Gets the left joystick
  12732. */
  12733. get leftStick(): StickValues;
  12734. /**
  12735. * Sets the left joystick values
  12736. */
  12737. set leftStick(newValues: StickValues);
  12738. /**
  12739. * Gets the right joystick
  12740. */
  12741. get rightStick(): StickValues;
  12742. /**
  12743. * Sets the right joystick value
  12744. */
  12745. set rightStick(newValues: StickValues);
  12746. /**
  12747. * Updates the gamepad joystick positions
  12748. */
  12749. update(): void;
  12750. /**
  12751. * Disposes the gamepad
  12752. */
  12753. dispose(): void;
  12754. }
  12755. /**
  12756. * Represents a generic gamepad
  12757. */
  12758. export class GenericPad extends Gamepad {
  12759. private _buttons;
  12760. private _onbuttondown;
  12761. private _onbuttonup;
  12762. /**
  12763. * Observable triggered when a button has been pressed
  12764. */
  12765. onButtonDownObservable: Observable<number>;
  12766. /**
  12767. * Observable triggered when a button has been released
  12768. */
  12769. onButtonUpObservable: Observable<number>;
  12770. /**
  12771. * Callback triggered when a button has been pressed
  12772. * @param callback Called when a button has been pressed
  12773. */
  12774. onbuttondown(callback: (buttonPressed: number) => void): void;
  12775. /**
  12776. * Callback triggered when a button has been released
  12777. * @param callback Called when a button has been released
  12778. */
  12779. onbuttonup(callback: (buttonReleased: number) => void): void;
  12780. /**
  12781. * Initializes the generic gamepad
  12782. * @param id The id of the generic gamepad
  12783. * @param index The index of the generic gamepad
  12784. * @param browserGamepad The browser gamepad
  12785. */
  12786. constructor(id: string, index: number, browserGamepad: any);
  12787. private _setButtonValue;
  12788. /**
  12789. * Updates the generic gamepad
  12790. */
  12791. update(): void;
  12792. /**
  12793. * Disposes the generic gamepad
  12794. */
  12795. dispose(): void;
  12796. }
  12797. }
  12798. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12799. import { Nullable } from "babylonjs/types";
  12800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12801. import { Scene } from "babylonjs/scene";
  12802. module "babylonjs/Engines/engine" {
  12803. interface Engine {
  12804. /**
  12805. * Creates a raw texture
  12806. * @param data defines the data to store in the texture
  12807. * @param width defines the width of the texture
  12808. * @param height defines the height of the texture
  12809. * @param format defines the format of the data
  12810. * @param generateMipMaps defines if the engine should generate the mip levels
  12811. * @param invertY defines if data must be stored with Y axis inverted
  12812. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12813. * @param compression defines the compression used (null by default)
  12814. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12815. * @returns the raw texture inside an InternalTexture
  12816. */
  12817. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12818. /**
  12819. * Update a raw texture
  12820. * @param texture defines the texture to update
  12821. * @param data defines the data to store in the texture
  12822. * @param format defines the format of the data
  12823. * @param invertY defines if data must be stored with Y axis inverted
  12824. */
  12825. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12826. /**
  12827. * Update a raw texture
  12828. * @param texture defines the texture to update
  12829. * @param data defines the data to store in the texture
  12830. * @param format defines the format of the data
  12831. * @param invertY defines if data must be stored with Y axis inverted
  12832. * @param compression defines the compression used (null by default)
  12833. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12834. */
  12835. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12836. /**
  12837. * Creates a new raw cube texture
  12838. * @param data defines the array of data to use to create each face
  12839. * @param size defines the size of the textures
  12840. * @param format defines the format of the data
  12841. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12842. * @param generateMipMaps defines if the engine should generate the mip levels
  12843. * @param invertY defines if data must be stored with Y axis inverted
  12844. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12845. * @param compression defines the compression used (null by default)
  12846. * @returns the cube texture as an InternalTexture
  12847. */
  12848. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12849. /**
  12850. * Update a raw cube texture
  12851. * @param texture defines the texture to udpdate
  12852. * @param data defines the data to store
  12853. * @param format defines the data format
  12854. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12855. * @param invertY defines if data must be stored with Y axis inverted
  12856. */
  12857. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12858. /**
  12859. * Update a raw cube texture
  12860. * @param texture defines the texture to udpdate
  12861. * @param data defines the data to store
  12862. * @param format defines the data format
  12863. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12864. * @param invertY defines if data must be stored with Y axis inverted
  12865. * @param compression defines the compression used (null by default)
  12866. */
  12867. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12868. /**
  12869. * Update a raw cube texture
  12870. * @param texture defines the texture to udpdate
  12871. * @param data defines the data to store
  12872. * @param format defines the data format
  12873. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12874. * @param invertY defines if data must be stored with Y axis inverted
  12875. * @param compression defines the compression used (null by default)
  12876. * @param level defines which level of the texture to update
  12877. */
  12878. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12879. /**
  12880. * Creates a new raw cube texture from a specified url
  12881. * @param url defines the url where the data is located
  12882. * @param scene defines the current scene
  12883. * @param size defines the size of the textures
  12884. * @param format defines the format of the data
  12885. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12886. * @param noMipmap defines if the engine should avoid generating the mip levels
  12887. * @param callback defines a callback used to extract texture data from loaded data
  12888. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12889. * @param onLoad defines a callback called when texture is loaded
  12890. * @param onError defines a callback called if there is an error
  12891. * @returns the cube texture as an InternalTexture
  12892. */
  12893. 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;
  12894. /**
  12895. * Creates a new raw cube texture from a specified url
  12896. * @param url defines the url where the data is located
  12897. * @param scene defines the current scene
  12898. * @param size defines the size of the textures
  12899. * @param format defines the format of the data
  12900. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12901. * @param noMipmap defines if the engine should avoid generating the mip levels
  12902. * @param callback defines a callback used to extract texture data from loaded data
  12903. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12904. * @param onLoad defines a callback called when texture is loaded
  12905. * @param onError defines a callback called if there is an error
  12906. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12907. * @param invertY defines if data must be stored with Y axis inverted
  12908. * @returns the cube texture as an InternalTexture
  12909. */
  12910. 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;
  12911. /**
  12912. * Creates a new raw 3D texture
  12913. * @param data defines the data used to create the texture
  12914. * @param width defines the width of the texture
  12915. * @param height defines the height of the texture
  12916. * @param depth defines the depth of the texture
  12917. * @param format defines the format of the texture
  12918. * @param generateMipMaps defines if the engine must generate mip levels
  12919. * @param invertY defines if data must be stored with Y axis inverted
  12920. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12921. * @param compression defines the compressed used (can be null)
  12922. * @param textureType defines the compressed used (can be null)
  12923. * @returns a new raw 3D texture (stored in an InternalTexture)
  12924. */
  12925. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12926. /**
  12927. * Update a raw 3D texture
  12928. * @param texture defines the texture to update
  12929. * @param data defines the data to store
  12930. * @param format defines the data format
  12931. * @param invertY defines if data must be stored with Y axis inverted
  12932. */
  12933. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12934. /**
  12935. * Update a raw 3D texture
  12936. * @param texture defines the texture to update
  12937. * @param data defines the data to store
  12938. * @param format defines the data format
  12939. * @param invertY defines if data must be stored with Y axis inverted
  12940. * @param compression defines the used compression (can be null)
  12941. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12942. */
  12943. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12944. /**
  12945. * Creates a new raw 2D array texture
  12946. * @param data defines the data used to create the texture
  12947. * @param width defines the width of the texture
  12948. * @param height defines the height of the texture
  12949. * @param depth defines the number of layers of the texture
  12950. * @param format defines the format of the texture
  12951. * @param generateMipMaps defines if the engine must generate mip levels
  12952. * @param invertY defines if data must be stored with Y axis inverted
  12953. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12954. * @param compression defines the compressed used (can be null)
  12955. * @param textureType defines the compressed used (can be null)
  12956. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12957. */
  12958. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12959. /**
  12960. * Update a raw 2D array texture
  12961. * @param texture defines the texture to update
  12962. * @param data defines the data to store
  12963. * @param format defines the data format
  12964. * @param invertY defines if data must be stored with Y axis inverted
  12965. */
  12966. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12967. /**
  12968. * Update a raw 2D array texture
  12969. * @param texture defines the texture to update
  12970. * @param data defines the data to store
  12971. * @param format defines the data format
  12972. * @param invertY defines if data must be stored with Y axis inverted
  12973. * @param compression defines the used compression (can be null)
  12974. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12975. */
  12976. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12977. }
  12978. }
  12979. }
  12980. declare module "babylonjs/Materials/Textures/rawTexture" {
  12981. import { Scene } from "babylonjs/scene";
  12982. import { Texture } from "babylonjs/Materials/Textures/texture";
  12983. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12984. /**
  12985. * Raw texture can help creating a texture directly from an array of data.
  12986. * This can be super useful if you either get the data from an uncompressed source or
  12987. * if you wish to create your texture pixel by pixel.
  12988. */
  12989. export class RawTexture extends Texture {
  12990. /**
  12991. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12992. */
  12993. format: number;
  12994. private _engine;
  12995. /**
  12996. * Instantiates a new RawTexture.
  12997. * Raw texture can help creating a texture directly from an array of data.
  12998. * This can be super useful if you either get the data from an uncompressed source or
  12999. * if you wish to create your texture pixel by pixel.
  13000. * @param data define the array of data to use to create the texture
  13001. * @param width define the width of the texture
  13002. * @param height define the height of the texture
  13003. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13004. * @param scene define the scene the texture belongs to
  13005. * @param generateMipMaps define whether mip maps should be generated or not
  13006. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13007. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13008. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13009. */
  13010. constructor(data: ArrayBufferView, width: number, height: number,
  13011. /**
  13012. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13013. */
  13014. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13015. /**
  13016. * Updates the texture underlying data.
  13017. * @param data Define the new data of the texture
  13018. */
  13019. update(data: ArrayBufferView): void;
  13020. /**
  13021. * Creates a luminance texture from some data.
  13022. * @param data Define the texture data
  13023. * @param width Define the width of the texture
  13024. * @param height Define the height of the texture
  13025. * @param scene Define the scene the texture belongs to
  13026. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13027. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13028. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13029. * @returns the luminance texture
  13030. */
  13031. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13032. /**
  13033. * Creates a luminance alpha texture from some data.
  13034. * @param data Define the texture data
  13035. * @param width Define the width of the texture
  13036. * @param height Define the height of the texture
  13037. * @param scene Define the scene the texture belongs to
  13038. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13039. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13040. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13041. * @returns the luminance alpha texture
  13042. */
  13043. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13044. /**
  13045. * Creates an alpha texture from some data.
  13046. * @param data Define the texture data
  13047. * @param width Define the width of the texture
  13048. * @param height Define the height of the texture
  13049. * @param scene Define the scene the texture belongs to
  13050. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13051. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13052. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13053. * @returns the alpha texture
  13054. */
  13055. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13056. /**
  13057. * Creates a RGB texture from some data.
  13058. * @param data Define the texture data
  13059. * @param width Define the width of the texture
  13060. * @param height Define the height of the texture
  13061. * @param scene Define the scene the texture belongs to
  13062. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13063. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13064. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13065. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13066. * @returns the RGB alpha texture
  13067. */
  13068. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13069. /**
  13070. * Creates a RGBA texture from some data.
  13071. * @param data Define the texture data
  13072. * @param width Define the width of the texture
  13073. * @param height Define the height of the texture
  13074. * @param scene Define the scene the texture belongs to
  13075. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13076. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13077. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13078. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13079. * @returns the RGBA texture
  13080. */
  13081. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13082. /**
  13083. * Creates a R texture from some data.
  13084. * @param data Define the texture data
  13085. * @param width Define the width of the texture
  13086. * @param height Define the height of the texture
  13087. * @param scene Define the scene the texture belongs to
  13088. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13089. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13090. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13091. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13092. * @returns the R texture
  13093. */
  13094. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13095. }
  13096. }
  13097. declare module "babylonjs/Maths/math.size" {
  13098. /**
  13099. * Interface for the size containing width and height
  13100. */
  13101. export interface ISize {
  13102. /**
  13103. * Width
  13104. */
  13105. width: number;
  13106. /**
  13107. * Heighht
  13108. */
  13109. height: number;
  13110. }
  13111. /**
  13112. * Size containing widht and height
  13113. */
  13114. export class Size implements ISize {
  13115. /**
  13116. * Width
  13117. */
  13118. width: number;
  13119. /**
  13120. * Height
  13121. */
  13122. height: number;
  13123. /**
  13124. * Creates a Size object from the given width and height (floats).
  13125. * @param width width of the new size
  13126. * @param height height of the new size
  13127. */
  13128. constructor(width: number, height: number);
  13129. /**
  13130. * Returns a string with the Size width and height
  13131. * @returns a string with the Size width and height
  13132. */
  13133. toString(): string;
  13134. /**
  13135. * "Size"
  13136. * @returns the string "Size"
  13137. */
  13138. getClassName(): string;
  13139. /**
  13140. * Returns the Size hash code.
  13141. * @returns a hash code for a unique width and height
  13142. */
  13143. getHashCode(): number;
  13144. /**
  13145. * Updates the current size from the given one.
  13146. * @param src the given size
  13147. */
  13148. copyFrom(src: Size): void;
  13149. /**
  13150. * Updates in place the current Size from the given floats.
  13151. * @param width width of the new size
  13152. * @param height height of the new size
  13153. * @returns the updated Size.
  13154. */
  13155. copyFromFloats(width: number, height: number): Size;
  13156. /**
  13157. * Updates in place the current Size from the given floats.
  13158. * @param width width to set
  13159. * @param height height to set
  13160. * @returns the updated Size.
  13161. */
  13162. set(width: number, height: number): Size;
  13163. /**
  13164. * Multiplies the width and height by numbers
  13165. * @param w factor to multiple the width by
  13166. * @param h factor to multiple the height by
  13167. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13168. */
  13169. multiplyByFloats(w: number, h: number): Size;
  13170. /**
  13171. * Clones the size
  13172. * @returns a new Size copied from the given one.
  13173. */
  13174. clone(): Size;
  13175. /**
  13176. * True if the current Size and the given one width and height are strictly equal.
  13177. * @param other the other size to compare against
  13178. * @returns True if the current Size and the given one width and height are strictly equal.
  13179. */
  13180. equals(other: Size): boolean;
  13181. /**
  13182. * The surface of the Size : width * height (float).
  13183. */
  13184. get surface(): number;
  13185. /**
  13186. * Create a new size of zero
  13187. * @returns a new Size set to (0.0, 0.0)
  13188. */
  13189. static Zero(): Size;
  13190. /**
  13191. * Sums the width and height of two sizes
  13192. * @param otherSize size to add to this size
  13193. * @returns a new Size set as the addition result of the current Size and the given one.
  13194. */
  13195. add(otherSize: Size): Size;
  13196. /**
  13197. * Subtracts the width and height of two
  13198. * @param otherSize size to subtract to this size
  13199. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13200. */
  13201. subtract(otherSize: Size): Size;
  13202. /**
  13203. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13204. * @param start starting size to lerp between
  13205. * @param end end size to lerp between
  13206. * @param amount amount to lerp between the start and end values
  13207. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13208. */
  13209. static Lerp(start: Size, end: Size, amount: number): Size;
  13210. }
  13211. }
  13212. declare module "babylonjs/Animations/runtimeAnimation" {
  13213. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13214. import { Animatable } from "babylonjs/Animations/animatable";
  13215. import { Scene } from "babylonjs/scene";
  13216. /**
  13217. * Defines a runtime animation
  13218. */
  13219. export class RuntimeAnimation {
  13220. private _events;
  13221. /**
  13222. * The current frame of the runtime animation
  13223. */
  13224. private _currentFrame;
  13225. /**
  13226. * The animation used by the runtime animation
  13227. */
  13228. private _animation;
  13229. /**
  13230. * The target of the runtime animation
  13231. */
  13232. private _target;
  13233. /**
  13234. * The initiating animatable
  13235. */
  13236. private _host;
  13237. /**
  13238. * The original value of the runtime animation
  13239. */
  13240. private _originalValue;
  13241. /**
  13242. * The original blend value of the runtime animation
  13243. */
  13244. private _originalBlendValue;
  13245. /**
  13246. * The offsets cache of the runtime animation
  13247. */
  13248. private _offsetsCache;
  13249. /**
  13250. * The high limits cache of the runtime animation
  13251. */
  13252. private _highLimitsCache;
  13253. /**
  13254. * Specifies if the runtime animation has been stopped
  13255. */
  13256. private _stopped;
  13257. /**
  13258. * The blending factor of the runtime animation
  13259. */
  13260. private _blendingFactor;
  13261. /**
  13262. * The BabylonJS scene
  13263. */
  13264. private _scene;
  13265. /**
  13266. * The current value of the runtime animation
  13267. */
  13268. private _currentValue;
  13269. /** @hidden */
  13270. _animationState: _IAnimationState;
  13271. /**
  13272. * The active target of the runtime animation
  13273. */
  13274. private _activeTargets;
  13275. private _currentActiveTarget;
  13276. private _directTarget;
  13277. /**
  13278. * The target path of the runtime animation
  13279. */
  13280. private _targetPath;
  13281. /**
  13282. * The weight of the runtime animation
  13283. */
  13284. private _weight;
  13285. /**
  13286. * The ratio offset of the runtime animation
  13287. */
  13288. private _ratioOffset;
  13289. /**
  13290. * The previous delay of the runtime animation
  13291. */
  13292. private _previousDelay;
  13293. /**
  13294. * The previous ratio of the runtime animation
  13295. */
  13296. private _previousRatio;
  13297. private _enableBlending;
  13298. private _keys;
  13299. private _minFrame;
  13300. private _maxFrame;
  13301. private _minValue;
  13302. private _maxValue;
  13303. private _targetIsArray;
  13304. /**
  13305. * Gets the current frame of the runtime animation
  13306. */
  13307. get currentFrame(): number;
  13308. /**
  13309. * Gets the weight of the runtime animation
  13310. */
  13311. get weight(): number;
  13312. /**
  13313. * Gets the current value of the runtime animation
  13314. */
  13315. get currentValue(): any;
  13316. /**
  13317. * Gets the target path of the runtime animation
  13318. */
  13319. get targetPath(): string;
  13320. /**
  13321. * Gets the actual target of the runtime animation
  13322. */
  13323. get target(): any;
  13324. /** @hidden */
  13325. _onLoop: () => void;
  13326. /**
  13327. * Create a new RuntimeAnimation object
  13328. * @param target defines the target of the animation
  13329. * @param animation defines the source animation object
  13330. * @param scene defines the hosting scene
  13331. * @param host defines the initiating Animatable
  13332. */
  13333. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13334. private _preparePath;
  13335. /**
  13336. * Gets the animation from the runtime animation
  13337. */
  13338. get animation(): Animation;
  13339. /**
  13340. * Resets the runtime animation to the beginning
  13341. * @param restoreOriginal defines whether to restore the target property to the original value
  13342. */
  13343. reset(restoreOriginal?: boolean): void;
  13344. /**
  13345. * Specifies if the runtime animation is stopped
  13346. * @returns Boolean specifying if the runtime animation is stopped
  13347. */
  13348. isStopped(): boolean;
  13349. /**
  13350. * Disposes of the runtime animation
  13351. */
  13352. dispose(): void;
  13353. /**
  13354. * Apply the interpolated value to the target
  13355. * @param currentValue defines the value computed by the animation
  13356. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13357. */
  13358. setValue(currentValue: any, weight: number): void;
  13359. private _getOriginalValues;
  13360. private _setValue;
  13361. /**
  13362. * Gets the loop pmode of the runtime animation
  13363. * @returns Loop Mode
  13364. */
  13365. private _getCorrectLoopMode;
  13366. /**
  13367. * Move the current animation to a given frame
  13368. * @param frame defines the frame to move to
  13369. */
  13370. goToFrame(frame: number): void;
  13371. /**
  13372. * @hidden Internal use only
  13373. */
  13374. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13375. /**
  13376. * Execute the current animation
  13377. * @param delay defines the delay to add to the current frame
  13378. * @param from defines the lower bound of the animation range
  13379. * @param to defines the upper bound of the animation range
  13380. * @param loop defines if the current animation must loop
  13381. * @param speedRatio defines the current speed ratio
  13382. * @param weight defines the weight of the animation (default is -1 so no weight)
  13383. * @param onLoop optional callback called when animation loops
  13384. * @returns a boolean indicating if the animation is running
  13385. */
  13386. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13387. }
  13388. }
  13389. declare module "babylonjs/Animations/animatable" {
  13390. import { Animation } from "babylonjs/Animations/animation";
  13391. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13392. import { Nullable } from "babylonjs/types";
  13393. import { Observable } from "babylonjs/Misc/observable";
  13394. import { Scene } from "babylonjs/scene";
  13395. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13396. import { Node } from "babylonjs/node";
  13397. /**
  13398. * Class used to store an actual running animation
  13399. */
  13400. export class Animatable {
  13401. /** defines the target object */
  13402. target: any;
  13403. /** defines the starting frame number (default is 0) */
  13404. fromFrame: number;
  13405. /** defines the ending frame number (default is 100) */
  13406. toFrame: number;
  13407. /** defines if the animation must loop (default is false) */
  13408. loopAnimation: boolean;
  13409. /** defines a callback to call when animation ends if it is not looping */
  13410. onAnimationEnd?: (() => void) | null | undefined;
  13411. /** defines a callback to call when animation loops */
  13412. onAnimationLoop?: (() => void) | null | undefined;
  13413. private _localDelayOffset;
  13414. private _pausedDelay;
  13415. private _runtimeAnimations;
  13416. private _paused;
  13417. private _scene;
  13418. private _speedRatio;
  13419. private _weight;
  13420. private _syncRoot;
  13421. /**
  13422. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13423. * This will only apply for non looping animation (default is true)
  13424. */
  13425. disposeOnEnd: boolean;
  13426. /**
  13427. * Gets a boolean indicating if the animation has started
  13428. */
  13429. animationStarted: boolean;
  13430. /**
  13431. * Observer raised when the animation ends
  13432. */
  13433. onAnimationEndObservable: Observable<Animatable>;
  13434. /**
  13435. * Observer raised when the animation loops
  13436. */
  13437. onAnimationLoopObservable: Observable<Animatable>;
  13438. /**
  13439. * Gets the root Animatable used to synchronize and normalize animations
  13440. */
  13441. get syncRoot(): Nullable<Animatable>;
  13442. /**
  13443. * Gets the current frame of the first RuntimeAnimation
  13444. * Used to synchronize Animatables
  13445. */
  13446. get masterFrame(): number;
  13447. /**
  13448. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13449. */
  13450. get weight(): number;
  13451. set weight(value: number);
  13452. /**
  13453. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13454. */
  13455. get speedRatio(): number;
  13456. set speedRatio(value: number);
  13457. /**
  13458. * Creates a new Animatable
  13459. * @param scene defines the hosting scene
  13460. * @param target defines the target object
  13461. * @param fromFrame defines the starting frame number (default is 0)
  13462. * @param toFrame defines the ending frame number (default is 100)
  13463. * @param loopAnimation defines if the animation must loop (default is false)
  13464. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13465. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13466. * @param animations defines a group of animation to add to the new Animatable
  13467. * @param onAnimationLoop defines a callback to call when animation loops
  13468. */
  13469. constructor(scene: Scene,
  13470. /** defines the target object */
  13471. target: any,
  13472. /** defines the starting frame number (default is 0) */
  13473. fromFrame?: number,
  13474. /** defines the ending frame number (default is 100) */
  13475. toFrame?: number,
  13476. /** defines if the animation must loop (default is false) */
  13477. loopAnimation?: boolean, speedRatio?: number,
  13478. /** defines a callback to call when animation ends if it is not looping */
  13479. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13480. /** defines a callback to call when animation loops */
  13481. onAnimationLoop?: (() => void) | null | undefined);
  13482. /**
  13483. * Synchronize and normalize current Animatable with a source Animatable
  13484. * This is useful when using animation weights and when animations are not of the same length
  13485. * @param root defines the root Animatable to synchronize with
  13486. * @returns the current Animatable
  13487. */
  13488. syncWith(root: Animatable): Animatable;
  13489. /**
  13490. * Gets the list of runtime animations
  13491. * @returns an array of RuntimeAnimation
  13492. */
  13493. getAnimations(): RuntimeAnimation[];
  13494. /**
  13495. * Adds more animations to the current animatable
  13496. * @param target defines the target of the animations
  13497. * @param animations defines the new animations to add
  13498. */
  13499. appendAnimations(target: any, animations: Animation[]): void;
  13500. /**
  13501. * Gets the source animation for a specific property
  13502. * @param property defines the propertyu to look for
  13503. * @returns null or the source animation for the given property
  13504. */
  13505. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13506. /**
  13507. * Gets the runtime animation for a specific property
  13508. * @param property defines the propertyu to look for
  13509. * @returns null or the runtime animation for the given property
  13510. */
  13511. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13512. /**
  13513. * Resets the animatable to its original state
  13514. */
  13515. reset(): void;
  13516. /**
  13517. * Allows the animatable to blend with current running animations
  13518. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13519. * @param blendingSpeed defines the blending speed to use
  13520. */
  13521. enableBlending(blendingSpeed: number): void;
  13522. /**
  13523. * Disable animation blending
  13524. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13525. */
  13526. disableBlending(): void;
  13527. /**
  13528. * Jump directly to a given frame
  13529. * @param frame defines the frame to jump to
  13530. */
  13531. goToFrame(frame: number): void;
  13532. /**
  13533. * Pause the animation
  13534. */
  13535. pause(): void;
  13536. /**
  13537. * Restart the animation
  13538. */
  13539. restart(): void;
  13540. private _raiseOnAnimationEnd;
  13541. /**
  13542. * Stop and delete the current animation
  13543. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13544. * @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)
  13545. */
  13546. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13547. /**
  13548. * Wait asynchronously for the animation to end
  13549. * @returns a promise which will be fullfilled when the animation ends
  13550. */
  13551. waitAsync(): Promise<Animatable>;
  13552. /** @hidden */
  13553. _animate(delay: number): boolean;
  13554. }
  13555. module "babylonjs/scene" {
  13556. interface Scene {
  13557. /** @hidden */
  13558. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13559. /** @hidden */
  13560. _processLateAnimationBindingsForMatrices(holder: {
  13561. totalWeight: number;
  13562. animations: RuntimeAnimation[];
  13563. originalValue: Matrix;
  13564. }): any;
  13565. /** @hidden */
  13566. _processLateAnimationBindingsForQuaternions(holder: {
  13567. totalWeight: number;
  13568. animations: RuntimeAnimation[];
  13569. originalValue: Quaternion;
  13570. }, refQuaternion: Quaternion): Quaternion;
  13571. /** @hidden */
  13572. _processLateAnimationBindings(): void;
  13573. /**
  13574. * Will start the animation sequence of a given target
  13575. * @param target defines the target
  13576. * @param from defines from which frame should animation start
  13577. * @param to defines until which frame should animation run.
  13578. * @param weight defines the weight to apply to the animation (1.0 by default)
  13579. * @param loop defines if the animation loops
  13580. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13581. * @param onAnimationEnd defines the function to be executed when the animation ends
  13582. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13583. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13584. * @param onAnimationLoop defines the callback to call when an animation loops
  13585. * @returns the animatable object created for this animation
  13586. */
  13587. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13588. /**
  13589. * Will start the animation sequence of a given target
  13590. * @param target defines the target
  13591. * @param from defines from which frame should animation start
  13592. * @param to defines until which frame should animation run.
  13593. * @param loop defines if the animation loops
  13594. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13595. * @param onAnimationEnd defines the function to be executed when the animation ends
  13596. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13597. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13598. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13599. * @param onAnimationLoop defines the callback to call when an animation loops
  13600. * @returns the animatable object created for this animation
  13601. */
  13602. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13603. /**
  13604. * Will start the animation sequence of a given target and its hierarchy
  13605. * @param target defines the target
  13606. * @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.
  13607. * @param from defines from which frame should animation start
  13608. * @param to defines until which frame should animation run.
  13609. * @param loop defines if the animation loops
  13610. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13611. * @param onAnimationEnd defines the function to be executed when the animation ends
  13612. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13613. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13614. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13615. * @param onAnimationLoop defines the callback to call when an animation loops
  13616. * @returns the list of created animatables
  13617. */
  13618. 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[];
  13619. /**
  13620. * Begin a new animation on a given node
  13621. * @param target defines the target where the animation will take place
  13622. * @param animations defines the list of animations to start
  13623. * @param from defines the initial value
  13624. * @param to defines the final value
  13625. * @param loop defines if you want animation to loop (off by default)
  13626. * @param speedRatio defines the speed ratio to apply to all animations
  13627. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13628. * @param onAnimationLoop defines the callback to call when an animation loops
  13629. * @returns the list of created animatables
  13630. */
  13631. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13632. /**
  13633. * Begin a new animation on a given node and its hierarchy
  13634. * @param target defines the root node where the animation will take place
  13635. * @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.
  13636. * @param animations defines the list of animations to start
  13637. * @param from defines the initial value
  13638. * @param to defines the final value
  13639. * @param loop defines if you want animation to loop (off by default)
  13640. * @param speedRatio defines the speed ratio to apply to all animations
  13641. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13642. * @param onAnimationLoop defines the callback to call when an animation loops
  13643. * @returns the list of animatables created for all nodes
  13644. */
  13645. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13646. /**
  13647. * Gets the animatable associated with a specific target
  13648. * @param target defines the target of the animatable
  13649. * @returns the required animatable if found
  13650. */
  13651. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13652. /**
  13653. * Gets all animatables associated with a given target
  13654. * @param target defines the target to look animatables for
  13655. * @returns an array of Animatables
  13656. */
  13657. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13658. /**
  13659. * Stops and removes all animations that have been applied to the scene
  13660. */
  13661. stopAllAnimations(): void;
  13662. /**
  13663. * Gets the current delta time used by animation engine
  13664. */
  13665. deltaTime: number;
  13666. }
  13667. }
  13668. module "babylonjs/Bones/bone" {
  13669. interface Bone {
  13670. /**
  13671. * Copy an animation range from another bone
  13672. * @param source defines the source bone
  13673. * @param rangeName defines the range name to copy
  13674. * @param frameOffset defines the frame offset
  13675. * @param rescaleAsRequired defines if rescaling must be applied if required
  13676. * @param skelDimensionsRatio defines the scaling ratio
  13677. * @returns true if operation was successful
  13678. */
  13679. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13680. }
  13681. }
  13682. }
  13683. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13684. /**
  13685. * Class used to override all child animations of a given target
  13686. */
  13687. export class AnimationPropertiesOverride {
  13688. /**
  13689. * Gets or sets a value indicating if animation blending must be used
  13690. */
  13691. enableBlending: boolean;
  13692. /**
  13693. * Gets or sets the blending speed to use when enableBlending is true
  13694. */
  13695. blendingSpeed: number;
  13696. /**
  13697. * Gets or sets the default loop mode to use
  13698. */
  13699. loopMode: number;
  13700. }
  13701. }
  13702. declare module "babylonjs/Bones/skeleton" {
  13703. import { Bone } from "babylonjs/Bones/bone";
  13704. import { Observable } from "babylonjs/Misc/observable";
  13705. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13706. import { Scene } from "babylonjs/scene";
  13707. import { Nullable } from "babylonjs/types";
  13708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13709. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13710. import { Animatable } from "babylonjs/Animations/animatable";
  13711. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13712. import { Animation } from "babylonjs/Animations/animation";
  13713. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13714. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13715. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13716. /**
  13717. * Class used to handle skinning animations
  13718. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13719. */
  13720. export class Skeleton implements IAnimatable {
  13721. /** defines the skeleton name */
  13722. name: string;
  13723. /** defines the skeleton Id */
  13724. id: string;
  13725. /**
  13726. * Defines the list of child bones
  13727. */
  13728. bones: Bone[];
  13729. /**
  13730. * Defines an estimate of the dimension of the skeleton at rest
  13731. */
  13732. dimensionsAtRest: Vector3;
  13733. /**
  13734. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13735. */
  13736. needInitialSkinMatrix: boolean;
  13737. /**
  13738. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13739. */
  13740. overrideMesh: Nullable<AbstractMesh>;
  13741. /**
  13742. * Gets the list of animations attached to this skeleton
  13743. */
  13744. animations: Array<Animation>;
  13745. private _scene;
  13746. private _isDirty;
  13747. private _transformMatrices;
  13748. private _transformMatrixTexture;
  13749. private _meshesWithPoseMatrix;
  13750. private _animatables;
  13751. private _identity;
  13752. private _synchronizedWithMesh;
  13753. private _ranges;
  13754. private _lastAbsoluteTransformsUpdateId;
  13755. private _canUseTextureForBones;
  13756. private _uniqueId;
  13757. /** @hidden */
  13758. _numBonesWithLinkedTransformNode: number;
  13759. /** @hidden */
  13760. _hasWaitingData: Nullable<boolean>;
  13761. /**
  13762. * Specifies if the skeleton should be serialized
  13763. */
  13764. doNotSerialize: boolean;
  13765. private _useTextureToStoreBoneMatrices;
  13766. /**
  13767. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13768. * Please note that this option is not available if the hardware does not support it
  13769. */
  13770. get useTextureToStoreBoneMatrices(): boolean;
  13771. set useTextureToStoreBoneMatrices(value: boolean);
  13772. private _animationPropertiesOverride;
  13773. /**
  13774. * Gets or sets the animation properties override
  13775. */
  13776. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13777. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13778. /**
  13779. * List of inspectable custom properties (used by the Inspector)
  13780. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13781. */
  13782. inspectableCustomProperties: IInspectable[];
  13783. /**
  13784. * An observable triggered before computing the skeleton's matrices
  13785. */
  13786. onBeforeComputeObservable: Observable<Skeleton>;
  13787. /**
  13788. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13789. */
  13790. get isUsingTextureForMatrices(): boolean;
  13791. /**
  13792. * Gets the unique ID of this skeleton
  13793. */
  13794. get uniqueId(): number;
  13795. /**
  13796. * Creates a new skeleton
  13797. * @param name defines the skeleton name
  13798. * @param id defines the skeleton Id
  13799. * @param scene defines the hosting scene
  13800. */
  13801. constructor(
  13802. /** defines the skeleton name */
  13803. name: string,
  13804. /** defines the skeleton Id */
  13805. id: string, scene: Scene);
  13806. /**
  13807. * Gets the current object class name.
  13808. * @return the class name
  13809. */
  13810. getClassName(): string;
  13811. /**
  13812. * Returns an array containing the root bones
  13813. * @returns an array containing the root bones
  13814. */
  13815. getChildren(): Array<Bone>;
  13816. /**
  13817. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13818. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13819. * @returns a Float32Array containing matrices data
  13820. */
  13821. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13822. /**
  13823. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13824. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13825. * @returns a raw texture containing the data
  13826. */
  13827. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13828. /**
  13829. * Gets the current hosting scene
  13830. * @returns a scene object
  13831. */
  13832. getScene(): Scene;
  13833. /**
  13834. * Gets a string representing the current skeleton data
  13835. * @param fullDetails defines a boolean indicating if we want a verbose version
  13836. * @returns a string representing the current skeleton data
  13837. */
  13838. toString(fullDetails?: boolean): string;
  13839. /**
  13840. * Get bone's index searching by name
  13841. * @param name defines bone's name to search for
  13842. * @return the indice of the bone. Returns -1 if not found
  13843. */
  13844. getBoneIndexByName(name: string): number;
  13845. /**
  13846. * Creater a new animation range
  13847. * @param name defines the name of the range
  13848. * @param from defines the start key
  13849. * @param to defines the end key
  13850. */
  13851. createAnimationRange(name: string, from: number, to: number): void;
  13852. /**
  13853. * Delete a specific animation range
  13854. * @param name defines the name of the range
  13855. * @param deleteFrames defines if frames must be removed as well
  13856. */
  13857. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13858. /**
  13859. * Gets a specific animation range
  13860. * @param name defines the name of the range to look for
  13861. * @returns the requested animation range or null if not found
  13862. */
  13863. getAnimationRange(name: string): Nullable<AnimationRange>;
  13864. /**
  13865. * Gets the list of all animation ranges defined on this skeleton
  13866. * @returns an array
  13867. */
  13868. getAnimationRanges(): Nullable<AnimationRange>[];
  13869. /**
  13870. * Copy animation range from a source skeleton.
  13871. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13872. * @param source defines the source skeleton
  13873. * @param name defines the name of the range to copy
  13874. * @param rescaleAsRequired defines if rescaling must be applied if required
  13875. * @returns true if operation was successful
  13876. */
  13877. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13878. /**
  13879. * Forces the skeleton to go to rest pose
  13880. */
  13881. returnToRest(): void;
  13882. private _getHighestAnimationFrame;
  13883. /**
  13884. * Begin a specific animation range
  13885. * @param name defines the name of the range to start
  13886. * @param loop defines if looping must be turned on (false by default)
  13887. * @param speedRatio defines the speed ratio to apply (1 by default)
  13888. * @param onAnimationEnd defines a callback which will be called when animation will end
  13889. * @returns a new animatable
  13890. */
  13891. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13892. /** @hidden */
  13893. _markAsDirty(): void;
  13894. /** @hidden */
  13895. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13896. /** @hidden */
  13897. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13898. private _computeTransformMatrices;
  13899. /**
  13900. * Build all resources required to render a skeleton
  13901. */
  13902. prepare(): void;
  13903. /**
  13904. * Gets the list of animatables currently running for this skeleton
  13905. * @returns an array of animatables
  13906. */
  13907. getAnimatables(): IAnimatable[];
  13908. /**
  13909. * Clone the current skeleton
  13910. * @param name defines the name of the new skeleton
  13911. * @param id defines the id of the new skeleton
  13912. * @returns the new skeleton
  13913. */
  13914. clone(name: string, id?: string): Skeleton;
  13915. /**
  13916. * Enable animation blending for this skeleton
  13917. * @param blendingSpeed defines the blending speed to apply
  13918. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13919. */
  13920. enableBlending(blendingSpeed?: number): void;
  13921. /**
  13922. * Releases all resources associated with the current skeleton
  13923. */
  13924. dispose(): void;
  13925. /**
  13926. * Serialize the skeleton in a JSON object
  13927. * @returns a JSON object
  13928. */
  13929. serialize(): any;
  13930. /**
  13931. * Creates a new skeleton from serialized data
  13932. * @param parsedSkeleton defines the serialized data
  13933. * @param scene defines the hosting scene
  13934. * @returns a new skeleton
  13935. */
  13936. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13937. /**
  13938. * Compute all node absolute transforms
  13939. * @param forceUpdate defines if computation must be done even if cache is up to date
  13940. */
  13941. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13942. /**
  13943. * Gets the root pose matrix
  13944. * @returns a matrix
  13945. */
  13946. getPoseMatrix(): Nullable<Matrix>;
  13947. /**
  13948. * Sorts bones per internal index
  13949. */
  13950. sortBones(): void;
  13951. private _sortBones;
  13952. }
  13953. }
  13954. declare module "babylonjs/Bones/bone" {
  13955. import { Skeleton } from "babylonjs/Bones/skeleton";
  13956. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13957. import { Nullable } from "babylonjs/types";
  13958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13959. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13960. import { Node } from "babylonjs/node";
  13961. import { Space } from "babylonjs/Maths/math.axis";
  13962. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13963. /**
  13964. * Class used to store bone information
  13965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13966. */
  13967. export class Bone extends Node {
  13968. /**
  13969. * defines the bone name
  13970. */
  13971. name: string;
  13972. private static _tmpVecs;
  13973. private static _tmpQuat;
  13974. private static _tmpMats;
  13975. /**
  13976. * Gets the list of child bones
  13977. */
  13978. children: Bone[];
  13979. /** Gets the animations associated with this bone */
  13980. animations: import("babylonjs/Animations/animation").Animation[];
  13981. /**
  13982. * Gets or sets bone length
  13983. */
  13984. length: number;
  13985. /**
  13986. * @hidden Internal only
  13987. * Set this value to map this bone to a different index in the transform matrices
  13988. * Set this value to -1 to exclude the bone from the transform matrices
  13989. */
  13990. _index: Nullable<number>;
  13991. private _skeleton;
  13992. private _localMatrix;
  13993. private _restPose;
  13994. private _baseMatrix;
  13995. private _absoluteTransform;
  13996. private _invertedAbsoluteTransform;
  13997. private _parent;
  13998. private _scalingDeterminant;
  13999. private _worldTransform;
  14000. private _localScaling;
  14001. private _localRotation;
  14002. private _localPosition;
  14003. private _needToDecompose;
  14004. private _needToCompose;
  14005. /** @hidden */
  14006. _linkedTransformNode: Nullable<TransformNode>;
  14007. /** @hidden */
  14008. _waitingTransformNodeId: Nullable<string>;
  14009. /** @hidden */
  14010. get _matrix(): Matrix;
  14011. /** @hidden */
  14012. set _matrix(value: Matrix);
  14013. /**
  14014. * Create a new bone
  14015. * @param name defines the bone name
  14016. * @param skeleton defines the parent skeleton
  14017. * @param parentBone defines the parent (can be null if the bone is the root)
  14018. * @param localMatrix defines the local matrix
  14019. * @param restPose defines the rest pose matrix
  14020. * @param baseMatrix defines the base matrix
  14021. * @param index defines index of the bone in the hiearchy
  14022. */
  14023. constructor(
  14024. /**
  14025. * defines the bone name
  14026. */
  14027. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14028. /**
  14029. * Gets the current object class name.
  14030. * @return the class name
  14031. */
  14032. getClassName(): string;
  14033. /**
  14034. * Gets the parent skeleton
  14035. * @returns a skeleton
  14036. */
  14037. getSkeleton(): Skeleton;
  14038. /**
  14039. * Gets parent bone
  14040. * @returns a bone or null if the bone is the root of the bone hierarchy
  14041. */
  14042. getParent(): Nullable<Bone>;
  14043. /**
  14044. * Returns an array containing the root bones
  14045. * @returns an array containing the root bones
  14046. */
  14047. getChildren(): Array<Bone>;
  14048. /**
  14049. * Gets the node index in matrix array generated for rendering
  14050. * @returns the node index
  14051. */
  14052. getIndex(): number;
  14053. /**
  14054. * Sets the parent bone
  14055. * @param parent defines the parent (can be null if the bone is the root)
  14056. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14057. */
  14058. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14059. /**
  14060. * Gets the local matrix
  14061. * @returns a matrix
  14062. */
  14063. getLocalMatrix(): Matrix;
  14064. /**
  14065. * Gets the base matrix (initial matrix which remains unchanged)
  14066. * @returns a matrix
  14067. */
  14068. getBaseMatrix(): Matrix;
  14069. /**
  14070. * Gets the rest pose matrix
  14071. * @returns a matrix
  14072. */
  14073. getRestPose(): Matrix;
  14074. /**
  14075. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14076. */
  14077. getWorldMatrix(): Matrix;
  14078. /**
  14079. * Sets the local matrix to rest pose matrix
  14080. */
  14081. returnToRest(): void;
  14082. /**
  14083. * Gets the inverse of the absolute transform matrix.
  14084. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14085. * @returns a matrix
  14086. */
  14087. getInvertedAbsoluteTransform(): Matrix;
  14088. /**
  14089. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14090. * @returns a matrix
  14091. */
  14092. getAbsoluteTransform(): Matrix;
  14093. /**
  14094. * Links with the given transform node.
  14095. * The local matrix of this bone is copied from the transform node every frame.
  14096. * @param transformNode defines the transform node to link to
  14097. */
  14098. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14099. /**
  14100. * Gets the node used to drive the bone's transformation
  14101. * @returns a transform node or null
  14102. */
  14103. getTransformNode(): Nullable<TransformNode>;
  14104. /** Gets or sets current position (in local space) */
  14105. get position(): Vector3;
  14106. set position(newPosition: Vector3);
  14107. /** Gets or sets current rotation (in local space) */
  14108. get rotation(): Vector3;
  14109. set rotation(newRotation: Vector3);
  14110. /** Gets or sets current rotation quaternion (in local space) */
  14111. get rotationQuaternion(): Quaternion;
  14112. set rotationQuaternion(newRotation: Quaternion);
  14113. /** Gets or sets current scaling (in local space) */
  14114. get scaling(): Vector3;
  14115. set scaling(newScaling: Vector3);
  14116. /**
  14117. * Gets the animation properties override
  14118. */
  14119. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14120. private _decompose;
  14121. private _compose;
  14122. /**
  14123. * Update the base and local matrices
  14124. * @param matrix defines the new base or local matrix
  14125. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14126. * @param updateLocalMatrix defines if the local matrix should be updated
  14127. */
  14128. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14129. /** @hidden */
  14130. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14131. /**
  14132. * Flag the bone as dirty (Forcing it to update everything)
  14133. */
  14134. markAsDirty(): void;
  14135. /** @hidden */
  14136. _markAsDirtyAndCompose(): void;
  14137. private _markAsDirtyAndDecompose;
  14138. /**
  14139. * Translate the bone in local or world space
  14140. * @param vec The amount to translate the bone
  14141. * @param space The space that the translation is in
  14142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14143. */
  14144. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14145. /**
  14146. * Set the postion of the bone in local or world space
  14147. * @param position The position to set the bone
  14148. * @param space The space that the position is in
  14149. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14150. */
  14151. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14152. /**
  14153. * Set the absolute position of the bone (world space)
  14154. * @param position The position to set the bone
  14155. * @param mesh The mesh that this bone is attached to
  14156. */
  14157. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14158. /**
  14159. * Scale the bone on the x, y and z axes (in local space)
  14160. * @param x The amount to scale the bone on the x axis
  14161. * @param y The amount to scale the bone on the y axis
  14162. * @param z The amount to scale the bone on the z axis
  14163. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14164. */
  14165. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14166. /**
  14167. * Set the bone scaling in local space
  14168. * @param scale defines the scaling vector
  14169. */
  14170. setScale(scale: Vector3): void;
  14171. /**
  14172. * Gets the current scaling in local space
  14173. * @returns the current scaling vector
  14174. */
  14175. getScale(): Vector3;
  14176. /**
  14177. * Gets the current scaling in local space and stores it in a target vector
  14178. * @param result defines the target vector
  14179. */
  14180. getScaleToRef(result: Vector3): void;
  14181. /**
  14182. * Set the yaw, pitch, and roll of the bone in local or world space
  14183. * @param yaw The rotation of the bone on the y axis
  14184. * @param pitch The rotation of the bone on the x axis
  14185. * @param roll The rotation of the bone on the z axis
  14186. * @param space The space that the axes of rotation are in
  14187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14188. */
  14189. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14190. /**
  14191. * Add a rotation to the bone on an axis in local or world space
  14192. * @param axis The axis to rotate the bone on
  14193. * @param amount The amount to rotate the bone
  14194. * @param space The space that the axis is in
  14195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14196. */
  14197. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14198. /**
  14199. * Set the rotation of the bone to a particular axis angle in local or world space
  14200. * @param axis The axis to rotate the bone on
  14201. * @param angle The angle that the bone should be rotated to
  14202. * @param space The space that the axis is in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. */
  14205. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14206. /**
  14207. * Set the euler rotation of the bone in local of world space
  14208. * @param rotation The euler rotation that the bone should be set to
  14209. * @param space The space that the rotation is in
  14210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14211. */
  14212. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14213. /**
  14214. * Set the quaternion rotation of the bone in local of world space
  14215. * @param quat The quaternion rotation that the bone should be set to
  14216. * @param space The space that the rotation is in
  14217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14218. */
  14219. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14220. /**
  14221. * Set the rotation matrix of the bone in local of world space
  14222. * @param rotMat The rotation matrix that the bone should be set to
  14223. * @param space The space that the rotation is in
  14224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14225. */
  14226. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14227. private _rotateWithMatrix;
  14228. private _getNegativeRotationToRef;
  14229. /**
  14230. * Get the position of the bone in local or world space
  14231. * @param space The space that the returned position is in
  14232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14233. * @returns The position of the bone
  14234. */
  14235. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14236. /**
  14237. * Copy the position of the bone to a vector3 in local or world space
  14238. * @param space The space that the returned position is in
  14239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14240. * @param result The vector3 to copy the position to
  14241. */
  14242. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14243. /**
  14244. * Get the absolute position of the bone (world space)
  14245. * @param mesh The mesh that this bone is attached to
  14246. * @returns The absolute position of the bone
  14247. */
  14248. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14249. /**
  14250. * Copy the absolute position of the bone (world space) to the result param
  14251. * @param mesh The mesh that this bone is attached to
  14252. * @param result The vector3 to copy the absolute position to
  14253. */
  14254. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14255. /**
  14256. * Compute the absolute transforms of this bone and its children
  14257. */
  14258. computeAbsoluteTransforms(): void;
  14259. /**
  14260. * Get the world direction from an axis that is in the local space of the bone
  14261. * @param localAxis The local direction that is used to compute the world direction
  14262. * @param mesh The mesh that this bone is attached to
  14263. * @returns The world direction
  14264. */
  14265. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14266. /**
  14267. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14268. * @param localAxis The local direction that is used to compute the world direction
  14269. * @param mesh The mesh that this bone is attached to
  14270. * @param result The vector3 that the world direction will be copied to
  14271. */
  14272. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14273. /**
  14274. * Get the euler rotation of the bone in local or world space
  14275. * @param space The space that the rotation should be in
  14276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14277. * @returns The euler rotation
  14278. */
  14279. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14280. /**
  14281. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14282. * @param space The space that the rotation should be in
  14283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14284. * @param result The vector3 that the rotation should be copied to
  14285. */
  14286. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14287. /**
  14288. * Get the quaternion rotation of the bone in either local or world space
  14289. * @param space The space that the rotation should be in
  14290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14291. * @returns The quaternion rotation
  14292. */
  14293. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14294. /**
  14295. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14296. * @param space The space that the rotation should be in
  14297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14298. * @param result The quaternion that the rotation should be copied to
  14299. */
  14300. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14301. /**
  14302. * Get the rotation matrix of the bone in local or world space
  14303. * @param space The space that the rotation should be in
  14304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14305. * @returns The rotation matrix
  14306. */
  14307. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14308. /**
  14309. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14310. * @param space The space that the rotation should be in
  14311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14312. * @param result The quaternion that the rotation should be copied to
  14313. */
  14314. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14315. /**
  14316. * Get the world position of a point that is in the local space of the bone
  14317. * @param position The local position
  14318. * @param mesh The mesh that this bone is attached to
  14319. * @returns The world position
  14320. */
  14321. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14322. /**
  14323. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14324. * @param position The local position
  14325. * @param mesh The mesh that this bone is attached to
  14326. * @param result The vector3 that the world position should be copied to
  14327. */
  14328. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14329. /**
  14330. * Get the local position of a point that is in world space
  14331. * @param position The world position
  14332. * @param mesh The mesh that this bone is attached to
  14333. * @returns The local position
  14334. */
  14335. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14336. /**
  14337. * Get the local position of a point that is in world space and copy it to the result param
  14338. * @param position The world position
  14339. * @param mesh The mesh that this bone is attached to
  14340. * @param result The vector3 that the local position should be copied to
  14341. */
  14342. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14343. }
  14344. }
  14345. declare module "babylonjs/Meshes/transformNode" {
  14346. import { DeepImmutable } from "babylonjs/types";
  14347. import { Observable } from "babylonjs/Misc/observable";
  14348. import { Nullable } from "babylonjs/types";
  14349. import { Camera } from "babylonjs/Cameras/camera";
  14350. import { Scene } from "babylonjs/scene";
  14351. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14352. import { Node } from "babylonjs/node";
  14353. import { Bone } from "babylonjs/Bones/bone";
  14354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14355. import { Space } from "babylonjs/Maths/math.axis";
  14356. /**
  14357. * 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.
  14358. * @see https://doc.babylonjs.com/how_to/transformnode
  14359. */
  14360. export class TransformNode extends Node {
  14361. /**
  14362. * Object will not rotate to face the camera
  14363. */
  14364. static BILLBOARDMODE_NONE: number;
  14365. /**
  14366. * Object will rotate to face the camera but only on the x axis
  14367. */
  14368. static BILLBOARDMODE_X: number;
  14369. /**
  14370. * Object will rotate to face the camera but only on the y axis
  14371. */
  14372. static BILLBOARDMODE_Y: number;
  14373. /**
  14374. * Object will rotate to face the camera but only on the z axis
  14375. */
  14376. static BILLBOARDMODE_Z: number;
  14377. /**
  14378. * Object will rotate to face the camera
  14379. */
  14380. static BILLBOARDMODE_ALL: number;
  14381. /**
  14382. * Object will rotate to face the camera's position instead of orientation
  14383. */
  14384. static BILLBOARDMODE_USE_POSITION: number;
  14385. private _forward;
  14386. private _forwardInverted;
  14387. private _up;
  14388. private _right;
  14389. private _rightInverted;
  14390. private _position;
  14391. private _rotation;
  14392. private _rotationQuaternion;
  14393. protected _scaling: Vector3;
  14394. protected _isDirty: boolean;
  14395. private _transformToBoneReferal;
  14396. private _isAbsoluteSynced;
  14397. private _billboardMode;
  14398. /**
  14399. * Gets or sets the billboard mode. Default is 0.
  14400. *
  14401. * | Value | Type | Description |
  14402. * | --- | --- | --- |
  14403. * | 0 | BILLBOARDMODE_NONE | |
  14404. * | 1 | BILLBOARDMODE_X | |
  14405. * | 2 | BILLBOARDMODE_Y | |
  14406. * | 4 | BILLBOARDMODE_Z | |
  14407. * | 7 | BILLBOARDMODE_ALL | |
  14408. *
  14409. */
  14410. get billboardMode(): number;
  14411. set billboardMode(value: number);
  14412. private _preserveParentRotationForBillboard;
  14413. /**
  14414. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14415. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14416. */
  14417. get preserveParentRotationForBillboard(): boolean;
  14418. set preserveParentRotationForBillboard(value: boolean);
  14419. /**
  14420. * 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
  14421. */
  14422. scalingDeterminant: number;
  14423. private _infiniteDistance;
  14424. /**
  14425. * Gets or sets the distance of the object to max, often used by skybox
  14426. */
  14427. get infiniteDistance(): boolean;
  14428. set infiniteDistance(value: boolean);
  14429. /**
  14430. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14431. * By default the system will update normals to compensate
  14432. */
  14433. ignoreNonUniformScaling: boolean;
  14434. /**
  14435. * 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
  14436. */
  14437. reIntegrateRotationIntoRotationQuaternion: boolean;
  14438. /** @hidden */
  14439. _poseMatrix: Nullable<Matrix>;
  14440. /** @hidden */
  14441. _localMatrix: Matrix;
  14442. private _usePivotMatrix;
  14443. private _absolutePosition;
  14444. private _absoluteScaling;
  14445. private _absoluteRotationQuaternion;
  14446. private _pivotMatrix;
  14447. private _pivotMatrixInverse;
  14448. protected _postMultiplyPivotMatrix: boolean;
  14449. protected _isWorldMatrixFrozen: boolean;
  14450. /** @hidden */
  14451. _indexInSceneTransformNodesArray: number;
  14452. /**
  14453. * An event triggered after the world matrix is updated
  14454. */
  14455. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14456. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14457. /**
  14458. * Gets a string identifying the name of the class
  14459. * @returns "TransformNode" string
  14460. */
  14461. getClassName(): string;
  14462. /**
  14463. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14464. */
  14465. get position(): Vector3;
  14466. set position(newPosition: Vector3);
  14467. /**
  14468. * 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)).
  14469. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14470. */
  14471. get rotation(): Vector3;
  14472. set rotation(newRotation: Vector3);
  14473. /**
  14474. * 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)).
  14475. */
  14476. get scaling(): Vector3;
  14477. set scaling(newScaling: Vector3);
  14478. /**
  14479. * 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).
  14480. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14481. */
  14482. get rotationQuaternion(): Nullable<Quaternion>;
  14483. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14484. /**
  14485. * The forward direction of that transform in world space.
  14486. */
  14487. get forward(): Vector3;
  14488. /**
  14489. * The up direction of that transform in world space.
  14490. */
  14491. get up(): Vector3;
  14492. /**
  14493. * The right direction of that transform in world space.
  14494. */
  14495. get right(): Vector3;
  14496. /**
  14497. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14498. * @param matrix the matrix to copy the pose from
  14499. * @returns this TransformNode.
  14500. */
  14501. updatePoseMatrix(matrix: Matrix): TransformNode;
  14502. /**
  14503. * Returns the mesh Pose matrix.
  14504. * @returns the pose matrix
  14505. */
  14506. getPoseMatrix(): Matrix;
  14507. /** @hidden */
  14508. _isSynchronized(): boolean;
  14509. /** @hidden */
  14510. _initCache(): void;
  14511. /**
  14512. * Flag the transform node as dirty (Forcing it to update everything)
  14513. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14514. * @returns this transform node
  14515. */
  14516. markAsDirty(property: string): TransformNode;
  14517. /**
  14518. * Returns the current mesh absolute position.
  14519. * Returns a Vector3.
  14520. */
  14521. get absolutePosition(): Vector3;
  14522. /**
  14523. * Returns the current mesh absolute scaling.
  14524. * Returns a Vector3.
  14525. */
  14526. get absoluteScaling(): Vector3;
  14527. /**
  14528. * Returns the current mesh absolute rotation.
  14529. * Returns a Quaternion.
  14530. */
  14531. get absoluteRotationQuaternion(): Quaternion;
  14532. /**
  14533. * Sets a new matrix to apply before all other transformation
  14534. * @param matrix defines the transform matrix
  14535. * @returns the current TransformNode
  14536. */
  14537. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14538. /**
  14539. * Sets a new pivot matrix to the current node
  14540. * @param matrix defines the new pivot matrix to use
  14541. * @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
  14542. * @returns the current TransformNode
  14543. */
  14544. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14545. /**
  14546. * Returns the mesh pivot matrix.
  14547. * Default : Identity.
  14548. * @returns the matrix
  14549. */
  14550. getPivotMatrix(): Matrix;
  14551. /**
  14552. * Instantiate (when possible) or clone that node with its hierarchy
  14553. * @param newParent defines the new parent to use for the instance (or clone)
  14554. * @param options defines options to configure how copy is done
  14555. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14556. * @returns an instance (or a clone) of the current node with its hiearchy
  14557. */
  14558. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14559. doNotInstantiate: boolean;
  14560. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14561. /**
  14562. * Prevents the World matrix to be computed any longer
  14563. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14564. * @returns the TransformNode.
  14565. */
  14566. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14567. /**
  14568. * Allows back the World matrix computation.
  14569. * @returns the TransformNode.
  14570. */
  14571. unfreezeWorldMatrix(): this;
  14572. /**
  14573. * True if the World matrix has been frozen.
  14574. */
  14575. get isWorldMatrixFrozen(): boolean;
  14576. /**
  14577. * Retuns the mesh absolute position in the World.
  14578. * @returns a Vector3.
  14579. */
  14580. getAbsolutePosition(): Vector3;
  14581. /**
  14582. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14583. * @param absolutePosition the absolute position to set
  14584. * @returns the TransformNode.
  14585. */
  14586. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14587. /**
  14588. * Sets the mesh position in its local space.
  14589. * @param vector3 the position to set in localspace
  14590. * @returns the TransformNode.
  14591. */
  14592. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14593. /**
  14594. * Returns the mesh position in the local space from the current World matrix values.
  14595. * @returns a new Vector3.
  14596. */
  14597. getPositionExpressedInLocalSpace(): Vector3;
  14598. /**
  14599. * Translates the mesh along the passed Vector3 in its local space.
  14600. * @param vector3 the distance to translate in localspace
  14601. * @returns the TransformNode.
  14602. */
  14603. locallyTranslate(vector3: Vector3): TransformNode;
  14604. private static _lookAtVectorCache;
  14605. /**
  14606. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14607. * @param targetPoint the position (must be in same space as current mesh) to look at
  14608. * @param yawCor optional yaw (y-axis) correction in radians
  14609. * @param pitchCor optional pitch (x-axis) correction in radians
  14610. * @param rollCor optional roll (z-axis) correction in radians
  14611. * @param space the choosen space of the target
  14612. * @returns the TransformNode.
  14613. */
  14614. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14615. /**
  14616. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14617. * This Vector3 is expressed in the World space.
  14618. * @param localAxis axis to rotate
  14619. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14620. */
  14621. getDirection(localAxis: Vector3): Vector3;
  14622. /**
  14623. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14624. * localAxis is expressed in the mesh local space.
  14625. * result is computed in the Wordl space from the mesh World matrix.
  14626. * @param localAxis axis to rotate
  14627. * @param result the resulting transformnode
  14628. * @returns this TransformNode.
  14629. */
  14630. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14631. /**
  14632. * Sets this transform node rotation to the given local axis.
  14633. * @param localAxis the axis in local space
  14634. * @param yawCor optional yaw (y-axis) correction in radians
  14635. * @param pitchCor optional pitch (x-axis) correction in radians
  14636. * @param rollCor optional roll (z-axis) correction in radians
  14637. * @returns this TransformNode
  14638. */
  14639. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14640. /**
  14641. * Sets a new pivot point to the current node
  14642. * @param point defines the new pivot point to use
  14643. * @param space defines if the point is in world or local space (local by default)
  14644. * @returns the current TransformNode
  14645. */
  14646. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14647. /**
  14648. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14649. * @returns the pivot point
  14650. */
  14651. getPivotPoint(): Vector3;
  14652. /**
  14653. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14654. * @param result the vector3 to store the result
  14655. * @returns this TransformNode.
  14656. */
  14657. getPivotPointToRef(result: Vector3): TransformNode;
  14658. /**
  14659. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14660. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14661. */
  14662. getAbsolutePivotPoint(): Vector3;
  14663. /**
  14664. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14665. * @param result vector3 to store the result
  14666. * @returns this TransformNode.
  14667. */
  14668. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14669. /**
  14670. * Defines the passed node as the parent of the current node.
  14671. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14672. * @see https://doc.babylonjs.com/how_to/parenting
  14673. * @param node the node ot set as the parent
  14674. * @returns this TransformNode.
  14675. */
  14676. setParent(node: Nullable<Node>): TransformNode;
  14677. private _nonUniformScaling;
  14678. /**
  14679. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14680. */
  14681. get nonUniformScaling(): boolean;
  14682. /** @hidden */
  14683. _updateNonUniformScalingState(value: boolean): boolean;
  14684. /**
  14685. * Attach the current TransformNode to another TransformNode associated with a bone
  14686. * @param bone Bone affecting the TransformNode
  14687. * @param affectedTransformNode TransformNode associated with the bone
  14688. * @returns this object
  14689. */
  14690. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14691. /**
  14692. * Detach the transform node if its associated with a bone
  14693. * @returns this object
  14694. */
  14695. detachFromBone(): TransformNode;
  14696. private static _rotationAxisCache;
  14697. /**
  14698. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14699. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14700. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14701. * The passed axis is also normalized.
  14702. * @param axis the axis to rotate around
  14703. * @param amount the amount to rotate in radians
  14704. * @param space Space to rotate in (Default: local)
  14705. * @returns the TransformNode.
  14706. */
  14707. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14708. /**
  14709. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14710. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14711. * The passed axis is also normalized. .
  14712. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14713. * @param point the point to rotate around
  14714. * @param axis the axis to rotate around
  14715. * @param amount the amount to rotate in radians
  14716. * @returns the TransformNode
  14717. */
  14718. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14719. /**
  14720. * Translates the mesh along the axis vector for the passed distance in the given space.
  14721. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14722. * @param axis the axis to translate in
  14723. * @param distance the distance to translate
  14724. * @param space Space to rotate in (Default: local)
  14725. * @returns the TransformNode.
  14726. */
  14727. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14728. /**
  14729. * Adds a rotation step to the mesh current rotation.
  14730. * x, y, z are Euler angles expressed in radians.
  14731. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14732. * This means this rotation is made in the mesh local space only.
  14733. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14734. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14735. * ```javascript
  14736. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14737. * ```
  14738. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14739. * 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.
  14740. * @param x Rotation to add
  14741. * @param y Rotation to add
  14742. * @param z Rotation to add
  14743. * @returns the TransformNode.
  14744. */
  14745. addRotation(x: number, y: number, z: number): TransformNode;
  14746. /**
  14747. * @hidden
  14748. */
  14749. protected _getEffectiveParent(): Nullable<Node>;
  14750. /**
  14751. * Computes the world matrix of the node
  14752. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14753. * @returns the world matrix
  14754. */
  14755. computeWorldMatrix(force?: boolean): Matrix;
  14756. protected _afterComputeWorldMatrix(): void;
  14757. /**
  14758. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14759. * @param func callback function to add
  14760. *
  14761. * @returns the TransformNode.
  14762. */
  14763. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14764. /**
  14765. * Removes a registered callback function.
  14766. * @param func callback function to remove
  14767. * @returns the TransformNode.
  14768. */
  14769. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14770. /**
  14771. * Gets the position of the current mesh in camera space
  14772. * @param camera defines the camera to use
  14773. * @returns a position
  14774. */
  14775. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14776. /**
  14777. * Returns the distance from the mesh to the active camera
  14778. * @param camera defines the camera to use
  14779. * @returns the distance
  14780. */
  14781. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14782. /**
  14783. * Clone the current transform node
  14784. * @param name Name of the new clone
  14785. * @param newParent New parent for the clone
  14786. * @param doNotCloneChildren Do not clone children hierarchy
  14787. * @returns the new transform node
  14788. */
  14789. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14790. /**
  14791. * Serializes the objects information.
  14792. * @param currentSerializationObject defines the object to serialize in
  14793. * @returns the serialized object
  14794. */
  14795. serialize(currentSerializationObject?: any): any;
  14796. /**
  14797. * Returns a new TransformNode object parsed from the source provided.
  14798. * @param parsedTransformNode is the source.
  14799. * @param scene the scne the object belongs to
  14800. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14801. * @returns a new TransformNode object parsed from the source provided.
  14802. */
  14803. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14804. /**
  14805. * Get all child-transformNodes of this node
  14806. * @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
  14807. * @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
  14808. * @returns an array of TransformNode
  14809. */
  14810. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14811. /**
  14812. * Releases resources associated with this transform node.
  14813. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14814. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14815. */
  14816. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14817. /**
  14818. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14819. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14820. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14821. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14822. * @returns the current mesh
  14823. */
  14824. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14825. private _syncAbsoluteScalingAndRotation;
  14826. }
  14827. }
  14828. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14829. import { Observable } from "babylonjs/Misc/observable";
  14830. import { Nullable } from "babylonjs/types";
  14831. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14832. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14834. import { Ray } from "babylonjs/Culling/ray";
  14835. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14836. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14837. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14838. /**
  14839. * Defines the types of pose enabled controllers that are supported
  14840. */
  14841. export enum PoseEnabledControllerType {
  14842. /**
  14843. * HTC Vive
  14844. */
  14845. VIVE = 0,
  14846. /**
  14847. * Oculus Rift
  14848. */
  14849. OCULUS = 1,
  14850. /**
  14851. * Windows mixed reality
  14852. */
  14853. WINDOWS = 2,
  14854. /**
  14855. * Samsung gear VR
  14856. */
  14857. GEAR_VR = 3,
  14858. /**
  14859. * Google Daydream
  14860. */
  14861. DAYDREAM = 4,
  14862. /**
  14863. * Generic
  14864. */
  14865. GENERIC = 5
  14866. }
  14867. /**
  14868. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14869. */
  14870. export interface MutableGamepadButton {
  14871. /**
  14872. * Value of the button/trigger
  14873. */
  14874. value: number;
  14875. /**
  14876. * If the button/trigger is currently touched
  14877. */
  14878. touched: boolean;
  14879. /**
  14880. * If the button/trigger is currently pressed
  14881. */
  14882. pressed: boolean;
  14883. }
  14884. /**
  14885. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14886. * @hidden
  14887. */
  14888. export interface ExtendedGamepadButton extends GamepadButton {
  14889. /**
  14890. * If the button/trigger is currently pressed
  14891. */
  14892. readonly pressed: boolean;
  14893. /**
  14894. * If the button/trigger is currently touched
  14895. */
  14896. readonly touched: boolean;
  14897. /**
  14898. * Value of the button/trigger
  14899. */
  14900. readonly value: number;
  14901. }
  14902. /** @hidden */
  14903. export interface _GamePadFactory {
  14904. /**
  14905. * Returns wether or not the current gamepad can be created for this type of controller.
  14906. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14907. * @returns true if it can be created, otherwise false
  14908. */
  14909. canCreate(gamepadInfo: any): boolean;
  14910. /**
  14911. * Creates a new instance of the Gamepad.
  14912. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14913. * @returns the new gamepad instance
  14914. */
  14915. create(gamepadInfo: any): Gamepad;
  14916. }
  14917. /**
  14918. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14919. */
  14920. export class PoseEnabledControllerHelper {
  14921. /** @hidden */
  14922. static _ControllerFactories: _GamePadFactory[];
  14923. /** @hidden */
  14924. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14925. /**
  14926. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14927. * @param vrGamepad the gamepad to initialized
  14928. * @returns a vr controller of the type the gamepad identified as
  14929. */
  14930. static InitiateController(vrGamepad: any): Gamepad;
  14931. }
  14932. /**
  14933. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14934. */
  14935. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14936. /**
  14937. * If the controller is used in a webXR session
  14938. */
  14939. isXR: boolean;
  14940. private _deviceRoomPosition;
  14941. private _deviceRoomRotationQuaternion;
  14942. /**
  14943. * The device position in babylon space
  14944. */
  14945. devicePosition: Vector3;
  14946. /**
  14947. * The device rotation in babylon space
  14948. */
  14949. deviceRotationQuaternion: Quaternion;
  14950. /**
  14951. * The scale factor of the device in babylon space
  14952. */
  14953. deviceScaleFactor: number;
  14954. /**
  14955. * (Likely devicePosition should be used instead) The device position in its room space
  14956. */
  14957. position: Vector3;
  14958. /**
  14959. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14960. */
  14961. rotationQuaternion: Quaternion;
  14962. /**
  14963. * The type of controller (Eg. Windows mixed reality)
  14964. */
  14965. controllerType: PoseEnabledControllerType;
  14966. protected _calculatedPosition: Vector3;
  14967. private _calculatedRotation;
  14968. /**
  14969. * The raw pose from the device
  14970. */
  14971. rawPose: DevicePose;
  14972. private _trackPosition;
  14973. private _maxRotationDistFromHeadset;
  14974. private _draggedRoomRotation;
  14975. /**
  14976. * @hidden
  14977. */
  14978. _disableTrackPosition(fixedPosition: Vector3): void;
  14979. /**
  14980. * Internal, the mesh attached to the controller
  14981. * @hidden
  14982. */
  14983. _mesh: Nullable<AbstractMesh>;
  14984. private _poseControlledCamera;
  14985. private _leftHandSystemQuaternion;
  14986. /**
  14987. * Internal, matrix used to convert room space to babylon space
  14988. * @hidden
  14989. */
  14990. _deviceToWorld: Matrix;
  14991. /**
  14992. * Node to be used when casting a ray from the controller
  14993. * @hidden
  14994. */
  14995. _pointingPoseNode: Nullable<TransformNode>;
  14996. /**
  14997. * Name of the child mesh that can be used to cast a ray from the controller
  14998. */
  14999. static readonly POINTING_POSE: string;
  15000. /**
  15001. * Creates a new PoseEnabledController from a gamepad
  15002. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15003. */
  15004. constructor(browserGamepad: any);
  15005. private _workingMatrix;
  15006. /**
  15007. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15008. */
  15009. update(): void;
  15010. /**
  15011. * Updates only the pose device and mesh without doing any button event checking
  15012. */
  15013. protected _updatePoseAndMesh(): void;
  15014. /**
  15015. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15016. * @param poseData raw pose fromthe device
  15017. */
  15018. updateFromDevice(poseData: DevicePose): void;
  15019. /**
  15020. * @hidden
  15021. */
  15022. _meshAttachedObservable: Observable<AbstractMesh>;
  15023. /**
  15024. * Attaches a mesh to the controller
  15025. * @param mesh the mesh to be attached
  15026. */
  15027. attachToMesh(mesh: AbstractMesh): void;
  15028. /**
  15029. * Attaches the controllers mesh to a camera
  15030. * @param camera the camera the mesh should be attached to
  15031. */
  15032. attachToPoseControlledCamera(camera: TargetCamera): void;
  15033. /**
  15034. * Disposes of the controller
  15035. */
  15036. dispose(): void;
  15037. /**
  15038. * The mesh that is attached to the controller
  15039. */
  15040. get mesh(): Nullable<AbstractMesh>;
  15041. /**
  15042. * Gets the ray of the controller in the direction the controller is pointing
  15043. * @param length the length the resulting ray should be
  15044. * @returns a ray in the direction the controller is pointing
  15045. */
  15046. getForwardRay(length?: number): Ray;
  15047. }
  15048. }
  15049. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15050. import { Observable } from "babylonjs/Misc/observable";
  15051. import { Scene } from "babylonjs/scene";
  15052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15053. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15054. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15055. import { Nullable } from "babylonjs/types";
  15056. /**
  15057. * Defines the WebVRController object that represents controllers tracked in 3D space
  15058. */
  15059. export abstract class WebVRController extends PoseEnabledController {
  15060. /**
  15061. * Internal, the default controller model for the controller
  15062. */
  15063. protected _defaultModel: Nullable<AbstractMesh>;
  15064. /**
  15065. * Fired when the trigger state has changed
  15066. */
  15067. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15068. /**
  15069. * Fired when the main button state has changed
  15070. */
  15071. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15072. /**
  15073. * Fired when the secondary button state has changed
  15074. */
  15075. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15076. /**
  15077. * Fired when the pad state has changed
  15078. */
  15079. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15080. /**
  15081. * Fired when controllers stick values have changed
  15082. */
  15083. onPadValuesChangedObservable: Observable<StickValues>;
  15084. /**
  15085. * Array of button availible on the controller
  15086. */
  15087. protected _buttons: Array<MutableGamepadButton>;
  15088. private _onButtonStateChange;
  15089. /**
  15090. * Fired when a controller button's state has changed
  15091. * @param callback the callback containing the button that was modified
  15092. */
  15093. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15094. /**
  15095. * X and Y axis corresponding to the controllers joystick
  15096. */
  15097. pad: StickValues;
  15098. /**
  15099. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15100. */
  15101. hand: string;
  15102. /**
  15103. * The default controller model for the controller
  15104. */
  15105. get defaultModel(): Nullable<AbstractMesh>;
  15106. /**
  15107. * Creates a new WebVRController from a gamepad
  15108. * @param vrGamepad the gamepad that the WebVRController should be created from
  15109. */
  15110. constructor(vrGamepad: any);
  15111. /**
  15112. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15113. */
  15114. update(): void;
  15115. /**
  15116. * Function to be called when a button is modified
  15117. */
  15118. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15119. /**
  15120. * Loads a mesh and attaches it to the controller
  15121. * @param scene the scene the mesh should be added to
  15122. * @param meshLoaded callback for when the mesh has been loaded
  15123. */
  15124. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15125. private _setButtonValue;
  15126. private _changes;
  15127. private _checkChanges;
  15128. /**
  15129. * Disposes of th webVRCOntroller
  15130. */
  15131. dispose(): void;
  15132. }
  15133. }
  15134. declare module "babylonjs/Lights/hemisphericLight" {
  15135. import { Nullable } from "babylonjs/types";
  15136. import { Scene } from "babylonjs/scene";
  15137. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15138. import { Color3 } from "babylonjs/Maths/math.color";
  15139. import { Effect } from "babylonjs/Materials/effect";
  15140. import { Light } from "babylonjs/Lights/light";
  15141. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15142. /**
  15143. * The HemisphericLight simulates the ambient environment light,
  15144. * so the passed direction is the light reflection direction, not the incoming direction.
  15145. */
  15146. export class HemisphericLight extends Light {
  15147. /**
  15148. * The groundColor is the light in the opposite direction to the one specified during creation.
  15149. * 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.
  15150. */
  15151. groundColor: Color3;
  15152. /**
  15153. * The light reflection direction, not the incoming direction.
  15154. */
  15155. direction: Vector3;
  15156. /**
  15157. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15158. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15159. * The HemisphericLight can't cast shadows.
  15160. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15161. * @param name The friendly name of the light
  15162. * @param direction The direction of the light reflection
  15163. * @param scene The scene the light belongs to
  15164. */
  15165. constructor(name: string, direction: Vector3, scene: Scene);
  15166. protected _buildUniformLayout(): void;
  15167. /**
  15168. * Returns the string "HemisphericLight".
  15169. * @return The class name
  15170. */
  15171. getClassName(): string;
  15172. /**
  15173. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15174. * Returns the updated direction.
  15175. * @param target The target the direction should point to
  15176. * @return The computed direction
  15177. */
  15178. setDirectionToTarget(target: Vector3): Vector3;
  15179. /**
  15180. * Returns the shadow generator associated to the light.
  15181. * @returns Always null for hemispheric lights because it does not support shadows.
  15182. */
  15183. getShadowGenerator(): Nullable<IShadowGenerator>;
  15184. /**
  15185. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15186. * @param effect The effect to update
  15187. * @param lightIndex The index of the light in the effect to update
  15188. * @returns The hemispheric light
  15189. */
  15190. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15191. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15192. /**
  15193. * Computes the world matrix of the node
  15194. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15195. * @param useWasUpdatedFlag defines a reserved property
  15196. * @returns the world matrix
  15197. */
  15198. computeWorldMatrix(): Matrix;
  15199. /**
  15200. * Returns the integer 3.
  15201. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15202. */
  15203. getTypeID(): number;
  15204. /**
  15205. * Prepares the list of defines specific to the light type.
  15206. * @param defines the list of defines
  15207. * @param lightIndex defines the index of the light for the effect
  15208. */
  15209. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15210. }
  15211. }
  15212. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15213. /** @hidden */
  15214. export var vrMultiviewToSingleviewPixelShader: {
  15215. name: string;
  15216. shader: string;
  15217. };
  15218. }
  15219. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15220. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15221. import { Scene } from "babylonjs/scene";
  15222. /**
  15223. * Renders to multiple views with a single draw call
  15224. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15225. */
  15226. export class MultiviewRenderTarget extends RenderTargetTexture {
  15227. /**
  15228. * Creates a multiview render target
  15229. * @param scene scene used with the render target
  15230. * @param size the size of the render target (used for each view)
  15231. */
  15232. constructor(scene: Scene, size?: number | {
  15233. width: number;
  15234. height: number;
  15235. } | {
  15236. ratio: number;
  15237. });
  15238. /**
  15239. * @hidden
  15240. * @param faceIndex the face index, if its a cube texture
  15241. */
  15242. _bindFrameBuffer(faceIndex?: number): void;
  15243. /**
  15244. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15245. * @returns the view count
  15246. */
  15247. getViewCount(): number;
  15248. }
  15249. }
  15250. declare module "babylonjs/Maths/math.frustum" {
  15251. import { Matrix } from "babylonjs/Maths/math.vector";
  15252. import { DeepImmutable } from "babylonjs/types";
  15253. import { Plane } from "babylonjs/Maths/math.plane";
  15254. /**
  15255. * Represents a camera frustum
  15256. */
  15257. export class Frustum {
  15258. /**
  15259. * Gets the planes representing the frustum
  15260. * @param transform matrix to be applied to the returned planes
  15261. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15262. */
  15263. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15264. /**
  15265. * Gets the near frustum plane transformed by the transform matrix
  15266. * @param transform transformation matrix to be applied to the resulting frustum plane
  15267. * @param frustumPlane the resuling frustum plane
  15268. */
  15269. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15270. /**
  15271. * Gets the far frustum plane transformed by the transform matrix
  15272. * @param transform transformation matrix to be applied to the resulting frustum plane
  15273. * @param frustumPlane the resuling frustum plane
  15274. */
  15275. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15276. /**
  15277. * Gets the left frustum plane transformed by the transform matrix
  15278. * @param transform transformation matrix to be applied to the resulting frustum plane
  15279. * @param frustumPlane the resuling frustum plane
  15280. */
  15281. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15282. /**
  15283. * Gets the right frustum plane transformed by the transform matrix
  15284. * @param transform transformation matrix to be applied to the resulting frustum plane
  15285. * @param frustumPlane the resuling frustum plane
  15286. */
  15287. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15288. /**
  15289. * Gets the top frustum plane transformed by the transform matrix
  15290. * @param transform transformation matrix to be applied to the resulting frustum plane
  15291. * @param frustumPlane the resuling frustum plane
  15292. */
  15293. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15294. /**
  15295. * Gets the bottom frustum plane transformed by the transform matrix
  15296. * @param transform transformation matrix to be applied to the resulting frustum plane
  15297. * @param frustumPlane the resuling frustum plane
  15298. */
  15299. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15300. /**
  15301. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15302. * @param transform transformation matrix to be applied to the resulting frustum planes
  15303. * @param frustumPlanes the resuling frustum planes
  15304. */
  15305. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15306. }
  15307. }
  15308. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15309. import { Camera } from "babylonjs/Cameras/camera";
  15310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15311. import { Nullable } from "babylonjs/types";
  15312. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15313. import { Matrix } from "babylonjs/Maths/math.vector";
  15314. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15315. module "babylonjs/Engines/engine" {
  15316. interface Engine {
  15317. /**
  15318. * Creates a new multiview render target
  15319. * @param width defines the width of the texture
  15320. * @param height defines the height of the texture
  15321. * @returns the created multiview texture
  15322. */
  15323. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15324. /**
  15325. * Binds a multiview framebuffer to be drawn to
  15326. * @param multiviewTexture texture to bind
  15327. */
  15328. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15329. }
  15330. }
  15331. module "babylonjs/Cameras/camera" {
  15332. interface Camera {
  15333. /**
  15334. * @hidden
  15335. * 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)
  15336. */
  15337. _useMultiviewToSingleView: boolean;
  15338. /**
  15339. * @hidden
  15340. * 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)
  15341. */
  15342. _multiviewTexture: Nullable<RenderTargetTexture>;
  15343. /**
  15344. * @hidden
  15345. * ensures the multiview texture of the camera exists and has the specified width/height
  15346. * @param width height to set on the multiview texture
  15347. * @param height width to set on the multiview texture
  15348. */
  15349. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15350. }
  15351. }
  15352. module "babylonjs/scene" {
  15353. interface Scene {
  15354. /** @hidden */
  15355. _transformMatrixR: Matrix;
  15356. /** @hidden */
  15357. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15358. /** @hidden */
  15359. _createMultiviewUbo(): void;
  15360. /** @hidden */
  15361. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15362. /** @hidden */
  15363. _renderMultiviewToSingleView(camera: Camera): void;
  15364. }
  15365. }
  15366. }
  15367. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15368. import { Camera } from "babylonjs/Cameras/camera";
  15369. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15370. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15371. import "babylonjs/Engines/Extensions/engine.multiview";
  15372. /**
  15373. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15374. * This will not be used for webXR as it supports displaying texture arrays directly
  15375. */
  15376. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15377. /**
  15378. * Initializes a VRMultiviewToSingleview
  15379. * @param name name of the post process
  15380. * @param camera camera to be applied to
  15381. * @param scaleFactor scaling factor to the size of the output texture
  15382. */
  15383. constructor(name: string, camera: Camera, scaleFactor: number);
  15384. }
  15385. }
  15386. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15387. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15388. import { Nullable } from "babylonjs/types";
  15389. import { Size } from "babylonjs/Maths/math.size";
  15390. import { Observable } from "babylonjs/Misc/observable";
  15391. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15392. /**
  15393. * Interface used to define additional presentation attributes
  15394. */
  15395. export interface IVRPresentationAttributes {
  15396. /**
  15397. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15398. */
  15399. highRefreshRate: boolean;
  15400. /**
  15401. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15402. */
  15403. foveationLevel: number;
  15404. }
  15405. module "babylonjs/Engines/engine" {
  15406. interface Engine {
  15407. /** @hidden */
  15408. _vrDisplay: any;
  15409. /** @hidden */
  15410. _vrSupported: boolean;
  15411. /** @hidden */
  15412. _oldSize: Size;
  15413. /** @hidden */
  15414. _oldHardwareScaleFactor: number;
  15415. /** @hidden */
  15416. _vrExclusivePointerMode: boolean;
  15417. /** @hidden */
  15418. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15419. /** @hidden */
  15420. _onVRDisplayPointerRestricted: () => void;
  15421. /** @hidden */
  15422. _onVRDisplayPointerUnrestricted: () => void;
  15423. /** @hidden */
  15424. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15425. /** @hidden */
  15426. _onVrDisplayDisconnect: Nullable<() => void>;
  15427. /** @hidden */
  15428. _onVrDisplayPresentChange: Nullable<() => void>;
  15429. /**
  15430. * Observable signaled when VR display mode changes
  15431. */
  15432. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15433. /**
  15434. * Observable signaled when VR request present is complete
  15435. */
  15436. onVRRequestPresentComplete: Observable<boolean>;
  15437. /**
  15438. * Observable signaled when VR request present starts
  15439. */
  15440. onVRRequestPresentStart: Observable<Engine>;
  15441. /**
  15442. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15443. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15444. */
  15445. isInVRExclusivePointerMode: boolean;
  15446. /**
  15447. * Gets a boolean indicating if a webVR device was detected
  15448. * @returns true if a webVR device was detected
  15449. */
  15450. isVRDevicePresent(): boolean;
  15451. /**
  15452. * Gets the current webVR device
  15453. * @returns the current webVR device (or null)
  15454. */
  15455. getVRDevice(): any;
  15456. /**
  15457. * Initializes a webVR display and starts listening to display change events
  15458. * The onVRDisplayChangedObservable will be notified upon these changes
  15459. * @returns A promise containing a VRDisplay and if vr is supported
  15460. */
  15461. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15462. /** @hidden */
  15463. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15464. /**
  15465. * Gets or sets the presentation attributes used to configure VR rendering
  15466. */
  15467. vrPresentationAttributes?: IVRPresentationAttributes;
  15468. /**
  15469. * Call this function to switch to webVR mode
  15470. * Will do nothing if webVR is not supported or if there is no webVR device
  15471. * @param options the webvr options provided to the camera. mainly used for multiview
  15472. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15473. */
  15474. enableVR(options: WebVROptions): void;
  15475. /** @hidden */
  15476. _onVRFullScreenTriggered(): void;
  15477. }
  15478. }
  15479. }
  15480. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15481. import { Nullable } from "babylonjs/types";
  15482. import { Observable } from "babylonjs/Misc/observable";
  15483. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15484. import { Scene } from "babylonjs/scene";
  15485. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15486. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15487. import { Node } from "babylonjs/node";
  15488. import { Ray } from "babylonjs/Culling/ray";
  15489. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15490. import "babylonjs/Engines/Extensions/engine.webVR";
  15491. /**
  15492. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15493. * IMPORTANT!! The data is right-hand data.
  15494. * @export
  15495. * @interface DevicePose
  15496. */
  15497. export interface DevicePose {
  15498. /**
  15499. * The position of the device, values in array are [x,y,z].
  15500. */
  15501. readonly position: Nullable<Float32Array>;
  15502. /**
  15503. * The linearVelocity of the device, values in array are [x,y,z].
  15504. */
  15505. readonly linearVelocity: Nullable<Float32Array>;
  15506. /**
  15507. * The linearAcceleration of the device, values in array are [x,y,z].
  15508. */
  15509. readonly linearAcceleration: Nullable<Float32Array>;
  15510. /**
  15511. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15512. */
  15513. readonly orientation: Nullable<Float32Array>;
  15514. /**
  15515. * The angularVelocity of the device, values in array are [x,y,z].
  15516. */
  15517. readonly angularVelocity: Nullable<Float32Array>;
  15518. /**
  15519. * The angularAcceleration of the device, values in array are [x,y,z].
  15520. */
  15521. readonly angularAcceleration: Nullable<Float32Array>;
  15522. }
  15523. /**
  15524. * Interface representing a pose controlled object in Babylon.
  15525. * A pose controlled object has both regular pose values as well as pose values
  15526. * from an external device such as a VR head mounted display
  15527. */
  15528. export interface PoseControlled {
  15529. /**
  15530. * The position of the object in babylon space.
  15531. */
  15532. position: Vector3;
  15533. /**
  15534. * The rotation quaternion of the object in babylon space.
  15535. */
  15536. rotationQuaternion: Quaternion;
  15537. /**
  15538. * The position of the device in babylon space.
  15539. */
  15540. devicePosition?: Vector3;
  15541. /**
  15542. * The rotation quaternion of the device in babylon space.
  15543. */
  15544. deviceRotationQuaternion: Quaternion;
  15545. /**
  15546. * The raw pose coming from the device.
  15547. */
  15548. rawPose: Nullable<DevicePose>;
  15549. /**
  15550. * The scale of the device to be used when translating from device space to babylon space.
  15551. */
  15552. deviceScaleFactor: number;
  15553. /**
  15554. * Updates the poseControlled values based on the input device pose.
  15555. * @param poseData the pose data to update the object with
  15556. */
  15557. updateFromDevice(poseData: DevicePose): void;
  15558. }
  15559. /**
  15560. * Set of options to customize the webVRCamera
  15561. */
  15562. export interface WebVROptions {
  15563. /**
  15564. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15565. */
  15566. trackPosition?: boolean;
  15567. /**
  15568. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15569. */
  15570. positionScale?: number;
  15571. /**
  15572. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15573. */
  15574. displayName?: string;
  15575. /**
  15576. * Should the native controller meshes be initialized. (default: true)
  15577. */
  15578. controllerMeshes?: boolean;
  15579. /**
  15580. * Creating a default HemiLight only on controllers. (default: true)
  15581. */
  15582. defaultLightingOnControllers?: boolean;
  15583. /**
  15584. * If you don't want to use the default VR button of the helper. (default: false)
  15585. */
  15586. useCustomVRButton?: boolean;
  15587. /**
  15588. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15589. */
  15590. customVRButton?: HTMLButtonElement;
  15591. /**
  15592. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15593. */
  15594. rayLength?: number;
  15595. /**
  15596. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15597. */
  15598. defaultHeight?: number;
  15599. /**
  15600. * If multiview should be used if availible (default: false)
  15601. */
  15602. useMultiview?: boolean;
  15603. }
  15604. /**
  15605. * This represents a WebVR camera.
  15606. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15607. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15608. */
  15609. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15610. private webVROptions;
  15611. /**
  15612. * @hidden
  15613. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15614. */
  15615. _vrDevice: any;
  15616. /**
  15617. * The rawPose of the vrDevice.
  15618. */
  15619. rawPose: Nullable<DevicePose>;
  15620. private _onVREnabled;
  15621. private _specsVersion;
  15622. private _attached;
  15623. private _frameData;
  15624. protected _descendants: Array<Node>;
  15625. private _deviceRoomPosition;
  15626. /** @hidden */
  15627. _deviceRoomRotationQuaternion: Quaternion;
  15628. private _standingMatrix;
  15629. /**
  15630. * Represents device position in babylon space.
  15631. */
  15632. devicePosition: Vector3;
  15633. /**
  15634. * Represents device rotation in babylon space.
  15635. */
  15636. deviceRotationQuaternion: Quaternion;
  15637. /**
  15638. * The scale of the device to be used when translating from device space to babylon space.
  15639. */
  15640. deviceScaleFactor: number;
  15641. private _deviceToWorld;
  15642. private _worldToDevice;
  15643. /**
  15644. * References to the webVR controllers for the vrDevice.
  15645. */
  15646. controllers: Array<WebVRController>;
  15647. /**
  15648. * Emits an event when a controller is attached.
  15649. */
  15650. onControllersAttachedObservable: Observable<WebVRController[]>;
  15651. /**
  15652. * Emits an event when a controller's mesh has been loaded;
  15653. */
  15654. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15655. /**
  15656. * Emits an event when the HMD's pose has been updated.
  15657. */
  15658. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15659. private _poseSet;
  15660. /**
  15661. * If the rig cameras be used as parent instead of this camera.
  15662. */
  15663. rigParenting: boolean;
  15664. private _lightOnControllers;
  15665. private _defaultHeight?;
  15666. /**
  15667. * Instantiates a WebVRFreeCamera.
  15668. * @param name The name of the WebVRFreeCamera
  15669. * @param position The starting anchor position for the camera
  15670. * @param scene The scene the camera belongs to
  15671. * @param webVROptions a set of customizable options for the webVRCamera
  15672. */
  15673. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15674. /**
  15675. * Gets the device distance from the ground in meters.
  15676. * @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.
  15677. */
  15678. deviceDistanceToRoomGround(): number;
  15679. /**
  15680. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15681. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15682. */
  15683. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15684. /**
  15685. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15686. * @returns A promise with a boolean set to if the standing matrix is supported.
  15687. */
  15688. useStandingMatrixAsync(): Promise<boolean>;
  15689. /**
  15690. * Disposes the camera
  15691. */
  15692. dispose(): void;
  15693. /**
  15694. * Gets a vrController by name.
  15695. * @param name The name of the controller to retreive
  15696. * @returns the controller matching the name specified or null if not found
  15697. */
  15698. getControllerByName(name: string): Nullable<WebVRController>;
  15699. private _leftController;
  15700. /**
  15701. * The controller corresponding to the users left hand.
  15702. */
  15703. get leftController(): Nullable<WebVRController>;
  15704. private _rightController;
  15705. /**
  15706. * The controller corresponding to the users right hand.
  15707. */
  15708. get rightController(): Nullable<WebVRController>;
  15709. /**
  15710. * Casts a ray forward from the vrCamera's gaze.
  15711. * @param length Length of the ray (default: 100)
  15712. * @returns the ray corresponding to the gaze
  15713. */
  15714. getForwardRay(length?: number): Ray;
  15715. /**
  15716. * @hidden
  15717. * Updates the camera based on device's frame data
  15718. */
  15719. _checkInputs(): void;
  15720. /**
  15721. * Updates the poseControlled values based on the input device pose.
  15722. * @param poseData Pose coming from the device
  15723. */
  15724. updateFromDevice(poseData: DevicePose): void;
  15725. private _htmlElementAttached;
  15726. private _detachIfAttached;
  15727. /**
  15728. * WebVR's attach control will start broadcasting frames to the device.
  15729. * Note that in certain browsers (chrome for example) this function must be called
  15730. * within a user-interaction callback. Example:
  15731. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15732. *
  15733. * @param element html element to attach the vrDevice to
  15734. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15735. */
  15736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15737. /**
  15738. * Detaches the camera from the html element and disables VR
  15739. *
  15740. * @param element html element to detach from
  15741. */
  15742. detachControl(element: HTMLElement): void;
  15743. /**
  15744. * @returns the name of this class
  15745. */
  15746. getClassName(): string;
  15747. /**
  15748. * Calls resetPose on the vrDisplay
  15749. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15750. */
  15751. resetToCurrentRotation(): void;
  15752. /**
  15753. * @hidden
  15754. * Updates the rig cameras (left and right eye)
  15755. */
  15756. _updateRigCameras(): void;
  15757. private _workingVector;
  15758. private _oneVector;
  15759. private _workingMatrix;
  15760. private updateCacheCalled;
  15761. private _correctPositionIfNotTrackPosition;
  15762. /**
  15763. * @hidden
  15764. * Updates the cached values of the camera
  15765. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15766. */
  15767. _updateCache(ignoreParentClass?: boolean): void;
  15768. /**
  15769. * @hidden
  15770. * Get current device position in babylon world
  15771. */
  15772. _computeDevicePosition(): void;
  15773. /**
  15774. * Updates the current device position and rotation in the babylon world
  15775. */
  15776. update(): void;
  15777. /**
  15778. * @hidden
  15779. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15780. * @returns an identity matrix
  15781. */
  15782. _getViewMatrix(): Matrix;
  15783. private _tmpMatrix;
  15784. /**
  15785. * This function is called by the two RIG cameras.
  15786. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15787. * @hidden
  15788. */
  15789. _getWebVRViewMatrix(): Matrix;
  15790. /** @hidden */
  15791. _getWebVRProjectionMatrix(): Matrix;
  15792. private _onGamepadConnectedObserver;
  15793. private _onGamepadDisconnectedObserver;
  15794. private _updateCacheWhenTrackingDisabledObserver;
  15795. /**
  15796. * Initializes the controllers and their meshes
  15797. */
  15798. initControllers(): void;
  15799. }
  15800. }
  15801. declare module "babylonjs/PostProcesses/postProcess" {
  15802. import { Nullable } from "babylonjs/types";
  15803. import { SmartArray } from "babylonjs/Misc/smartArray";
  15804. import { Observable } from "babylonjs/Misc/observable";
  15805. import { Vector2 } from "babylonjs/Maths/math.vector";
  15806. import { Camera } from "babylonjs/Cameras/camera";
  15807. import { Effect } from "babylonjs/Materials/effect";
  15808. import "babylonjs/Shaders/postprocess.vertex";
  15809. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15810. import { Engine } from "babylonjs/Engines/engine";
  15811. import { Color4 } from "babylonjs/Maths/math.color";
  15812. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15813. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15814. /**
  15815. * Size options for a post process
  15816. */
  15817. export type PostProcessOptions = {
  15818. width: number;
  15819. height: number;
  15820. };
  15821. /**
  15822. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15823. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15824. */
  15825. export class PostProcess {
  15826. /** Name of the PostProcess. */
  15827. name: string;
  15828. /**
  15829. * Gets or sets the unique id of the post process
  15830. */
  15831. uniqueId: number;
  15832. /**
  15833. * Width of the texture to apply the post process on
  15834. */
  15835. width: number;
  15836. /**
  15837. * Height of the texture to apply the post process on
  15838. */
  15839. height: number;
  15840. /**
  15841. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15842. * @hidden
  15843. */
  15844. _outputTexture: Nullable<InternalTexture>;
  15845. /**
  15846. * Sampling mode used by the shader
  15847. * See https://doc.babylonjs.com/classes/3.1/texture
  15848. */
  15849. renderTargetSamplingMode: number;
  15850. /**
  15851. * Clear color to use when screen clearing
  15852. */
  15853. clearColor: Color4;
  15854. /**
  15855. * If the buffer needs to be cleared before applying the post process. (default: true)
  15856. * Should be set to false if shader will overwrite all previous pixels.
  15857. */
  15858. autoClear: boolean;
  15859. /**
  15860. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15861. */
  15862. alphaMode: number;
  15863. /**
  15864. * Sets the setAlphaBlendConstants of the babylon engine
  15865. */
  15866. alphaConstants: Color4;
  15867. /**
  15868. * Animations to be used for the post processing
  15869. */
  15870. animations: import("babylonjs/Animations/animation").Animation[];
  15871. /**
  15872. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15873. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15874. */
  15875. enablePixelPerfectMode: boolean;
  15876. /**
  15877. * Force the postprocess to be applied without taking in account viewport
  15878. */
  15879. forceFullscreenViewport: boolean;
  15880. /**
  15881. * List of inspectable custom properties (used by the Inspector)
  15882. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15883. */
  15884. inspectableCustomProperties: IInspectable[];
  15885. /**
  15886. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15887. *
  15888. * | Value | Type | Description |
  15889. * | ----- | ----------------------------------- | ----------- |
  15890. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15891. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15892. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15893. *
  15894. */
  15895. scaleMode: number;
  15896. /**
  15897. * Force textures to be a power of two (default: false)
  15898. */
  15899. alwaysForcePOT: boolean;
  15900. private _samples;
  15901. /**
  15902. * Number of sample textures (default: 1)
  15903. */
  15904. get samples(): number;
  15905. set samples(n: number);
  15906. /**
  15907. * Modify the scale of the post process to be the same as the viewport (default: false)
  15908. */
  15909. adaptScaleToCurrentViewport: boolean;
  15910. private _camera;
  15911. private _scene;
  15912. private _engine;
  15913. private _options;
  15914. private _reusable;
  15915. private _textureType;
  15916. /**
  15917. * Smart array of input and output textures for the post process.
  15918. * @hidden
  15919. */
  15920. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15921. /**
  15922. * The index in _textures that corresponds to the output texture.
  15923. * @hidden
  15924. */
  15925. _currentRenderTextureInd: number;
  15926. private _effect;
  15927. private _samplers;
  15928. private _fragmentUrl;
  15929. private _vertexUrl;
  15930. private _parameters;
  15931. private _scaleRatio;
  15932. protected _indexParameters: any;
  15933. private _shareOutputWithPostProcess;
  15934. private _texelSize;
  15935. private _forcedOutputTexture;
  15936. /**
  15937. * Returns the fragment url or shader name used in the post process.
  15938. * @returns the fragment url or name in the shader store.
  15939. */
  15940. getEffectName(): string;
  15941. /**
  15942. * An event triggered when the postprocess is activated.
  15943. */
  15944. onActivateObservable: Observable<Camera>;
  15945. private _onActivateObserver;
  15946. /**
  15947. * A function that is added to the onActivateObservable
  15948. */
  15949. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15950. /**
  15951. * An event triggered when the postprocess changes its size.
  15952. */
  15953. onSizeChangedObservable: Observable<PostProcess>;
  15954. private _onSizeChangedObserver;
  15955. /**
  15956. * A function that is added to the onSizeChangedObservable
  15957. */
  15958. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15959. /**
  15960. * An event triggered when the postprocess applies its effect.
  15961. */
  15962. onApplyObservable: Observable<Effect>;
  15963. private _onApplyObserver;
  15964. /**
  15965. * A function that is added to the onApplyObservable
  15966. */
  15967. set onApply(callback: (effect: Effect) => void);
  15968. /**
  15969. * An event triggered before rendering the postprocess
  15970. */
  15971. onBeforeRenderObservable: Observable<Effect>;
  15972. private _onBeforeRenderObserver;
  15973. /**
  15974. * A function that is added to the onBeforeRenderObservable
  15975. */
  15976. set onBeforeRender(callback: (effect: Effect) => void);
  15977. /**
  15978. * An event triggered after rendering the postprocess
  15979. */
  15980. onAfterRenderObservable: Observable<Effect>;
  15981. private _onAfterRenderObserver;
  15982. /**
  15983. * A function that is added to the onAfterRenderObservable
  15984. */
  15985. set onAfterRender(callback: (efect: Effect) => void);
  15986. /**
  15987. * 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
  15988. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15989. */
  15990. get inputTexture(): InternalTexture;
  15991. set inputTexture(value: InternalTexture);
  15992. /**
  15993. * Gets the camera which post process is applied to.
  15994. * @returns The camera the post process is applied to.
  15995. */
  15996. getCamera(): Camera;
  15997. /**
  15998. * Gets the texel size of the postprocess.
  15999. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16000. */
  16001. get texelSize(): Vector2;
  16002. /**
  16003. * Creates a new instance PostProcess
  16004. * @param name The name of the PostProcess.
  16005. * @param fragmentUrl The url of the fragment shader to be used.
  16006. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16007. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16008. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16009. * @param camera The camera to apply the render pass to.
  16010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16011. * @param engine The engine which the post process will be applied. (default: current engine)
  16012. * @param reusable If the post process can be reused on the same frame. (default: false)
  16013. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16014. * @param textureType Type of textures used when performing the post process. (default: 0)
  16015. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16016. * @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
  16017. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16018. */
  16019. constructor(
  16020. /** Name of the PostProcess. */
  16021. 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);
  16022. /**
  16023. * Gets a string idenfifying the name of the class
  16024. * @returns "PostProcess" string
  16025. */
  16026. getClassName(): string;
  16027. /**
  16028. * Gets the engine which this post process belongs to.
  16029. * @returns The engine the post process was enabled with.
  16030. */
  16031. getEngine(): Engine;
  16032. /**
  16033. * The effect that is created when initializing the post process.
  16034. * @returns The created effect corresponding the the postprocess.
  16035. */
  16036. getEffect(): Effect;
  16037. /**
  16038. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16039. * @param postProcess The post process to share the output with.
  16040. * @returns This post process.
  16041. */
  16042. shareOutputWith(postProcess: PostProcess): PostProcess;
  16043. /**
  16044. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16045. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16046. */
  16047. useOwnOutput(): void;
  16048. /**
  16049. * Updates the effect with the current post process compile time values and recompiles the shader.
  16050. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16051. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16052. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16053. * @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
  16054. * @param onCompiled Called when the shader has been compiled.
  16055. * @param onError Called if there is an error when compiling a shader.
  16056. */
  16057. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16058. /**
  16059. * The post process is reusable if it can be used multiple times within one frame.
  16060. * @returns If the post process is reusable
  16061. */
  16062. isReusable(): boolean;
  16063. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16064. markTextureDirty(): void;
  16065. /**
  16066. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16067. * 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.
  16068. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16069. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16070. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16071. * @returns The target texture that was bound to be written to.
  16072. */
  16073. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16074. /**
  16075. * If the post process is supported.
  16076. */
  16077. get isSupported(): boolean;
  16078. /**
  16079. * The aspect ratio of the output texture.
  16080. */
  16081. get aspectRatio(): number;
  16082. /**
  16083. * Get a value indicating if the post-process is ready to be used
  16084. * @returns true if the post-process is ready (shader is compiled)
  16085. */
  16086. isReady(): boolean;
  16087. /**
  16088. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16089. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16090. */
  16091. apply(): Nullable<Effect>;
  16092. private _disposeTextures;
  16093. /**
  16094. * Disposes the post process.
  16095. * @param camera The camera to dispose the post process on.
  16096. */
  16097. dispose(camera?: Camera): void;
  16098. }
  16099. }
  16100. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16101. /** @hidden */
  16102. export var kernelBlurVaryingDeclaration: {
  16103. name: string;
  16104. shader: string;
  16105. };
  16106. }
  16107. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16108. /** @hidden */
  16109. export var kernelBlurFragment: {
  16110. name: string;
  16111. shader: string;
  16112. };
  16113. }
  16114. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16115. /** @hidden */
  16116. export var kernelBlurFragment2: {
  16117. name: string;
  16118. shader: string;
  16119. };
  16120. }
  16121. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16122. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16123. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16124. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16125. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16126. /** @hidden */
  16127. export var kernelBlurPixelShader: {
  16128. name: string;
  16129. shader: string;
  16130. };
  16131. }
  16132. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16133. /** @hidden */
  16134. export var kernelBlurVertex: {
  16135. name: string;
  16136. shader: string;
  16137. };
  16138. }
  16139. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16140. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16141. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16142. /** @hidden */
  16143. export var kernelBlurVertexShader: {
  16144. name: string;
  16145. shader: string;
  16146. };
  16147. }
  16148. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16149. import { Vector2 } from "babylonjs/Maths/math.vector";
  16150. import { Nullable } from "babylonjs/types";
  16151. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16152. import { Camera } from "babylonjs/Cameras/camera";
  16153. import { Effect } from "babylonjs/Materials/effect";
  16154. import { Engine } from "babylonjs/Engines/engine";
  16155. import "babylonjs/Shaders/kernelBlur.fragment";
  16156. import "babylonjs/Shaders/kernelBlur.vertex";
  16157. /**
  16158. * The Blur Post Process which blurs an image based on a kernel and direction.
  16159. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16160. */
  16161. export class BlurPostProcess extends PostProcess {
  16162. /** The direction in which to blur the image. */
  16163. direction: Vector2;
  16164. private blockCompilation;
  16165. protected _kernel: number;
  16166. protected _idealKernel: number;
  16167. protected _packedFloat: boolean;
  16168. private _staticDefines;
  16169. /**
  16170. * Sets the length in pixels of the blur sample region
  16171. */
  16172. set kernel(v: number);
  16173. /**
  16174. * Gets the length in pixels of the blur sample region
  16175. */
  16176. get kernel(): number;
  16177. /**
  16178. * Sets wether or not the blur needs to unpack/repack floats
  16179. */
  16180. set packedFloat(v: boolean);
  16181. /**
  16182. * Gets wether or not the blur is unpacking/repacking floats
  16183. */
  16184. get packedFloat(): boolean;
  16185. /**
  16186. * Creates a new instance BlurPostProcess
  16187. * @param name The name of the effect.
  16188. * @param direction The direction in which to blur the image.
  16189. * @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.
  16190. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16191. * @param camera The camera to apply the render pass to.
  16192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16193. * @param engine The engine which the post process will be applied. (default: current engine)
  16194. * @param reusable If the post process can be reused on the same frame. (default: false)
  16195. * @param textureType Type of textures used when performing the post process. (default: 0)
  16196. * @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)
  16197. */
  16198. constructor(name: string,
  16199. /** The direction in which to blur the image. */
  16200. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16201. /**
  16202. * Updates the effect with the current post process compile time values and recompiles the shader.
  16203. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16204. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16205. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16206. * @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
  16207. * @param onCompiled Called when the shader has been compiled.
  16208. * @param onError Called if there is an error when compiling a shader.
  16209. */
  16210. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16211. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16212. /**
  16213. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16214. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16215. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16216. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16217. * The gaps between physical kernels are compensated for in the weighting of the samples
  16218. * @param idealKernel Ideal blur kernel.
  16219. * @return Nearest best kernel.
  16220. */
  16221. protected _nearestBestKernel(idealKernel: number): number;
  16222. /**
  16223. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16224. * @param x The point on the Gaussian distribution to sample.
  16225. * @return the value of the Gaussian function at x.
  16226. */
  16227. protected _gaussianWeight(x: number): number;
  16228. /**
  16229. * Generates a string that can be used as a floating point number in GLSL.
  16230. * @param x Value to print.
  16231. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16232. * @return GLSL float string.
  16233. */
  16234. protected _glslFloat(x: number, decimalFigures?: number): string;
  16235. }
  16236. }
  16237. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16238. import { Scene } from "babylonjs/scene";
  16239. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16240. import { Plane } from "babylonjs/Maths/math.plane";
  16241. /**
  16242. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16243. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16244. * You can then easily use it as a reflectionTexture on a flat surface.
  16245. * In case the surface is not a plane, please consider relying on reflection probes.
  16246. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16247. */
  16248. export class MirrorTexture extends RenderTargetTexture {
  16249. private scene;
  16250. /**
  16251. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16252. * 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.
  16253. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16254. */
  16255. mirrorPlane: Plane;
  16256. /**
  16257. * Define the blur ratio used to blur the reflection if needed.
  16258. */
  16259. set blurRatio(value: number);
  16260. get blurRatio(): number;
  16261. /**
  16262. * Define the adaptive blur kernel used to blur the reflection if needed.
  16263. * This will autocompute the closest best match for the `blurKernel`
  16264. */
  16265. set adaptiveBlurKernel(value: number);
  16266. /**
  16267. * Define the blur kernel used to blur the reflection if needed.
  16268. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16269. */
  16270. set blurKernel(value: number);
  16271. /**
  16272. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16273. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16274. */
  16275. set blurKernelX(value: number);
  16276. get blurKernelX(): number;
  16277. /**
  16278. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16279. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16280. */
  16281. set blurKernelY(value: number);
  16282. get blurKernelY(): number;
  16283. private _autoComputeBlurKernel;
  16284. protected _onRatioRescale(): void;
  16285. private _updateGammaSpace;
  16286. private _imageProcessingConfigChangeObserver;
  16287. private _transformMatrix;
  16288. private _mirrorMatrix;
  16289. private _savedViewMatrix;
  16290. private _blurX;
  16291. private _blurY;
  16292. private _adaptiveBlurKernel;
  16293. private _blurKernelX;
  16294. private _blurKernelY;
  16295. private _blurRatio;
  16296. /**
  16297. * Instantiates a Mirror Texture.
  16298. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16299. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16300. * You can then easily use it as a reflectionTexture on a flat surface.
  16301. * In case the surface is not a plane, please consider relying on reflection probes.
  16302. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16303. * @param name
  16304. * @param size
  16305. * @param scene
  16306. * @param generateMipMaps
  16307. * @param type
  16308. * @param samplingMode
  16309. * @param generateDepthBuffer
  16310. */
  16311. constructor(name: string, size: number | {
  16312. width: number;
  16313. height: number;
  16314. } | {
  16315. ratio: number;
  16316. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16317. private _preparePostProcesses;
  16318. /**
  16319. * Clone the mirror texture.
  16320. * @returns the cloned texture
  16321. */
  16322. clone(): MirrorTexture;
  16323. /**
  16324. * Serialize the texture to a JSON representation you could use in Parse later on
  16325. * @returns the serialized JSON representation
  16326. */
  16327. serialize(): any;
  16328. /**
  16329. * Dispose the texture and release its associated resources.
  16330. */
  16331. dispose(): void;
  16332. }
  16333. }
  16334. declare module "babylonjs/Materials/Textures/texture" {
  16335. import { Observable } from "babylonjs/Misc/observable";
  16336. import { Nullable } from "babylonjs/types";
  16337. import { Matrix } from "babylonjs/Maths/math.vector";
  16338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16339. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16340. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16341. import { Scene } from "babylonjs/scene";
  16342. /**
  16343. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16344. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16345. */
  16346. export class Texture extends BaseTexture {
  16347. /**
  16348. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16349. */
  16350. static SerializeBuffers: boolean;
  16351. /** @hidden */
  16352. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16353. /** @hidden */
  16354. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16355. /** @hidden */
  16356. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16357. /** nearest is mag = nearest and min = nearest and mip = linear */
  16358. static readonly NEAREST_SAMPLINGMODE: number;
  16359. /** nearest is mag = nearest and min = nearest and mip = linear */
  16360. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16361. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16362. static readonly BILINEAR_SAMPLINGMODE: number;
  16363. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16364. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16365. /** Trilinear is mag = linear and min = linear and mip = linear */
  16366. static readonly TRILINEAR_SAMPLINGMODE: number;
  16367. /** Trilinear is mag = linear and min = linear and mip = linear */
  16368. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16369. /** mag = nearest and min = nearest and mip = nearest */
  16370. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16371. /** mag = nearest and min = linear and mip = nearest */
  16372. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16373. /** mag = nearest and min = linear and mip = linear */
  16374. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16375. /** mag = nearest and min = linear and mip = none */
  16376. static readonly NEAREST_LINEAR: number;
  16377. /** mag = nearest and min = nearest and mip = none */
  16378. static readonly NEAREST_NEAREST: number;
  16379. /** mag = linear and min = nearest and mip = nearest */
  16380. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16381. /** mag = linear and min = nearest and mip = linear */
  16382. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16383. /** mag = linear and min = linear and mip = none */
  16384. static readonly LINEAR_LINEAR: number;
  16385. /** mag = linear and min = nearest and mip = none */
  16386. static readonly LINEAR_NEAREST: number;
  16387. /** Explicit coordinates mode */
  16388. static readonly EXPLICIT_MODE: number;
  16389. /** Spherical coordinates mode */
  16390. static readonly SPHERICAL_MODE: number;
  16391. /** Planar coordinates mode */
  16392. static readonly PLANAR_MODE: number;
  16393. /** Cubic coordinates mode */
  16394. static readonly CUBIC_MODE: number;
  16395. /** Projection coordinates mode */
  16396. static readonly PROJECTION_MODE: number;
  16397. /** Inverse Cubic coordinates mode */
  16398. static readonly SKYBOX_MODE: number;
  16399. /** Inverse Cubic coordinates mode */
  16400. static readonly INVCUBIC_MODE: number;
  16401. /** Equirectangular coordinates mode */
  16402. static readonly EQUIRECTANGULAR_MODE: number;
  16403. /** Equirectangular Fixed coordinates mode */
  16404. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16405. /** Equirectangular Fixed Mirrored coordinates mode */
  16406. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16407. /** Texture is not repeating outside of 0..1 UVs */
  16408. static readonly CLAMP_ADDRESSMODE: number;
  16409. /** Texture is repeating outside of 0..1 UVs */
  16410. static readonly WRAP_ADDRESSMODE: number;
  16411. /** Texture is repeating and mirrored */
  16412. static readonly MIRROR_ADDRESSMODE: number;
  16413. /**
  16414. * 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
  16415. */
  16416. static UseSerializedUrlIfAny: boolean;
  16417. /**
  16418. * Define the url of the texture.
  16419. */
  16420. url: Nullable<string>;
  16421. /**
  16422. * Define an offset on the texture to offset the u coordinates of the UVs
  16423. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16424. */
  16425. uOffset: number;
  16426. /**
  16427. * Define an offset on the texture to offset the v coordinates of the UVs
  16428. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16429. */
  16430. vOffset: number;
  16431. /**
  16432. * Define an offset on the texture to scale the u coordinates of the UVs
  16433. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16434. */
  16435. uScale: number;
  16436. /**
  16437. * Define an offset on the texture to scale the v coordinates of the UVs
  16438. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16439. */
  16440. vScale: number;
  16441. /**
  16442. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16443. * @see http://doc.babylonjs.com/how_to/more_materials
  16444. */
  16445. uAng: number;
  16446. /**
  16447. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16448. * @see http://doc.babylonjs.com/how_to/more_materials
  16449. */
  16450. vAng: number;
  16451. /**
  16452. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16453. * @see http://doc.babylonjs.com/how_to/more_materials
  16454. */
  16455. wAng: number;
  16456. /**
  16457. * Defines the center of rotation (U)
  16458. */
  16459. uRotationCenter: number;
  16460. /**
  16461. * Defines the center of rotation (V)
  16462. */
  16463. vRotationCenter: number;
  16464. /**
  16465. * Defines the center of rotation (W)
  16466. */
  16467. wRotationCenter: number;
  16468. /**
  16469. * Are mip maps generated for this texture or not.
  16470. */
  16471. get noMipmap(): boolean;
  16472. /**
  16473. * List of inspectable custom properties (used by the Inspector)
  16474. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16475. */
  16476. inspectableCustomProperties: Nullable<IInspectable[]>;
  16477. private _noMipmap;
  16478. /** @hidden */
  16479. _invertY: boolean;
  16480. private _rowGenerationMatrix;
  16481. private _cachedTextureMatrix;
  16482. private _projectionModeMatrix;
  16483. private _t0;
  16484. private _t1;
  16485. private _t2;
  16486. private _cachedUOffset;
  16487. private _cachedVOffset;
  16488. private _cachedUScale;
  16489. private _cachedVScale;
  16490. private _cachedUAng;
  16491. private _cachedVAng;
  16492. private _cachedWAng;
  16493. private _cachedProjectionMatrixId;
  16494. private _cachedCoordinatesMode;
  16495. /** @hidden */
  16496. protected _initialSamplingMode: number;
  16497. /** @hidden */
  16498. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16499. private _deleteBuffer;
  16500. protected _format: Nullable<number>;
  16501. private _delayedOnLoad;
  16502. private _delayedOnError;
  16503. private _mimeType?;
  16504. /**
  16505. * Observable triggered once the texture has been loaded.
  16506. */
  16507. onLoadObservable: Observable<Texture>;
  16508. protected _isBlocking: boolean;
  16509. /**
  16510. * Is the texture preventing material to render while loading.
  16511. * If false, a default texture will be used instead of the loading one during the preparation step.
  16512. */
  16513. set isBlocking(value: boolean);
  16514. get isBlocking(): boolean;
  16515. /**
  16516. * Get the current sampling mode associated with the texture.
  16517. */
  16518. get samplingMode(): number;
  16519. /**
  16520. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16521. */
  16522. get invertY(): boolean;
  16523. /**
  16524. * Instantiates a new texture.
  16525. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16526. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16527. * @param url defines the url of the picture to load as a texture
  16528. * @param scene defines the scene or engine the texture will belong to
  16529. * @param noMipmap defines if the texture will require mip maps or not
  16530. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16531. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16532. * @param onLoad defines a callback triggered when the texture has been loaded
  16533. * @param onError defines a callback triggered when an error occurred during the loading session
  16534. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16535. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16536. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16537. * @param mimeType defines an optional mime type information
  16538. */
  16539. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16540. /**
  16541. * Update the url (and optional buffer) of this texture if url was null during construction.
  16542. * @param url the url of the texture
  16543. * @param buffer the buffer of the texture (defaults to null)
  16544. * @param onLoad callback called when the texture is loaded (defaults to null)
  16545. */
  16546. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16547. /**
  16548. * Finish the loading sequence of a texture flagged as delayed load.
  16549. * @hidden
  16550. */
  16551. delayLoad(): void;
  16552. private _prepareRowForTextureGeneration;
  16553. /**
  16554. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16555. * @returns the transform matrix of the texture.
  16556. */
  16557. getTextureMatrix(uBase?: number): Matrix;
  16558. /**
  16559. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16560. * @returns The reflection texture transform
  16561. */
  16562. getReflectionTextureMatrix(): Matrix;
  16563. /**
  16564. * Clones the texture.
  16565. * @returns the cloned texture
  16566. */
  16567. clone(): Texture;
  16568. /**
  16569. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16570. * @returns The JSON representation of the texture
  16571. */
  16572. serialize(): any;
  16573. /**
  16574. * Get the current class name of the texture useful for serialization or dynamic coding.
  16575. * @returns "Texture"
  16576. */
  16577. getClassName(): string;
  16578. /**
  16579. * Dispose the texture and release its associated resources.
  16580. */
  16581. dispose(): void;
  16582. /**
  16583. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16584. * @param parsedTexture Define the JSON representation of the texture
  16585. * @param scene Define the scene the parsed texture should be instantiated in
  16586. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16587. * @returns The parsed texture if successful
  16588. */
  16589. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16590. /**
  16591. * Creates a texture from its base 64 representation.
  16592. * @param data Define the base64 payload without the data: prefix
  16593. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16594. * @param scene Define the scene the texture should belong to
  16595. * @param noMipmap Forces the texture to not create mip map information if true
  16596. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16597. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16598. * @param onLoad define a callback triggered when the texture has been loaded
  16599. * @param onError define a callback triggered when an error occurred during the loading session
  16600. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16601. * @returns the created texture
  16602. */
  16603. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16604. /**
  16605. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16606. * @param data Define the base64 payload without the data: prefix
  16607. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16608. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16609. * @param scene Define the scene the texture should belong to
  16610. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16611. * @param noMipmap Forces the texture to not create mip map information if true
  16612. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16613. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16614. * @param onLoad define a callback triggered when the texture has been loaded
  16615. * @param onError define a callback triggered when an error occurred during the loading session
  16616. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16617. * @returns the created texture
  16618. */
  16619. 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;
  16620. }
  16621. }
  16622. declare module "babylonjs/PostProcesses/postProcessManager" {
  16623. import { Nullable } from "babylonjs/types";
  16624. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16625. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16626. import { Scene } from "babylonjs/scene";
  16627. /**
  16628. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16629. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16630. */
  16631. export class PostProcessManager {
  16632. private _scene;
  16633. private _indexBuffer;
  16634. private _vertexBuffers;
  16635. /**
  16636. * Creates a new instance PostProcess
  16637. * @param scene The scene that the post process is associated with.
  16638. */
  16639. constructor(scene: Scene);
  16640. private _prepareBuffers;
  16641. private _buildIndexBuffer;
  16642. /**
  16643. * Rebuilds the vertex buffers of the manager.
  16644. * @hidden
  16645. */
  16646. _rebuild(): void;
  16647. /**
  16648. * Prepares a frame to be run through a post process.
  16649. * @param sourceTexture The input texture to the post procesess. (default: null)
  16650. * @param postProcesses An array of post processes to be run. (default: null)
  16651. * @returns True if the post processes were able to be run.
  16652. * @hidden
  16653. */
  16654. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16655. /**
  16656. * Manually render a set of post processes to a texture.
  16657. * @param postProcesses An array of post processes to be run.
  16658. * @param targetTexture The target texture to render to.
  16659. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16660. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16661. * @param lodLevel defines which lod of the texture to render to
  16662. */
  16663. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16664. /**
  16665. * Finalize the result of the output of the postprocesses.
  16666. * @param doNotPresent If true the result will not be displayed to the screen.
  16667. * @param targetTexture The target texture to render to.
  16668. * @param faceIndex The index of the face to bind the target texture to.
  16669. * @param postProcesses The array of post processes to render.
  16670. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16671. * @hidden
  16672. */
  16673. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16674. /**
  16675. * Disposes of the post process manager.
  16676. */
  16677. dispose(): void;
  16678. }
  16679. }
  16680. declare module "babylonjs/Misc/gradients" {
  16681. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16682. /** Interface used by value gradients (color, factor, ...) */
  16683. export interface IValueGradient {
  16684. /**
  16685. * Gets or sets the gradient value (between 0 and 1)
  16686. */
  16687. gradient: number;
  16688. }
  16689. /** Class used to store color4 gradient */
  16690. export class ColorGradient implements IValueGradient {
  16691. /**
  16692. * Gets or sets the gradient value (between 0 and 1)
  16693. */
  16694. gradient: number;
  16695. /**
  16696. * Gets or sets first associated color
  16697. */
  16698. color1: Color4;
  16699. /**
  16700. * Gets or sets second associated color
  16701. */
  16702. color2?: Color4;
  16703. /**
  16704. * Will get a color picked randomly between color1 and color2.
  16705. * If color2 is undefined then color1 will be used
  16706. * @param result defines the target Color4 to store the result in
  16707. */
  16708. getColorToRef(result: Color4): void;
  16709. }
  16710. /** Class used to store color 3 gradient */
  16711. export class Color3Gradient implements IValueGradient {
  16712. /**
  16713. * Gets or sets the gradient value (between 0 and 1)
  16714. */
  16715. gradient: number;
  16716. /**
  16717. * Gets or sets the associated color
  16718. */
  16719. color: Color3;
  16720. }
  16721. /** Class used to store factor gradient */
  16722. export class FactorGradient implements IValueGradient {
  16723. /**
  16724. * Gets or sets the gradient value (between 0 and 1)
  16725. */
  16726. gradient: number;
  16727. /**
  16728. * Gets or sets first associated factor
  16729. */
  16730. factor1: number;
  16731. /**
  16732. * Gets or sets second associated factor
  16733. */
  16734. factor2?: number;
  16735. /**
  16736. * Will get a number picked randomly between factor1 and factor2.
  16737. * If factor2 is undefined then factor1 will be used
  16738. * @returns the picked number
  16739. */
  16740. getFactor(): number;
  16741. }
  16742. /**
  16743. * Helper used to simplify some generic gradient tasks
  16744. */
  16745. export class GradientHelper {
  16746. /**
  16747. * Gets the current gradient from an array of IValueGradient
  16748. * @param ratio defines the current ratio to get
  16749. * @param gradients defines the array of IValueGradient
  16750. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16751. */
  16752. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16753. }
  16754. }
  16755. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16756. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16757. import { Nullable } from "babylonjs/types";
  16758. module "babylonjs/Engines/thinEngine" {
  16759. interface ThinEngine {
  16760. /**
  16761. * Creates a dynamic texture
  16762. * @param width defines the width of the texture
  16763. * @param height defines the height of the texture
  16764. * @param generateMipMaps defines if the engine should generate the mip levels
  16765. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16766. * @returns the dynamic texture inside an InternalTexture
  16767. */
  16768. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16769. /**
  16770. * Update the content of a dynamic texture
  16771. * @param texture defines the texture to update
  16772. * @param canvas defines the canvas containing the source
  16773. * @param invertY defines if data must be stored with Y axis inverted
  16774. * @param premulAlpha defines if alpha is stored as premultiplied
  16775. * @param format defines the format of the data
  16776. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16777. */
  16778. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16779. }
  16780. }
  16781. }
  16782. declare module "babylonjs/Misc/canvasGenerator" {
  16783. /**
  16784. * Helper class used to generate a canvas to manipulate images
  16785. */
  16786. export class CanvasGenerator {
  16787. /**
  16788. * Create a new canvas (or offscreen canvas depending on the context)
  16789. * @param width defines the expected width
  16790. * @param height defines the expected height
  16791. * @return a new canvas or offscreen canvas
  16792. */
  16793. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16794. }
  16795. }
  16796. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16797. import { Scene } from "babylonjs/scene";
  16798. import { Texture } from "babylonjs/Materials/Textures/texture";
  16799. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16800. /**
  16801. * A class extending Texture allowing drawing on a texture
  16802. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16803. */
  16804. export class DynamicTexture extends Texture {
  16805. private _generateMipMaps;
  16806. private _canvas;
  16807. private _context;
  16808. private _engine;
  16809. /**
  16810. * Creates a DynamicTexture
  16811. * @param name defines the name of the texture
  16812. * @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
  16813. * @param scene defines the scene where you want the texture
  16814. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16815. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16816. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16817. */
  16818. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16819. /**
  16820. * Get the current class name of the texture useful for serialization or dynamic coding.
  16821. * @returns "DynamicTexture"
  16822. */
  16823. getClassName(): string;
  16824. /**
  16825. * Gets the current state of canRescale
  16826. */
  16827. get canRescale(): boolean;
  16828. private _recreate;
  16829. /**
  16830. * Scales the texture
  16831. * @param ratio the scale factor to apply to both width and height
  16832. */
  16833. scale(ratio: number): void;
  16834. /**
  16835. * Resizes the texture
  16836. * @param width the new width
  16837. * @param height the new height
  16838. */
  16839. scaleTo(width: number, height: number): void;
  16840. /**
  16841. * Gets the context of the canvas used by the texture
  16842. * @returns the canvas context of the dynamic texture
  16843. */
  16844. getContext(): CanvasRenderingContext2D;
  16845. /**
  16846. * Clears the texture
  16847. */
  16848. clear(): void;
  16849. /**
  16850. * Updates the texture
  16851. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16852. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16853. */
  16854. update(invertY?: boolean, premulAlpha?: boolean): void;
  16855. /**
  16856. * Draws text onto the texture
  16857. * @param text defines the text to be drawn
  16858. * @param x defines the placement of the text from the left
  16859. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16860. * @param font defines the font to be used with font-style, font-size, font-name
  16861. * @param color defines the color used for the text
  16862. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16863. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16864. * @param update defines whether texture is immediately update (default is true)
  16865. */
  16866. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16867. /**
  16868. * Clones the texture
  16869. * @returns the clone of the texture.
  16870. */
  16871. clone(): DynamicTexture;
  16872. /**
  16873. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16874. * @returns a serialized dynamic texture object
  16875. */
  16876. serialize(): any;
  16877. /** @hidden */
  16878. _rebuild(): void;
  16879. }
  16880. }
  16881. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16882. import { Scene } from "babylonjs/scene";
  16883. import { ISceneComponent } from "babylonjs/sceneComponent";
  16884. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16885. module "babylonjs/abstractScene" {
  16886. interface AbstractScene {
  16887. /**
  16888. * The list of procedural textures added to the scene
  16889. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16890. */
  16891. proceduralTextures: Array<ProceduralTexture>;
  16892. }
  16893. }
  16894. /**
  16895. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16896. * in a given scene.
  16897. */
  16898. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16899. /**
  16900. * The component name helpfull to identify the component in the list of scene components.
  16901. */
  16902. readonly name: string;
  16903. /**
  16904. * The scene the component belongs to.
  16905. */
  16906. scene: Scene;
  16907. /**
  16908. * Creates a new instance of the component for the given scene
  16909. * @param scene Defines the scene to register the component in
  16910. */
  16911. constructor(scene: Scene);
  16912. /**
  16913. * Registers the component in a given scene
  16914. */
  16915. register(): void;
  16916. /**
  16917. * Rebuilds the elements related to this component in case of
  16918. * context lost for instance.
  16919. */
  16920. rebuild(): void;
  16921. /**
  16922. * Disposes the component and the associated ressources.
  16923. */
  16924. dispose(): void;
  16925. private _beforeClear;
  16926. }
  16927. }
  16928. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16929. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16930. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16931. module "babylonjs/Engines/thinEngine" {
  16932. interface ThinEngine {
  16933. /**
  16934. * Creates a new render target cube texture
  16935. * @param size defines the size of the texture
  16936. * @param options defines the options used to create the texture
  16937. * @returns a new render target cube texture stored in an InternalTexture
  16938. */
  16939. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16940. }
  16941. }
  16942. }
  16943. declare module "babylonjs/Shaders/procedural.vertex" {
  16944. /** @hidden */
  16945. export var proceduralVertexShader: {
  16946. name: string;
  16947. shader: string;
  16948. };
  16949. }
  16950. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16951. import { Observable } from "babylonjs/Misc/observable";
  16952. import { Nullable } from "babylonjs/types";
  16953. import { Scene } from "babylonjs/scene";
  16954. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16955. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16956. import { Effect } from "babylonjs/Materials/effect";
  16957. import { Texture } from "babylonjs/Materials/Textures/texture";
  16958. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16959. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16960. import "babylonjs/Shaders/procedural.vertex";
  16961. /**
  16962. * 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.
  16963. * This is the base class of any Procedural texture and contains most of the shareable code.
  16964. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16965. */
  16966. export class ProceduralTexture extends Texture {
  16967. isCube: boolean;
  16968. /**
  16969. * Define if the texture is enabled or not (disabled texture will not render)
  16970. */
  16971. isEnabled: boolean;
  16972. /**
  16973. * Define if the texture must be cleared before rendering (default is true)
  16974. */
  16975. autoClear: boolean;
  16976. /**
  16977. * Callback called when the texture is generated
  16978. */
  16979. onGenerated: () => void;
  16980. /**
  16981. * Event raised when the texture is generated
  16982. */
  16983. onGeneratedObservable: Observable<ProceduralTexture>;
  16984. /** @hidden */
  16985. _generateMipMaps: boolean;
  16986. /** @hidden **/
  16987. _effect: Effect;
  16988. /** @hidden */
  16989. _textures: {
  16990. [key: string]: Texture;
  16991. };
  16992. private _size;
  16993. private _currentRefreshId;
  16994. private _frameId;
  16995. private _refreshRate;
  16996. private _vertexBuffers;
  16997. private _indexBuffer;
  16998. private _uniforms;
  16999. private _samplers;
  17000. private _fragment;
  17001. private _floats;
  17002. private _ints;
  17003. private _floatsArrays;
  17004. private _colors3;
  17005. private _colors4;
  17006. private _vectors2;
  17007. private _vectors3;
  17008. private _matrices;
  17009. private _fallbackTexture;
  17010. private _fallbackTextureUsed;
  17011. private _engine;
  17012. private _cachedDefines;
  17013. private _contentUpdateId;
  17014. private _contentData;
  17015. /**
  17016. * Instantiates a new procedural texture.
  17017. * 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.
  17018. * This is the base class of any Procedural texture and contains most of the shareable code.
  17019. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17020. * @param name Define the name of the texture
  17021. * @param size Define the size of the texture to create
  17022. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17023. * @param scene Define the scene the texture belongs to
  17024. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17025. * @param generateMipMaps Define if the texture should creates mip maps or not
  17026. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17027. */
  17028. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17029. /**
  17030. * The effect that is created when initializing the post process.
  17031. * @returns The created effect corresponding the the postprocess.
  17032. */
  17033. getEffect(): Effect;
  17034. /**
  17035. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17036. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17037. */
  17038. getContent(): Nullable<ArrayBufferView>;
  17039. private _createIndexBuffer;
  17040. /** @hidden */
  17041. _rebuild(): void;
  17042. /**
  17043. * Resets the texture in order to recreate its associated resources.
  17044. * This can be called in case of context loss
  17045. */
  17046. reset(): void;
  17047. protected _getDefines(): string;
  17048. /**
  17049. * Is the texture ready to be used ? (rendered at least once)
  17050. * @returns true if ready, otherwise, false.
  17051. */
  17052. isReady(): boolean;
  17053. /**
  17054. * Resets the refresh counter of the texture and start bak from scratch.
  17055. * Could be useful to regenerate the texture if it is setup to render only once.
  17056. */
  17057. resetRefreshCounter(): void;
  17058. /**
  17059. * Set the fragment shader to use in order to render the texture.
  17060. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17061. */
  17062. setFragment(fragment: any): void;
  17063. /**
  17064. * Define the refresh rate of the texture or the rendering frequency.
  17065. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17066. */
  17067. get refreshRate(): number;
  17068. set refreshRate(value: number);
  17069. /** @hidden */
  17070. _shouldRender(): boolean;
  17071. /**
  17072. * Get the size the texture is rendering at.
  17073. * @returns the size (texture is always squared)
  17074. */
  17075. getRenderSize(): number;
  17076. /**
  17077. * Resize the texture to new value.
  17078. * @param size Define the new size the texture should have
  17079. * @param generateMipMaps Define whether the new texture should create mip maps
  17080. */
  17081. resize(size: number, generateMipMaps: boolean): void;
  17082. private _checkUniform;
  17083. /**
  17084. * Set a texture in the shader program used to render.
  17085. * @param name Define the name of the uniform samplers as defined in the shader
  17086. * @param texture Define the texture to bind to this sampler
  17087. * @return the texture itself allowing "fluent" like uniform updates
  17088. */
  17089. setTexture(name: string, texture: Texture): ProceduralTexture;
  17090. /**
  17091. * Set a float in the shader.
  17092. * @param name Define the name of the uniform as defined in the shader
  17093. * @param value Define the value to give to the uniform
  17094. * @return the texture itself allowing "fluent" like uniform updates
  17095. */
  17096. setFloat(name: string, value: number): ProceduralTexture;
  17097. /**
  17098. * Set a int in the shader.
  17099. * @param name Define the name of the uniform as defined in the shader
  17100. * @param value Define the value to give to the uniform
  17101. * @return the texture itself allowing "fluent" like uniform updates
  17102. */
  17103. setInt(name: string, value: number): ProceduralTexture;
  17104. /**
  17105. * Set an array of floats in the shader.
  17106. * @param name Define the name of the uniform as defined in the shader
  17107. * @param value Define the value to give to the uniform
  17108. * @return the texture itself allowing "fluent" like uniform updates
  17109. */
  17110. setFloats(name: string, value: number[]): ProceduralTexture;
  17111. /**
  17112. * Set a vec3 in the shader from a Color3.
  17113. * @param name Define the name of the uniform as defined in the shader
  17114. * @param value Define the value to give to the uniform
  17115. * @return the texture itself allowing "fluent" like uniform updates
  17116. */
  17117. setColor3(name: string, value: Color3): ProceduralTexture;
  17118. /**
  17119. * Set a vec4 in the shader from a Color4.
  17120. * @param name Define the name of the uniform as defined in the shader
  17121. * @param value Define the value to give to the uniform
  17122. * @return the texture itself allowing "fluent" like uniform updates
  17123. */
  17124. setColor4(name: string, value: Color4): ProceduralTexture;
  17125. /**
  17126. * Set a vec2 in the shader from a Vector2.
  17127. * @param name Define the name of the uniform as defined in the shader
  17128. * @param value Define the value to give to the uniform
  17129. * @return the texture itself allowing "fluent" like uniform updates
  17130. */
  17131. setVector2(name: string, value: Vector2): ProceduralTexture;
  17132. /**
  17133. * Set a vec3 in the shader from a Vector3.
  17134. * @param name Define the name of the uniform as defined in the shader
  17135. * @param value Define the value to give to the uniform
  17136. * @return the texture itself allowing "fluent" like uniform updates
  17137. */
  17138. setVector3(name: string, value: Vector3): ProceduralTexture;
  17139. /**
  17140. * Set a mat4 in the shader from a MAtrix.
  17141. * @param name Define the name of the uniform as defined in the shader
  17142. * @param value Define the value to give to the uniform
  17143. * @return the texture itself allowing "fluent" like uniform updates
  17144. */
  17145. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17146. /**
  17147. * Render the texture to its associated render target.
  17148. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17149. */
  17150. render(useCameraPostProcess?: boolean): void;
  17151. /**
  17152. * Clone the texture.
  17153. * @returns the cloned texture
  17154. */
  17155. clone(): ProceduralTexture;
  17156. /**
  17157. * Dispose the texture and release its asoociated resources.
  17158. */
  17159. dispose(): void;
  17160. }
  17161. }
  17162. declare module "babylonjs/Particles/baseParticleSystem" {
  17163. import { Nullable } from "babylonjs/types";
  17164. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17166. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17167. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17168. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17169. import { Scene } from "babylonjs/scene";
  17170. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17171. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17172. import { Texture } from "babylonjs/Materials/Textures/texture";
  17173. import { Color4 } from "babylonjs/Maths/math.color";
  17174. import { Animation } from "babylonjs/Animations/animation";
  17175. /**
  17176. * This represents the base class for particle system in Babylon.
  17177. * 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.
  17178. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17179. * @example https://doc.babylonjs.com/babylon101/particles
  17180. */
  17181. export class BaseParticleSystem {
  17182. /**
  17183. * Source color is added to the destination color without alpha affecting the result
  17184. */
  17185. static BLENDMODE_ONEONE: number;
  17186. /**
  17187. * Blend current color and particle color using particle’s alpha
  17188. */
  17189. static BLENDMODE_STANDARD: number;
  17190. /**
  17191. * Add current color and particle color multiplied by particle’s alpha
  17192. */
  17193. static BLENDMODE_ADD: number;
  17194. /**
  17195. * Multiply current color with particle color
  17196. */
  17197. static BLENDMODE_MULTIPLY: number;
  17198. /**
  17199. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17200. */
  17201. static BLENDMODE_MULTIPLYADD: number;
  17202. /**
  17203. * List of animations used by the particle system.
  17204. */
  17205. animations: Animation[];
  17206. /**
  17207. * The id of the Particle system.
  17208. */
  17209. id: string;
  17210. /**
  17211. * The friendly name of the Particle system.
  17212. */
  17213. name: string;
  17214. /**
  17215. * The rendering group used by the Particle system to chose when to render.
  17216. */
  17217. renderingGroupId: number;
  17218. /**
  17219. * The emitter represents the Mesh or position we are attaching the particle system to.
  17220. */
  17221. emitter: Nullable<AbstractMesh | Vector3>;
  17222. /**
  17223. * The maximum number of particles to emit per frame
  17224. */
  17225. emitRate: number;
  17226. /**
  17227. * If you want to launch only a few particles at once, that can be done, as well.
  17228. */
  17229. manualEmitCount: number;
  17230. /**
  17231. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17232. */
  17233. updateSpeed: number;
  17234. /**
  17235. * The amount of time the particle system is running (depends of the overall update speed).
  17236. */
  17237. targetStopDuration: number;
  17238. /**
  17239. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17240. */
  17241. disposeOnStop: boolean;
  17242. /**
  17243. * Minimum power of emitting particles.
  17244. */
  17245. minEmitPower: number;
  17246. /**
  17247. * Maximum power of emitting particles.
  17248. */
  17249. maxEmitPower: number;
  17250. /**
  17251. * Minimum life time of emitting particles.
  17252. */
  17253. minLifeTime: number;
  17254. /**
  17255. * Maximum life time of emitting particles.
  17256. */
  17257. maxLifeTime: number;
  17258. /**
  17259. * Minimum Size of emitting particles.
  17260. */
  17261. minSize: number;
  17262. /**
  17263. * Maximum Size of emitting particles.
  17264. */
  17265. maxSize: number;
  17266. /**
  17267. * Minimum scale of emitting particles on X axis.
  17268. */
  17269. minScaleX: number;
  17270. /**
  17271. * Maximum scale of emitting particles on X axis.
  17272. */
  17273. maxScaleX: number;
  17274. /**
  17275. * Minimum scale of emitting particles on Y axis.
  17276. */
  17277. minScaleY: number;
  17278. /**
  17279. * Maximum scale of emitting particles on Y axis.
  17280. */
  17281. maxScaleY: number;
  17282. /**
  17283. * Gets or sets the minimal initial rotation in radians.
  17284. */
  17285. minInitialRotation: number;
  17286. /**
  17287. * Gets or sets the maximal initial rotation in radians.
  17288. */
  17289. maxInitialRotation: number;
  17290. /**
  17291. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17292. */
  17293. minAngularSpeed: number;
  17294. /**
  17295. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17296. */
  17297. maxAngularSpeed: number;
  17298. /**
  17299. * The texture used to render each particle. (this can be a spritesheet)
  17300. */
  17301. particleTexture: Nullable<Texture>;
  17302. /**
  17303. * The layer mask we are rendering the particles through.
  17304. */
  17305. layerMask: number;
  17306. /**
  17307. * This can help using your own shader to render the particle system.
  17308. * The according effect will be created
  17309. */
  17310. customShader: any;
  17311. /**
  17312. * By default particle system starts as soon as they are created. This prevents the
  17313. * automatic start to happen and let you decide when to start emitting particles.
  17314. */
  17315. preventAutoStart: boolean;
  17316. private _noiseTexture;
  17317. /**
  17318. * Gets or sets a texture used to add random noise to particle positions
  17319. */
  17320. get noiseTexture(): Nullable<ProceduralTexture>;
  17321. set noiseTexture(value: Nullable<ProceduralTexture>);
  17322. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17323. noiseStrength: Vector3;
  17324. /**
  17325. * Callback triggered when the particle animation is ending.
  17326. */
  17327. onAnimationEnd: Nullable<() => void>;
  17328. /**
  17329. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17330. */
  17331. blendMode: number;
  17332. /**
  17333. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17334. * to override the particles.
  17335. */
  17336. forceDepthWrite: boolean;
  17337. /** 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 */
  17338. preWarmCycles: number;
  17339. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17340. preWarmStepOffset: number;
  17341. /**
  17342. * 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)
  17343. */
  17344. spriteCellChangeSpeed: number;
  17345. /**
  17346. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17347. */
  17348. startSpriteCellID: number;
  17349. /**
  17350. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17351. */
  17352. endSpriteCellID: number;
  17353. /**
  17354. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17355. */
  17356. spriteCellWidth: number;
  17357. /**
  17358. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17359. */
  17360. spriteCellHeight: number;
  17361. /**
  17362. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17363. */
  17364. spriteRandomStartCell: boolean;
  17365. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17366. translationPivot: Vector2;
  17367. /** @hidden */
  17368. protected _isAnimationSheetEnabled: boolean;
  17369. /**
  17370. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17371. */
  17372. beginAnimationOnStart: boolean;
  17373. /**
  17374. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17375. */
  17376. beginAnimationFrom: number;
  17377. /**
  17378. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17379. */
  17380. beginAnimationTo: number;
  17381. /**
  17382. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17383. */
  17384. beginAnimationLoop: boolean;
  17385. /**
  17386. * Gets or sets a world offset applied to all particles
  17387. */
  17388. worldOffset: Vector3;
  17389. /**
  17390. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17391. */
  17392. get isAnimationSheetEnabled(): boolean;
  17393. set isAnimationSheetEnabled(value: boolean);
  17394. /**
  17395. * Get hosting scene
  17396. * @returns the scene
  17397. */
  17398. getScene(): Scene;
  17399. /**
  17400. * You can use gravity if you want to give an orientation to your particles.
  17401. */
  17402. gravity: Vector3;
  17403. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17404. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17405. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17406. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17407. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17408. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17409. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17410. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17411. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17412. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17413. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17414. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17415. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17416. /**
  17417. * Defines the delay in milliseconds before starting the system (0 by default)
  17418. */
  17419. startDelay: number;
  17420. /**
  17421. * Gets the current list of drag gradients.
  17422. * You must use addDragGradient and removeDragGradient to udpate this list
  17423. * @returns the list of drag gradients
  17424. */
  17425. getDragGradients(): Nullable<Array<FactorGradient>>;
  17426. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17427. limitVelocityDamping: number;
  17428. /**
  17429. * Gets the current list of limit velocity gradients.
  17430. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17431. * @returns the list of limit velocity gradients
  17432. */
  17433. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17434. /**
  17435. * Gets the current list of color gradients.
  17436. * You must use addColorGradient and removeColorGradient to udpate this list
  17437. * @returns the list of color gradients
  17438. */
  17439. getColorGradients(): Nullable<Array<ColorGradient>>;
  17440. /**
  17441. * Gets the current list of size gradients.
  17442. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17443. * @returns the list of size gradients
  17444. */
  17445. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17446. /**
  17447. * Gets the current list of color remap gradients.
  17448. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17449. * @returns the list of color remap gradients
  17450. */
  17451. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17452. /**
  17453. * Gets the current list of alpha remap gradients.
  17454. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17455. * @returns the list of alpha remap gradients
  17456. */
  17457. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17458. /**
  17459. * Gets the current list of life time gradients.
  17460. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17461. * @returns the list of life time gradients
  17462. */
  17463. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17464. /**
  17465. * Gets the current list of angular speed gradients.
  17466. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17467. * @returns the list of angular speed gradients
  17468. */
  17469. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17470. /**
  17471. * Gets the current list of velocity gradients.
  17472. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17473. * @returns the list of velocity gradients
  17474. */
  17475. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17476. /**
  17477. * Gets the current list of start size gradients.
  17478. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17479. * @returns the list of start size gradients
  17480. */
  17481. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17482. /**
  17483. * Gets the current list of emit rate gradients.
  17484. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17485. * @returns the list of emit rate gradients
  17486. */
  17487. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17488. /**
  17489. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17490. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17491. */
  17492. get direction1(): Vector3;
  17493. set direction1(value: Vector3);
  17494. /**
  17495. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17496. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17497. */
  17498. get direction2(): Vector3;
  17499. set direction2(value: Vector3);
  17500. /**
  17501. * 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.
  17502. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17503. */
  17504. get minEmitBox(): Vector3;
  17505. set minEmitBox(value: Vector3);
  17506. /**
  17507. * 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.
  17508. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17509. */
  17510. get maxEmitBox(): Vector3;
  17511. set maxEmitBox(value: Vector3);
  17512. /**
  17513. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17514. */
  17515. color1: Color4;
  17516. /**
  17517. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17518. */
  17519. color2: Color4;
  17520. /**
  17521. * Color the particle will have at the end of its lifetime
  17522. */
  17523. colorDead: Color4;
  17524. /**
  17525. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17526. */
  17527. textureMask: Color4;
  17528. /**
  17529. * The particle emitter type defines the emitter used by the particle system.
  17530. * It can be for example box, sphere, or cone...
  17531. */
  17532. particleEmitterType: IParticleEmitterType;
  17533. /** @hidden */
  17534. _isSubEmitter: boolean;
  17535. /**
  17536. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17537. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17538. */
  17539. billboardMode: number;
  17540. protected _isBillboardBased: boolean;
  17541. /**
  17542. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17543. */
  17544. get isBillboardBased(): boolean;
  17545. set isBillboardBased(value: boolean);
  17546. /**
  17547. * The scene the particle system belongs to.
  17548. */
  17549. protected _scene: Scene;
  17550. /**
  17551. * Local cache of defines for image processing.
  17552. */
  17553. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17554. /**
  17555. * Default configuration related to image processing available in the standard Material.
  17556. */
  17557. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17558. /**
  17559. * Gets the image processing configuration used either in this material.
  17560. */
  17561. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17562. /**
  17563. * Sets the Default image processing configuration used either in the this material.
  17564. *
  17565. * If sets to null, the scene one is in use.
  17566. */
  17567. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17568. /**
  17569. * Attaches a new image processing configuration to the Standard Material.
  17570. * @param configuration
  17571. */
  17572. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17573. /** @hidden */
  17574. protected _reset(): void;
  17575. /** @hidden */
  17576. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17577. /**
  17578. * Instantiates a particle system.
  17579. * 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.
  17580. * @param name The name of the particle system
  17581. */
  17582. constructor(name: string);
  17583. /**
  17584. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17585. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17586. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17587. * @returns the emitter
  17588. */
  17589. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17590. /**
  17591. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17592. * @param radius The radius of the hemisphere to emit from
  17593. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17594. * @returns the emitter
  17595. */
  17596. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17597. /**
  17598. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17599. * @param radius The radius of the sphere to emit from
  17600. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17601. * @returns the emitter
  17602. */
  17603. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17604. /**
  17605. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17606. * @param radius The radius of the sphere to emit from
  17607. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17608. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17609. * @returns the emitter
  17610. */
  17611. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17612. /**
  17613. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17614. * @param radius The radius of the emission cylinder
  17615. * @param height The height of the emission cylinder
  17616. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17617. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17618. * @returns the emitter
  17619. */
  17620. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17621. /**
  17622. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17623. * @param radius The radius of the cylinder to emit from
  17624. * @param height The height of the emission cylinder
  17625. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17628. * @returns the emitter
  17629. */
  17630. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17631. /**
  17632. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17633. * @param radius The radius of the cone to emit from
  17634. * @param angle The base angle of the cone
  17635. * @returns the emitter
  17636. */
  17637. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17638. /**
  17639. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17640. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17641. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17642. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17643. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17644. * @returns the emitter
  17645. */
  17646. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17647. }
  17648. }
  17649. declare module "babylonjs/Particles/subEmitter" {
  17650. import { Scene } from "babylonjs/scene";
  17651. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17652. /**
  17653. * Type of sub emitter
  17654. */
  17655. export enum SubEmitterType {
  17656. /**
  17657. * Attached to the particle over it's lifetime
  17658. */
  17659. ATTACHED = 0,
  17660. /**
  17661. * Created when the particle dies
  17662. */
  17663. END = 1
  17664. }
  17665. /**
  17666. * Sub emitter class used to emit particles from an existing particle
  17667. */
  17668. export class SubEmitter {
  17669. /**
  17670. * the particle system to be used by the sub emitter
  17671. */
  17672. particleSystem: ParticleSystem;
  17673. /**
  17674. * Type of the submitter (Default: END)
  17675. */
  17676. type: SubEmitterType;
  17677. /**
  17678. * 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)
  17679. * Note: This only is supported when using an emitter of type Mesh
  17680. */
  17681. inheritDirection: boolean;
  17682. /**
  17683. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17684. */
  17685. inheritedVelocityAmount: number;
  17686. /**
  17687. * Creates a sub emitter
  17688. * @param particleSystem the particle system to be used by the sub emitter
  17689. */
  17690. constructor(
  17691. /**
  17692. * the particle system to be used by the sub emitter
  17693. */
  17694. particleSystem: ParticleSystem);
  17695. /**
  17696. * Clones the sub emitter
  17697. * @returns the cloned sub emitter
  17698. */
  17699. clone(): SubEmitter;
  17700. /**
  17701. * Serialize current object to a JSON object
  17702. * @returns the serialized object
  17703. */
  17704. serialize(): any;
  17705. /** @hidden */
  17706. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17707. /**
  17708. * Creates a new SubEmitter from a serialized JSON version
  17709. * @param serializationObject defines the JSON object to read from
  17710. * @param scene defines the hosting scene
  17711. * @param rootUrl defines the rootUrl for data loading
  17712. * @returns a new SubEmitter
  17713. */
  17714. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17715. /** Release associated resources */
  17716. dispose(): void;
  17717. }
  17718. }
  17719. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17720. /** @hidden */
  17721. export var clipPlaneFragmentDeclaration: {
  17722. name: string;
  17723. shader: string;
  17724. };
  17725. }
  17726. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17727. /** @hidden */
  17728. export var imageProcessingDeclaration: {
  17729. name: string;
  17730. shader: string;
  17731. };
  17732. }
  17733. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17734. /** @hidden */
  17735. export var imageProcessingFunctions: {
  17736. name: string;
  17737. shader: string;
  17738. };
  17739. }
  17740. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17741. /** @hidden */
  17742. export var clipPlaneFragment: {
  17743. name: string;
  17744. shader: string;
  17745. };
  17746. }
  17747. declare module "babylonjs/Shaders/particles.fragment" {
  17748. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17749. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17750. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17751. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17752. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17753. /** @hidden */
  17754. export var particlesPixelShader: {
  17755. name: string;
  17756. shader: string;
  17757. };
  17758. }
  17759. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17760. /** @hidden */
  17761. export var clipPlaneVertexDeclaration: {
  17762. name: string;
  17763. shader: string;
  17764. };
  17765. }
  17766. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17767. /** @hidden */
  17768. export var clipPlaneVertex: {
  17769. name: string;
  17770. shader: string;
  17771. };
  17772. }
  17773. declare module "babylonjs/Shaders/particles.vertex" {
  17774. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17775. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17776. /** @hidden */
  17777. export var particlesVertexShader: {
  17778. name: string;
  17779. shader: string;
  17780. };
  17781. }
  17782. declare module "babylonjs/Particles/particleSystem" {
  17783. import { Nullable } from "babylonjs/types";
  17784. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17785. import { Observable } from "babylonjs/Misc/observable";
  17786. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17787. import { Effect } from "babylonjs/Materials/effect";
  17788. import { Scene, IDisposable } from "babylonjs/scene";
  17789. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17790. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17791. import { Particle } from "babylonjs/Particles/particle";
  17792. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17793. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17794. import "babylonjs/Shaders/particles.fragment";
  17795. import "babylonjs/Shaders/particles.vertex";
  17796. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17797. /**
  17798. * This represents a particle system in Babylon.
  17799. * 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.
  17800. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17801. * @example https://doc.babylonjs.com/babylon101/particles
  17802. */
  17803. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17804. /**
  17805. * Billboard mode will only apply to Y axis
  17806. */
  17807. static readonly BILLBOARDMODE_Y: number;
  17808. /**
  17809. * Billboard mode will apply to all axes
  17810. */
  17811. static readonly BILLBOARDMODE_ALL: number;
  17812. /**
  17813. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17814. */
  17815. static readonly BILLBOARDMODE_STRETCHED: number;
  17816. /**
  17817. * This function can be defined to provide custom update for active particles.
  17818. * This function will be called instead of regular update (age, position, color, etc.).
  17819. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17820. */
  17821. updateFunction: (particles: Particle[]) => void;
  17822. private _emitterWorldMatrix;
  17823. /**
  17824. * This function can be defined to specify initial direction for every new particle.
  17825. * It by default use the emitterType defined function
  17826. */
  17827. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17828. /**
  17829. * This function can be defined to specify initial position for every new particle.
  17830. * It by default use the emitterType defined function
  17831. */
  17832. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17833. /**
  17834. * @hidden
  17835. */
  17836. _inheritedVelocityOffset: Vector3;
  17837. /**
  17838. * An event triggered when the system is disposed
  17839. */
  17840. onDisposeObservable: Observable<ParticleSystem>;
  17841. private _onDisposeObserver;
  17842. /**
  17843. * Sets a callback that will be triggered when the system is disposed
  17844. */
  17845. set onDispose(callback: () => void);
  17846. private _particles;
  17847. private _epsilon;
  17848. private _capacity;
  17849. private _stockParticles;
  17850. private _newPartsExcess;
  17851. private _vertexData;
  17852. private _vertexBuffer;
  17853. private _vertexBuffers;
  17854. private _spriteBuffer;
  17855. private _indexBuffer;
  17856. private _effect;
  17857. private _customEffect;
  17858. private _cachedDefines;
  17859. private _scaledColorStep;
  17860. private _colorDiff;
  17861. private _scaledDirection;
  17862. private _scaledGravity;
  17863. private _currentRenderId;
  17864. private _alive;
  17865. private _useInstancing;
  17866. private _started;
  17867. private _stopped;
  17868. private _actualFrame;
  17869. private _scaledUpdateSpeed;
  17870. private _vertexBufferSize;
  17871. /** @hidden */
  17872. _currentEmitRateGradient: Nullable<FactorGradient>;
  17873. /** @hidden */
  17874. _currentEmitRate1: number;
  17875. /** @hidden */
  17876. _currentEmitRate2: number;
  17877. /** @hidden */
  17878. _currentStartSizeGradient: Nullable<FactorGradient>;
  17879. /** @hidden */
  17880. _currentStartSize1: number;
  17881. /** @hidden */
  17882. _currentStartSize2: number;
  17883. private readonly _rawTextureWidth;
  17884. private _rampGradientsTexture;
  17885. private _useRampGradients;
  17886. /** Gets or sets a boolean indicating that ramp gradients must be used
  17887. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17888. */
  17889. get useRampGradients(): boolean;
  17890. set useRampGradients(value: boolean);
  17891. /**
  17892. * 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.
  17893. * 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: [])
  17894. */
  17895. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17896. private _subEmitters;
  17897. /**
  17898. * @hidden
  17899. * If the particle systems emitter should be disposed when the particle system is disposed
  17900. */
  17901. _disposeEmitterOnDispose: boolean;
  17902. /**
  17903. * The current active Sub-systems, this property is used by the root particle system only.
  17904. */
  17905. activeSubSystems: Array<ParticleSystem>;
  17906. private _rootParticleSystem;
  17907. /**
  17908. * Gets the current list of active particles
  17909. */
  17910. get particles(): Particle[];
  17911. /**
  17912. * Returns the string "ParticleSystem"
  17913. * @returns a string containing the class name
  17914. */
  17915. getClassName(): string;
  17916. /**
  17917. * Instantiates a particle system.
  17918. * 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.
  17919. * @param name The name of the particle system
  17920. * @param capacity The max number of particles alive at the same time
  17921. * @param scene The scene the particle system belongs to
  17922. * @param customEffect a custom effect used to change the way particles are rendered by default
  17923. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17924. * @param epsilon Offset used to render the particles
  17925. */
  17926. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17927. private _addFactorGradient;
  17928. private _removeFactorGradient;
  17929. /**
  17930. * Adds a new life time gradient
  17931. * @param gradient defines the gradient to use (between 0 and 1)
  17932. * @param factor defines the life time factor to affect to the specified gradient
  17933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17934. * @returns the current particle system
  17935. */
  17936. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17937. /**
  17938. * Remove a specific life time gradient
  17939. * @param gradient defines the gradient to remove
  17940. * @returns the current particle system
  17941. */
  17942. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17943. /**
  17944. * Adds a new size gradient
  17945. * @param gradient defines the gradient to use (between 0 and 1)
  17946. * @param factor defines the size factor to affect to the specified gradient
  17947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17948. * @returns the current particle system
  17949. */
  17950. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17951. /**
  17952. * Remove a specific size gradient
  17953. * @param gradient defines the gradient to remove
  17954. * @returns the current particle system
  17955. */
  17956. removeSizeGradient(gradient: number): IParticleSystem;
  17957. /**
  17958. * Adds a new color remap gradient
  17959. * @param gradient defines the gradient to use (between 0 and 1)
  17960. * @param min defines the color remap minimal range
  17961. * @param max defines the color remap maximal range
  17962. * @returns the current particle system
  17963. */
  17964. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17965. /**
  17966. * Remove a specific color remap gradient
  17967. * @param gradient defines the gradient to remove
  17968. * @returns the current particle system
  17969. */
  17970. removeColorRemapGradient(gradient: number): IParticleSystem;
  17971. /**
  17972. * Adds a new alpha remap gradient
  17973. * @param gradient defines the gradient to use (between 0 and 1)
  17974. * @param min defines the alpha remap minimal range
  17975. * @param max defines the alpha remap maximal range
  17976. * @returns the current particle system
  17977. */
  17978. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17979. /**
  17980. * Remove a specific alpha remap gradient
  17981. * @param gradient defines the gradient to remove
  17982. * @returns the current particle system
  17983. */
  17984. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17985. /**
  17986. * Adds a new angular speed gradient
  17987. * @param gradient defines the gradient to use (between 0 and 1)
  17988. * @param factor defines the angular speed to affect to the specified gradient
  17989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17990. * @returns the current particle system
  17991. */
  17992. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17993. /**
  17994. * Remove a specific angular speed gradient
  17995. * @param gradient defines the gradient to remove
  17996. * @returns the current particle system
  17997. */
  17998. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17999. /**
  18000. * Adds a new velocity gradient
  18001. * @param gradient defines the gradient to use (between 0 and 1)
  18002. * @param factor defines the velocity to affect to the specified gradient
  18003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18004. * @returns the current particle system
  18005. */
  18006. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18007. /**
  18008. * Remove a specific velocity gradient
  18009. * @param gradient defines the gradient to remove
  18010. * @returns the current particle system
  18011. */
  18012. removeVelocityGradient(gradient: number): IParticleSystem;
  18013. /**
  18014. * Adds a new limit velocity gradient
  18015. * @param gradient defines the gradient to use (between 0 and 1)
  18016. * @param factor defines the limit velocity value to affect to the specified gradient
  18017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18018. * @returns the current particle system
  18019. */
  18020. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18021. /**
  18022. * Remove a specific limit velocity gradient
  18023. * @param gradient defines the gradient to remove
  18024. * @returns the current particle system
  18025. */
  18026. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18027. /**
  18028. * Adds a new drag gradient
  18029. * @param gradient defines the gradient to use (between 0 and 1)
  18030. * @param factor defines the drag value to affect to the specified gradient
  18031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18032. * @returns the current particle system
  18033. */
  18034. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18035. /**
  18036. * Remove a specific drag gradient
  18037. * @param gradient defines the gradient to remove
  18038. * @returns the current particle system
  18039. */
  18040. removeDragGradient(gradient: number): IParticleSystem;
  18041. /**
  18042. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18043. * @param gradient defines the gradient to use (between 0 and 1)
  18044. * @param factor defines the emit rate value to affect to the specified gradient
  18045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18046. * @returns the current particle system
  18047. */
  18048. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18049. /**
  18050. * Remove a specific emit rate gradient
  18051. * @param gradient defines the gradient to remove
  18052. * @returns the current particle system
  18053. */
  18054. removeEmitRateGradient(gradient: number): IParticleSystem;
  18055. /**
  18056. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18057. * @param gradient defines the gradient to use (between 0 and 1)
  18058. * @param factor defines the start size value to affect to the specified gradient
  18059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18060. * @returns the current particle system
  18061. */
  18062. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18063. /**
  18064. * Remove a specific start size gradient
  18065. * @param gradient defines the gradient to remove
  18066. * @returns the current particle system
  18067. */
  18068. removeStartSizeGradient(gradient: number): IParticleSystem;
  18069. private _createRampGradientTexture;
  18070. /**
  18071. * Gets the current list of ramp gradients.
  18072. * You must use addRampGradient and removeRampGradient to udpate this list
  18073. * @returns the list of ramp gradients
  18074. */
  18075. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18076. /**
  18077. * Adds a new ramp gradient used to remap particle colors
  18078. * @param gradient defines the gradient to use (between 0 and 1)
  18079. * @param color defines the color to affect to the specified gradient
  18080. * @returns the current particle system
  18081. */
  18082. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18083. /**
  18084. * Remove a specific ramp gradient
  18085. * @param gradient defines the gradient to remove
  18086. * @returns the current particle system
  18087. */
  18088. removeRampGradient(gradient: number): ParticleSystem;
  18089. /**
  18090. * Adds a new color gradient
  18091. * @param gradient defines the gradient to use (between 0 and 1)
  18092. * @param color1 defines the color to affect to the specified gradient
  18093. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18094. * @returns this particle system
  18095. */
  18096. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18097. /**
  18098. * Remove a specific color gradient
  18099. * @param gradient defines the gradient to remove
  18100. * @returns this particle system
  18101. */
  18102. removeColorGradient(gradient: number): IParticleSystem;
  18103. private _fetchR;
  18104. protected _reset(): void;
  18105. private _resetEffect;
  18106. private _createVertexBuffers;
  18107. private _createIndexBuffer;
  18108. /**
  18109. * Gets the maximum number of particles active at the same time.
  18110. * @returns The max number of active particles.
  18111. */
  18112. getCapacity(): number;
  18113. /**
  18114. * Gets whether there are still active particles in the system.
  18115. * @returns True if it is alive, otherwise false.
  18116. */
  18117. isAlive(): boolean;
  18118. /**
  18119. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18120. * @returns True if it has been started, otherwise false.
  18121. */
  18122. isStarted(): boolean;
  18123. private _prepareSubEmitterInternalArray;
  18124. /**
  18125. * Starts the particle system and begins to emit
  18126. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18127. */
  18128. start(delay?: number): void;
  18129. /**
  18130. * Stops the particle system.
  18131. * @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.
  18132. */
  18133. stop(stopSubEmitters?: boolean): void;
  18134. /**
  18135. * Remove all active particles
  18136. */
  18137. reset(): void;
  18138. /**
  18139. * @hidden (for internal use only)
  18140. */
  18141. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18142. /**
  18143. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18144. * Its lifetime will start back at 0.
  18145. */
  18146. recycleParticle: (particle: Particle) => void;
  18147. private _stopSubEmitters;
  18148. private _createParticle;
  18149. private _removeFromRoot;
  18150. private _emitFromParticle;
  18151. private _update;
  18152. /** @hidden */
  18153. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18154. /** @hidden */
  18155. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18156. /** @hidden */
  18157. private _getEffect;
  18158. /**
  18159. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18160. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18161. */
  18162. animate(preWarmOnly?: boolean): void;
  18163. private _appendParticleVertices;
  18164. /**
  18165. * Rebuilds the particle system.
  18166. */
  18167. rebuild(): void;
  18168. /**
  18169. * Is this system ready to be used/rendered
  18170. * @return true if the system is ready
  18171. */
  18172. isReady(): boolean;
  18173. private _render;
  18174. /**
  18175. * Renders the particle system in its current state.
  18176. * @returns the current number of particles
  18177. */
  18178. render(): number;
  18179. /**
  18180. * Disposes the particle system and free the associated resources
  18181. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18182. */
  18183. dispose(disposeTexture?: boolean): void;
  18184. /**
  18185. * Clones the particle system.
  18186. * @param name The name of the cloned object
  18187. * @param newEmitter The new emitter to use
  18188. * @returns the cloned particle system
  18189. */
  18190. clone(name: string, newEmitter: any): ParticleSystem;
  18191. /**
  18192. * Serializes the particle system to a JSON object.
  18193. * @returns the JSON object
  18194. */
  18195. serialize(): any;
  18196. /** @hidden */
  18197. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18198. /** @hidden */
  18199. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18200. /**
  18201. * Parses a JSON object to create a particle system.
  18202. * @param parsedParticleSystem The JSON object to parse
  18203. * @param scene The scene to create the particle system in
  18204. * @param rootUrl The root url to use to load external dependencies like texture
  18205. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18206. * @returns the Parsed particle system
  18207. */
  18208. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18209. }
  18210. }
  18211. declare module "babylonjs/Particles/particle" {
  18212. import { Nullable } from "babylonjs/types";
  18213. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18214. import { Color4 } from "babylonjs/Maths/math.color";
  18215. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18216. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18217. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18218. /**
  18219. * A particle represents one of the element emitted by a particle system.
  18220. * This is mainly define by its coordinates, direction, velocity and age.
  18221. */
  18222. export class Particle {
  18223. /**
  18224. * The particle system the particle belongs to.
  18225. */
  18226. particleSystem: ParticleSystem;
  18227. private static _Count;
  18228. /**
  18229. * Unique ID of the particle
  18230. */
  18231. id: number;
  18232. /**
  18233. * The world position of the particle in the scene.
  18234. */
  18235. position: Vector3;
  18236. /**
  18237. * The world direction of the particle in the scene.
  18238. */
  18239. direction: Vector3;
  18240. /**
  18241. * The color of the particle.
  18242. */
  18243. color: Color4;
  18244. /**
  18245. * The color change of the particle per step.
  18246. */
  18247. colorStep: Color4;
  18248. /**
  18249. * Defines how long will the life of the particle be.
  18250. */
  18251. lifeTime: number;
  18252. /**
  18253. * The current age of the particle.
  18254. */
  18255. age: number;
  18256. /**
  18257. * The current size of the particle.
  18258. */
  18259. size: number;
  18260. /**
  18261. * The current scale of the particle.
  18262. */
  18263. scale: Vector2;
  18264. /**
  18265. * The current angle of the particle.
  18266. */
  18267. angle: number;
  18268. /**
  18269. * Defines how fast is the angle changing.
  18270. */
  18271. angularSpeed: number;
  18272. /**
  18273. * Defines the cell index used by the particle to be rendered from a sprite.
  18274. */
  18275. cellIndex: number;
  18276. /**
  18277. * The information required to support color remapping
  18278. */
  18279. remapData: Vector4;
  18280. /** @hidden */
  18281. _randomCellOffset?: number;
  18282. /** @hidden */
  18283. _initialDirection: Nullable<Vector3>;
  18284. /** @hidden */
  18285. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18286. /** @hidden */
  18287. _initialStartSpriteCellID: number;
  18288. /** @hidden */
  18289. _initialEndSpriteCellID: number;
  18290. /** @hidden */
  18291. _currentColorGradient: Nullable<ColorGradient>;
  18292. /** @hidden */
  18293. _currentColor1: Color4;
  18294. /** @hidden */
  18295. _currentColor2: Color4;
  18296. /** @hidden */
  18297. _currentSizeGradient: Nullable<FactorGradient>;
  18298. /** @hidden */
  18299. _currentSize1: number;
  18300. /** @hidden */
  18301. _currentSize2: number;
  18302. /** @hidden */
  18303. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18304. /** @hidden */
  18305. _currentAngularSpeed1: number;
  18306. /** @hidden */
  18307. _currentAngularSpeed2: number;
  18308. /** @hidden */
  18309. _currentVelocityGradient: Nullable<FactorGradient>;
  18310. /** @hidden */
  18311. _currentVelocity1: number;
  18312. /** @hidden */
  18313. _currentVelocity2: number;
  18314. /** @hidden */
  18315. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18316. /** @hidden */
  18317. _currentLimitVelocity1: number;
  18318. /** @hidden */
  18319. _currentLimitVelocity2: number;
  18320. /** @hidden */
  18321. _currentDragGradient: Nullable<FactorGradient>;
  18322. /** @hidden */
  18323. _currentDrag1: number;
  18324. /** @hidden */
  18325. _currentDrag2: number;
  18326. /** @hidden */
  18327. _randomNoiseCoordinates1: Vector3;
  18328. /** @hidden */
  18329. _randomNoiseCoordinates2: Vector3;
  18330. /**
  18331. * Creates a new instance Particle
  18332. * @param particleSystem the particle system the particle belongs to
  18333. */
  18334. constructor(
  18335. /**
  18336. * The particle system the particle belongs to.
  18337. */
  18338. particleSystem: ParticleSystem);
  18339. private updateCellInfoFromSystem;
  18340. /**
  18341. * Defines how the sprite cell index is updated for the particle
  18342. */
  18343. updateCellIndex(): void;
  18344. /** @hidden */
  18345. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18346. /** @hidden */
  18347. _inheritParticleInfoToSubEmitters(): void;
  18348. /** @hidden */
  18349. _reset(): void;
  18350. /**
  18351. * Copy the properties of particle to another one.
  18352. * @param other the particle to copy the information to.
  18353. */
  18354. copyTo(other: Particle): void;
  18355. }
  18356. }
  18357. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18358. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18359. import { Effect } from "babylonjs/Materials/effect";
  18360. import { Particle } from "babylonjs/Particles/particle";
  18361. /**
  18362. * Particle emitter represents a volume emitting particles.
  18363. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18364. */
  18365. export interface IParticleEmitterType {
  18366. /**
  18367. * Called by the particle System when the direction is computed for the created particle.
  18368. * @param worldMatrix is the world matrix of the particle system
  18369. * @param directionToUpdate is the direction vector to update with the result
  18370. * @param particle is the particle we are computed the direction for
  18371. */
  18372. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18373. /**
  18374. * Called by the particle System when the position is computed for the created particle.
  18375. * @param worldMatrix is the world matrix of the particle system
  18376. * @param positionToUpdate is the position vector to update with the result
  18377. * @param particle is the particle we are computed the position for
  18378. */
  18379. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18380. /**
  18381. * Clones the current emitter and returns a copy of it
  18382. * @returns the new emitter
  18383. */
  18384. clone(): IParticleEmitterType;
  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 the effect defines string
  18393. */
  18394. getEffectDefines(): string;
  18395. /**
  18396. * Returns a string representing the class name
  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/boxParticleEmitter" {
  18413. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18414. import { Effect } from "babylonjs/Materials/effect";
  18415. import { Particle } from "babylonjs/Particles/particle";
  18416. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18417. /**
  18418. * Particle emitter emitting particles from the inside of a box.
  18419. * It emits the particles randomly between 2 given directions.
  18420. */
  18421. export class BoxParticleEmitter implements IParticleEmitterType {
  18422. /**
  18423. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18424. */
  18425. direction1: Vector3;
  18426. /**
  18427. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18428. */
  18429. direction2: Vector3;
  18430. /**
  18431. * 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.
  18432. */
  18433. minEmitBox: Vector3;
  18434. /**
  18435. * 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.
  18436. */
  18437. maxEmitBox: Vector3;
  18438. /**
  18439. * Creates a new instance BoxParticleEmitter
  18440. */
  18441. constructor();
  18442. /**
  18443. * Called by the particle System when the direction is computed for the created particle.
  18444. * @param worldMatrix is the world matrix of the particle system
  18445. * @param directionToUpdate is the direction vector to update with the result
  18446. * @param particle is the particle we are computed the direction for
  18447. */
  18448. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18449. /**
  18450. * Called by the particle System when the position is computed for the created particle.
  18451. * @param worldMatrix is the world matrix of the particle system
  18452. * @param positionToUpdate is the position vector to update with the result
  18453. * @param particle is the particle we are computed the position for
  18454. */
  18455. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18456. /**
  18457. * Clones the current emitter and returns a copy of it
  18458. * @returns the new emitter
  18459. */
  18460. clone(): BoxParticleEmitter;
  18461. /**
  18462. * Called by the GPUParticleSystem to setup the update shader
  18463. * @param effect defines the update shader
  18464. */
  18465. applyToShader(effect: Effect): void;
  18466. /**
  18467. * Returns a string to use to update the GPU particles update shader
  18468. * @returns a string containng the defines string
  18469. */
  18470. getEffectDefines(): string;
  18471. /**
  18472. * Returns the string "BoxParticleEmitter"
  18473. * @returns a string containing the class name
  18474. */
  18475. getClassName(): string;
  18476. /**
  18477. * Serializes the particle system to a JSON object.
  18478. * @returns the JSON object
  18479. */
  18480. serialize(): any;
  18481. /**
  18482. * Parse properties from a JSON object
  18483. * @param serializationObject defines the JSON object
  18484. */
  18485. parse(serializationObject: any): void;
  18486. }
  18487. }
  18488. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18489. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18490. import { Effect } from "babylonjs/Materials/effect";
  18491. import { Particle } from "babylonjs/Particles/particle";
  18492. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18493. /**
  18494. * Particle emitter emitting particles from the inside of a cone.
  18495. * It emits the particles alongside the cone volume from the base to the particle.
  18496. * The emission direction might be randomized.
  18497. */
  18498. export class ConeParticleEmitter implements IParticleEmitterType {
  18499. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18500. directionRandomizer: number;
  18501. private _radius;
  18502. private _angle;
  18503. private _height;
  18504. /**
  18505. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18506. */
  18507. radiusRange: number;
  18508. /**
  18509. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18510. */
  18511. heightRange: number;
  18512. /**
  18513. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18514. */
  18515. emitFromSpawnPointOnly: boolean;
  18516. /**
  18517. * Gets or sets the radius of the emission cone
  18518. */
  18519. get radius(): number;
  18520. set radius(value: number);
  18521. /**
  18522. * Gets or sets the angle of the emission cone
  18523. */
  18524. get angle(): number;
  18525. set angle(value: number);
  18526. private _buildHeight;
  18527. /**
  18528. * Creates a new instance ConeParticleEmitter
  18529. * @param radius the radius of the emission cone (1 by default)
  18530. * @param angle the cone base angle (PI by default)
  18531. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18532. */
  18533. constructor(radius?: number, angle?: number,
  18534. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18535. directionRandomizer?: number);
  18536. /**
  18537. * Called by the particle System when the direction is computed for the created particle.
  18538. * @param worldMatrix is the world matrix of the particle system
  18539. * @param directionToUpdate is the direction vector to update with the result
  18540. * @param particle is the particle we are computed the direction for
  18541. */
  18542. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18543. /**
  18544. * Called by the particle System when the position is computed for the created particle.
  18545. * @param worldMatrix is the world matrix of the particle system
  18546. * @param positionToUpdate is the position vector to update with the result
  18547. * @param particle is the particle we are computed the position for
  18548. */
  18549. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18550. /**
  18551. * Clones the current emitter and returns a copy of it
  18552. * @returns the new emitter
  18553. */
  18554. clone(): ConeParticleEmitter;
  18555. /**
  18556. * Called by the GPUParticleSystem to setup the update shader
  18557. * @param effect defines the update shader
  18558. */
  18559. applyToShader(effect: Effect): void;
  18560. /**
  18561. * Returns a string to use to update the GPU particles update shader
  18562. * @returns a string containng the defines string
  18563. */
  18564. getEffectDefines(): string;
  18565. /**
  18566. * Returns the string "ConeParticleEmitter"
  18567. * @returns a string containing the class name
  18568. */
  18569. getClassName(): string;
  18570. /**
  18571. * Serializes the particle system to a JSON object.
  18572. * @returns the JSON object
  18573. */
  18574. serialize(): any;
  18575. /**
  18576. * Parse properties from a JSON object
  18577. * @param serializationObject defines the JSON object
  18578. */
  18579. parse(serializationObject: any): void;
  18580. }
  18581. }
  18582. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18583. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18584. import { Effect } from "babylonjs/Materials/effect";
  18585. import { Particle } from "babylonjs/Particles/particle";
  18586. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18587. /**
  18588. * Particle emitter emitting particles from the inside of a cylinder.
  18589. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18590. */
  18591. export class CylinderParticleEmitter implements IParticleEmitterType {
  18592. /**
  18593. * The radius of the emission cylinder.
  18594. */
  18595. radius: number;
  18596. /**
  18597. * The height of the emission cylinder.
  18598. */
  18599. height: number;
  18600. /**
  18601. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18602. */
  18603. radiusRange: number;
  18604. /**
  18605. * How much to randomize the particle direction [0-1].
  18606. */
  18607. directionRandomizer: number;
  18608. /**
  18609. * Creates a new instance CylinderParticleEmitter
  18610. * @param radius the radius of the emission cylinder (1 by default)
  18611. * @param height the height of the emission cylinder (1 by default)
  18612. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18613. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18614. */
  18615. constructor(
  18616. /**
  18617. * The radius of the emission cylinder.
  18618. */
  18619. radius?: number,
  18620. /**
  18621. * The height of the emission cylinder.
  18622. */
  18623. height?: number,
  18624. /**
  18625. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18626. */
  18627. radiusRange?: number,
  18628. /**
  18629. * How much to randomize the particle direction [0-1].
  18630. */
  18631. directionRandomizer?: number);
  18632. /**
  18633. * Called by the particle System when the direction is computed for the created particle.
  18634. * @param worldMatrix is the world matrix of the particle system
  18635. * @param directionToUpdate is the direction vector to update with the result
  18636. * @param particle is the particle we are computed the direction for
  18637. */
  18638. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18639. /**
  18640. * Called by the particle System when the position is computed for the created particle.
  18641. * @param worldMatrix is the world matrix of the particle system
  18642. * @param positionToUpdate is the position vector to update with the result
  18643. * @param particle is the particle we are computed the position for
  18644. */
  18645. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18646. /**
  18647. * Clones the current emitter and returns a copy of it
  18648. * @returns the new emitter
  18649. */
  18650. clone(): CylinderParticleEmitter;
  18651. /**
  18652. * Called by the GPUParticleSystem to setup the update shader
  18653. * @param effect defines the update shader
  18654. */
  18655. applyToShader(effect: Effect): void;
  18656. /**
  18657. * Returns a string to use to update the GPU particles update shader
  18658. * @returns a string containng the defines string
  18659. */
  18660. getEffectDefines(): string;
  18661. /**
  18662. * Returns the string "CylinderParticleEmitter"
  18663. * @returns a string containing the class name
  18664. */
  18665. getClassName(): string;
  18666. /**
  18667. * Serializes the particle system to a JSON object.
  18668. * @returns the JSON object
  18669. */
  18670. serialize(): any;
  18671. /**
  18672. * Parse properties from a JSON object
  18673. * @param serializationObject defines the JSON object
  18674. */
  18675. parse(serializationObject: any): void;
  18676. }
  18677. /**
  18678. * Particle emitter emitting particles from the inside of a cylinder.
  18679. * It emits the particles randomly between two vectors.
  18680. */
  18681. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18682. /**
  18683. * The min limit of the emission direction.
  18684. */
  18685. direction1: Vector3;
  18686. /**
  18687. * The max limit of the emission direction.
  18688. */
  18689. direction2: Vector3;
  18690. /**
  18691. * Creates a new instance CylinderDirectedParticleEmitter
  18692. * @param radius the radius of the emission cylinder (1 by default)
  18693. * @param height the height of the emission cylinder (1 by default)
  18694. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18695. * @param direction1 the min limit of the emission direction (up vector by default)
  18696. * @param direction2 the max limit of the emission direction (up vector by default)
  18697. */
  18698. constructor(radius?: number, height?: number, radiusRange?: number,
  18699. /**
  18700. * The min limit of the emission direction.
  18701. */
  18702. direction1?: Vector3,
  18703. /**
  18704. * The max limit of the emission direction.
  18705. */
  18706. direction2?: Vector3);
  18707. /**
  18708. * Called by the particle System when the direction is computed for the created particle.
  18709. * @param worldMatrix is the world matrix of the particle system
  18710. * @param directionToUpdate is the direction vector to update with the result
  18711. * @param particle is the particle we are computed the direction for
  18712. */
  18713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18714. /**
  18715. * Clones the current emitter and returns a copy of it
  18716. * @returns the new emitter
  18717. */
  18718. clone(): CylinderDirectedParticleEmitter;
  18719. /**
  18720. * Called by the GPUParticleSystem to setup the update shader
  18721. * @param effect defines the update shader
  18722. */
  18723. applyToShader(effect: Effect): void;
  18724. /**
  18725. * Returns a string to use to update the GPU particles update shader
  18726. * @returns a string containng the defines string
  18727. */
  18728. getEffectDefines(): string;
  18729. /**
  18730. * Returns the string "CylinderDirectedParticleEmitter"
  18731. * @returns a string containing the class name
  18732. */
  18733. getClassName(): string;
  18734. /**
  18735. * Serializes the particle system to a JSON object.
  18736. * @returns the JSON object
  18737. */
  18738. serialize(): any;
  18739. /**
  18740. * Parse properties from a JSON object
  18741. * @param serializationObject defines the JSON object
  18742. */
  18743. parse(serializationObject: any): void;
  18744. }
  18745. }
  18746. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18747. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18748. import { Effect } from "babylonjs/Materials/effect";
  18749. import { Particle } from "babylonjs/Particles/particle";
  18750. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18751. /**
  18752. * Particle emitter emitting particles from the inside of a hemisphere.
  18753. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18754. */
  18755. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18756. /**
  18757. * The radius of the emission hemisphere.
  18758. */
  18759. radius: number;
  18760. /**
  18761. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18762. */
  18763. radiusRange: number;
  18764. /**
  18765. * How much to randomize the particle direction [0-1].
  18766. */
  18767. directionRandomizer: number;
  18768. /**
  18769. * Creates a new instance HemisphericParticleEmitter
  18770. * @param radius the radius of the emission hemisphere (1 by default)
  18771. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18772. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18773. */
  18774. constructor(
  18775. /**
  18776. * The radius of the emission hemisphere.
  18777. */
  18778. radius?: number,
  18779. /**
  18780. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18781. */
  18782. radiusRange?: number,
  18783. /**
  18784. * How much to randomize the particle direction [0-1].
  18785. */
  18786. directionRandomizer?: number);
  18787. /**
  18788. * Called by the particle System when the direction is computed for the created particle.
  18789. * @param worldMatrix is the world matrix of the particle system
  18790. * @param directionToUpdate is the direction vector to update with the result
  18791. * @param particle is the particle we are computed the direction for
  18792. */
  18793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18794. /**
  18795. * Called by the particle System when the position is computed for the created particle.
  18796. * @param worldMatrix is the world matrix of the particle system
  18797. * @param positionToUpdate is the position vector to update with the result
  18798. * @param particle is the particle we are computed the position for
  18799. */
  18800. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18801. /**
  18802. * Clones the current emitter and returns a copy of it
  18803. * @returns the new emitter
  18804. */
  18805. clone(): HemisphericParticleEmitter;
  18806. /**
  18807. * Called by the GPUParticleSystem to setup the update shader
  18808. * @param effect defines the update shader
  18809. */
  18810. applyToShader(effect: Effect): void;
  18811. /**
  18812. * Returns a string to use to update the GPU particles update shader
  18813. * @returns a string containng the defines string
  18814. */
  18815. getEffectDefines(): string;
  18816. /**
  18817. * Returns the string "HemisphericParticleEmitter"
  18818. * @returns a string containing the class name
  18819. */
  18820. getClassName(): string;
  18821. /**
  18822. * Serializes the particle system to a JSON object.
  18823. * @returns the JSON object
  18824. */
  18825. serialize(): any;
  18826. /**
  18827. * Parse properties from a JSON object
  18828. * @param serializationObject defines the JSON object
  18829. */
  18830. parse(serializationObject: any): void;
  18831. }
  18832. }
  18833. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18834. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18835. import { Effect } from "babylonjs/Materials/effect";
  18836. import { Particle } from "babylonjs/Particles/particle";
  18837. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18838. /**
  18839. * Particle emitter emitting particles from a point.
  18840. * It emits the particles randomly between 2 given directions.
  18841. */
  18842. export class PointParticleEmitter implements IParticleEmitterType {
  18843. /**
  18844. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18845. */
  18846. direction1: Vector3;
  18847. /**
  18848. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18849. */
  18850. direction2: Vector3;
  18851. /**
  18852. * Creates a new instance PointParticleEmitter
  18853. */
  18854. constructor();
  18855. /**
  18856. * Called by the particle System when the direction is computed for the created particle.
  18857. * @param worldMatrix is the world matrix of the particle system
  18858. * @param directionToUpdate is the direction vector to update with the result
  18859. * @param particle is the particle we are computed the direction for
  18860. */
  18861. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18862. /**
  18863. * Called by the particle System when the position is computed for the created particle.
  18864. * @param worldMatrix is the world matrix of the particle system
  18865. * @param positionToUpdate is the position vector to update with the result
  18866. * @param particle is the particle we are computed the position for
  18867. */
  18868. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18869. /**
  18870. * Clones the current emitter and returns a copy of it
  18871. * @returns the new emitter
  18872. */
  18873. clone(): PointParticleEmitter;
  18874. /**
  18875. * Called by the GPUParticleSystem to setup the update shader
  18876. * @param effect defines the update shader
  18877. */
  18878. applyToShader(effect: Effect): void;
  18879. /**
  18880. * Returns a string to use to update the GPU particles update shader
  18881. * @returns a string containng the defines string
  18882. */
  18883. getEffectDefines(): string;
  18884. /**
  18885. * Returns the string "PointParticleEmitter"
  18886. * @returns a string containing the class name
  18887. */
  18888. getClassName(): string;
  18889. /**
  18890. * Serializes the particle system to a JSON object.
  18891. * @returns the JSON object
  18892. */
  18893. serialize(): any;
  18894. /**
  18895. * Parse properties from a JSON object
  18896. * @param serializationObject defines the JSON object
  18897. */
  18898. parse(serializationObject: any): void;
  18899. }
  18900. }
  18901. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18902. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18903. import { Effect } from "babylonjs/Materials/effect";
  18904. import { Particle } from "babylonjs/Particles/particle";
  18905. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18906. /**
  18907. * Particle emitter emitting particles from the inside of a sphere.
  18908. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18909. */
  18910. export class SphereParticleEmitter implements IParticleEmitterType {
  18911. /**
  18912. * The radius of the emission sphere.
  18913. */
  18914. radius: number;
  18915. /**
  18916. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18917. */
  18918. radiusRange: number;
  18919. /**
  18920. * How much to randomize the particle direction [0-1].
  18921. */
  18922. directionRandomizer: number;
  18923. /**
  18924. * Creates a new instance SphereParticleEmitter
  18925. * @param radius the radius of the emission sphere (1 by default)
  18926. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18927. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18928. */
  18929. constructor(
  18930. /**
  18931. * The radius of the emission sphere.
  18932. */
  18933. radius?: number,
  18934. /**
  18935. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18936. */
  18937. radiusRange?: number,
  18938. /**
  18939. * How much to randomize the particle direction [0-1].
  18940. */
  18941. directionRandomizer?: number);
  18942. /**
  18943. * Called by the particle System when the direction is computed for the created particle.
  18944. * @param worldMatrix is the world matrix of the particle system
  18945. * @param directionToUpdate is the direction vector to update with the result
  18946. * @param particle is the particle we are computed the direction for
  18947. */
  18948. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18949. /**
  18950. * Called by the particle System when the position is computed for the created particle.
  18951. * @param worldMatrix is the world matrix of the particle system
  18952. * @param positionToUpdate is the position vector to update with the result
  18953. * @param particle is the particle we are computed the position for
  18954. */
  18955. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18956. /**
  18957. * Clones the current emitter and returns a copy of it
  18958. * @returns the new emitter
  18959. */
  18960. clone(): SphereParticleEmitter;
  18961. /**
  18962. * Called by the GPUParticleSystem to setup the update shader
  18963. * @param effect defines the update shader
  18964. */
  18965. applyToShader(effect: Effect): void;
  18966. /**
  18967. * Returns a string to use to update the GPU particles update shader
  18968. * @returns a string containng the defines string
  18969. */
  18970. getEffectDefines(): string;
  18971. /**
  18972. * Returns the string "SphereParticleEmitter"
  18973. * @returns a string containing the class name
  18974. */
  18975. getClassName(): string;
  18976. /**
  18977. * Serializes the particle system to a JSON object.
  18978. * @returns the JSON object
  18979. */
  18980. serialize(): any;
  18981. /**
  18982. * Parse properties from a JSON object
  18983. * @param serializationObject defines the JSON object
  18984. */
  18985. parse(serializationObject: any): void;
  18986. }
  18987. /**
  18988. * Particle emitter emitting particles from the inside of a sphere.
  18989. * It emits the particles randomly between two vectors.
  18990. */
  18991. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18992. /**
  18993. * The min limit of the emission direction.
  18994. */
  18995. direction1: Vector3;
  18996. /**
  18997. * The max limit of the emission direction.
  18998. */
  18999. direction2: Vector3;
  19000. /**
  19001. * Creates a new instance SphereDirectedParticleEmitter
  19002. * @param radius the radius of the emission sphere (1 by default)
  19003. * @param direction1 the min limit of the emission direction (up vector by default)
  19004. * @param direction2 the max limit of the emission direction (up vector by default)
  19005. */
  19006. constructor(radius?: number,
  19007. /**
  19008. * The min limit of the emission direction.
  19009. */
  19010. direction1?: Vector3,
  19011. /**
  19012. * The max limit of the emission direction.
  19013. */
  19014. direction2?: Vector3);
  19015. /**
  19016. * Called by the particle System when the direction is computed for the created particle.
  19017. * @param worldMatrix is the world matrix of the particle system
  19018. * @param directionToUpdate is the direction vector to update with the result
  19019. * @param particle is the particle we are computed the direction for
  19020. */
  19021. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19022. /**
  19023. * Clones the current emitter and returns a copy of it
  19024. * @returns the new emitter
  19025. */
  19026. clone(): SphereDirectedParticleEmitter;
  19027. /**
  19028. * Called by the GPUParticleSystem to setup the update shader
  19029. * @param effect defines the update shader
  19030. */
  19031. applyToShader(effect: Effect): void;
  19032. /**
  19033. * Returns a string to use to update the GPU particles update shader
  19034. * @returns a string containng the defines string
  19035. */
  19036. getEffectDefines(): string;
  19037. /**
  19038. * Returns the string "SphereDirectedParticleEmitter"
  19039. * @returns a string containing the class name
  19040. */
  19041. getClassName(): string;
  19042. /**
  19043. * Serializes the particle system to a JSON object.
  19044. * @returns the JSON object
  19045. */
  19046. serialize(): any;
  19047. /**
  19048. * Parse properties from a JSON object
  19049. * @param serializationObject defines the JSON object
  19050. */
  19051. parse(serializationObject: any): void;
  19052. }
  19053. }
  19054. declare module "babylonjs/Particles/EmitterTypes/index" {
  19055. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19056. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19057. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19058. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19059. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19060. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19061. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19062. }
  19063. declare module "babylonjs/Particles/IParticleSystem" {
  19064. import { Nullable } from "babylonjs/types";
  19065. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19066. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19069. import { Texture } from "babylonjs/Materials/Textures/texture";
  19070. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19071. import { Scene } from "babylonjs/scene";
  19072. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19073. import { Animation } from "babylonjs/Animations/animation";
  19074. /**
  19075. * Interface representing a particle system in Babylon.js.
  19076. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19077. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19078. */
  19079. export interface IParticleSystem {
  19080. /**
  19081. * List of animations used by the particle system.
  19082. */
  19083. animations: Animation[];
  19084. /**
  19085. * The id of the Particle system.
  19086. */
  19087. id: string;
  19088. /**
  19089. * The name of the Particle system.
  19090. */
  19091. name: string;
  19092. /**
  19093. * The emitter represents the Mesh or position we are attaching the particle system to.
  19094. */
  19095. emitter: Nullable<AbstractMesh | Vector3>;
  19096. /**
  19097. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19098. */
  19099. isBillboardBased: boolean;
  19100. /**
  19101. * The rendering group used by the Particle system to chose when to render.
  19102. */
  19103. renderingGroupId: number;
  19104. /**
  19105. * The layer mask we are rendering the particles through.
  19106. */
  19107. layerMask: number;
  19108. /**
  19109. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19110. */
  19111. updateSpeed: number;
  19112. /**
  19113. * The amount of time the particle system is running (depends of the overall update speed).
  19114. */
  19115. targetStopDuration: number;
  19116. /**
  19117. * The texture used to render each particle. (this can be a spritesheet)
  19118. */
  19119. particleTexture: Nullable<Texture>;
  19120. /**
  19121. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19122. */
  19123. blendMode: number;
  19124. /**
  19125. * Minimum life time of emitting particles.
  19126. */
  19127. minLifeTime: number;
  19128. /**
  19129. * Maximum life time of emitting particles.
  19130. */
  19131. maxLifeTime: number;
  19132. /**
  19133. * Minimum Size of emitting particles.
  19134. */
  19135. minSize: number;
  19136. /**
  19137. * Maximum Size of emitting particles.
  19138. */
  19139. maxSize: number;
  19140. /**
  19141. * Minimum scale of emitting particles on X axis.
  19142. */
  19143. minScaleX: number;
  19144. /**
  19145. * Maximum scale of emitting particles on X axis.
  19146. */
  19147. maxScaleX: number;
  19148. /**
  19149. * Minimum scale of emitting particles on Y axis.
  19150. */
  19151. minScaleY: number;
  19152. /**
  19153. * Maximum scale of emitting particles on Y axis.
  19154. */
  19155. maxScaleY: number;
  19156. /**
  19157. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19158. */
  19159. color1: Color4;
  19160. /**
  19161. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19162. */
  19163. color2: Color4;
  19164. /**
  19165. * Color the particle will have at the end of its lifetime.
  19166. */
  19167. colorDead: Color4;
  19168. /**
  19169. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19170. */
  19171. emitRate: number;
  19172. /**
  19173. * You can use gravity if you want to give an orientation to your particles.
  19174. */
  19175. gravity: Vector3;
  19176. /**
  19177. * Minimum power of emitting particles.
  19178. */
  19179. minEmitPower: number;
  19180. /**
  19181. * Maximum power of emitting particles.
  19182. */
  19183. maxEmitPower: number;
  19184. /**
  19185. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19186. */
  19187. minAngularSpeed: number;
  19188. /**
  19189. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19190. */
  19191. maxAngularSpeed: number;
  19192. /**
  19193. * Gets or sets the minimal initial rotation in radians.
  19194. */
  19195. minInitialRotation: number;
  19196. /**
  19197. * Gets or sets the maximal initial rotation in radians.
  19198. */
  19199. maxInitialRotation: number;
  19200. /**
  19201. * The particle emitter type defines the emitter used by the particle system.
  19202. * It can be for example box, sphere, or cone...
  19203. */
  19204. particleEmitterType: Nullable<IParticleEmitterType>;
  19205. /**
  19206. * Defines the delay in milliseconds before starting the system (0 by default)
  19207. */
  19208. startDelay: number;
  19209. /**
  19210. * 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
  19211. */
  19212. preWarmCycles: number;
  19213. /**
  19214. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19215. */
  19216. preWarmStepOffset: number;
  19217. /**
  19218. * 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)
  19219. */
  19220. spriteCellChangeSpeed: number;
  19221. /**
  19222. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19223. */
  19224. startSpriteCellID: number;
  19225. /**
  19226. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19227. */
  19228. endSpriteCellID: number;
  19229. /**
  19230. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19231. */
  19232. spriteCellWidth: number;
  19233. /**
  19234. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19235. */
  19236. spriteCellHeight: number;
  19237. /**
  19238. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19239. */
  19240. spriteRandomStartCell: boolean;
  19241. /**
  19242. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19243. */
  19244. isAnimationSheetEnabled: boolean;
  19245. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19246. translationPivot: Vector2;
  19247. /**
  19248. * Gets or sets a texture used to add random noise to particle positions
  19249. */
  19250. noiseTexture: Nullable<BaseTexture>;
  19251. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19252. noiseStrength: Vector3;
  19253. /**
  19254. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19255. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19256. */
  19257. billboardMode: number;
  19258. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19259. limitVelocityDamping: number;
  19260. /**
  19261. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19262. */
  19263. beginAnimationOnStart: boolean;
  19264. /**
  19265. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19266. */
  19267. beginAnimationFrom: number;
  19268. /**
  19269. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19270. */
  19271. beginAnimationTo: number;
  19272. /**
  19273. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19274. */
  19275. beginAnimationLoop: boolean;
  19276. /**
  19277. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19278. */
  19279. disposeOnStop: boolean;
  19280. /**
  19281. * Gets the maximum number of particles active at the same time.
  19282. * @returns The max number of active particles.
  19283. */
  19284. getCapacity(): number;
  19285. /**
  19286. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19287. * @returns True if it has been started, otherwise false.
  19288. */
  19289. isStarted(): boolean;
  19290. /**
  19291. * Animates the particle system for this frame.
  19292. */
  19293. animate(): void;
  19294. /**
  19295. * Renders the particle system in its current state.
  19296. * @returns the current number of particles
  19297. */
  19298. render(): number;
  19299. /**
  19300. * Dispose the particle system and frees its associated resources.
  19301. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19302. */
  19303. dispose(disposeTexture?: boolean): void;
  19304. /**
  19305. * Clones the particle system.
  19306. * @param name The name of the cloned object
  19307. * @param newEmitter The new emitter to use
  19308. * @returns the cloned particle system
  19309. */
  19310. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19311. /**
  19312. * Serializes the particle system to a JSON object.
  19313. * @returns the JSON object
  19314. */
  19315. serialize(): any;
  19316. /**
  19317. * Rebuild the particle system
  19318. */
  19319. rebuild(): void;
  19320. /**
  19321. * Starts the particle system and begins to emit
  19322. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19323. */
  19324. start(delay?: number): void;
  19325. /**
  19326. * Stops the particle system.
  19327. */
  19328. stop(): void;
  19329. /**
  19330. * Remove all active particles
  19331. */
  19332. reset(): void;
  19333. /**
  19334. * Is this system ready to be used/rendered
  19335. * @return true if the system is ready
  19336. */
  19337. isReady(): boolean;
  19338. /**
  19339. * Adds a new color gradient
  19340. * @param gradient defines the gradient to use (between 0 and 1)
  19341. * @param color1 defines the color to affect to the specified gradient
  19342. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19343. * @returns the current particle system
  19344. */
  19345. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19346. /**
  19347. * Remove a specific color gradient
  19348. * @param gradient defines the gradient to remove
  19349. * @returns the current particle system
  19350. */
  19351. removeColorGradient(gradient: number): IParticleSystem;
  19352. /**
  19353. * Adds a new size gradient
  19354. * @param gradient defines the gradient to use (between 0 and 1)
  19355. * @param factor defines the size factor to affect to the specified gradient
  19356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19357. * @returns the current particle system
  19358. */
  19359. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19360. /**
  19361. * Remove a specific size gradient
  19362. * @param gradient defines the gradient to remove
  19363. * @returns the current particle system
  19364. */
  19365. removeSizeGradient(gradient: number): IParticleSystem;
  19366. /**
  19367. * Gets the current list of color gradients.
  19368. * You must use addColorGradient and removeColorGradient to udpate this list
  19369. * @returns the list of color gradients
  19370. */
  19371. getColorGradients(): Nullable<Array<ColorGradient>>;
  19372. /**
  19373. * Gets the current list of size gradients.
  19374. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19375. * @returns the list of size gradients
  19376. */
  19377. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19378. /**
  19379. * Gets the current list of angular speed gradients.
  19380. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19381. * @returns the list of angular speed gradients
  19382. */
  19383. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19384. /**
  19385. * Adds a new angular speed gradient
  19386. * @param gradient defines the gradient to use (between 0 and 1)
  19387. * @param factor defines the angular speed to affect to the specified gradient
  19388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19389. * @returns the current particle system
  19390. */
  19391. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19392. /**
  19393. * Remove a specific angular speed gradient
  19394. * @param gradient defines the gradient to remove
  19395. * @returns the current particle system
  19396. */
  19397. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19398. /**
  19399. * Gets the current list of velocity gradients.
  19400. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19401. * @returns the list of velocity gradients
  19402. */
  19403. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19404. /**
  19405. * Adds a new velocity gradient
  19406. * @param gradient defines the gradient to use (between 0 and 1)
  19407. * @param factor defines the velocity to affect to the specified gradient
  19408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19409. * @returns the current particle system
  19410. */
  19411. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19412. /**
  19413. * Remove a specific velocity gradient
  19414. * @param gradient defines the gradient to remove
  19415. * @returns the current particle system
  19416. */
  19417. removeVelocityGradient(gradient: number): IParticleSystem;
  19418. /**
  19419. * Gets the current list of limit velocity gradients.
  19420. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19421. * @returns the list of limit velocity gradients
  19422. */
  19423. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19424. /**
  19425. * Adds a new limit velocity gradient
  19426. * @param gradient defines the gradient to use (between 0 and 1)
  19427. * @param factor defines the limit velocity to affect to the specified gradient
  19428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19429. * @returns the current particle system
  19430. */
  19431. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19432. /**
  19433. * Remove a specific limit velocity gradient
  19434. * @param gradient defines the gradient to remove
  19435. * @returns the current particle system
  19436. */
  19437. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19438. /**
  19439. * Adds a new drag gradient
  19440. * @param gradient defines the gradient to use (between 0 and 1)
  19441. * @param factor defines the drag to affect to the specified gradient
  19442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19443. * @returns the current particle system
  19444. */
  19445. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19446. /**
  19447. * Remove a specific drag gradient
  19448. * @param gradient defines the gradient to remove
  19449. * @returns the current particle system
  19450. */
  19451. removeDragGradient(gradient: number): IParticleSystem;
  19452. /**
  19453. * Gets the current list of drag gradients.
  19454. * You must use addDragGradient and removeDragGradient to udpate this list
  19455. * @returns the list of drag gradients
  19456. */
  19457. getDragGradients(): Nullable<Array<FactorGradient>>;
  19458. /**
  19459. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19460. * @param gradient defines the gradient to use (between 0 and 1)
  19461. * @param factor defines the emit rate to affect to the specified gradient
  19462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19463. * @returns the current particle system
  19464. */
  19465. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19466. /**
  19467. * Remove a specific emit rate gradient
  19468. * @param gradient defines the gradient to remove
  19469. * @returns the current particle system
  19470. */
  19471. removeEmitRateGradient(gradient: number): IParticleSystem;
  19472. /**
  19473. * Gets the current list of emit rate gradients.
  19474. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19475. * @returns the list of emit rate gradients
  19476. */
  19477. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19478. /**
  19479. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19480. * @param gradient defines the gradient to use (between 0 and 1)
  19481. * @param factor defines the start size to affect to the specified gradient
  19482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19483. * @returns the current particle system
  19484. */
  19485. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19486. /**
  19487. * Remove a specific start size gradient
  19488. * @param gradient defines the gradient to remove
  19489. * @returns the current particle system
  19490. */
  19491. removeStartSizeGradient(gradient: number): IParticleSystem;
  19492. /**
  19493. * Gets the current list of start size gradients.
  19494. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19495. * @returns the list of start size gradients
  19496. */
  19497. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19498. /**
  19499. * Adds a new life time gradient
  19500. * @param gradient defines the gradient to use (between 0 and 1)
  19501. * @param factor defines the life time factor to affect to the specified gradient
  19502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19503. * @returns the current particle system
  19504. */
  19505. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19506. /**
  19507. * Remove a specific life time gradient
  19508. * @param gradient defines the gradient to remove
  19509. * @returns the current particle system
  19510. */
  19511. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19512. /**
  19513. * Gets the current list of life time gradients.
  19514. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19515. * @returns the list of life time gradients
  19516. */
  19517. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19518. /**
  19519. * Gets the current list of color gradients.
  19520. * You must use addColorGradient and removeColorGradient to udpate this list
  19521. * @returns the list of color gradients
  19522. */
  19523. getColorGradients(): Nullable<Array<ColorGradient>>;
  19524. /**
  19525. * Adds a new ramp gradient used to remap particle colors
  19526. * @param gradient defines the gradient to use (between 0 and 1)
  19527. * @param color defines the color to affect to the specified gradient
  19528. * @returns the current particle system
  19529. */
  19530. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19531. /**
  19532. * Gets the current list of ramp gradients.
  19533. * You must use addRampGradient and removeRampGradient to udpate this list
  19534. * @returns the list of ramp gradients
  19535. */
  19536. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19537. /** Gets or sets a boolean indicating that ramp gradients must be used
  19538. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19539. */
  19540. useRampGradients: boolean;
  19541. /**
  19542. * Adds a new color remap gradient
  19543. * @param gradient defines the gradient to use (between 0 and 1)
  19544. * @param min defines the color remap minimal range
  19545. * @param max defines the color remap maximal range
  19546. * @returns the current particle system
  19547. */
  19548. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19549. /**
  19550. * Gets the current list of color remap gradients.
  19551. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19552. * @returns the list of color remap gradients
  19553. */
  19554. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19555. /**
  19556. * Adds a new alpha remap gradient
  19557. * @param gradient defines the gradient to use (between 0 and 1)
  19558. * @param min defines the alpha remap minimal range
  19559. * @param max defines the alpha remap maximal range
  19560. * @returns the current particle system
  19561. */
  19562. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19563. /**
  19564. * Gets the current list of alpha remap gradients.
  19565. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19566. * @returns the list of alpha remap gradients
  19567. */
  19568. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19569. /**
  19570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19573. * @returns the emitter
  19574. */
  19575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19576. /**
  19577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19578. * @param radius The radius of the hemisphere to emit from
  19579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19580. * @returns the emitter
  19581. */
  19582. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19583. /**
  19584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19585. * @param radius The radius of the sphere to emit from
  19586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19587. * @returns the emitter
  19588. */
  19589. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19590. /**
  19591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19592. * @param radius The radius of the sphere to emit from
  19593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19595. * @returns the emitter
  19596. */
  19597. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19598. /**
  19599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19600. * @param radius The radius of the emission cylinder
  19601. * @param height The height of the emission cylinder
  19602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19604. * @returns the emitter
  19605. */
  19606. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19607. /**
  19608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19609. * @param radius The radius of the cylinder to emit from
  19610. * @param height The height of the emission cylinder
  19611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19614. * @returns the emitter
  19615. */
  19616. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19617. /**
  19618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19619. * @param radius The radius of the cone to emit from
  19620. * @param angle The base angle of the cone
  19621. * @returns the emitter
  19622. */
  19623. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19624. /**
  19625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19630. * @returns the emitter
  19631. */
  19632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19633. /**
  19634. * Get hosting scene
  19635. * @returns the scene
  19636. */
  19637. getScene(): Scene;
  19638. }
  19639. }
  19640. declare module "babylonjs/Meshes/instancedMesh" {
  19641. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19642. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19643. import { Camera } from "babylonjs/Cameras/camera";
  19644. import { Node } from "babylonjs/node";
  19645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19646. import { Mesh } from "babylonjs/Meshes/mesh";
  19647. import { Material } from "babylonjs/Materials/material";
  19648. import { Skeleton } from "babylonjs/Bones/skeleton";
  19649. import { Light } from "babylonjs/Lights/light";
  19650. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19651. /**
  19652. * Creates an instance based on a source mesh.
  19653. */
  19654. export class InstancedMesh extends AbstractMesh {
  19655. private _sourceMesh;
  19656. private _currentLOD;
  19657. /** @hidden */
  19658. _indexInSourceMeshInstanceArray: number;
  19659. constructor(name: string, source: Mesh);
  19660. /**
  19661. * Returns the string "InstancedMesh".
  19662. */
  19663. getClassName(): string;
  19664. /** Gets the list of lights affecting that mesh */
  19665. get lightSources(): Light[];
  19666. _resyncLightSources(): void;
  19667. _resyncLightSource(light: Light): void;
  19668. _removeLightSource(light: Light, dispose: boolean): void;
  19669. /**
  19670. * If the source mesh receives shadows
  19671. */
  19672. get receiveShadows(): boolean;
  19673. /**
  19674. * The material of the source mesh
  19675. */
  19676. get material(): Nullable<Material>;
  19677. /**
  19678. * Visibility of the source mesh
  19679. */
  19680. get visibility(): number;
  19681. /**
  19682. * Skeleton of the source mesh
  19683. */
  19684. get skeleton(): Nullable<Skeleton>;
  19685. /**
  19686. * Rendering ground id of the source mesh
  19687. */
  19688. get renderingGroupId(): number;
  19689. set renderingGroupId(value: number);
  19690. /**
  19691. * Returns the total number of vertices (integer).
  19692. */
  19693. getTotalVertices(): number;
  19694. /**
  19695. * Returns a positive integer : the total number of indices in this mesh geometry.
  19696. * @returns the numner of indices or zero if the mesh has no geometry.
  19697. */
  19698. getTotalIndices(): number;
  19699. /**
  19700. * The source mesh of the instance
  19701. */
  19702. get sourceMesh(): Mesh;
  19703. /**
  19704. * Is this node ready to be used/rendered
  19705. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19706. * @return {boolean} is it ready
  19707. */
  19708. isReady(completeCheck?: boolean): boolean;
  19709. /**
  19710. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19711. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19712. * @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.
  19713. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19714. */
  19715. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19716. /**
  19717. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19718. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19719. * The `data` are either a numeric array either a Float32Array.
  19720. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19721. * 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).
  19722. * Note that a new underlying VertexBuffer object is created each call.
  19723. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19724. *
  19725. * Possible `kind` values :
  19726. * - VertexBuffer.PositionKind
  19727. * - VertexBuffer.UVKind
  19728. * - VertexBuffer.UV2Kind
  19729. * - VertexBuffer.UV3Kind
  19730. * - VertexBuffer.UV4Kind
  19731. * - VertexBuffer.UV5Kind
  19732. * - VertexBuffer.UV6Kind
  19733. * - VertexBuffer.ColorKind
  19734. * - VertexBuffer.MatricesIndicesKind
  19735. * - VertexBuffer.MatricesIndicesExtraKind
  19736. * - VertexBuffer.MatricesWeightsKind
  19737. * - VertexBuffer.MatricesWeightsExtraKind
  19738. *
  19739. * Returns the Mesh.
  19740. */
  19741. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19742. /**
  19743. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19744. * If the mesh has no geometry, it is simply returned as it is.
  19745. * The `data` are either a numeric array either a Float32Array.
  19746. * No new underlying VertexBuffer object is created.
  19747. * 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.
  19748. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19749. *
  19750. * Possible `kind` values :
  19751. * - VertexBuffer.PositionKind
  19752. * - VertexBuffer.UVKind
  19753. * - VertexBuffer.UV2Kind
  19754. * - VertexBuffer.UV3Kind
  19755. * - VertexBuffer.UV4Kind
  19756. * - VertexBuffer.UV5Kind
  19757. * - VertexBuffer.UV6Kind
  19758. * - VertexBuffer.ColorKind
  19759. * - VertexBuffer.MatricesIndicesKind
  19760. * - VertexBuffer.MatricesIndicesExtraKind
  19761. * - VertexBuffer.MatricesWeightsKind
  19762. * - VertexBuffer.MatricesWeightsExtraKind
  19763. *
  19764. * Returns the Mesh.
  19765. */
  19766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19767. /**
  19768. * Sets the mesh indices.
  19769. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19770. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19771. * This method creates a new index buffer each call.
  19772. * Returns the Mesh.
  19773. */
  19774. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19775. /**
  19776. * Boolean : True if the mesh owns the requested kind of data.
  19777. */
  19778. isVerticesDataPresent(kind: string): boolean;
  19779. /**
  19780. * Returns an array of indices (IndicesArray).
  19781. */
  19782. getIndices(): Nullable<IndicesArray>;
  19783. get _positions(): Nullable<Vector3[]>;
  19784. /**
  19785. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19786. * This means the mesh underlying bounding box and sphere are recomputed.
  19787. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19788. * @returns the current mesh
  19789. */
  19790. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19791. /** @hidden */
  19792. _preActivate(): InstancedMesh;
  19793. /** @hidden */
  19794. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19795. /** @hidden */
  19796. _postActivate(): void;
  19797. getWorldMatrix(): Matrix;
  19798. get isAnInstance(): boolean;
  19799. /**
  19800. * Returns the current associated LOD AbstractMesh.
  19801. */
  19802. getLOD(camera: Camera): AbstractMesh;
  19803. /** @hidden */
  19804. _syncSubMeshes(): InstancedMesh;
  19805. /** @hidden */
  19806. _generatePointsArray(): boolean;
  19807. /**
  19808. * Creates a new InstancedMesh from the current mesh.
  19809. * - name (string) : the cloned mesh name
  19810. * - newParent (optional Node) : the optional Node to parent the clone to.
  19811. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19812. *
  19813. * Returns the clone.
  19814. */
  19815. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19816. /**
  19817. * Disposes the InstancedMesh.
  19818. * Returns nothing.
  19819. */
  19820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19821. }
  19822. module "babylonjs/Meshes/mesh" {
  19823. interface Mesh {
  19824. /**
  19825. * Register a custom buffer that will be instanced
  19826. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19827. * @param kind defines the buffer kind
  19828. * @param stride defines the stride in floats
  19829. */
  19830. registerInstancedBuffer(kind: string, stride: number): void;
  19831. /** @hidden */
  19832. _userInstancedBuffersStorage: {
  19833. data: {
  19834. [key: string]: Float32Array;
  19835. };
  19836. sizes: {
  19837. [key: string]: number;
  19838. };
  19839. vertexBuffers: {
  19840. [key: string]: Nullable<VertexBuffer>;
  19841. };
  19842. strides: {
  19843. [key: string]: number;
  19844. };
  19845. };
  19846. }
  19847. }
  19848. module "babylonjs/Meshes/abstractMesh" {
  19849. interface AbstractMesh {
  19850. /**
  19851. * Object used to store instanced buffers defined by user
  19852. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19853. */
  19854. instancedBuffers: {
  19855. [key: string]: any;
  19856. };
  19857. }
  19858. }
  19859. }
  19860. declare module "babylonjs/Materials/shaderMaterial" {
  19861. import { Scene } from "babylonjs/scene";
  19862. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19864. import { Mesh } from "babylonjs/Meshes/mesh";
  19865. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19867. import { Texture } from "babylonjs/Materials/Textures/texture";
  19868. import { Material } from "babylonjs/Materials/material";
  19869. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19870. /**
  19871. * Defines the options associated with the creation of a shader material.
  19872. */
  19873. export interface IShaderMaterialOptions {
  19874. /**
  19875. * Does the material work in alpha blend mode
  19876. */
  19877. needAlphaBlending: boolean;
  19878. /**
  19879. * Does the material work in alpha test mode
  19880. */
  19881. needAlphaTesting: boolean;
  19882. /**
  19883. * The list of attribute names used in the shader
  19884. */
  19885. attributes: string[];
  19886. /**
  19887. * The list of unifrom names used in the shader
  19888. */
  19889. uniforms: string[];
  19890. /**
  19891. * The list of UBO names used in the shader
  19892. */
  19893. uniformBuffers: string[];
  19894. /**
  19895. * The list of sampler names used in the shader
  19896. */
  19897. samplers: string[];
  19898. /**
  19899. * The list of defines used in the shader
  19900. */
  19901. defines: string[];
  19902. }
  19903. /**
  19904. * 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.
  19905. *
  19906. * This returned material effects how the mesh will look based on the code in the shaders.
  19907. *
  19908. * @see http://doc.babylonjs.com/how_to/shader_material
  19909. */
  19910. export class ShaderMaterial extends Material {
  19911. private _shaderPath;
  19912. private _options;
  19913. private _textures;
  19914. private _textureArrays;
  19915. private _floats;
  19916. private _ints;
  19917. private _floatsArrays;
  19918. private _colors3;
  19919. private _colors3Arrays;
  19920. private _colors4;
  19921. private _colors4Arrays;
  19922. private _vectors2;
  19923. private _vectors3;
  19924. private _vectors4;
  19925. private _matrices;
  19926. private _matrixArrays;
  19927. private _matrices3x3;
  19928. private _matrices2x2;
  19929. private _vectors2Arrays;
  19930. private _vectors3Arrays;
  19931. private _vectors4Arrays;
  19932. private _cachedWorldViewMatrix;
  19933. private _cachedWorldViewProjectionMatrix;
  19934. private _renderId;
  19935. private _multiview;
  19936. /**
  19937. * Instantiate a new shader material.
  19938. * 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.
  19939. * This returned material effects how the mesh will look based on the code in the shaders.
  19940. * @see http://doc.babylonjs.com/how_to/shader_material
  19941. * @param name Define the name of the material in the scene
  19942. * @param scene Define the scene the material belongs to
  19943. * @param shaderPath Defines the route to the shader code in one of three ways:
  19944. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19945. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19946. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19947. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19948. * @param options Define the options used to create the shader
  19949. */
  19950. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19951. /**
  19952. * Gets the shader path used to define the shader code
  19953. * It can be modified to trigger a new compilation
  19954. */
  19955. get shaderPath(): any;
  19956. /**
  19957. * Sets the shader path used to define the shader code
  19958. * It can be modified to trigger a new compilation
  19959. */
  19960. set shaderPath(shaderPath: any);
  19961. /**
  19962. * Gets the options used to compile the shader.
  19963. * They can be modified to trigger a new compilation
  19964. */
  19965. get options(): IShaderMaterialOptions;
  19966. /**
  19967. * Gets the current class name of the material e.g. "ShaderMaterial"
  19968. * Mainly use in serialization.
  19969. * @returns the class name
  19970. */
  19971. getClassName(): string;
  19972. /**
  19973. * Specifies if the material will require alpha blending
  19974. * @returns a boolean specifying if alpha blending is needed
  19975. */
  19976. needAlphaBlending(): boolean;
  19977. /**
  19978. * Specifies if this material should be rendered in alpha test mode
  19979. * @returns a boolean specifying if an alpha test is needed.
  19980. */
  19981. needAlphaTesting(): boolean;
  19982. private _checkUniform;
  19983. /**
  19984. * Set a texture in the shader.
  19985. * @param name Define the name of the uniform samplers as defined in the shader
  19986. * @param texture Define the texture to bind to this sampler
  19987. * @return the material itself allowing "fluent" like uniform updates
  19988. */
  19989. setTexture(name: string, texture: Texture): ShaderMaterial;
  19990. /**
  19991. * Set a texture array in the shader.
  19992. * @param name Define the name of the uniform sampler array as defined in the shader
  19993. * @param textures Define the list of textures to bind to this sampler
  19994. * @return the material itself allowing "fluent" like uniform updates
  19995. */
  19996. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19997. /**
  19998. * Set a float in the shader.
  19999. * @param name Define the name of the uniform as defined in the shader
  20000. * @param value Define the value to give to the uniform
  20001. * @return the material itself allowing "fluent" like uniform updates
  20002. */
  20003. setFloat(name: string, value: number): ShaderMaterial;
  20004. /**
  20005. * Set a int in the shader.
  20006. * @param name Define the name of the uniform as defined in the shader
  20007. * @param value Define the value to give to the uniform
  20008. * @return the material itself allowing "fluent" like uniform updates
  20009. */
  20010. setInt(name: string, value: number): ShaderMaterial;
  20011. /**
  20012. * Set an array of floats in the shader.
  20013. * @param name Define the name of the uniform as defined in the shader
  20014. * @param value Define the value to give to the uniform
  20015. * @return the material itself allowing "fluent" like uniform updates
  20016. */
  20017. setFloats(name: string, value: number[]): ShaderMaterial;
  20018. /**
  20019. * Set a vec3 in the shader from a Color3.
  20020. * @param name Define the name of the uniform as defined in the shader
  20021. * @param value Define the value to give to the uniform
  20022. * @return the material itself allowing "fluent" like uniform updates
  20023. */
  20024. setColor3(name: string, value: Color3): ShaderMaterial;
  20025. /**
  20026. * Set a vec3 array in the shader from a Color3 array.
  20027. * @param name Define the name of the uniform as defined in the shader
  20028. * @param value Define the value to give to the uniform
  20029. * @return the material itself allowing "fluent" like uniform updates
  20030. */
  20031. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20032. /**
  20033. * Set a vec4 in the shader from a Color4.
  20034. * @param name Define the name of the uniform as defined in the shader
  20035. * @param value Define the value to give to the uniform
  20036. * @return the material itself allowing "fluent" like uniform updates
  20037. */
  20038. setColor4(name: string, value: Color4): ShaderMaterial;
  20039. /**
  20040. * Set a vec4 array in the shader from a Color4 array.
  20041. * @param name Define the name of the uniform as defined in the shader
  20042. * @param value Define the value to give to the uniform
  20043. * @return the material itself allowing "fluent" like uniform updates
  20044. */
  20045. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20046. /**
  20047. * Set a vec2 in the shader from a Vector2.
  20048. * @param name Define the name of the uniform as defined in the shader
  20049. * @param value Define the value to give to the uniform
  20050. * @return the material itself allowing "fluent" like uniform updates
  20051. */
  20052. setVector2(name: string, value: Vector2): ShaderMaterial;
  20053. /**
  20054. * Set a vec3 in the shader from a Vector3.
  20055. * @param name Define the name of the uniform as defined in the shader
  20056. * @param value Define the value to give to the uniform
  20057. * @return the material itself allowing "fluent" like uniform updates
  20058. */
  20059. setVector3(name: string, value: Vector3): ShaderMaterial;
  20060. /**
  20061. * Set a vec4 in the shader from a Vector4.
  20062. * @param name Define the name of the uniform as defined in the shader
  20063. * @param value Define the value to give to the uniform
  20064. * @return the material itself allowing "fluent" like uniform updates
  20065. */
  20066. setVector4(name: string, value: Vector4): ShaderMaterial;
  20067. /**
  20068. * Set a mat4 in the shader from a Matrix.
  20069. * @param name Define the name of the uniform as defined in the shader
  20070. * @param value Define the value to give to the uniform
  20071. * @return the material itself allowing "fluent" like uniform updates
  20072. */
  20073. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20074. /**
  20075. * Set a float32Array in the shader from a matrix array.
  20076. * @param name Define the name of the uniform as defined in the shader
  20077. * @param value Define the value to give to the uniform
  20078. * @return the material itself allowing "fluent" like uniform updates
  20079. */
  20080. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20081. /**
  20082. * Set a mat3 in the shader from a Float32Array.
  20083. * @param name Define the name of the uniform as defined in the shader
  20084. * @param value Define the value to give to the uniform
  20085. * @return the material itself allowing "fluent" like uniform updates
  20086. */
  20087. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20088. /**
  20089. * Set a mat2 in the shader from a Float32Array.
  20090. * @param name Define the name of the uniform as defined in the shader
  20091. * @param value Define the value to give to the uniform
  20092. * @return the material itself allowing "fluent" like uniform updates
  20093. */
  20094. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20095. /**
  20096. * Set a vec2 array in the shader from a number array.
  20097. * @param name Define the name of the uniform as defined in the shader
  20098. * @param value Define the value to give to the uniform
  20099. * @return the material itself allowing "fluent" like uniform updates
  20100. */
  20101. setArray2(name: string, value: number[]): ShaderMaterial;
  20102. /**
  20103. * Set a vec3 array in the shader from a number array.
  20104. * @param name Define the name of the uniform as defined in the shader
  20105. * @param value Define the value to give to the uniform
  20106. * @return the material itself allowing "fluent" like uniform updates
  20107. */
  20108. setArray3(name: string, value: number[]): ShaderMaterial;
  20109. /**
  20110. * Set a vec4 array in the shader from a number array.
  20111. * @param name Define the name of the uniform as defined in the shader
  20112. * @param value Define the value to give to the uniform
  20113. * @return the material itself allowing "fluent" like uniform updates
  20114. */
  20115. setArray4(name: string, value: number[]): ShaderMaterial;
  20116. private _checkCache;
  20117. /**
  20118. * Specifies that the submesh is ready to be used
  20119. * @param mesh defines the mesh to check
  20120. * @param subMesh defines which submesh to check
  20121. * @param useInstances specifies that instances should be used
  20122. * @returns a boolean indicating that the submesh is ready or not
  20123. */
  20124. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20125. /**
  20126. * Checks if the material is ready to render the requested mesh
  20127. * @param mesh Define the mesh to render
  20128. * @param useInstances Define whether or not the material is used with instances
  20129. * @returns true if ready, otherwise false
  20130. */
  20131. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20132. /**
  20133. * Binds the world matrix to the material
  20134. * @param world defines the world transformation matrix
  20135. */
  20136. bindOnlyWorldMatrix(world: Matrix): void;
  20137. /**
  20138. * Binds the material to the mesh
  20139. * @param world defines the world transformation matrix
  20140. * @param mesh defines the mesh to bind the material to
  20141. */
  20142. bind(world: Matrix, mesh?: Mesh): void;
  20143. /**
  20144. * Gets the active textures from the material
  20145. * @returns an array of textures
  20146. */
  20147. getActiveTextures(): BaseTexture[];
  20148. /**
  20149. * Specifies if the material uses a texture
  20150. * @param texture defines the texture to check against the material
  20151. * @returns a boolean specifying if the material uses the texture
  20152. */
  20153. hasTexture(texture: BaseTexture): boolean;
  20154. /**
  20155. * Makes a duplicate of the material, and gives it a new name
  20156. * @param name defines the new name for the duplicated material
  20157. * @returns the cloned material
  20158. */
  20159. clone(name: string): ShaderMaterial;
  20160. /**
  20161. * Disposes the material
  20162. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20163. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20164. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20165. */
  20166. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20167. /**
  20168. * Serializes this material in a JSON representation
  20169. * @returns the serialized material object
  20170. */
  20171. serialize(): any;
  20172. /**
  20173. * Creates a shader material from parsed shader material data
  20174. * @param source defines the JSON represnetation of the material
  20175. * @param scene defines the hosting scene
  20176. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20177. * @returns a new material
  20178. */
  20179. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20180. }
  20181. }
  20182. declare module "babylonjs/Shaders/color.fragment" {
  20183. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20184. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20185. /** @hidden */
  20186. export var colorPixelShader: {
  20187. name: string;
  20188. shader: string;
  20189. };
  20190. }
  20191. declare module "babylonjs/Shaders/color.vertex" {
  20192. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20193. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20194. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20195. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20196. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20197. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20198. /** @hidden */
  20199. export var colorVertexShader: {
  20200. name: string;
  20201. shader: string;
  20202. };
  20203. }
  20204. declare module "babylonjs/Meshes/linesMesh" {
  20205. import { Nullable } from "babylonjs/types";
  20206. import { Scene } from "babylonjs/scene";
  20207. import { Color3 } from "babylonjs/Maths/math.color";
  20208. import { Node } from "babylonjs/node";
  20209. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20210. import { Mesh } from "babylonjs/Meshes/mesh";
  20211. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20212. import { Effect } from "babylonjs/Materials/effect";
  20213. import { Material } from "babylonjs/Materials/material";
  20214. import "babylonjs/Shaders/color.fragment";
  20215. import "babylonjs/Shaders/color.vertex";
  20216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20217. /**
  20218. * Line mesh
  20219. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20220. */
  20221. export class LinesMesh extends Mesh {
  20222. /**
  20223. * If vertex color should be applied to the mesh
  20224. */
  20225. readonly useVertexColor?: boolean | undefined;
  20226. /**
  20227. * If vertex alpha should be applied to the mesh
  20228. */
  20229. readonly useVertexAlpha?: boolean | undefined;
  20230. /**
  20231. * Color of the line (Default: White)
  20232. */
  20233. color: Color3;
  20234. /**
  20235. * Alpha of the line (Default: 1)
  20236. */
  20237. alpha: number;
  20238. /**
  20239. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20240. * This margin is expressed in world space coordinates, so its value may vary.
  20241. * Default value is 0.1
  20242. */
  20243. intersectionThreshold: number;
  20244. private _colorShader;
  20245. private color4;
  20246. /**
  20247. * Creates a new LinesMesh
  20248. * @param name defines the name
  20249. * @param scene defines the hosting scene
  20250. * @param parent defines the parent mesh if any
  20251. * @param source defines the optional source LinesMesh used to clone data from
  20252. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20253. * When false, achieved by calling a clone(), also passing False.
  20254. * This will make creation of children, recursive.
  20255. * @param useVertexColor defines if this LinesMesh supports vertex color
  20256. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20257. */
  20258. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20259. /**
  20260. * If vertex color should be applied to the mesh
  20261. */
  20262. useVertexColor?: boolean | undefined,
  20263. /**
  20264. * If vertex alpha should be applied to the mesh
  20265. */
  20266. useVertexAlpha?: boolean | undefined);
  20267. private _addClipPlaneDefine;
  20268. private _removeClipPlaneDefine;
  20269. isReady(): boolean;
  20270. /**
  20271. * Returns the string "LineMesh"
  20272. */
  20273. getClassName(): string;
  20274. /**
  20275. * @hidden
  20276. */
  20277. get material(): Material;
  20278. /**
  20279. * @hidden
  20280. */
  20281. set material(value: Material);
  20282. /**
  20283. * @hidden
  20284. */
  20285. get checkCollisions(): boolean;
  20286. /** @hidden */
  20287. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20288. /** @hidden */
  20289. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20290. /**
  20291. * Disposes of the line mesh
  20292. * @param doNotRecurse If children should be disposed
  20293. */
  20294. dispose(doNotRecurse?: boolean): void;
  20295. /**
  20296. * Returns a new LineMesh object cloned from the current one.
  20297. */
  20298. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20299. /**
  20300. * Creates a new InstancedLinesMesh object from the mesh model.
  20301. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20302. * @param name defines the name of the new instance
  20303. * @returns a new InstancedLinesMesh
  20304. */
  20305. createInstance(name: string): InstancedLinesMesh;
  20306. }
  20307. /**
  20308. * Creates an instance based on a source LinesMesh
  20309. */
  20310. export class InstancedLinesMesh extends InstancedMesh {
  20311. /**
  20312. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20313. * This margin is expressed in world space coordinates, so its value may vary.
  20314. * Initilized with the intersectionThreshold value of the source LinesMesh
  20315. */
  20316. intersectionThreshold: number;
  20317. constructor(name: string, source: LinesMesh);
  20318. /**
  20319. * Returns the string "InstancedLinesMesh".
  20320. */
  20321. getClassName(): string;
  20322. }
  20323. }
  20324. declare module "babylonjs/Shaders/line.fragment" {
  20325. /** @hidden */
  20326. export var linePixelShader: {
  20327. name: string;
  20328. shader: string;
  20329. };
  20330. }
  20331. declare module "babylonjs/Shaders/line.vertex" {
  20332. /** @hidden */
  20333. export var lineVertexShader: {
  20334. name: string;
  20335. shader: string;
  20336. };
  20337. }
  20338. declare module "babylonjs/Rendering/edgesRenderer" {
  20339. import { Nullable } from "babylonjs/types";
  20340. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20342. import { Vector3 } from "babylonjs/Maths/math.vector";
  20343. import { IDisposable } from "babylonjs/scene";
  20344. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20345. import "babylonjs/Shaders/line.fragment";
  20346. import "babylonjs/Shaders/line.vertex";
  20347. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20348. module "babylonjs/Meshes/abstractMesh" {
  20349. interface AbstractMesh {
  20350. /**
  20351. * Gets the edgesRenderer associated with the mesh
  20352. */
  20353. edgesRenderer: Nullable<EdgesRenderer>;
  20354. }
  20355. }
  20356. module "babylonjs/Meshes/linesMesh" {
  20357. interface LinesMesh {
  20358. /**
  20359. * Enables the edge rendering mode on the mesh.
  20360. * This mode makes the mesh edges visible
  20361. * @param epsilon defines the maximal distance between two angles to detect a face
  20362. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20363. * @returns the currentAbstractMesh
  20364. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20365. */
  20366. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20367. }
  20368. }
  20369. module "babylonjs/Meshes/linesMesh" {
  20370. interface InstancedLinesMesh {
  20371. /**
  20372. * Enables the edge rendering mode on the mesh.
  20373. * This mode makes the mesh edges visible
  20374. * @param epsilon defines the maximal distance between two angles to detect a face
  20375. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20376. * @returns the current InstancedLinesMesh
  20377. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20378. */
  20379. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20380. }
  20381. }
  20382. /**
  20383. * Defines the minimum contract an Edges renderer should follow.
  20384. */
  20385. export interface IEdgesRenderer extends IDisposable {
  20386. /**
  20387. * Gets or sets a boolean indicating if the edgesRenderer is active
  20388. */
  20389. isEnabled: boolean;
  20390. /**
  20391. * Renders the edges of the attached mesh,
  20392. */
  20393. render(): void;
  20394. /**
  20395. * Checks wether or not the edges renderer is ready to render.
  20396. * @return true if ready, otherwise false.
  20397. */
  20398. isReady(): boolean;
  20399. }
  20400. /**
  20401. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20402. */
  20403. export class EdgesRenderer implements IEdgesRenderer {
  20404. /**
  20405. * Define the size of the edges with an orthographic camera
  20406. */
  20407. edgesWidthScalerForOrthographic: number;
  20408. /**
  20409. * Define the size of the edges with a perspective camera
  20410. */
  20411. edgesWidthScalerForPerspective: number;
  20412. protected _source: AbstractMesh;
  20413. protected _linesPositions: number[];
  20414. protected _linesNormals: number[];
  20415. protected _linesIndices: number[];
  20416. protected _epsilon: number;
  20417. protected _indicesCount: number;
  20418. protected _lineShader: ShaderMaterial;
  20419. protected _ib: DataBuffer;
  20420. protected _buffers: {
  20421. [key: string]: Nullable<VertexBuffer>;
  20422. };
  20423. protected _checkVerticesInsteadOfIndices: boolean;
  20424. private _meshRebuildObserver;
  20425. private _meshDisposeObserver;
  20426. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20427. isEnabled: boolean;
  20428. /**
  20429. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20430. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20431. * @param source Mesh used to create edges
  20432. * @param epsilon sum of angles in adjacency to check for edge
  20433. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20434. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20435. */
  20436. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20437. protected _prepareRessources(): void;
  20438. /** @hidden */
  20439. _rebuild(): void;
  20440. /**
  20441. * Releases the required resources for the edges renderer
  20442. */
  20443. dispose(): void;
  20444. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20445. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20446. /**
  20447. * Checks if the pair of p0 and p1 is en edge
  20448. * @param faceIndex
  20449. * @param edge
  20450. * @param faceNormals
  20451. * @param p0
  20452. * @param p1
  20453. * @private
  20454. */
  20455. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20456. /**
  20457. * push line into the position, normal and index buffer
  20458. * @protected
  20459. */
  20460. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20461. /**
  20462. * Generates lines edges from adjacencjes
  20463. * @private
  20464. */
  20465. _generateEdgesLines(): void;
  20466. /**
  20467. * Checks wether or not the edges renderer is ready to render.
  20468. * @return true if ready, otherwise false.
  20469. */
  20470. isReady(): boolean;
  20471. /**
  20472. * Renders the edges of the attached mesh,
  20473. */
  20474. render(): void;
  20475. }
  20476. /**
  20477. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20478. */
  20479. export class LineEdgesRenderer extends EdgesRenderer {
  20480. /**
  20481. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20482. * @param source LineMesh used to generate edges
  20483. * @param epsilon not important (specified angle for edge detection)
  20484. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20485. */
  20486. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20487. /**
  20488. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20489. */
  20490. _generateEdgesLines(): void;
  20491. }
  20492. }
  20493. declare module "babylonjs/Rendering/renderingGroup" {
  20494. import { SmartArray } from "babylonjs/Misc/smartArray";
  20495. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20497. import { Nullable } from "babylonjs/types";
  20498. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20499. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20500. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20501. import { Material } from "babylonjs/Materials/material";
  20502. import { Scene } from "babylonjs/scene";
  20503. /**
  20504. * This represents the object necessary to create a rendering group.
  20505. * This is exclusively used and created by the rendering manager.
  20506. * To modify the behavior, you use the available helpers in your scene or meshes.
  20507. * @hidden
  20508. */
  20509. export class RenderingGroup {
  20510. index: number;
  20511. private static _zeroVector;
  20512. private _scene;
  20513. private _opaqueSubMeshes;
  20514. private _transparentSubMeshes;
  20515. private _alphaTestSubMeshes;
  20516. private _depthOnlySubMeshes;
  20517. private _particleSystems;
  20518. private _spriteManagers;
  20519. private _opaqueSortCompareFn;
  20520. private _alphaTestSortCompareFn;
  20521. private _transparentSortCompareFn;
  20522. private _renderOpaque;
  20523. private _renderAlphaTest;
  20524. private _renderTransparent;
  20525. /** @hidden */
  20526. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20527. onBeforeTransparentRendering: () => void;
  20528. /**
  20529. * Set the opaque sort comparison function.
  20530. * If null the sub meshes will be render in the order they were created
  20531. */
  20532. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20533. /**
  20534. * Set the alpha test sort comparison function.
  20535. * If null the sub meshes will be render in the order they were created
  20536. */
  20537. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20538. /**
  20539. * Set the transparent sort comparison function.
  20540. * If null the sub meshes will be render in the order they were created
  20541. */
  20542. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20543. /**
  20544. * Creates a new rendering group.
  20545. * @param index The rendering group index
  20546. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20547. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20548. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20549. */
  20550. 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>);
  20551. /**
  20552. * Render all the sub meshes contained in the group.
  20553. * @param customRenderFunction Used to override the default render behaviour of the group.
  20554. * @returns true if rendered some submeshes.
  20555. */
  20556. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20557. /**
  20558. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20559. * @param subMeshes The submeshes to render
  20560. */
  20561. private renderOpaqueSorted;
  20562. /**
  20563. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20564. * @param subMeshes The submeshes to render
  20565. */
  20566. private renderAlphaTestSorted;
  20567. /**
  20568. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20569. * @param subMeshes The submeshes to render
  20570. */
  20571. private renderTransparentSorted;
  20572. /**
  20573. * Renders the submeshes in a specified order.
  20574. * @param subMeshes The submeshes to sort before render
  20575. * @param sortCompareFn The comparison function use to sort
  20576. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20577. * @param transparent Specifies to activate blending if true
  20578. */
  20579. private static renderSorted;
  20580. /**
  20581. * Renders the submeshes in the order they were dispatched (no sort applied).
  20582. * @param subMeshes The submeshes to render
  20583. */
  20584. private static renderUnsorted;
  20585. /**
  20586. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20587. * are rendered back to front if in the same alpha index.
  20588. *
  20589. * @param a The first submesh
  20590. * @param b The second submesh
  20591. * @returns The result of the comparison
  20592. */
  20593. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20594. /**
  20595. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20596. * are rendered back to front.
  20597. *
  20598. * @param a The first submesh
  20599. * @param b The second submesh
  20600. * @returns The result of the comparison
  20601. */
  20602. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20603. /**
  20604. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20605. * are rendered front to back (prevent overdraw).
  20606. *
  20607. * @param a The first submesh
  20608. * @param b The second submesh
  20609. * @returns The result of the comparison
  20610. */
  20611. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20612. /**
  20613. * Resets the different lists of submeshes to prepare a new frame.
  20614. */
  20615. prepare(): void;
  20616. dispose(): void;
  20617. /**
  20618. * Inserts the submesh in its correct queue depending on its material.
  20619. * @param subMesh The submesh to dispatch
  20620. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20621. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20622. */
  20623. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20624. dispatchSprites(spriteManager: ISpriteManager): void;
  20625. dispatchParticles(particleSystem: IParticleSystem): void;
  20626. private _renderParticles;
  20627. private _renderSprites;
  20628. }
  20629. }
  20630. declare module "babylonjs/Rendering/renderingManager" {
  20631. import { Nullable } from "babylonjs/types";
  20632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20633. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20634. import { SmartArray } from "babylonjs/Misc/smartArray";
  20635. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20636. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20637. import { Material } from "babylonjs/Materials/material";
  20638. import { Scene } from "babylonjs/scene";
  20639. import { Camera } from "babylonjs/Cameras/camera";
  20640. /**
  20641. * Interface describing the different options available in the rendering manager
  20642. * regarding Auto Clear between groups.
  20643. */
  20644. export interface IRenderingManagerAutoClearSetup {
  20645. /**
  20646. * Defines whether or not autoclear is enable.
  20647. */
  20648. autoClear: boolean;
  20649. /**
  20650. * Defines whether or not to autoclear the depth buffer.
  20651. */
  20652. depth: boolean;
  20653. /**
  20654. * Defines whether or not to autoclear the stencil buffer.
  20655. */
  20656. stencil: boolean;
  20657. }
  20658. /**
  20659. * This class is used by the onRenderingGroupObservable
  20660. */
  20661. export class RenderingGroupInfo {
  20662. /**
  20663. * The Scene that being rendered
  20664. */
  20665. scene: Scene;
  20666. /**
  20667. * The camera currently used for the rendering pass
  20668. */
  20669. camera: Nullable<Camera>;
  20670. /**
  20671. * The ID of the renderingGroup being processed
  20672. */
  20673. renderingGroupId: number;
  20674. }
  20675. /**
  20676. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20677. * It is enable to manage the different groups as well as the different necessary sort functions.
  20678. * This should not be used directly aside of the few static configurations
  20679. */
  20680. export class RenderingManager {
  20681. /**
  20682. * The max id used for rendering groups (not included)
  20683. */
  20684. static MAX_RENDERINGGROUPS: number;
  20685. /**
  20686. * The min id used for rendering groups (included)
  20687. */
  20688. static MIN_RENDERINGGROUPS: number;
  20689. /**
  20690. * Used to globally prevent autoclearing scenes.
  20691. */
  20692. static AUTOCLEAR: boolean;
  20693. /**
  20694. * @hidden
  20695. */
  20696. _useSceneAutoClearSetup: boolean;
  20697. private _scene;
  20698. private _renderingGroups;
  20699. private _depthStencilBufferAlreadyCleaned;
  20700. private _autoClearDepthStencil;
  20701. private _customOpaqueSortCompareFn;
  20702. private _customAlphaTestSortCompareFn;
  20703. private _customTransparentSortCompareFn;
  20704. private _renderingGroupInfo;
  20705. /**
  20706. * Instantiates a new rendering group for a particular scene
  20707. * @param scene Defines the scene the groups belongs to
  20708. */
  20709. constructor(scene: Scene);
  20710. private _clearDepthStencilBuffer;
  20711. /**
  20712. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20713. * @hidden
  20714. */
  20715. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20716. /**
  20717. * Resets the different information of the group to prepare a new frame
  20718. * @hidden
  20719. */
  20720. reset(): void;
  20721. /**
  20722. * Dispose and release the group and its associated resources.
  20723. * @hidden
  20724. */
  20725. dispose(): void;
  20726. /**
  20727. * Clear the info related to rendering groups preventing retention points during dispose.
  20728. */
  20729. freeRenderingGroups(): void;
  20730. private _prepareRenderingGroup;
  20731. /**
  20732. * Add a sprite manager to the rendering manager in order to render it this frame.
  20733. * @param spriteManager Define the sprite manager to render
  20734. */
  20735. dispatchSprites(spriteManager: ISpriteManager): void;
  20736. /**
  20737. * Add a particle system to the rendering manager in order to render it this frame.
  20738. * @param particleSystem Define the particle system to render
  20739. */
  20740. dispatchParticles(particleSystem: IParticleSystem): void;
  20741. /**
  20742. * Add a submesh to the manager in order to render it this frame
  20743. * @param subMesh The submesh to dispatch
  20744. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20745. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20746. */
  20747. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20748. /**
  20749. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20750. * This allowed control for front to back rendering or reversly depending of the special needs.
  20751. *
  20752. * @param renderingGroupId The rendering group id corresponding to its index
  20753. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20754. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20755. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20756. */
  20757. 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;
  20758. /**
  20759. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20760. *
  20761. * @param renderingGroupId The rendering group id corresponding to its index
  20762. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20763. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20764. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20765. */
  20766. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20767. /**
  20768. * Gets the current auto clear configuration for one rendering group of the rendering
  20769. * manager.
  20770. * @param index the rendering group index to get the information for
  20771. * @returns The auto clear setup for the requested rendering group
  20772. */
  20773. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20774. }
  20775. }
  20776. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20777. import { Observable } from "babylonjs/Misc/observable";
  20778. import { SmartArray } from "babylonjs/Misc/smartArray";
  20779. import { Nullable } from "babylonjs/types";
  20780. import { Camera } from "babylonjs/Cameras/camera";
  20781. import { Scene } from "babylonjs/scene";
  20782. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20783. import { Color4 } from "babylonjs/Maths/math.color";
  20784. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20786. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20787. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20788. import { Texture } from "babylonjs/Materials/Textures/texture";
  20789. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20790. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20791. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20792. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20793. import { Engine } from "babylonjs/Engines/engine";
  20794. /**
  20795. * This Helps creating a texture that will be created from a camera in your scene.
  20796. * It is basically a dynamic texture that could be used to create special effects for instance.
  20797. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20798. */
  20799. export class RenderTargetTexture extends Texture {
  20800. isCube: boolean;
  20801. /**
  20802. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20803. */
  20804. static readonly REFRESHRATE_RENDER_ONCE: number;
  20805. /**
  20806. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20807. */
  20808. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20809. /**
  20810. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20811. * the central point of your effect and can save a lot of performances.
  20812. */
  20813. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20814. /**
  20815. * Use this predicate to dynamically define the list of mesh you want to render.
  20816. * If set, the renderList property will be overwritten.
  20817. */
  20818. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20819. private _renderList;
  20820. /**
  20821. * Use this list to define the list of mesh you want to render.
  20822. */
  20823. get renderList(): Nullable<Array<AbstractMesh>>;
  20824. set renderList(value: Nullable<Array<AbstractMesh>>);
  20825. private _hookArray;
  20826. /**
  20827. * Define if particles should be rendered in your texture.
  20828. */
  20829. renderParticles: boolean;
  20830. /**
  20831. * Define if sprites should be rendered in your texture.
  20832. */
  20833. renderSprites: boolean;
  20834. /**
  20835. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20836. */
  20837. coordinatesMode: number;
  20838. /**
  20839. * Define the camera used to render the texture.
  20840. */
  20841. activeCamera: Nullable<Camera>;
  20842. /**
  20843. * Override the render function of the texture with your own one.
  20844. */
  20845. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20846. /**
  20847. * Define if camera post processes should be use while rendering the texture.
  20848. */
  20849. useCameraPostProcesses: boolean;
  20850. /**
  20851. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20852. */
  20853. ignoreCameraViewport: boolean;
  20854. private _postProcessManager;
  20855. private _postProcesses;
  20856. private _resizeObserver;
  20857. /**
  20858. * An event triggered when the texture is unbind.
  20859. */
  20860. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20861. /**
  20862. * An event triggered when the texture is unbind.
  20863. */
  20864. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20865. private _onAfterUnbindObserver;
  20866. /**
  20867. * Set a after unbind callback in the texture.
  20868. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20869. */
  20870. set onAfterUnbind(callback: () => void);
  20871. /**
  20872. * An event triggered before rendering the texture
  20873. */
  20874. onBeforeRenderObservable: Observable<number>;
  20875. private _onBeforeRenderObserver;
  20876. /**
  20877. * Set a before render callback in the texture.
  20878. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20879. */
  20880. set onBeforeRender(callback: (faceIndex: number) => void);
  20881. /**
  20882. * An event triggered after rendering the texture
  20883. */
  20884. onAfterRenderObservable: Observable<number>;
  20885. private _onAfterRenderObserver;
  20886. /**
  20887. * Set a after render callback in the texture.
  20888. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20889. */
  20890. set onAfterRender(callback: (faceIndex: number) => void);
  20891. /**
  20892. * An event triggered after the texture clear
  20893. */
  20894. onClearObservable: Observable<Engine>;
  20895. private _onClearObserver;
  20896. /**
  20897. * Set a clear callback in the texture.
  20898. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20899. */
  20900. set onClear(callback: (Engine: Engine) => void);
  20901. /**
  20902. * An event triggered when the texture is resized.
  20903. */
  20904. onResizeObservable: Observable<RenderTargetTexture>;
  20905. /**
  20906. * Define the clear color of the Render Target if it should be different from the scene.
  20907. */
  20908. clearColor: Color4;
  20909. protected _size: number | {
  20910. width: number;
  20911. height: number;
  20912. };
  20913. protected _initialSizeParameter: number | {
  20914. width: number;
  20915. height: number;
  20916. } | {
  20917. ratio: number;
  20918. };
  20919. protected _sizeRatio: Nullable<number>;
  20920. /** @hidden */
  20921. _generateMipMaps: boolean;
  20922. protected _renderingManager: RenderingManager;
  20923. /** @hidden */
  20924. _waitingRenderList: string[];
  20925. protected _doNotChangeAspectRatio: boolean;
  20926. protected _currentRefreshId: number;
  20927. protected _refreshRate: number;
  20928. protected _textureMatrix: Matrix;
  20929. protected _samples: number;
  20930. protected _renderTargetOptions: RenderTargetCreationOptions;
  20931. /**
  20932. * Gets render target creation options that were used.
  20933. */
  20934. get renderTargetOptions(): RenderTargetCreationOptions;
  20935. protected _engine: Engine;
  20936. protected _onRatioRescale(): void;
  20937. /**
  20938. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20939. * It must define where the camera used to render the texture is set
  20940. */
  20941. boundingBoxPosition: Vector3;
  20942. private _boundingBoxSize;
  20943. /**
  20944. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20945. * When defined, the cubemap will switch to local mode
  20946. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20947. * @example https://www.babylonjs-playground.com/#RNASML
  20948. */
  20949. set boundingBoxSize(value: Vector3);
  20950. get boundingBoxSize(): Vector3;
  20951. /**
  20952. * In case the RTT has been created with a depth texture, get the associated
  20953. * depth texture.
  20954. * Otherwise, return null.
  20955. */
  20956. depthStencilTexture: Nullable<InternalTexture>;
  20957. /**
  20958. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20959. * or used a shadow, depth texture...
  20960. * @param name The friendly name of the texture
  20961. * @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)
  20962. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20963. * @param generateMipMaps True if mip maps need to be generated after render.
  20964. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20965. * @param type The type of the buffer in the RTT (int, half float, float...)
  20966. * @param isCube True if a cube texture needs to be created
  20967. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20968. * @param generateDepthBuffer True to generate a depth buffer
  20969. * @param generateStencilBuffer True to generate a stencil buffer
  20970. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20971. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20972. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20973. */
  20974. constructor(name: string, size: number | {
  20975. width: number;
  20976. height: number;
  20977. } | {
  20978. ratio: number;
  20979. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20980. /**
  20981. * Creates a depth stencil texture.
  20982. * This is only available in WebGL 2 or with the depth texture extension available.
  20983. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20984. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20985. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20986. */
  20987. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20988. private _processSizeParameter;
  20989. /**
  20990. * Define the number of samples to use in case of MSAA.
  20991. * It defaults to one meaning no MSAA has been enabled.
  20992. */
  20993. get samples(): number;
  20994. set samples(value: number);
  20995. /**
  20996. * Resets the refresh counter of the texture and start bak from scratch.
  20997. * Could be useful to regenerate the texture if it is setup to render only once.
  20998. */
  20999. resetRefreshCounter(): void;
  21000. /**
  21001. * Define the refresh rate of the texture or the rendering frequency.
  21002. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21003. */
  21004. get refreshRate(): number;
  21005. set refreshRate(value: number);
  21006. /**
  21007. * Adds a post process to the render target rendering passes.
  21008. * @param postProcess define the post process to add
  21009. */
  21010. addPostProcess(postProcess: PostProcess): void;
  21011. /**
  21012. * Clear all the post processes attached to the render target
  21013. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21014. */
  21015. clearPostProcesses(dispose?: boolean): void;
  21016. /**
  21017. * Remove one of the post process from the list of attached post processes to the texture
  21018. * @param postProcess define the post process to remove from the list
  21019. */
  21020. removePostProcess(postProcess: PostProcess): void;
  21021. /** @hidden */
  21022. _shouldRender(): boolean;
  21023. /**
  21024. * Gets the actual render size of the texture.
  21025. * @returns the width of the render size
  21026. */
  21027. getRenderSize(): number;
  21028. /**
  21029. * Gets the actual render width of the texture.
  21030. * @returns the width of the render size
  21031. */
  21032. getRenderWidth(): number;
  21033. /**
  21034. * Gets the actual render height of the texture.
  21035. * @returns the height of the render size
  21036. */
  21037. getRenderHeight(): number;
  21038. /**
  21039. * Get if the texture can be rescaled or not.
  21040. */
  21041. get canRescale(): boolean;
  21042. /**
  21043. * Resize the texture using a ratio.
  21044. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21045. */
  21046. scale(ratio: number): void;
  21047. /**
  21048. * Get the texture reflection matrix used to rotate/transform the reflection.
  21049. * @returns the reflection matrix
  21050. */
  21051. getReflectionTextureMatrix(): Matrix;
  21052. /**
  21053. * Resize the texture to a new desired size.
  21054. * Be carrefull as it will recreate all the data in the new texture.
  21055. * @param size Define the new size. It can be:
  21056. * - a number for squared texture,
  21057. * - an object containing { width: number, height: number }
  21058. * - or an object containing a ratio { ratio: number }
  21059. */
  21060. resize(size: number | {
  21061. width: number;
  21062. height: number;
  21063. } | {
  21064. ratio: number;
  21065. }): void;
  21066. /**
  21067. * Renders all the objects from the render list into the texture.
  21068. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21069. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21070. */
  21071. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21072. private _bestReflectionRenderTargetDimension;
  21073. /**
  21074. * @hidden
  21075. * @param faceIndex face index to bind to if this is a cubetexture
  21076. */
  21077. _bindFrameBuffer(faceIndex?: number): void;
  21078. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21079. private renderToTarget;
  21080. /**
  21081. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21082. * This allowed control for front to back rendering or reversly depending of the special needs.
  21083. *
  21084. * @param renderingGroupId The rendering group id corresponding to its index
  21085. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21086. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21087. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21088. */
  21089. 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;
  21090. /**
  21091. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21092. *
  21093. * @param renderingGroupId The rendering group id corresponding to its index
  21094. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21095. */
  21096. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21097. /**
  21098. * Clones the texture.
  21099. * @returns the cloned texture
  21100. */
  21101. clone(): RenderTargetTexture;
  21102. /**
  21103. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21104. * @returns The JSON representation of the texture
  21105. */
  21106. serialize(): any;
  21107. /**
  21108. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21109. */
  21110. disposeFramebufferObjects(): void;
  21111. /**
  21112. * Dispose the texture and release its associated resources.
  21113. */
  21114. dispose(): void;
  21115. /** @hidden */
  21116. _rebuild(): void;
  21117. /**
  21118. * Clear the info related to rendering groups preventing retention point in material dispose.
  21119. */
  21120. freeRenderingGroups(): void;
  21121. /**
  21122. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21123. * @returns the view count
  21124. */
  21125. getViewCount(): number;
  21126. }
  21127. }
  21128. declare module "babylonjs/Materials/material" {
  21129. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21130. import { SmartArray } from "babylonjs/Misc/smartArray";
  21131. import { Observable } from "babylonjs/Misc/observable";
  21132. import { Nullable } from "babylonjs/types";
  21133. import { Scene } from "babylonjs/scene";
  21134. import { Matrix } from "babylonjs/Maths/math.vector";
  21135. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21137. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21138. import { Effect } from "babylonjs/Materials/effect";
  21139. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21140. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21141. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21142. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21143. import { Mesh } from "babylonjs/Meshes/mesh";
  21144. import { Animation } from "babylonjs/Animations/animation";
  21145. /**
  21146. * Options for compiling materials.
  21147. */
  21148. export interface IMaterialCompilationOptions {
  21149. /**
  21150. * Defines whether clip planes are enabled.
  21151. */
  21152. clipPlane: boolean;
  21153. /**
  21154. * Defines whether instances are enabled.
  21155. */
  21156. useInstances: boolean;
  21157. }
  21158. /**
  21159. * Base class for the main features of a material in Babylon.js
  21160. */
  21161. export class Material implements IAnimatable {
  21162. /**
  21163. * Returns the triangle fill mode
  21164. */
  21165. static readonly TriangleFillMode: number;
  21166. /**
  21167. * Returns the wireframe mode
  21168. */
  21169. static readonly WireFrameFillMode: number;
  21170. /**
  21171. * Returns the point fill mode
  21172. */
  21173. static readonly PointFillMode: number;
  21174. /**
  21175. * Returns the point list draw mode
  21176. */
  21177. static readonly PointListDrawMode: number;
  21178. /**
  21179. * Returns the line list draw mode
  21180. */
  21181. static readonly LineListDrawMode: number;
  21182. /**
  21183. * Returns the line loop draw mode
  21184. */
  21185. static readonly LineLoopDrawMode: number;
  21186. /**
  21187. * Returns the line strip draw mode
  21188. */
  21189. static readonly LineStripDrawMode: number;
  21190. /**
  21191. * Returns the triangle strip draw mode
  21192. */
  21193. static readonly TriangleStripDrawMode: number;
  21194. /**
  21195. * Returns the triangle fan draw mode
  21196. */
  21197. static readonly TriangleFanDrawMode: number;
  21198. /**
  21199. * Stores the clock-wise side orientation
  21200. */
  21201. static readonly ClockWiseSideOrientation: number;
  21202. /**
  21203. * Stores the counter clock-wise side orientation
  21204. */
  21205. static readonly CounterClockWiseSideOrientation: number;
  21206. /**
  21207. * The dirty texture flag value
  21208. */
  21209. static readonly TextureDirtyFlag: number;
  21210. /**
  21211. * The dirty light flag value
  21212. */
  21213. static readonly LightDirtyFlag: number;
  21214. /**
  21215. * The dirty fresnel flag value
  21216. */
  21217. static readonly FresnelDirtyFlag: number;
  21218. /**
  21219. * The dirty attribute flag value
  21220. */
  21221. static readonly AttributesDirtyFlag: number;
  21222. /**
  21223. * The dirty misc flag value
  21224. */
  21225. static readonly MiscDirtyFlag: number;
  21226. /**
  21227. * The all dirty flag value
  21228. */
  21229. static readonly AllDirtyFlag: number;
  21230. /**
  21231. * The ID of the material
  21232. */
  21233. id: string;
  21234. /**
  21235. * Gets or sets the unique id of the material
  21236. */
  21237. uniqueId: number;
  21238. /**
  21239. * The name of the material
  21240. */
  21241. name: string;
  21242. /**
  21243. * Gets or sets user defined metadata
  21244. */
  21245. metadata: any;
  21246. /**
  21247. * For internal use only. Please do not use.
  21248. */
  21249. reservedDataStore: any;
  21250. /**
  21251. * Specifies if the ready state should be checked on each call
  21252. */
  21253. checkReadyOnEveryCall: boolean;
  21254. /**
  21255. * Specifies if the ready state should be checked once
  21256. */
  21257. checkReadyOnlyOnce: boolean;
  21258. /**
  21259. * The state of the material
  21260. */
  21261. state: string;
  21262. /**
  21263. * The alpha value of the material
  21264. */
  21265. protected _alpha: number;
  21266. /**
  21267. * List of inspectable custom properties (used by the Inspector)
  21268. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21269. */
  21270. inspectableCustomProperties: IInspectable[];
  21271. /**
  21272. * Sets the alpha value of the material
  21273. */
  21274. set alpha(value: number);
  21275. /**
  21276. * Gets the alpha value of the material
  21277. */
  21278. get alpha(): number;
  21279. /**
  21280. * Specifies if back face culling is enabled
  21281. */
  21282. protected _backFaceCulling: boolean;
  21283. /**
  21284. * Sets the back-face culling state
  21285. */
  21286. set backFaceCulling(value: boolean);
  21287. /**
  21288. * Gets the back-face culling state
  21289. */
  21290. get backFaceCulling(): boolean;
  21291. /**
  21292. * Stores the value for side orientation
  21293. */
  21294. sideOrientation: number;
  21295. /**
  21296. * Callback triggered when the material is compiled
  21297. */
  21298. onCompiled: Nullable<(effect: Effect) => void>;
  21299. /**
  21300. * Callback triggered when an error occurs
  21301. */
  21302. onError: Nullable<(effect: Effect, errors: string) => void>;
  21303. /**
  21304. * Callback triggered to get the render target textures
  21305. */
  21306. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21307. /**
  21308. * Gets a boolean indicating that current material needs to register RTT
  21309. */
  21310. get hasRenderTargetTextures(): boolean;
  21311. /**
  21312. * Specifies if the material should be serialized
  21313. */
  21314. doNotSerialize: boolean;
  21315. /**
  21316. * @hidden
  21317. */
  21318. _storeEffectOnSubMeshes: boolean;
  21319. /**
  21320. * Stores the animations for the material
  21321. */
  21322. animations: Nullable<Array<Animation>>;
  21323. /**
  21324. * An event triggered when the material is disposed
  21325. */
  21326. onDisposeObservable: Observable<Material>;
  21327. /**
  21328. * An observer which watches for dispose events
  21329. */
  21330. private _onDisposeObserver;
  21331. private _onUnBindObservable;
  21332. /**
  21333. * Called during a dispose event
  21334. */
  21335. set onDispose(callback: () => void);
  21336. private _onBindObservable;
  21337. /**
  21338. * An event triggered when the material is bound
  21339. */
  21340. get onBindObservable(): Observable<AbstractMesh>;
  21341. /**
  21342. * An observer which watches for bind events
  21343. */
  21344. private _onBindObserver;
  21345. /**
  21346. * Called during a bind event
  21347. */
  21348. set onBind(callback: (Mesh: AbstractMesh) => void);
  21349. /**
  21350. * An event triggered when the material is unbound
  21351. */
  21352. get onUnBindObservable(): Observable<Material>;
  21353. /**
  21354. * Stores the value of the alpha mode
  21355. */
  21356. private _alphaMode;
  21357. /**
  21358. * Sets the value of the alpha mode.
  21359. *
  21360. * | Value | Type | Description |
  21361. * | --- | --- | --- |
  21362. * | 0 | ALPHA_DISABLE | |
  21363. * | 1 | ALPHA_ADD | |
  21364. * | 2 | ALPHA_COMBINE | |
  21365. * | 3 | ALPHA_SUBTRACT | |
  21366. * | 4 | ALPHA_MULTIPLY | |
  21367. * | 5 | ALPHA_MAXIMIZED | |
  21368. * | 6 | ALPHA_ONEONE | |
  21369. * | 7 | ALPHA_PREMULTIPLIED | |
  21370. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21371. * | 9 | ALPHA_INTERPOLATE | |
  21372. * | 10 | ALPHA_SCREENMODE | |
  21373. *
  21374. */
  21375. set alphaMode(value: number);
  21376. /**
  21377. * Gets the value of the alpha mode
  21378. */
  21379. get alphaMode(): number;
  21380. /**
  21381. * Stores the state of the need depth pre-pass value
  21382. */
  21383. private _needDepthPrePass;
  21384. /**
  21385. * Sets the need depth pre-pass value
  21386. */
  21387. set needDepthPrePass(value: boolean);
  21388. /**
  21389. * Gets the depth pre-pass value
  21390. */
  21391. get needDepthPrePass(): boolean;
  21392. /**
  21393. * Specifies if depth writing should be disabled
  21394. */
  21395. disableDepthWrite: boolean;
  21396. /**
  21397. * Specifies if depth writing should be forced
  21398. */
  21399. forceDepthWrite: boolean;
  21400. /**
  21401. * Specifies the depth function that should be used. 0 means the default engine function
  21402. */
  21403. depthFunction: number;
  21404. /**
  21405. * Specifies if there should be a separate pass for culling
  21406. */
  21407. separateCullingPass: boolean;
  21408. /**
  21409. * Stores the state specifing if fog should be enabled
  21410. */
  21411. private _fogEnabled;
  21412. /**
  21413. * Sets the state for enabling fog
  21414. */
  21415. set fogEnabled(value: boolean);
  21416. /**
  21417. * Gets the value of the fog enabled state
  21418. */
  21419. get fogEnabled(): boolean;
  21420. /**
  21421. * Stores the size of points
  21422. */
  21423. pointSize: number;
  21424. /**
  21425. * Stores the z offset value
  21426. */
  21427. zOffset: number;
  21428. /**
  21429. * Gets a value specifying if wireframe mode is enabled
  21430. */
  21431. get wireframe(): boolean;
  21432. /**
  21433. * Sets the state of wireframe mode
  21434. */
  21435. set wireframe(value: boolean);
  21436. /**
  21437. * Gets the value specifying if point clouds are enabled
  21438. */
  21439. get pointsCloud(): boolean;
  21440. /**
  21441. * Sets the state of point cloud mode
  21442. */
  21443. set pointsCloud(value: boolean);
  21444. /**
  21445. * Gets the material fill mode
  21446. */
  21447. get fillMode(): number;
  21448. /**
  21449. * Sets the material fill mode
  21450. */
  21451. set fillMode(value: number);
  21452. /**
  21453. * @hidden
  21454. * Stores the effects for the material
  21455. */
  21456. _effect: Nullable<Effect>;
  21457. /**
  21458. * @hidden
  21459. * Specifies if the material was previously ready
  21460. */
  21461. _wasPreviouslyReady: boolean;
  21462. /**
  21463. * Specifies if uniform buffers should be used
  21464. */
  21465. private _useUBO;
  21466. /**
  21467. * Stores a reference to the scene
  21468. */
  21469. private _scene;
  21470. /**
  21471. * Stores the fill mode state
  21472. */
  21473. private _fillMode;
  21474. /**
  21475. * Specifies if the depth write state should be cached
  21476. */
  21477. private _cachedDepthWriteState;
  21478. /**
  21479. * Specifies if the depth function state should be cached
  21480. */
  21481. private _cachedDepthFunctionState;
  21482. /**
  21483. * Stores the uniform buffer
  21484. */
  21485. protected _uniformBuffer: UniformBuffer;
  21486. /** @hidden */
  21487. _indexInSceneMaterialArray: number;
  21488. /** @hidden */
  21489. meshMap: Nullable<{
  21490. [id: string]: AbstractMesh | undefined;
  21491. }>;
  21492. /**
  21493. * Creates a material instance
  21494. * @param name defines the name of the material
  21495. * @param scene defines the scene to reference
  21496. * @param doNotAdd specifies if the material should be added to the scene
  21497. */
  21498. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21499. /**
  21500. * Returns a string representation of the current material
  21501. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21502. * @returns a string with material information
  21503. */
  21504. toString(fullDetails?: boolean): string;
  21505. /**
  21506. * Gets the class name of the material
  21507. * @returns a string with the class name of the material
  21508. */
  21509. getClassName(): string;
  21510. /**
  21511. * Specifies if updates for the material been locked
  21512. */
  21513. get isFrozen(): boolean;
  21514. /**
  21515. * Locks updates for the material
  21516. */
  21517. freeze(): void;
  21518. /**
  21519. * Unlocks updates for the material
  21520. */
  21521. unfreeze(): void;
  21522. /**
  21523. * Specifies if the material is ready to be used
  21524. * @param mesh defines the mesh to check
  21525. * @param useInstances specifies if instances should be used
  21526. * @returns a boolean indicating if the material is ready to be used
  21527. */
  21528. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21529. /**
  21530. * Specifies that the submesh is ready to be used
  21531. * @param mesh defines the mesh to check
  21532. * @param subMesh defines which submesh to check
  21533. * @param useInstances specifies that instances should be used
  21534. * @returns a boolean indicating that the submesh is ready or not
  21535. */
  21536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21537. /**
  21538. * Returns the material effect
  21539. * @returns the effect associated with the material
  21540. */
  21541. getEffect(): Nullable<Effect>;
  21542. /**
  21543. * Returns the current scene
  21544. * @returns a Scene
  21545. */
  21546. getScene(): Scene;
  21547. /**
  21548. * Specifies if the material will require alpha blending
  21549. * @returns a boolean specifying if alpha blending is needed
  21550. */
  21551. needAlphaBlending(): boolean;
  21552. /**
  21553. * Specifies if the mesh will require alpha blending
  21554. * @param mesh defines the mesh to check
  21555. * @returns a boolean specifying if alpha blending is needed for the mesh
  21556. */
  21557. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21558. /**
  21559. * Specifies if this material should be rendered in alpha test mode
  21560. * @returns a boolean specifying if an alpha test is needed.
  21561. */
  21562. needAlphaTesting(): boolean;
  21563. /**
  21564. * Gets the texture used for the alpha test
  21565. * @returns the texture to use for alpha testing
  21566. */
  21567. getAlphaTestTexture(): Nullable<BaseTexture>;
  21568. /**
  21569. * Marks the material to indicate that it needs to be re-calculated
  21570. */
  21571. markDirty(): void;
  21572. /** @hidden */
  21573. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21574. /**
  21575. * Binds the material to the mesh
  21576. * @param world defines the world transformation matrix
  21577. * @param mesh defines the mesh to bind the material to
  21578. */
  21579. bind(world: Matrix, mesh?: Mesh): void;
  21580. /**
  21581. * Binds the submesh to the material
  21582. * @param world defines the world transformation matrix
  21583. * @param mesh defines the mesh containing the submesh
  21584. * @param subMesh defines the submesh to bind the material to
  21585. */
  21586. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21587. /**
  21588. * Binds the world matrix to the material
  21589. * @param world defines the world transformation matrix
  21590. */
  21591. bindOnlyWorldMatrix(world: Matrix): void;
  21592. /**
  21593. * Binds the scene's uniform buffer to the effect.
  21594. * @param effect defines the effect to bind to the scene uniform buffer
  21595. * @param sceneUbo defines the uniform buffer storing scene data
  21596. */
  21597. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21598. /**
  21599. * Binds the view matrix to the effect
  21600. * @param effect defines the effect to bind the view matrix to
  21601. */
  21602. bindView(effect: Effect): void;
  21603. /**
  21604. * Binds the view projection matrix to the effect
  21605. * @param effect defines the effect to bind the view projection matrix to
  21606. */
  21607. bindViewProjection(effect: Effect): void;
  21608. /**
  21609. * Specifies if material alpha testing should be turned on for the mesh
  21610. * @param mesh defines the mesh to check
  21611. */
  21612. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21613. /**
  21614. * Processes to execute after binding the material to a mesh
  21615. * @param mesh defines the rendered mesh
  21616. */
  21617. protected _afterBind(mesh?: Mesh): void;
  21618. /**
  21619. * Unbinds the material from the mesh
  21620. */
  21621. unbind(): void;
  21622. /**
  21623. * Gets the active textures from the material
  21624. * @returns an array of textures
  21625. */
  21626. getActiveTextures(): BaseTexture[];
  21627. /**
  21628. * Specifies if the material uses a texture
  21629. * @param texture defines the texture to check against the material
  21630. * @returns a boolean specifying if the material uses the texture
  21631. */
  21632. hasTexture(texture: BaseTexture): boolean;
  21633. /**
  21634. * Makes a duplicate of the material, and gives it a new name
  21635. * @param name defines the new name for the duplicated material
  21636. * @returns the cloned material
  21637. */
  21638. clone(name: string): Nullable<Material>;
  21639. /**
  21640. * Gets the meshes bound to the material
  21641. * @returns an array of meshes bound to the material
  21642. */
  21643. getBindedMeshes(): AbstractMesh[];
  21644. /**
  21645. * Force shader compilation
  21646. * @param mesh defines the mesh associated with this material
  21647. * @param onCompiled defines a function to execute once the material is compiled
  21648. * @param options defines the options to configure the compilation
  21649. * @param onError defines a function to execute if the material fails compiling
  21650. */
  21651. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21652. /**
  21653. * Force shader compilation
  21654. * @param mesh defines the mesh that will use this material
  21655. * @param options defines additional options for compiling the shaders
  21656. * @returns a promise that resolves when the compilation completes
  21657. */
  21658. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21659. private static readonly _AllDirtyCallBack;
  21660. private static readonly _ImageProcessingDirtyCallBack;
  21661. private static readonly _TextureDirtyCallBack;
  21662. private static readonly _FresnelDirtyCallBack;
  21663. private static readonly _MiscDirtyCallBack;
  21664. private static readonly _LightsDirtyCallBack;
  21665. private static readonly _AttributeDirtyCallBack;
  21666. private static _FresnelAndMiscDirtyCallBack;
  21667. private static _TextureAndMiscDirtyCallBack;
  21668. private static readonly _DirtyCallbackArray;
  21669. private static readonly _RunDirtyCallBacks;
  21670. /**
  21671. * Marks a define in the material to indicate that it needs to be re-computed
  21672. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21673. */
  21674. markAsDirty(flag: number): void;
  21675. /**
  21676. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21677. * @param func defines a function which checks material defines against the submeshes
  21678. */
  21679. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21680. /**
  21681. * Indicates that we need to re-calculated for all submeshes
  21682. */
  21683. protected _markAllSubMeshesAsAllDirty(): void;
  21684. /**
  21685. * Indicates that image processing needs to be re-calculated for all submeshes
  21686. */
  21687. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21688. /**
  21689. * Indicates that textures need to be re-calculated for all submeshes
  21690. */
  21691. protected _markAllSubMeshesAsTexturesDirty(): void;
  21692. /**
  21693. * Indicates that fresnel needs to be re-calculated for all submeshes
  21694. */
  21695. protected _markAllSubMeshesAsFresnelDirty(): void;
  21696. /**
  21697. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21698. */
  21699. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21700. /**
  21701. * Indicates that lights need to be re-calculated for all submeshes
  21702. */
  21703. protected _markAllSubMeshesAsLightsDirty(): void;
  21704. /**
  21705. * Indicates that attributes need to be re-calculated for all submeshes
  21706. */
  21707. protected _markAllSubMeshesAsAttributesDirty(): void;
  21708. /**
  21709. * Indicates that misc needs to be re-calculated for all submeshes
  21710. */
  21711. protected _markAllSubMeshesAsMiscDirty(): void;
  21712. /**
  21713. * Indicates that textures and misc need to be re-calculated for all submeshes
  21714. */
  21715. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21716. /**
  21717. * Disposes the material
  21718. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21719. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21720. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21721. */
  21722. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21723. /** @hidden */
  21724. private releaseVertexArrayObject;
  21725. /**
  21726. * Serializes this material
  21727. * @returns the serialized material object
  21728. */
  21729. serialize(): any;
  21730. /**
  21731. * Creates a material from parsed material data
  21732. * @param parsedMaterial defines parsed material data
  21733. * @param scene defines the hosting scene
  21734. * @param rootUrl defines the root URL to use to load textures
  21735. * @returns a new material
  21736. */
  21737. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21738. }
  21739. }
  21740. declare module "babylonjs/Materials/multiMaterial" {
  21741. import { Nullable } from "babylonjs/types";
  21742. import { Scene } from "babylonjs/scene";
  21743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21744. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21745. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21746. import { Material } from "babylonjs/Materials/material";
  21747. /**
  21748. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21749. * separate meshes. This can be use to improve performances.
  21750. * @see http://doc.babylonjs.com/how_to/multi_materials
  21751. */
  21752. export class MultiMaterial extends Material {
  21753. private _subMaterials;
  21754. /**
  21755. * Gets or Sets the list of Materials used within the multi material.
  21756. * They need to be ordered according to the submeshes order in the associated mesh
  21757. */
  21758. get subMaterials(): Nullable<Material>[];
  21759. set subMaterials(value: Nullable<Material>[]);
  21760. /**
  21761. * Function used to align with Node.getChildren()
  21762. * @returns the list of Materials used within the multi material
  21763. */
  21764. getChildren(): Nullable<Material>[];
  21765. /**
  21766. * Instantiates a new Multi Material
  21767. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21768. * separate meshes. This can be use to improve performances.
  21769. * @see http://doc.babylonjs.com/how_to/multi_materials
  21770. * @param name Define the name in the scene
  21771. * @param scene Define the scene the material belongs to
  21772. */
  21773. constructor(name: string, scene: Scene);
  21774. private _hookArray;
  21775. /**
  21776. * Get one of the submaterial by its index in the submaterials array
  21777. * @param index The index to look the sub material at
  21778. * @returns The Material if the index has been defined
  21779. */
  21780. getSubMaterial(index: number): Nullable<Material>;
  21781. /**
  21782. * Get the list of active textures for the whole sub materials list.
  21783. * @returns All the textures that will be used during the rendering
  21784. */
  21785. getActiveTextures(): BaseTexture[];
  21786. /**
  21787. * Gets the current class name of the material e.g. "MultiMaterial"
  21788. * Mainly use in serialization.
  21789. * @returns the class name
  21790. */
  21791. getClassName(): string;
  21792. /**
  21793. * Checks if the material is ready to render the requested sub mesh
  21794. * @param mesh Define the mesh the submesh belongs to
  21795. * @param subMesh Define the sub mesh to look readyness for
  21796. * @param useInstances Define whether or not the material is used with instances
  21797. * @returns true if ready, otherwise false
  21798. */
  21799. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21800. /**
  21801. * Clones the current material and its related sub materials
  21802. * @param name Define the name of the newly cloned material
  21803. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21804. * @returns the cloned material
  21805. */
  21806. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21807. /**
  21808. * Serializes the materials into a JSON representation.
  21809. * @returns the JSON representation
  21810. */
  21811. serialize(): any;
  21812. /**
  21813. * Dispose the material and release its associated resources
  21814. * @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)
  21815. * @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)
  21816. * @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)
  21817. */
  21818. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21819. /**
  21820. * Creates a MultiMaterial from parsed MultiMaterial data.
  21821. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21822. * @param scene defines the hosting scene
  21823. * @returns a new MultiMaterial
  21824. */
  21825. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21826. }
  21827. }
  21828. declare module "babylonjs/Meshes/subMesh" {
  21829. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21830. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21831. import { Engine } from "babylonjs/Engines/engine";
  21832. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21833. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21834. import { Effect } from "babylonjs/Materials/effect";
  21835. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21836. import { Plane } from "babylonjs/Maths/math.plane";
  21837. import { Collider } from "babylonjs/Collisions/collider";
  21838. import { Material } from "babylonjs/Materials/material";
  21839. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21841. import { Mesh } from "babylonjs/Meshes/mesh";
  21842. import { Ray } from "babylonjs/Culling/ray";
  21843. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21844. /**
  21845. * Base class for submeshes
  21846. */
  21847. export class BaseSubMesh {
  21848. /** @hidden */
  21849. _materialDefines: Nullable<MaterialDefines>;
  21850. /** @hidden */
  21851. _materialEffect: Nullable<Effect>;
  21852. /**
  21853. * Gets material defines used by the effect associated to the sub mesh
  21854. */
  21855. get materialDefines(): Nullable<MaterialDefines>;
  21856. /**
  21857. * Sets material defines used by the effect associated to the sub mesh
  21858. */
  21859. set materialDefines(defines: Nullable<MaterialDefines>);
  21860. /**
  21861. * Gets associated effect
  21862. */
  21863. get effect(): Nullable<Effect>;
  21864. /**
  21865. * Sets associated effect (effect used to render this submesh)
  21866. * @param effect defines the effect to associate with
  21867. * @param defines defines the set of defines used to compile this effect
  21868. */
  21869. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21870. }
  21871. /**
  21872. * Defines a subdivision inside a mesh
  21873. */
  21874. export class SubMesh extends BaseSubMesh implements ICullable {
  21875. /** the material index to use */
  21876. materialIndex: number;
  21877. /** vertex index start */
  21878. verticesStart: number;
  21879. /** vertices count */
  21880. verticesCount: number;
  21881. /** index start */
  21882. indexStart: number;
  21883. /** indices count */
  21884. indexCount: number;
  21885. /** @hidden */
  21886. _linesIndexCount: number;
  21887. private _mesh;
  21888. private _renderingMesh;
  21889. private _boundingInfo;
  21890. private _linesIndexBuffer;
  21891. /** @hidden */
  21892. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21893. /** @hidden */
  21894. _trianglePlanes: Plane[];
  21895. /** @hidden */
  21896. _lastColliderTransformMatrix: Nullable<Matrix>;
  21897. /** @hidden */
  21898. _renderId: number;
  21899. /** @hidden */
  21900. _alphaIndex: number;
  21901. /** @hidden */
  21902. _distanceToCamera: number;
  21903. /** @hidden */
  21904. _id: number;
  21905. private _currentMaterial;
  21906. /**
  21907. * Add a new submesh to a mesh
  21908. * @param materialIndex defines the material index to use
  21909. * @param verticesStart defines vertex index start
  21910. * @param verticesCount defines vertices count
  21911. * @param indexStart defines index start
  21912. * @param indexCount defines indices count
  21913. * @param mesh defines the parent mesh
  21914. * @param renderingMesh defines an optional rendering mesh
  21915. * @param createBoundingBox defines if bounding box should be created for this submesh
  21916. * @returns the new submesh
  21917. */
  21918. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21919. /**
  21920. * Creates a new submesh
  21921. * @param materialIndex defines the material index to use
  21922. * @param verticesStart defines vertex index start
  21923. * @param verticesCount defines vertices count
  21924. * @param indexStart defines index start
  21925. * @param indexCount defines indices count
  21926. * @param mesh defines the parent mesh
  21927. * @param renderingMesh defines an optional rendering mesh
  21928. * @param createBoundingBox defines if bounding box should be created for this submesh
  21929. */
  21930. constructor(
  21931. /** the material index to use */
  21932. materialIndex: number,
  21933. /** vertex index start */
  21934. verticesStart: number,
  21935. /** vertices count */
  21936. verticesCount: number,
  21937. /** index start */
  21938. indexStart: number,
  21939. /** indices count */
  21940. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21941. /**
  21942. * Returns true if this submesh covers the entire parent mesh
  21943. * @ignorenaming
  21944. */
  21945. get IsGlobal(): boolean;
  21946. /**
  21947. * Returns the submesh BoudingInfo object
  21948. * @returns current bounding info (or mesh's one if the submesh is global)
  21949. */
  21950. getBoundingInfo(): BoundingInfo;
  21951. /**
  21952. * Sets the submesh BoundingInfo
  21953. * @param boundingInfo defines the new bounding info to use
  21954. * @returns the SubMesh
  21955. */
  21956. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21957. /**
  21958. * Returns the mesh of the current submesh
  21959. * @return the parent mesh
  21960. */
  21961. getMesh(): AbstractMesh;
  21962. /**
  21963. * Returns the rendering mesh of the submesh
  21964. * @returns the rendering mesh (could be different from parent mesh)
  21965. */
  21966. getRenderingMesh(): Mesh;
  21967. /**
  21968. * Returns the submesh material
  21969. * @returns null or the current material
  21970. */
  21971. getMaterial(): Nullable<Material>;
  21972. /**
  21973. * Sets a new updated BoundingInfo object to the submesh
  21974. * @param data defines an optional position array to use to determine the bounding info
  21975. * @returns the SubMesh
  21976. */
  21977. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21978. /** @hidden */
  21979. _checkCollision(collider: Collider): boolean;
  21980. /**
  21981. * Updates the submesh BoundingInfo
  21982. * @param world defines the world matrix to use to update the bounding info
  21983. * @returns the submesh
  21984. */
  21985. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21986. /**
  21987. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21988. * @param frustumPlanes defines the frustum planes
  21989. * @returns true if the submesh is intersecting with the frustum
  21990. */
  21991. isInFrustum(frustumPlanes: Plane[]): boolean;
  21992. /**
  21993. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21994. * @param frustumPlanes defines the frustum planes
  21995. * @returns true if the submesh is inside the frustum
  21996. */
  21997. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21998. /**
  21999. * Renders the submesh
  22000. * @param enableAlphaMode defines if alpha needs to be used
  22001. * @returns the submesh
  22002. */
  22003. render(enableAlphaMode: boolean): SubMesh;
  22004. /**
  22005. * @hidden
  22006. */
  22007. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22008. /**
  22009. * Checks if the submesh intersects with a ray
  22010. * @param ray defines the ray to test
  22011. * @returns true is the passed ray intersects the submesh bounding box
  22012. */
  22013. canIntersects(ray: Ray): boolean;
  22014. /**
  22015. * Intersects current submesh with a ray
  22016. * @param ray defines the ray to test
  22017. * @param positions defines mesh's positions array
  22018. * @param indices defines mesh's indices array
  22019. * @param fastCheck defines if only bounding info should be used
  22020. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22021. * @returns intersection info or null if no intersection
  22022. */
  22023. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22024. /** @hidden */
  22025. private _intersectLines;
  22026. /** @hidden */
  22027. private _intersectUnIndexedLines;
  22028. /** @hidden */
  22029. private _intersectTriangles;
  22030. /** @hidden */
  22031. private _intersectUnIndexedTriangles;
  22032. /** @hidden */
  22033. _rebuild(): void;
  22034. /**
  22035. * Creates a new submesh from the passed mesh
  22036. * @param newMesh defines the new hosting mesh
  22037. * @param newRenderingMesh defines an optional rendering mesh
  22038. * @returns the new submesh
  22039. */
  22040. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22041. /**
  22042. * Release associated resources
  22043. */
  22044. dispose(): void;
  22045. /**
  22046. * Gets the class name
  22047. * @returns the string "SubMesh".
  22048. */
  22049. getClassName(): string;
  22050. /**
  22051. * Creates a new submesh from indices data
  22052. * @param materialIndex the index of the main mesh material
  22053. * @param startIndex the index where to start the copy in the mesh indices array
  22054. * @param indexCount the number of indices to copy then from the startIndex
  22055. * @param mesh the main mesh to create the submesh from
  22056. * @param renderingMesh the optional rendering mesh
  22057. * @returns a new submesh
  22058. */
  22059. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22060. }
  22061. }
  22062. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22063. /**
  22064. * Class used to represent data loading progression
  22065. */
  22066. export class SceneLoaderFlags {
  22067. private static _ForceFullSceneLoadingForIncremental;
  22068. private static _ShowLoadingScreen;
  22069. private static _CleanBoneMatrixWeights;
  22070. private static _loggingLevel;
  22071. /**
  22072. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22073. */
  22074. static get ForceFullSceneLoadingForIncremental(): boolean;
  22075. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22076. /**
  22077. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22078. */
  22079. static get ShowLoadingScreen(): boolean;
  22080. static set ShowLoadingScreen(value: boolean);
  22081. /**
  22082. * Defines the current logging level (while loading the scene)
  22083. * @ignorenaming
  22084. */
  22085. static get loggingLevel(): number;
  22086. static set loggingLevel(value: number);
  22087. /**
  22088. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22089. */
  22090. static get CleanBoneMatrixWeights(): boolean;
  22091. static set CleanBoneMatrixWeights(value: boolean);
  22092. }
  22093. }
  22094. declare module "babylonjs/Meshes/geometry" {
  22095. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22096. import { Scene } from "babylonjs/scene";
  22097. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22098. import { Engine } from "babylonjs/Engines/engine";
  22099. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22100. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22101. import { Effect } from "babylonjs/Materials/effect";
  22102. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22103. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22104. import { Mesh } from "babylonjs/Meshes/mesh";
  22105. /**
  22106. * Class used to store geometry data (vertex buffers + index buffer)
  22107. */
  22108. export class Geometry implements IGetSetVerticesData {
  22109. /**
  22110. * Gets or sets the ID of the geometry
  22111. */
  22112. id: string;
  22113. /**
  22114. * Gets or sets the unique ID of the geometry
  22115. */
  22116. uniqueId: number;
  22117. /**
  22118. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22119. */
  22120. delayLoadState: number;
  22121. /**
  22122. * Gets the file containing the data to load when running in delay load state
  22123. */
  22124. delayLoadingFile: Nullable<string>;
  22125. /**
  22126. * Callback called when the geometry is updated
  22127. */
  22128. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22129. private _scene;
  22130. private _engine;
  22131. private _meshes;
  22132. private _totalVertices;
  22133. /** @hidden */
  22134. _indices: IndicesArray;
  22135. /** @hidden */
  22136. _vertexBuffers: {
  22137. [key: string]: VertexBuffer;
  22138. };
  22139. private _isDisposed;
  22140. private _extend;
  22141. private _boundingBias;
  22142. /** @hidden */
  22143. _delayInfo: Array<string>;
  22144. private _indexBuffer;
  22145. private _indexBufferIsUpdatable;
  22146. /** @hidden */
  22147. _boundingInfo: Nullable<BoundingInfo>;
  22148. /** @hidden */
  22149. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22150. /** @hidden */
  22151. _softwareSkinningFrameId: number;
  22152. private _vertexArrayObjects;
  22153. private _updatable;
  22154. /** @hidden */
  22155. _positions: Nullable<Vector3[]>;
  22156. /**
  22157. * 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
  22158. */
  22159. get boundingBias(): Vector2;
  22160. /**
  22161. * 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
  22162. */
  22163. set boundingBias(value: Vector2);
  22164. /**
  22165. * Static function used to attach a new empty geometry to a mesh
  22166. * @param mesh defines the mesh to attach the geometry to
  22167. * @returns the new Geometry
  22168. */
  22169. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22170. /**
  22171. * Creates a new geometry
  22172. * @param id defines the unique ID
  22173. * @param scene defines the hosting scene
  22174. * @param vertexData defines the VertexData used to get geometry data
  22175. * @param updatable defines if geometry must be updatable (false by default)
  22176. * @param mesh defines the mesh that will be associated with the geometry
  22177. */
  22178. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22179. /**
  22180. * Gets the current extend of the geometry
  22181. */
  22182. get extend(): {
  22183. minimum: Vector3;
  22184. maximum: Vector3;
  22185. };
  22186. /**
  22187. * Gets the hosting scene
  22188. * @returns the hosting Scene
  22189. */
  22190. getScene(): Scene;
  22191. /**
  22192. * Gets the hosting engine
  22193. * @returns the hosting Engine
  22194. */
  22195. getEngine(): Engine;
  22196. /**
  22197. * Defines if the geometry is ready to use
  22198. * @returns true if the geometry is ready to be used
  22199. */
  22200. isReady(): boolean;
  22201. /**
  22202. * Gets a value indicating that the geometry should not be serialized
  22203. */
  22204. get doNotSerialize(): boolean;
  22205. /** @hidden */
  22206. _rebuild(): void;
  22207. /**
  22208. * Affects all geometry data in one call
  22209. * @param vertexData defines the geometry data
  22210. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22211. */
  22212. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22213. /**
  22214. * Set specific vertex data
  22215. * @param kind defines the data kind (Position, normal, etc...)
  22216. * @param data defines the vertex data to use
  22217. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22218. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22219. */
  22220. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22221. /**
  22222. * Removes a specific vertex data
  22223. * @param kind defines the data kind (Position, normal, etc...)
  22224. */
  22225. removeVerticesData(kind: string): void;
  22226. /**
  22227. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22228. * @param buffer defines the vertex buffer to use
  22229. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22230. */
  22231. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22232. /**
  22233. * Update a specific vertex buffer
  22234. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22235. * It will do nothing if the buffer is not updatable
  22236. * @param kind defines the data kind (Position, normal, etc...)
  22237. * @param data defines the data to use
  22238. * @param offset defines the offset in the target buffer where to store the data
  22239. * @param useBytes set to true if the offset is in bytes
  22240. */
  22241. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22242. /**
  22243. * Update a specific vertex buffer
  22244. * This function will create a new buffer if the current one is not updatable
  22245. * @param kind defines the data kind (Position, normal, etc...)
  22246. * @param data defines the data to use
  22247. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22248. */
  22249. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22250. private _updateBoundingInfo;
  22251. /** @hidden */
  22252. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22253. /**
  22254. * Gets total number of vertices
  22255. * @returns the total number of vertices
  22256. */
  22257. getTotalVertices(): number;
  22258. /**
  22259. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22260. * @param kind defines the data kind (Position, normal, etc...)
  22261. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22262. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22263. * @returns a float array containing vertex data
  22264. */
  22265. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22266. /**
  22267. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22268. * @param kind defines the data kind (Position, normal, etc...)
  22269. * @returns true if the vertex buffer with the specified kind is updatable
  22270. */
  22271. isVertexBufferUpdatable(kind: string): boolean;
  22272. /**
  22273. * Gets a specific vertex buffer
  22274. * @param kind defines the data kind (Position, normal, etc...)
  22275. * @returns a VertexBuffer
  22276. */
  22277. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22278. /**
  22279. * Returns all vertex buffers
  22280. * @return an object holding all vertex buffers indexed by kind
  22281. */
  22282. getVertexBuffers(): Nullable<{
  22283. [key: string]: VertexBuffer;
  22284. }>;
  22285. /**
  22286. * Gets a boolean indicating if specific vertex buffer is present
  22287. * @param kind defines the data kind (Position, normal, etc...)
  22288. * @returns true if data is present
  22289. */
  22290. isVerticesDataPresent(kind: string): boolean;
  22291. /**
  22292. * Gets a list of all attached data kinds (Position, normal, etc...)
  22293. * @returns a list of string containing all kinds
  22294. */
  22295. getVerticesDataKinds(): string[];
  22296. /**
  22297. * Update index buffer
  22298. * @param indices defines the indices to store in the index buffer
  22299. * @param offset defines the offset in the target buffer where to store the data
  22300. * @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)
  22301. */
  22302. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22303. /**
  22304. * Creates a new index buffer
  22305. * @param indices defines the indices to store in the index buffer
  22306. * @param totalVertices defines the total number of vertices (could be null)
  22307. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22308. */
  22309. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22310. /**
  22311. * Return the total number of indices
  22312. * @returns the total number of indices
  22313. */
  22314. getTotalIndices(): number;
  22315. /**
  22316. * Gets the index buffer array
  22317. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22318. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22319. * @returns the index buffer array
  22320. */
  22321. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22322. /**
  22323. * Gets the index buffer
  22324. * @return the index buffer
  22325. */
  22326. getIndexBuffer(): Nullable<DataBuffer>;
  22327. /** @hidden */
  22328. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22329. /**
  22330. * Release the associated resources for a specific mesh
  22331. * @param mesh defines the source mesh
  22332. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22333. */
  22334. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22335. /**
  22336. * Apply current geometry to a given mesh
  22337. * @param mesh defines the mesh to apply geometry to
  22338. */
  22339. applyToMesh(mesh: Mesh): void;
  22340. private _updateExtend;
  22341. private _applyToMesh;
  22342. private notifyUpdate;
  22343. /**
  22344. * Load the geometry if it was flagged as delay loaded
  22345. * @param scene defines the hosting scene
  22346. * @param onLoaded defines a callback called when the geometry is loaded
  22347. */
  22348. load(scene: Scene, onLoaded?: () => void): void;
  22349. private _queueLoad;
  22350. /**
  22351. * Invert the geometry to move from a right handed system to a left handed one.
  22352. */
  22353. toLeftHanded(): void;
  22354. /** @hidden */
  22355. _resetPointsArrayCache(): void;
  22356. /** @hidden */
  22357. _generatePointsArray(): boolean;
  22358. /**
  22359. * Gets a value indicating if the geometry is disposed
  22360. * @returns true if the geometry was disposed
  22361. */
  22362. isDisposed(): boolean;
  22363. private _disposeVertexArrayObjects;
  22364. /**
  22365. * Free all associated resources
  22366. */
  22367. dispose(): void;
  22368. /**
  22369. * Clone the current geometry into a new geometry
  22370. * @param id defines the unique ID of the new geometry
  22371. * @returns a new geometry object
  22372. */
  22373. copy(id: string): Geometry;
  22374. /**
  22375. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22376. * @return a JSON representation of the current geometry data (without the vertices data)
  22377. */
  22378. serialize(): any;
  22379. private toNumberArray;
  22380. /**
  22381. * Serialize all vertices data into a JSON oject
  22382. * @returns a JSON representation of the current geometry data
  22383. */
  22384. serializeVerticeData(): any;
  22385. /**
  22386. * Extracts a clone of a mesh geometry
  22387. * @param mesh defines the source mesh
  22388. * @param id defines the unique ID of the new geometry object
  22389. * @returns the new geometry object
  22390. */
  22391. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22392. /**
  22393. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22394. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22395. * Be aware Math.random() could cause collisions, but:
  22396. * "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"
  22397. * @returns a string containing a new GUID
  22398. */
  22399. static RandomId(): string;
  22400. /** @hidden */
  22401. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22402. private static _CleanMatricesWeights;
  22403. /**
  22404. * Create a new geometry from persisted data (Using .babylon file format)
  22405. * @param parsedVertexData defines the persisted data
  22406. * @param scene defines the hosting scene
  22407. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22408. * @returns the new geometry object
  22409. */
  22410. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22411. }
  22412. }
  22413. declare module "babylonjs/Meshes/mesh.vertexData" {
  22414. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22415. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22416. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22417. import { Geometry } from "babylonjs/Meshes/geometry";
  22418. import { Mesh } from "babylonjs/Meshes/mesh";
  22419. /**
  22420. * Define an interface for all classes that will get and set the data on vertices
  22421. */
  22422. export interface IGetSetVerticesData {
  22423. /**
  22424. * Gets a boolean indicating if specific vertex data is present
  22425. * @param kind defines the vertex data kind to use
  22426. * @returns true is data kind is present
  22427. */
  22428. isVerticesDataPresent(kind: string): boolean;
  22429. /**
  22430. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22431. * @param kind defines the data kind (Position, normal, etc...)
  22432. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22433. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22434. * @returns a float array containing vertex data
  22435. */
  22436. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22437. /**
  22438. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22439. * @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.
  22440. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22441. * @returns the indices array or an empty array if the mesh has no geometry
  22442. */
  22443. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22444. /**
  22445. * Set specific vertex data
  22446. * @param kind defines the data kind (Position, normal, etc...)
  22447. * @param data defines the vertex data to use
  22448. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22449. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22450. */
  22451. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22452. /**
  22453. * Update a specific associated vertex buffer
  22454. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22455. * - VertexBuffer.PositionKind
  22456. * - VertexBuffer.UVKind
  22457. * - VertexBuffer.UV2Kind
  22458. * - VertexBuffer.UV3Kind
  22459. * - VertexBuffer.UV4Kind
  22460. * - VertexBuffer.UV5Kind
  22461. * - VertexBuffer.UV6Kind
  22462. * - VertexBuffer.ColorKind
  22463. * - VertexBuffer.MatricesIndicesKind
  22464. * - VertexBuffer.MatricesIndicesExtraKind
  22465. * - VertexBuffer.MatricesWeightsKind
  22466. * - VertexBuffer.MatricesWeightsExtraKind
  22467. * @param data defines the data source
  22468. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22469. * @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)
  22470. */
  22471. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22472. /**
  22473. * Creates a new index buffer
  22474. * @param indices defines the indices to store in the index buffer
  22475. * @param totalVertices defines the total number of vertices (could be null)
  22476. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22477. */
  22478. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22479. }
  22480. /**
  22481. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22482. */
  22483. export class VertexData {
  22484. /**
  22485. * Mesh side orientation : usually the external or front surface
  22486. */
  22487. static readonly FRONTSIDE: number;
  22488. /**
  22489. * Mesh side orientation : usually the internal or back surface
  22490. */
  22491. static readonly BACKSIDE: number;
  22492. /**
  22493. * Mesh side orientation : both internal and external or front and back surfaces
  22494. */
  22495. static readonly DOUBLESIDE: number;
  22496. /**
  22497. * Mesh side orientation : by default, `FRONTSIDE`
  22498. */
  22499. static readonly DEFAULTSIDE: number;
  22500. /**
  22501. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22502. */
  22503. positions: Nullable<FloatArray>;
  22504. /**
  22505. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22506. */
  22507. normals: Nullable<FloatArray>;
  22508. /**
  22509. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22510. */
  22511. tangents: Nullable<FloatArray>;
  22512. /**
  22513. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22514. */
  22515. uvs: Nullable<FloatArray>;
  22516. /**
  22517. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22518. */
  22519. uvs2: Nullable<FloatArray>;
  22520. /**
  22521. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22522. */
  22523. uvs3: Nullable<FloatArray>;
  22524. /**
  22525. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22526. */
  22527. uvs4: Nullable<FloatArray>;
  22528. /**
  22529. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22530. */
  22531. uvs5: Nullable<FloatArray>;
  22532. /**
  22533. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22534. */
  22535. uvs6: Nullable<FloatArray>;
  22536. /**
  22537. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22538. */
  22539. colors: Nullable<FloatArray>;
  22540. /**
  22541. * 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).
  22542. */
  22543. matricesIndices: Nullable<FloatArray>;
  22544. /**
  22545. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22546. */
  22547. matricesWeights: Nullable<FloatArray>;
  22548. /**
  22549. * An array extending the number of possible indices
  22550. */
  22551. matricesIndicesExtra: Nullable<FloatArray>;
  22552. /**
  22553. * An array extending the number of possible weights when the number of indices is extended
  22554. */
  22555. matricesWeightsExtra: Nullable<FloatArray>;
  22556. /**
  22557. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22558. */
  22559. indices: Nullable<IndicesArray>;
  22560. /**
  22561. * Uses the passed data array to set the set the values for the specified kind of data
  22562. * @param data a linear array of floating numbers
  22563. * @param kind the type of data that is being set, eg positions, colors etc
  22564. */
  22565. set(data: FloatArray, kind: string): void;
  22566. /**
  22567. * Associates the vertexData to the passed Mesh.
  22568. * Sets it as updatable or not (default `false`)
  22569. * @param mesh the mesh the vertexData is applied to
  22570. * @param updatable when used and having the value true allows new data to update the vertexData
  22571. * @returns the VertexData
  22572. */
  22573. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22574. /**
  22575. * Associates the vertexData to the passed Geometry.
  22576. * Sets it as updatable or not (default `false`)
  22577. * @param geometry the geometry the vertexData is applied to
  22578. * @param updatable when used and having the value true allows new data to update the vertexData
  22579. * @returns VertexData
  22580. */
  22581. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22582. /**
  22583. * Updates the associated mesh
  22584. * @param mesh the mesh to be updated
  22585. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22586. * @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
  22587. * @returns VertexData
  22588. */
  22589. updateMesh(mesh: Mesh): VertexData;
  22590. /**
  22591. * Updates the associated geometry
  22592. * @param geometry the geometry to be updated
  22593. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22594. * @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
  22595. * @returns VertexData.
  22596. */
  22597. updateGeometry(geometry: Geometry): VertexData;
  22598. private _applyTo;
  22599. private _update;
  22600. /**
  22601. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22602. * @param matrix the transforming matrix
  22603. * @returns the VertexData
  22604. */
  22605. transform(matrix: Matrix): VertexData;
  22606. /**
  22607. * Merges the passed VertexData into the current one
  22608. * @param other the VertexData to be merged into the current one
  22609. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22610. * @returns the modified VertexData
  22611. */
  22612. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22613. private _mergeElement;
  22614. private _validate;
  22615. /**
  22616. * Serializes the VertexData
  22617. * @returns a serialized object
  22618. */
  22619. serialize(): any;
  22620. /**
  22621. * Extracts the vertexData from a mesh
  22622. * @param mesh the mesh from which to extract the VertexData
  22623. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22624. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22625. * @returns the object VertexData associated to the passed mesh
  22626. */
  22627. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22628. /**
  22629. * Extracts the vertexData from the geometry
  22630. * @param geometry the geometry from which to extract the VertexData
  22631. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22632. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22633. * @returns the object VertexData associated to the passed mesh
  22634. */
  22635. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22636. private static _ExtractFrom;
  22637. /**
  22638. * Creates the VertexData for a Ribbon
  22639. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22640. * * pathArray array of paths, each of which an array of successive Vector3
  22641. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22642. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22643. * * 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
  22644. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22645. * * 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)
  22646. * * 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)
  22647. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22648. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22649. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22650. * @returns the VertexData of the ribbon
  22651. */
  22652. static CreateRibbon(options: {
  22653. pathArray: Vector3[][];
  22654. closeArray?: boolean;
  22655. closePath?: boolean;
  22656. offset?: number;
  22657. sideOrientation?: number;
  22658. frontUVs?: Vector4;
  22659. backUVs?: Vector4;
  22660. invertUV?: boolean;
  22661. uvs?: Vector2[];
  22662. colors?: Color4[];
  22663. }): VertexData;
  22664. /**
  22665. * Creates the VertexData for a box
  22666. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22667. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22668. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22669. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22670. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22671. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22672. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22673. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22674. * * 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)
  22675. * * 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)
  22676. * @returns the VertexData of the box
  22677. */
  22678. static CreateBox(options: {
  22679. size?: number;
  22680. width?: number;
  22681. height?: number;
  22682. depth?: number;
  22683. faceUV?: Vector4[];
  22684. faceColors?: Color4[];
  22685. sideOrientation?: number;
  22686. frontUVs?: Vector4;
  22687. backUVs?: Vector4;
  22688. }): VertexData;
  22689. /**
  22690. * Creates the VertexData for a tiled box
  22691. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22692. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22693. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22694. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22695. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22696. * @returns the VertexData of the box
  22697. */
  22698. static CreateTiledBox(options: {
  22699. pattern?: number;
  22700. width?: number;
  22701. height?: number;
  22702. depth?: number;
  22703. tileSize?: number;
  22704. tileWidth?: number;
  22705. tileHeight?: number;
  22706. alignHorizontal?: number;
  22707. alignVertical?: number;
  22708. faceUV?: Vector4[];
  22709. faceColors?: Color4[];
  22710. sideOrientation?: number;
  22711. }): VertexData;
  22712. /**
  22713. * Creates the VertexData for a tiled plane
  22714. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22715. * * pattern a limited pattern arrangement depending on the number
  22716. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22717. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22718. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22720. * * 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)
  22721. * * 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)
  22722. * @returns the VertexData of the tiled plane
  22723. */
  22724. static CreateTiledPlane(options: {
  22725. pattern?: number;
  22726. tileSize?: number;
  22727. tileWidth?: number;
  22728. tileHeight?: number;
  22729. size?: number;
  22730. width?: number;
  22731. height?: number;
  22732. alignHorizontal?: number;
  22733. alignVertical?: number;
  22734. sideOrientation?: number;
  22735. frontUVs?: Vector4;
  22736. backUVs?: Vector4;
  22737. }): VertexData;
  22738. /**
  22739. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22740. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22741. * * segments sets the number of horizontal strips optional, default 32
  22742. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22743. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22744. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22745. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22746. * * 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
  22747. * * 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
  22748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22749. * * 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)
  22750. * * 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)
  22751. * @returns the VertexData of the ellipsoid
  22752. */
  22753. static CreateSphere(options: {
  22754. segments?: number;
  22755. diameter?: number;
  22756. diameterX?: number;
  22757. diameterY?: number;
  22758. diameterZ?: number;
  22759. arc?: number;
  22760. slice?: number;
  22761. sideOrientation?: number;
  22762. frontUVs?: Vector4;
  22763. backUVs?: Vector4;
  22764. }): VertexData;
  22765. /**
  22766. * Creates the VertexData for a cylinder, cone or prism
  22767. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22768. * * height sets the height (y direction) of the cylinder, optional, default 2
  22769. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22770. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22771. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22772. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22773. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22774. * * 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
  22775. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22776. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22777. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22778. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22780. * * 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)
  22781. * * 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)
  22782. * @returns the VertexData of the cylinder, cone or prism
  22783. */
  22784. static CreateCylinder(options: {
  22785. height?: number;
  22786. diameterTop?: number;
  22787. diameterBottom?: number;
  22788. diameter?: number;
  22789. tessellation?: number;
  22790. subdivisions?: number;
  22791. arc?: number;
  22792. faceColors?: Color4[];
  22793. faceUV?: Vector4[];
  22794. hasRings?: boolean;
  22795. enclose?: boolean;
  22796. sideOrientation?: number;
  22797. frontUVs?: Vector4;
  22798. backUVs?: Vector4;
  22799. }): VertexData;
  22800. /**
  22801. * Creates the VertexData for a torus
  22802. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22803. * * diameter the diameter of the torus, optional default 1
  22804. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22805. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22807. * * 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)
  22808. * * 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)
  22809. * @returns the VertexData of the torus
  22810. */
  22811. static CreateTorus(options: {
  22812. diameter?: number;
  22813. thickness?: number;
  22814. tessellation?: number;
  22815. sideOrientation?: number;
  22816. frontUVs?: Vector4;
  22817. backUVs?: Vector4;
  22818. }): VertexData;
  22819. /**
  22820. * Creates the VertexData of the LineSystem
  22821. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22822. * - lines an array of lines, each line being an array of successive Vector3
  22823. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22824. * @returns the VertexData of the LineSystem
  22825. */
  22826. static CreateLineSystem(options: {
  22827. lines: Vector3[][];
  22828. colors?: Nullable<Color4[][]>;
  22829. }): VertexData;
  22830. /**
  22831. * Create the VertexData for a DashedLines
  22832. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22833. * - points an array successive Vector3
  22834. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22835. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22836. * - dashNb the intended total number of dashes, optional, default 200
  22837. * @returns the VertexData for the DashedLines
  22838. */
  22839. static CreateDashedLines(options: {
  22840. points: Vector3[];
  22841. dashSize?: number;
  22842. gapSize?: number;
  22843. dashNb?: number;
  22844. }): VertexData;
  22845. /**
  22846. * Creates the VertexData for a Ground
  22847. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22848. * - width the width (x direction) of the ground, optional, default 1
  22849. * - height the height (z direction) of the ground, optional, default 1
  22850. * - subdivisions the number of subdivisions per side, optional, default 1
  22851. * @returns the VertexData of the Ground
  22852. */
  22853. static CreateGround(options: {
  22854. width?: number;
  22855. height?: number;
  22856. subdivisions?: number;
  22857. subdivisionsX?: number;
  22858. subdivisionsY?: number;
  22859. }): VertexData;
  22860. /**
  22861. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22862. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22863. * * xmin the ground minimum X coordinate, optional, default -1
  22864. * * zmin the ground minimum Z coordinate, optional, default -1
  22865. * * xmax the ground maximum X coordinate, optional, default 1
  22866. * * zmax the ground maximum Z coordinate, optional, default 1
  22867. * * 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}
  22868. * * 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}
  22869. * @returns the VertexData of the TiledGround
  22870. */
  22871. static CreateTiledGround(options: {
  22872. xmin: number;
  22873. zmin: number;
  22874. xmax: number;
  22875. zmax: number;
  22876. subdivisions?: {
  22877. w: number;
  22878. h: number;
  22879. };
  22880. precision?: {
  22881. w: number;
  22882. h: number;
  22883. };
  22884. }): VertexData;
  22885. /**
  22886. * Creates the VertexData of the Ground designed from a heightmap
  22887. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22888. * * width the width (x direction) of the ground
  22889. * * height the height (z direction) of the ground
  22890. * * subdivisions the number of subdivisions per side
  22891. * * minHeight the minimum altitude on the ground, optional, default 0
  22892. * * maxHeight the maximum altitude on the ground, optional default 1
  22893. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22894. * * buffer the array holding the image color data
  22895. * * bufferWidth the width of image
  22896. * * bufferHeight the height of image
  22897. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22898. * @returns the VertexData of the Ground designed from a heightmap
  22899. */
  22900. static CreateGroundFromHeightMap(options: {
  22901. width: number;
  22902. height: number;
  22903. subdivisions: number;
  22904. minHeight: number;
  22905. maxHeight: number;
  22906. colorFilter: Color3;
  22907. buffer: Uint8Array;
  22908. bufferWidth: number;
  22909. bufferHeight: number;
  22910. alphaFilter: number;
  22911. }): VertexData;
  22912. /**
  22913. * Creates the VertexData for a Plane
  22914. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22915. * * size sets the width and height of the plane to the value of size, optional default 1
  22916. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22917. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22918. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22919. * * 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)
  22920. * * 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)
  22921. * @returns the VertexData of the box
  22922. */
  22923. static CreatePlane(options: {
  22924. size?: number;
  22925. width?: number;
  22926. height?: number;
  22927. sideOrientation?: number;
  22928. frontUVs?: Vector4;
  22929. backUVs?: Vector4;
  22930. }): VertexData;
  22931. /**
  22932. * Creates the VertexData of the Disc or regular Polygon
  22933. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22934. * * radius the radius of the disc, optional default 0.5
  22935. * * tessellation the number of polygon sides, optional, default 64
  22936. * * 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
  22937. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22938. * * 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)
  22939. * * 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)
  22940. * @returns the VertexData of the box
  22941. */
  22942. static CreateDisc(options: {
  22943. radius?: number;
  22944. tessellation?: number;
  22945. arc?: number;
  22946. sideOrientation?: number;
  22947. frontUVs?: Vector4;
  22948. backUVs?: Vector4;
  22949. }): VertexData;
  22950. /**
  22951. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22952. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22953. * @param polygon a mesh built from polygonTriangulation.build()
  22954. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22955. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22956. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22957. * @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)
  22958. * @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)
  22959. * @returns the VertexData of the Polygon
  22960. */
  22961. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22962. /**
  22963. * Creates the VertexData of the IcoSphere
  22964. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22965. * * radius the radius of the IcoSphere, optional default 1
  22966. * * radiusX allows stretching in the x direction, optional, default radius
  22967. * * radiusY allows stretching in the y direction, optional, default radius
  22968. * * radiusZ allows stretching in the z direction, optional, default radius
  22969. * * flat when true creates a flat shaded mesh, optional, default true
  22970. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22972. * * 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)
  22973. * * 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)
  22974. * @returns the VertexData of the IcoSphere
  22975. */
  22976. static CreateIcoSphere(options: {
  22977. radius?: number;
  22978. radiusX?: number;
  22979. radiusY?: number;
  22980. radiusZ?: number;
  22981. flat?: boolean;
  22982. subdivisions?: number;
  22983. sideOrientation?: number;
  22984. frontUVs?: Vector4;
  22985. backUVs?: Vector4;
  22986. }): VertexData;
  22987. /**
  22988. * Creates the VertexData for a Polyhedron
  22989. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22990. * * type provided types are:
  22991. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22992. * * 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)
  22993. * * size the size of the IcoSphere, optional default 1
  22994. * * sizeX allows stretching in the x direction, optional, default size
  22995. * * sizeY allows stretching in the y direction, optional, default size
  22996. * * sizeZ allows stretching in the z direction, optional, default size
  22997. * * 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
  22998. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22999. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23000. * * flat when true creates a flat shaded mesh, optional, default true
  23001. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23002. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23003. * * 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)
  23004. * * 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)
  23005. * @returns the VertexData of the Polyhedron
  23006. */
  23007. static CreatePolyhedron(options: {
  23008. type?: number;
  23009. size?: number;
  23010. sizeX?: number;
  23011. sizeY?: number;
  23012. sizeZ?: number;
  23013. custom?: any;
  23014. faceUV?: Vector4[];
  23015. faceColors?: Color4[];
  23016. flat?: boolean;
  23017. sideOrientation?: number;
  23018. frontUVs?: Vector4;
  23019. backUVs?: Vector4;
  23020. }): VertexData;
  23021. /**
  23022. * Creates the VertexData for a TorusKnot
  23023. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23024. * * radius the radius of the torus knot, optional, default 2
  23025. * * tube the thickness of the tube, optional, default 0.5
  23026. * * radialSegments the number of sides on each tube segments, optional, default 32
  23027. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23028. * * p the number of windings around the z axis, optional, default 2
  23029. * * q the number of windings around the x axis, optional, default 3
  23030. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23031. * * 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)
  23032. * * 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)
  23033. * @returns the VertexData of the Torus Knot
  23034. */
  23035. static CreateTorusKnot(options: {
  23036. radius?: number;
  23037. tube?: number;
  23038. radialSegments?: number;
  23039. tubularSegments?: number;
  23040. p?: number;
  23041. q?: number;
  23042. sideOrientation?: number;
  23043. frontUVs?: Vector4;
  23044. backUVs?: Vector4;
  23045. }): VertexData;
  23046. /**
  23047. * Compute normals for given positions and indices
  23048. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23049. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23050. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23051. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23052. * * facetNormals : optional array of facet normals (vector3)
  23053. * * facetPositions : optional array of facet positions (vector3)
  23054. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23055. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23056. * * bInfo : optional bounding info, required for facetPartitioning computation
  23057. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23058. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23059. * * useRightHandedSystem: optional boolean to for right handed system computation
  23060. * * depthSort : optional boolean to enable the facet depth sort computation
  23061. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23062. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23063. */
  23064. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23065. facetNormals?: any;
  23066. facetPositions?: any;
  23067. facetPartitioning?: any;
  23068. ratio?: number;
  23069. bInfo?: any;
  23070. bbSize?: Vector3;
  23071. subDiv?: any;
  23072. useRightHandedSystem?: boolean;
  23073. depthSort?: boolean;
  23074. distanceTo?: Vector3;
  23075. depthSortedFacets?: any;
  23076. }): void;
  23077. /** @hidden */
  23078. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23079. /**
  23080. * Applies VertexData created from the imported parameters to the geometry
  23081. * @param parsedVertexData the parsed data from an imported file
  23082. * @param geometry the geometry to apply the VertexData to
  23083. */
  23084. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23085. }
  23086. }
  23087. declare module "babylonjs/Morph/morphTarget" {
  23088. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23089. import { Observable } from "babylonjs/Misc/observable";
  23090. import { Nullable, FloatArray } from "babylonjs/types";
  23091. import { Scene } from "babylonjs/scene";
  23092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23093. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23094. /**
  23095. * Defines a target to use with MorphTargetManager
  23096. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23097. */
  23098. export class MorphTarget implements IAnimatable {
  23099. /** defines the name of the target */
  23100. name: string;
  23101. /**
  23102. * Gets or sets the list of animations
  23103. */
  23104. animations: import("babylonjs/Animations/animation").Animation[];
  23105. private _scene;
  23106. private _positions;
  23107. private _normals;
  23108. private _tangents;
  23109. private _uvs;
  23110. private _influence;
  23111. private _uniqueId;
  23112. /**
  23113. * Observable raised when the influence changes
  23114. */
  23115. onInfluenceChanged: Observable<boolean>;
  23116. /** @hidden */
  23117. _onDataLayoutChanged: Observable<void>;
  23118. /**
  23119. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23120. */
  23121. get influence(): number;
  23122. set influence(influence: number);
  23123. /**
  23124. * Gets or sets the id of the morph Target
  23125. */
  23126. id: string;
  23127. private _animationPropertiesOverride;
  23128. /**
  23129. * Gets or sets the animation properties override
  23130. */
  23131. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23132. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23133. /**
  23134. * Creates a new MorphTarget
  23135. * @param name defines the name of the target
  23136. * @param influence defines the influence to use
  23137. * @param scene defines the scene the morphtarget belongs to
  23138. */
  23139. constructor(
  23140. /** defines the name of the target */
  23141. name: string, influence?: number, scene?: Nullable<Scene>);
  23142. /**
  23143. * Gets the unique ID of this manager
  23144. */
  23145. get uniqueId(): number;
  23146. /**
  23147. * Gets a boolean defining if the target contains position data
  23148. */
  23149. get hasPositions(): boolean;
  23150. /**
  23151. * Gets a boolean defining if the target contains normal data
  23152. */
  23153. get hasNormals(): boolean;
  23154. /**
  23155. * Gets a boolean defining if the target contains tangent data
  23156. */
  23157. get hasTangents(): boolean;
  23158. /**
  23159. * Gets a boolean defining if the target contains texture coordinates data
  23160. */
  23161. get hasUVs(): boolean;
  23162. /**
  23163. * Affects position data to this target
  23164. * @param data defines the position data to use
  23165. */
  23166. setPositions(data: Nullable<FloatArray>): void;
  23167. /**
  23168. * Gets the position data stored in this target
  23169. * @returns a FloatArray containing the position data (or null if not present)
  23170. */
  23171. getPositions(): Nullable<FloatArray>;
  23172. /**
  23173. * Affects normal data to this target
  23174. * @param data defines the normal data to use
  23175. */
  23176. setNormals(data: Nullable<FloatArray>): void;
  23177. /**
  23178. * Gets the normal data stored in this target
  23179. * @returns a FloatArray containing the normal data (or null if not present)
  23180. */
  23181. getNormals(): Nullable<FloatArray>;
  23182. /**
  23183. * Affects tangent data to this target
  23184. * @param data defines the tangent data to use
  23185. */
  23186. setTangents(data: Nullable<FloatArray>): void;
  23187. /**
  23188. * Gets the tangent data stored in this target
  23189. * @returns a FloatArray containing the tangent data (or null if not present)
  23190. */
  23191. getTangents(): Nullable<FloatArray>;
  23192. /**
  23193. * Affects texture coordinates data to this target
  23194. * @param data defines the texture coordinates data to use
  23195. */
  23196. setUVs(data: Nullable<FloatArray>): void;
  23197. /**
  23198. * Gets the texture coordinates data stored in this target
  23199. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23200. */
  23201. getUVs(): Nullable<FloatArray>;
  23202. /**
  23203. * Clone the current target
  23204. * @returns a new MorphTarget
  23205. */
  23206. clone(): MorphTarget;
  23207. /**
  23208. * Serializes the current target into a Serialization object
  23209. * @returns the serialized object
  23210. */
  23211. serialize(): any;
  23212. /**
  23213. * Returns the string "MorphTarget"
  23214. * @returns "MorphTarget"
  23215. */
  23216. getClassName(): string;
  23217. /**
  23218. * Creates a new target from serialized data
  23219. * @param serializationObject defines the serialized data to use
  23220. * @returns a new MorphTarget
  23221. */
  23222. static Parse(serializationObject: any): MorphTarget;
  23223. /**
  23224. * Creates a MorphTarget from mesh data
  23225. * @param mesh defines the source mesh
  23226. * @param name defines the name to use for the new target
  23227. * @param influence defines the influence to attach to the target
  23228. * @returns a new MorphTarget
  23229. */
  23230. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23231. }
  23232. }
  23233. declare module "babylonjs/Morph/morphTargetManager" {
  23234. import { Nullable } from "babylonjs/types";
  23235. import { Scene } from "babylonjs/scene";
  23236. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23237. /**
  23238. * This class is used to deform meshes using morphing between different targets
  23239. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23240. */
  23241. export class MorphTargetManager {
  23242. private _targets;
  23243. private _targetInfluenceChangedObservers;
  23244. private _targetDataLayoutChangedObservers;
  23245. private _activeTargets;
  23246. private _scene;
  23247. private _influences;
  23248. private _supportsNormals;
  23249. private _supportsTangents;
  23250. private _supportsUVs;
  23251. private _vertexCount;
  23252. private _uniqueId;
  23253. private _tempInfluences;
  23254. /**
  23255. * Gets or sets a boolean indicating if normals must be morphed
  23256. */
  23257. enableNormalMorphing: boolean;
  23258. /**
  23259. * Gets or sets a boolean indicating if tangents must be morphed
  23260. */
  23261. enableTangentMorphing: boolean;
  23262. /**
  23263. * Gets or sets a boolean indicating if UV must be morphed
  23264. */
  23265. enableUVMorphing: boolean;
  23266. /**
  23267. * Creates a new MorphTargetManager
  23268. * @param scene defines the current scene
  23269. */
  23270. constructor(scene?: Nullable<Scene>);
  23271. /**
  23272. * Gets the unique ID of this manager
  23273. */
  23274. get uniqueId(): number;
  23275. /**
  23276. * Gets the number of vertices handled by this manager
  23277. */
  23278. get vertexCount(): number;
  23279. /**
  23280. * Gets a boolean indicating if this manager supports morphing of normals
  23281. */
  23282. get supportsNormals(): boolean;
  23283. /**
  23284. * Gets a boolean indicating if this manager supports morphing of tangents
  23285. */
  23286. get supportsTangents(): boolean;
  23287. /**
  23288. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23289. */
  23290. get supportsUVs(): boolean;
  23291. /**
  23292. * Gets the number of targets stored in this manager
  23293. */
  23294. get numTargets(): number;
  23295. /**
  23296. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23297. */
  23298. get numInfluencers(): number;
  23299. /**
  23300. * Gets the list of influences (one per target)
  23301. */
  23302. get influences(): Float32Array;
  23303. /**
  23304. * Gets the active target at specified index. An active target is a target with an influence > 0
  23305. * @param index defines the index to check
  23306. * @returns the requested target
  23307. */
  23308. getActiveTarget(index: number): MorphTarget;
  23309. /**
  23310. * Gets the target at specified index
  23311. * @param index defines the index to check
  23312. * @returns the requested target
  23313. */
  23314. getTarget(index: number): MorphTarget;
  23315. /**
  23316. * Add a new target to this manager
  23317. * @param target defines the target to add
  23318. */
  23319. addTarget(target: MorphTarget): void;
  23320. /**
  23321. * Removes a target from the manager
  23322. * @param target defines the target to remove
  23323. */
  23324. removeTarget(target: MorphTarget): void;
  23325. /**
  23326. * Clone the current manager
  23327. * @returns a new MorphTargetManager
  23328. */
  23329. clone(): MorphTargetManager;
  23330. /**
  23331. * Serializes the current manager into a Serialization object
  23332. * @returns the serialized object
  23333. */
  23334. serialize(): any;
  23335. private _syncActiveTargets;
  23336. /**
  23337. * Syncrhonize the targets with all the meshes using this morph target manager
  23338. */
  23339. synchronize(): void;
  23340. /**
  23341. * Creates a new MorphTargetManager from serialized data
  23342. * @param serializationObject defines the serialized data
  23343. * @param scene defines the hosting scene
  23344. * @returns the new MorphTargetManager
  23345. */
  23346. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23347. }
  23348. }
  23349. declare module "babylonjs/Meshes/meshLODLevel" {
  23350. import { Mesh } from "babylonjs/Meshes/mesh";
  23351. import { Nullable } from "babylonjs/types";
  23352. /**
  23353. * Class used to represent a specific level of detail of a mesh
  23354. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23355. */
  23356. export class MeshLODLevel {
  23357. /** Defines the distance where this level should start being displayed */
  23358. distance: number;
  23359. /** Defines the mesh to use to render this level */
  23360. mesh: Nullable<Mesh>;
  23361. /**
  23362. * Creates a new LOD level
  23363. * @param distance defines the distance where this level should star being displayed
  23364. * @param mesh defines the mesh to use to render this level
  23365. */
  23366. constructor(
  23367. /** Defines the distance where this level should start being displayed */
  23368. distance: number,
  23369. /** Defines the mesh to use to render this level */
  23370. mesh: Nullable<Mesh>);
  23371. }
  23372. }
  23373. declare module "babylonjs/Meshes/groundMesh" {
  23374. import { Scene } from "babylonjs/scene";
  23375. import { Vector3 } from "babylonjs/Maths/math.vector";
  23376. import { Mesh } from "babylonjs/Meshes/mesh";
  23377. /**
  23378. * Mesh representing the gorund
  23379. */
  23380. export class GroundMesh extends Mesh {
  23381. /** If octree should be generated */
  23382. generateOctree: boolean;
  23383. private _heightQuads;
  23384. /** @hidden */
  23385. _subdivisionsX: number;
  23386. /** @hidden */
  23387. _subdivisionsY: number;
  23388. /** @hidden */
  23389. _width: number;
  23390. /** @hidden */
  23391. _height: number;
  23392. /** @hidden */
  23393. _minX: number;
  23394. /** @hidden */
  23395. _maxX: number;
  23396. /** @hidden */
  23397. _minZ: number;
  23398. /** @hidden */
  23399. _maxZ: number;
  23400. constructor(name: string, scene: Scene);
  23401. /**
  23402. * "GroundMesh"
  23403. * @returns "GroundMesh"
  23404. */
  23405. getClassName(): string;
  23406. /**
  23407. * The minimum of x and y subdivisions
  23408. */
  23409. get subdivisions(): number;
  23410. /**
  23411. * X subdivisions
  23412. */
  23413. get subdivisionsX(): number;
  23414. /**
  23415. * Y subdivisions
  23416. */
  23417. get subdivisionsY(): number;
  23418. /**
  23419. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23420. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23421. * @param chunksCount the number of subdivisions for x and y
  23422. * @param octreeBlocksSize (Default: 32)
  23423. */
  23424. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23425. /**
  23426. * Returns a height (y) value in the Worl system :
  23427. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23428. * @param x x coordinate
  23429. * @param z z coordinate
  23430. * @returns the ground y position if (x, z) are outside the ground surface.
  23431. */
  23432. getHeightAtCoordinates(x: number, z: number): number;
  23433. /**
  23434. * Returns a normalized vector (Vector3) orthogonal to the ground
  23435. * at the ground coordinates (x, z) expressed in the World system.
  23436. * @param x x coordinate
  23437. * @param z z coordinate
  23438. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23439. */
  23440. getNormalAtCoordinates(x: number, z: number): Vector3;
  23441. /**
  23442. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23443. * at the ground coordinates (x, z) expressed in the World system.
  23444. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23445. * @param x x coordinate
  23446. * @param z z coordinate
  23447. * @param ref vector to store the result
  23448. * @returns the GroundMesh.
  23449. */
  23450. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23451. /**
  23452. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23453. * if the ground has been updated.
  23454. * This can be used in the render loop.
  23455. * @returns the GroundMesh.
  23456. */
  23457. updateCoordinateHeights(): GroundMesh;
  23458. private _getFacetAt;
  23459. private _initHeightQuads;
  23460. private _computeHeightQuads;
  23461. /**
  23462. * Serializes this ground mesh
  23463. * @param serializationObject object to write serialization to
  23464. */
  23465. serialize(serializationObject: any): void;
  23466. /**
  23467. * Parses a serialized ground mesh
  23468. * @param parsedMesh the serialized mesh
  23469. * @param scene the scene to create the ground mesh in
  23470. * @returns the created ground mesh
  23471. */
  23472. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23473. }
  23474. }
  23475. declare module "babylonjs/Physics/physicsJoint" {
  23476. import { Vector3 } from "babylonjs/Maths/math.vector";
  23477. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23478. /**
  23479. * Interface for Physics-Joint data
  23480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23481. */
  23482. export interface PhysicsJointData {
  23483. /**
  23484. * The main pivot of the joint
  23485. */
  23486. mainPivot?: Vector3;
  23487. /**
  23488. * The connected pivot of the joint
  23489. */
  23490. connectedPivot?: Vector3;
  23491. /**
  23492. * The main axis of the joint
  23493. */
  23494. mainAxis?: Vector3;
  23495. /**
  23496. * The connected axis of the joint
  23497. */
  23498. connectedAxis?: Vector3;
  23499. /**
  23500. * The collision of the joint
  23501. */
  23502. collision?: boolean;
  23503. /**
  23504. * Native Oimo/Cannon/Energy data
  23505. */
  23506. nativeParams?: any;
  23507. }
  23508. /**
  23509. * This is a holder class for the physics joint created by the physics plugin
  23510. * It holds a set of functions to control the underlying joint
  23511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23512. */
  23513. export class PhysicsJoint {
  23514. /**
  23515. * The type of the physics joint
  23516. */
  23517. type: number;
  23518. /**
  23519. * The data for the physics joint
  23520. */
  23521. jointData: PhysicsJointData;
  23522. private _physicsJoint;
  23523. protected _physicsPlugin: IPhysicsEnginePlugin;
  23524. /**
  23525. * Initializes the physics joint
  23526. * @param type The type of the physics joint
  23527. * @param jointData The data for the physics joint
  23528. */
  23529. constructor(
  23530. /**
  23531. * The type of the physics joint
  23532. */
  23533. type: number,
  23534. /**
  23535. * The data for the physics joint
  23536. */
  23537. jointData: PhysicsJointData);
  23538. /**
  23539. * Gets the physics joint
  23540. */
  23541. get physicsJoint(): any;
  23542. /**
  23543. * Sets the physics joint
  23544. */
  23545. set physicsJoint(newJoint: any);
  23546. /**
  23547. * Sets the physics plugin
  23548. */
  23549. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23550. /**
  23551. * Execute a function that is physics-plugin specific.
  23552. * @param {Function} func the function that will be executed.
  23553. * It accepts two parameters: the physics world and the physics joint
  23554. */
  23555. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23556. /**
  23557. * Distance-Joint type
  23558. */
  23559. static DistanceJoint: number;
  23560. /**
  23561. * Hinge-Joint type
  23562. */
  23563. static HingeJoint: number;
  23564. /**
  23565. * Ball-and-Socket joint type
  23566. */
  23567. static BallAndSocketJoint: number;
  23568. /**
  23569. * Wheel-Joint type
  23570. */
  23571. static WheelJoint: number;
  23572. /**
  23573. * Slider-Joint type
  23574. */
  23575. static SliderJoint: number;
  23576. /**
  23577. * Prismatic-Joint type
  23578. */
  23579. static PrismaticJoint: number;
  23580. /**
  23581. * Universal-Joint type
  23582. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23583. */
  23584. static UniversalJoint: number;
  23585. /**
  23586. * Hinge-Joint 2 type
  23587. */
  23588. static Hinge2Joint: number;
  23589. /**
  23590. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23591. */
  23592. static PointToPointJoint: number;
  23593. /**
  23594. * Spring-Joint type
  23595. */
  23596. static SpringJoint: number;
  23597. /**
  23598. * Lock-Joint type
  23599. */
  23600. static LockJoint: number;
  23601. }
  23602. /**
  23603. * A class representing a physics distance joint
  23604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23605. */
  23606. export class DistanceJoint extends PhysicsJoint {
  23607. /**
  23608. *
  23609. * @param jointData The data for the Distance-Joint
  23610. */
  23611. constructor(jointData: DistanceJointData);
  23612. /**
  23613. * Update the predefined distance.
  23614. * @param maxDistance The maximum preferred distance
  23615. * @param minDistance The minimum preferred distance
  23616. */
  23617. updateDistance(maxDistance: number, minDistance?: number): void;
  23618. }
  23619. /**
  23620. * Represents a Motor-Enabled Joint
  23621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23622. */
  23623. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23624. /**
  23625. * Initializes the Motor-Enabled Joint
  23626. * @param type The type of the joint
  23627. * @param jointData The physica joint data for the joint
  23628. */
  23629. constructor(type: number, jointData: PhysicsJointData);
  23630. /**
  23631. * Set the motor values.
  23632. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23633. * @param force the force to apply
  23634. * @param maxForce max force for this motor.
  23635. */
  23636. setMotor(force?: number, maxForce?: number): void;
  23637. /**
  23638. * Set the motor's limits.
  23639. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23640. * @param upperLimit The upper limit of the motor
  23641. * @param lowerLimit The lower limit of the motor
  23642. */
  23643. setLimit(upperLimit: number, lowerLimit?: number): void;
  23644. }
  23645. /**
  23646. * This class represents a single physics Hinge-Joint
  23647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23648. */
  23649. export class HingeJoint extends MotorEnabledJoint {
  23650. /**
  23651. * Initializes the Hinge-Joint
  23652. * @param jointData The joint data for the Hinge-Joint
  23653. */
  23654. constructor(jointData: PhysicsJointData);
  23655. /**
  23656. * Set the motor values.
  23657. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23658. * @param {number} force the force to apply
  23659. * @param {number} maxForce max force for this motor.
  23660. */
  23661. setMotor(force?: number, maxForce?: number): void;
  23662. /**
  23663. * Set the motor's limits.
  23664. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23665. * @param upperLimit The upper limit of the motor
  23666. * @param lowerLimit The lower limit of the motor
  23667. */
  23668. setLimit(upperLimit: number, lowerLimit?: number): void;
  23669. }
  23670. /**
  23671. * This class represents a dual hinge physics joint (same as wheel joint)
  23672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23673. */
  23674. export class Hinge2Joint extends MotorEnabledJoint {
  23675. /**
  23676. * Initializes the Hinge2-Joint
  23677. * @param jointData The joint data for the Hinge2-Joint
  23678. */
  23679. constructor(jointData: PhysicsJointData);
  23680. /**
  23681. * Set the motor values.
  23682. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23683. * @param {number} targetSpeed the speed the motor is to reach
  23684. * @param {number} maxForce max force for this motor.
  23685. * @param {motorIndex} the motor's index, 0 or 1.
  23686. */
  23687. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23688. /**
  23689. * Set the motor limits.
  23690. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23691. * @param {number} upperLimit the upper limit
  23692. * @param {number} lowerLimit lower limit
  23693. * @param {motorIndex} the motor's index, 0 or 1.
  23694. */
  23695. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23696. }
  23697. /**
  23698. * Interface for a motor enabled joint
  23699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23700. */
  23701. export interface IMotorEnabledJoint {
  23702. /**
  23703. * Physics joint
  23704. */
  23705. physicsJoint: any;
  23706. /**
  23707. * Sets the motor of the motor-enabled joint
  23708. * @param force The force of the motor
  23709. * @param maxForce The maximum force of the motor
  23710. * @param motorIndex The index of the motor
  23711. */
  23712. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23713. /**
  23714. * Sets the limit of the motor
  23715. * @param upperLimit The upper limit of the motor
  23716. * @param lowerLimit The lower limit of the motor
  23717. * @param motorIndex The index of the motor
  23718. */
  23719. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23720. }
  23721. /**
  23722. * Joint data for a Distance-Joint
  23723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23724. */
  23725. export interface DistanceJointData extends PhysicsJointData {
  23726. /**
  23727. * Max distance the 2 joint objects can be apart
  23728. */
  23729. maxDistance: number;
  23730. }
  23731. /**
  23732. * Joint data from a spring joint
  23733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23734. */
  23735. export interface SpringJointData extends PhysicsJointData {
  23736. /**
  23737. * Length of the spring
  23738. */
  23739. length: number;
  23740. /**
  23741. * Stiffness of the spring
  23742. */
  23743. stiffness: number;
  23744. /**
  23745. * Damping of the spring
  23746. */
  23747. damping: number;
  23748. /** this callback will be called when applying the force to the impostors. */
  23749. forceApplicationCallback: () => void;
  23750. }
  23751. }
  23752. declare module "babylonjs/Physics/physicsRaycastResult" {
  23753. import { Vector3 } from "babylonjs/Maths/math.vector";
  23754. /**
  23755. * Holds the data for the raycast result
  23756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23757. */
  23758. export class PhysicsRaycastResult {
  23759. private _hasHit;
  23760. private _hitDistance;
  23761. private _hitNormalWorld;
  23762. private _hitPointWorld;
  23763. private _rayFromWorld;
  23764. private _rayToWorld;
  23765. /**
  23766. * Gets if there was a hit
  23767. */
  23768. get hasHit(): boolean;
  23769. /**
  23770. * Gets the distance from the hit
  23771. */
  23772. get hitDistance(): number;
  23773. /**
  23774. * Gets the hit normal/direction in the world
  23775. */
  23776. get hitNormalWorld(): Vector3;
  23777. /**
  23778. * Gets the hit point in the world
  23779. */
  23780. get hitPointWorld(): Vector3;
  23781. /**
  23782. * Gets the ray "start point" of the ray in the world
  23783. */
  23784. get rayFromWorld(): Vector3;
  23785. /**
  23786. * Gets the ray "end point" of the ray in the world
  23787. */
  23788. get rayToWorld(): Vector3;
  23789. /**
  23790. * Sets the hit data (normal & point in world space)
  23791. * @param hitNormalWorld defines the normal in world space
  23792. * @param hitPointWorld defines the point in world space
  23793. */
  23794. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23795. /**
  23796. * Sets the distance from the start point to the hit point
  23797. * @param distance
  23798. */
  23799. setHitDistance(distance: number): void;
  23800. /**
  23801. * Calculates the distance manually
  23802. */
  23803. calculateHitDistance(): void;
  23804. /**
  23805. * Resets all the values to default
  23806. * @param from The from point on world space
  23807. * @param to The to point on world space
  23808. */
  23809. reset(from?: Vector3, to?: Vector3): void;
  23810. }
  23811. /**
  23812. * Interface for the size containing width and height
  23813. */
  23814. interface IXYZ {
  23815. /**
  23816. * X
  23817. */
  23818. x: number;
  23819. /**
  23820. * Y
  23821. */
  23822. y: number;
  23823. /**
  23824. * Z
  23825. */
  23826. z: number;
  23827. }
  23828. }
  23829. declare module "babylonjs/Physics/IPhysicsEngine" {
  23830. import { Nullable } from "babylonjs/types";
  23831. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23833. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23834. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23835. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23836. /**
  23837. * Interface used to describe a physics joint
  23838. */
  23839. export interface PhysicsImpostorJoint {
  23840. /** Defines the main impostor to which the joint is linked */
  23841. mainImpostor: PhysicsImpostor;
  23842. /** Defines the impostor that is connected to the main impostor using this joint */
  23843. connectedImpostor: PhysicsImpostor;
  23844. /** Defines the joint itself */
  23845. joint: PhysicsJoint;
  23846. }
  23847. /** @hidden */
  23848. export interface IPhysicsEnginePlugin {
  23849. world: any;
  23850. name: string;
  23851. setGravity(gravity: Vector3): void;
  23852. setTimeStep(timeStep: number): void;
  23853. getTimeStep(): number;
  23854. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23855. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23856. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23857. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23858. removePhysicsBody(impostor: PhysicsImpostor): void;
  23859. generateJoint(joint: PhysicsImpostorJoint): void;
  23860. removeJoint(joint: PhysicsImpostorJoint): void;
  23861. isSupported(): boolean;
  23862. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23863. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23864. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23865. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23866. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23867. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23868. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23869. getBodyMass(impostor: PhysicsImpostor): number;
  23870. getBodyFriction(impostor: PhysicsImpostor): number;
  23871. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23872. getBodyRestitution(impostor: PhysicsImpostor): number;
  23873. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23874. getBodyPressure?(impostor: PhysicsImpostor): number;
  23875. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23876. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23877. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23878. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23879. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23880. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23881. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23882. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23883. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23884. sleepBody(impostor: PhysicsImpostor): void;
  23885. wakeUpBody(impostor: PhysicsImpostor): void;
  23886. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23887. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23888. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23889. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23890. getRadius(impostor: PhysicsImpostor): number;
  23891. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23892. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23893. dispose(): void;
  23894. }
  23895. /**
  23896. * Interface used to define a physics engine
  23897. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23898. */
  23899. export interface IPhysicsEngine {
  23900. /**
  23901. * Gets the gravity vector used by the simulation
  23902. */
  23903. gravity: Vector3;
  23904. /**
  23905. * Sets the gravity vector used by the simulation
  23906. * @param gravity defines the gravity vector to use
  23907. */
  23908. setGravity(gravity: Vector3): void;
  23909. /**
  23910. * Set the time step of the physics engine.
  23911. * Default is 1/60.
  23912. * To slow it down, enter 1/600 for example.
  23913. * To speed it up, 1/30
  23914. * @param newTimeStep the new timestep to apply to this world.
  23915. */
  23916. setTimeStep(newTimeStep: number): void;
  23917. /**
  23918. * Get the time step of the physics engine.
  23919. * @returns the current time step
  23920. */
  23921. getTimeStep(): number;
  23922. /**
  23923. * Set the sub time step of the physics engine.
  23924. * Default is 0 meaning there is no sub steps
  23925. * To increase physics resolution precision, set a small value (like 1 ms)
  23926. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23927. */
  23928. setSubTimeStep(subTimeStep: number): void;
  23929. /**
  23930. * Get the sub time step of the physics engine.
  23931. * @returns the current sub time step
  23932. */
  23933. getSubTimeStep(): number;
  23934. /**
  23935. * Release all resources
  23936. */
  23937. dispose(): void;
  23938. /**
  23939. * Gets the name of the current physics plugin
  23940. * @returns the name of the plugin
  23941. */
  23942. getPhysicsPluginName(): string;
  23943. /**
  23944. * Adding a new impostor for the impostor tracking.
  23945. * This will be done by the impostor itself.
  23946. * @param impostor the impostor to add
  23947. */
  23948. addImpostor(impostor: PhysicsImpostor): void;
  23949. /**
  23950. * Remove an impostor from the engine.
  23951. * This impostor and its mesh will not longer be updated by the physics engine.
  23952. * @param impostor the impostor to remove
  23953. */
  23954. removeImpostor(impostor: PhysicsImpostor): void;
  23955. /**
  23956. * Add a joint to the physics engine
  23957. * @param mainImpostor defines the main impostor to which the joint is added.
  23958. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23959. * @param joint defines the joint that will connect both impostors.
  23960. */
  23961. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23962. /**
  23963. * Removes a joint from the simulation
  23964. * @param mainImpostor defines the impostor used with the joint
  23965. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23966. * @param joint defines the joint to remove
  23967. */
  23968. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23969. /**
  23970. * Gets the current plugin used to run the simulation
  23971. * @returns current plugin
  23972. */
  23973. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23974. /**
  23975. * Gets the list of physic impostors
  23976. * @returns an array of PhysicsImpostor
  23977. */
  23978. getImpostors(): Array<PhysicsImpostor>;
  23979. /**
  23980. * Gets the impostor for a physics enabled object
  23981. * @param object defines the object impersonated by the impostor
  23982. * @returns the PhysicsImpostor or null if not found
  23983. */
  23984. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23985. /**
  23986. * Gets the impostor for a physics body object
  23987. * @param body defines physics body used by the impostor
  23988. * @returns the PhysicsImpostor or null if not found
  23989. */
  23990. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23991. /**
  23992. * Does a raycast in the physics world
  23993. * @param from when should the ray start?
  23994. * @param to when should the ray end?
  23995. * @returns PhysicsRaycastResult
  23996. */
  23997. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23998. /**
  23999. * Called by the scene. No need to call it.
  24000. * @param delta defines the timespam between frames
  24001. */
  24002. _step(delta: number): void;
  24003. }
  24004. }
  24005. declare module "babylonjs/Physics/physicsImpostor" {
  24006. import { Nullable, IndicesArray } from "babylonjs/types";
  24007. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24008. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24010. import { Scene } from "babylonjs/scene";
  24011. import { Bone } from "babylonjs/Bones/bone";
  24012. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24013. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24014. import { Space } from "babylonjs/Maths/math.axis";
  24015. /**
  24016. * The interface for the physics imposter parameters
  24017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24018. */
  24019. export interface PhysicsImpostorParameters {
  24020. /**
  24021. * The mass of the physics imposter
  24022. */
  24023. mass: number;
  24024. /**
  24025. * The friction of the physics imposter
  24026. */
  24027. friction?: number;
  24028. /**
  24029. * The coefficient of restitution of the physics imposter
  24030. */
  24031. restitution?: number;
  24032. /**
  24033. * The native options of the physics imposter
  24034. */
  24035. nativeOptions?: any;
  24036. /**
  24037. * Specifies if the parent should be ignored
  24038. */
  24039. ignoreParent?: boolean;
  24040. /**
  24041. * Specifies if bi-directional transformations should be disabled
  24042. */
  24043. disableBidirectionalTransformation?: boolean;
  24044. /**
  24045. * The pressure inside the physics imposter, soft object only
  24046. */
  24047. pressure?: number;
  24048. /**
  24049. * The stiffness the physics imposter, soft object only
  24050. */
  24051. stiffness?: number;
  24052. /**
  24053. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24054. */
  24055. velocityIterations?: number;
  24056. /**
  24057. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24058. */
  24059. positionIterations?: number;
  24060. /**
  24061. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24062. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24063. * Add to fix multiple points
  24064. */
  24065. fixedPoints?: number;
  24066. /**
  24067. * The collision margin around a soft object
  24068. */
  24069. margin?: number;
  24070. /**
  24071. * The collision margin around a soft object
  24072. */
  24073. damping?: number;
  24074. /**
  24075. * The path for a rope based on an extrusion
  24076. */
  24077. path?: any;
  24078. /**
  24079. * The shape of an extrusion used for a rope based on an extrusion
  24080. */
  24081. shape?: any;
  24082. }
  24083. /**
  24084. * Interface for a physics-enabled object
  24085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24086. */
  24087. export interface IPhysicsEnabledObject {
  24088. /**
  24089. * The position of the physics-enabled object
  24090. */
  24091. position: Vector3;
  24092. /**
  24093. * The rotation of the physics-enabled object
  24094. */
  24095. rotationQuaternion: Nullable<Quaternion>;
  24096. /**
  24097. * The scale of the physics-enabled object
  24098. */
  24099. scaling: Vector3;
  24100. /**
  24101. * The rotation of the physics-enabled object
  24102. */
  24103. rotation?: Vector3;
  24104. /**
  24105. * The parent of the physics-enabled object
  24106. */
  24107. parent?: any;
  24108. /**
  24109. * The bounding info of the physics-enabled object
  24110. * @returns The bounding info of the physics-enabled object
  24111. */
  24112. getBoundingInfo(): BoundingInfo;
  24113. /**
  24114. * Computes the world matrix
  24115. * @param force Specifies if the world matrix should be computed by force
  24116. * @returns A world matrix
  24117. */
  24118. computeWorldMatrix(force: boolean): Matrix;
  24119. /**
  24120. * Gets the world matrix
  24121. * @returns A world matrix
  24122. */
  24123. getWorldMatrix?(): Matrix;
  24124. /**
  24125. * Gets the child meshes
  24126. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24127. * @returns An array of abstract meshes
  24128. */
  24129. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24130. /**
  24131. * Gets the vertex data
  24132. * @param kind The type of vertex data
  24133. * @returns A nullable array of numbers, or a float32 array
  24134. */
  24135. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24136. /**
  24137. * Gets the indices from the mesh
  24138. * @returns A nullable array of index arrays
  24139. */
  24140. getIndices?(): Nullable<IndicesArray>;
  24141. /**
  24142. * Gets the scene from the mesh
  24143. * @returns the indices array or null
  24144. */
  24145. getScene?(): Scene;
  24146. /**
  24147. * Gets the absolute position from the mesh
  24148. * @returns the absolute position
  24149. */
  24150. getAbsolutePosition(): Vector3;
  24151. /**
  24152. * Gets the absolute pivot point from the mesh
  24153. * @returns the absolute pivot point
  24154. */
  24155. getAbsolutePivotPoint(): Vector3;
  24156. /**
  24157. * Rotates the mesh
  24158. * @param axis The axis of rotation
  24159. * @param amount The amount of rotation
  24160. * @param space The space of the rotation
  24161. * @returns The rotation transform node
  24162. */
  24163. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24164. /**
  24165. * Translates the mesh
  24166. * @param axis The axis of translation
  24167. * @param distance The distance of translation
  24168. * @param space The space of the translation
  24169. * @returns The transform node
  24170. */
  24171. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24172. /**
  24173. * Sets the absolute position of the mesh
  24174. * @param absolutePosition The absolute position of the mesh
  24175. * @returns The transform node
  24176. */
  24177. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24178. /**
  24179. * Gets the class name of the mesh
  24180. * @returns The class name
  24181. */
  24182. getClassName(): string;
  24183. }
  24184. /**
  24185. * Represents a physics imposter
  24186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24187. */
  24188. export class PhysicsImpostor {
  24189. /**
  24190. * The physics-enabled object used as the physics imposter
  24191. */
  24192. object: IPhysicsEnabledObject;
  24193. /**
  24194. * The type of the physics imposter
  24195. */
  24196. type: number;
  24197. private _options;
  24198. private _scene?;
  24199. /**
  24200. * The default object size of the imposter
  24201. */
  24202. static DEFAULT_OBJECT_SIZE: Vector3;
  24203. /**
  24204. * The identity quaternion of the imposter
  24205. */
  24206. static IDENTITY_QUATERNION: Quaternion;
  24207. /** @hidden */
  24208. _pluginData: any;
  24209. private _physicsEngine;
  24210. private _physicsBody;
  24211. private _bodyUpdateRequired;
  24212. private _onBeforePhysicsStepCallbacks;
  24213. private _onAfterPhysicsStepCallbacks;
  24214. /** @hidden */
  24215. _onPhysicsCollideCallbacks: Array<{
  24216. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24217. otherImpostors: Array<PhysicsImpostor>;
  24218. }>;
  24219. private _deltaPosition;
  24220. private _deltaRotation;
  24221. private _deltaRotationConjugated;
  24222. /** @hidden */
  24223. _isFromLine: boolean;
  24224. private _parent;
  24225. private _isDisposed;
  24226. private static _tmpVecs;
  24227. private static _tmpQuat;
  24228. /**
  24229. * Specifies if the physics imposter is disposed
  24230. */
  24231. get isDisposed(): boolean;
  24232. /**
  24233. * Gets the mass of the physics imposter
  24234. */
  24235. get mass(): number;
  24236. set mass(value: number);
  24237. /**
  24238. * Gets the coefficient of friction
  24239. */
  24240. get friction(): number;
  24241. /**
  24242. * Sets the coefficient of friction
  24243. */
  24244. set friction(value: number);
  24245. /**
  24246. * Gets the coefficient of restitution
  24247. */
  24248. get restitution(): number;
  24249. /**
  24250. * Sets the coefficient of restitution
  24251. */
  24252. set restitution(value: number);
  24253. /**
  24254. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24255. */
  24256. get pressure(): number;
  24257. /**
  24258. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24259. */
  24260. set pressure(value: number);
  24261. /**
  24262. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24263. */
  24264. get stiffness(): number;
  24265. /**
  24266. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24267. */
  24268. set stiffness(value: number);
  24269. /**
  24270. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24271. */
  24272. get velocityIterations(): number;
  24273. /**
  24274. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24275. */
  24276. set velocityIterations(value: number);
  24277. /**
  24278. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24279. */
  24280. get positionIterations(): number;
  24281. /**
  24282. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24283. */
  24284. set positionIterations(value: number);
  24285. /**
  24286. * The unique id of the physics imposter
  24287. * set by the physics engine when adding this impostor to the array
  24288. */
  24289. uniqueId: number;
  24290. /**
  24291. * @hidden
  24292. */
  24293. soft: boolean;
  24294. /**
  24295. * @hidden
  24296. */
  24297. segments: number;
  24298. private _joints;
  24299. /**
  24300. * Initializes the physics imposter
  24301. * @param object The physics-enabled object used as the physics imposter
  24302. * @param type The type of the physics imposter
  24303. * @param _options The options for the physics imposter
  24304. * @param _scene The Babylon scene
  24305. */
  24306. constructor(
  24307. /**
  24308. * The physics-enabled object used as the physics imposter
  24309. */
  24310. object: IPhysicsEnabledObject,
  24311. /**
  24312. * The type of the physics imposter
  24313. */
  24314. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24315. /**
  24316. * This function will completly initialize this impostor.
  24317. * It will create a new body - but only if this mesh has no parent.
  24318. * If it has, this impostor will not be used other than to define the impostor
  24319. * of the child mesh.
  24320. * @hidden
  24321. */
  24322. _init(): void;
  24323. private _getPhysicsParent;
  24324. /**
  24325. * Should a new body be generated.
  24326. * @returns boolean specifying if body initialization is required
  24327. */
  24328. isBodyInitRequired(): boolean;
  24329. /**
  24330. * Sets the updated scaling
  24331. * @param updated Specifies if the scaling is updated
  24332. */
  24333. setScalingUpdated(): void;
  24334. /**
  24335. * Force a regeneration of this or the parent's impostor's body.
  24336. * Use under cautious - This will remove all joints already implemented.
  24337. */
  24338. forceUpdate(): void;
  24339. /**
  24340. * Gets the body that holds this impostor. Either its own, or its parent.
  24341. */
  24342. get physicsBody(): any;
  24343. /**
  24344. * Get the parent of the physics imposter
  24345. * @returns Physics imposter or null
  24346. */
  24347. get parent(): Nullable<PhysicsImpostor>;
  24348. /**
  24349. * Sets the parent of the physics imposter
  24350. */
  24351. set parent(value: Nullable<PhysicsImpostor>);
  24352. /**
  24353. * Set the physics body. Used mainly by the physics engine/plugin
  24354. */
  24355. set physicsBody(physicsBody: any);
  24356. /**
  24357. * Resets the update flags
  24358. */
  24359. resetUpdateFlags(): void;
  24360. /**
  24361. * Gets the object extend size
  24362. * @returns the object extend size
  24363. */
  24364. getObjectExtendSize(): Vector3;
  24365. /**
  24366. * Gets the object center
  24367. * @returns The object center
  24368. */
  24369. getObjectCenter(): Vector3;
  24370. /**
  24371. * Get a specific parametes from the options parameter
  24372. * @param paramName The object parameter name
  24373. * @returns The object parameter
  24374. */
  24375. getParam(paramName: string): any;
  24376. /**
  24377. * Sets a specific parameter in the options given to the physics plugin
  24378. * @param paramName The parameter name
  24379. * @param value The value of the parameter
  24380. */
  24381. setParam(paramName: string, value: number): void;
  24382. /**
  24383. * Specifically change the body's mass option. Won't recreate the physics body object
  24384. * @param mass The mass of the physics imposter
  24385. */
  24386. setMass(mass: number): void;
  24387. /**
  24388. * Gets the linear velocity
  24389. * @returns linear velocity or null
  24390. */
  24391. getLinearVelocity(): Nullable<Vector3>;
  24392. /**
  24393. * Sets the linear velocity
  24394. * @param velocity linear velocity or null
  24395. */
  24396. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24397. /**
  24398. * Gets the angular velocity
  24399. * @returns angular velocity or null
  24400. */
  24401. getAngularVelocity(): Nullable<Vector3>;
  24402. /**
  24403. * Sets the angular velocity
  24404. * @param velocity The velocity or null
  24405. */
  24406. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24407. /**
  24408. * Execute a function with the physics plugin native code
  24409. * Provide a function the will have two variables - the world object and the physics body object
  24410. * @param func The function to execute with the physics plugin native code
  24411. */
  24412. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24413. /**
  24414. * Register a function that will be executed before the physics world is stepping forward
  24415. * @param func The function to execute before the physics world is stepped forward
  24416. */
  24417. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24418. /**
  24419. * Unregister a function that will be executed before the physics world is stepping forward
  24420. * @param func The function to execute before the physics world is stepped forward
  24421. */
  24422. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24423. /**
  24424. * Register a function that will be executed after the physics step
  24425. * @param func The function to execute after physics step
  24426. */
  24427. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24428. /**
  24429. * Unregisters a function that will be executed after the physics step
  24430. * @param func The function to execute after physics step
  24431. */
  24432. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24433. /**
  24434. * register a function that will be executed when this impostor collides against a different body
  24435. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24436. * @param func Callback that is executed on collision
  24437. */
  24438. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24439. /**
  24440. * Unregisters the physics imposter on contact
  24441. * @param collideAgainst The physics object to collide against
  24442. * @param func Callback to execute on collision
  24443. */
  24444. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24445. private _tmpQuat;
  24446. private _tmpQuat2;
  24447. /**
  24448. * Get the parent rotation
  24449. * @returns The parent rotation
  24450. */
  24451. getParentsRotation(): Quaternion;
  24452. /**
  24453. * this function is executed by the physics engine.
  24454. */
  24455. beforeStep: () => void;
  24456. /**
  24457. * this function is executed by the physics engine
  24458. */
  24459. afterStep: () => void;
  24460. /**
  24461. * Legacy collision detection event support
  24462. */
  24463. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24464. /**
  24465. * event and body object due to cannon's event-based architecture.
  24466. */
  24467. onCollide: (e: {
  24468. body: any;
  24469. }) => void;
  24470. /**
  24471. * Apply a force
  24472. * @param force The force to apply
  24473. * @param contactPoint The contact point for the force
  24474. * @returns The physics imposter
  24475. */
  24476. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24477. /**
  24478. * Apply an impulse
  24479. * @param force The impulse force
  24480. * @param contactPoint The contact point for the impulse force
  24481. * @returns The physics imposter
  24482. */
  24483. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24484. /**
  24485. * A help function to create a joint
  24486. * @param otherImpostor A physics imposter used to create a joint
  24487. * @param jointType The type of joint
  24488. * @param jointData The data for the joint
  24489. * @returns The physics imposter
  24490. */
  24491. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24492. /**
  24493. * Add a joint to this impostor with a different impostor
  24494. * @param otherImpostor A physics imposter used to add a joint
  24495. * @param joint The joint to add
  24496. * @returns The physics imposter
  24497. */
  24498. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24499. /**
  24500. * Add an anchor to a cloth impostor
  24501. * @param otherImpostor rigid impostor to anchor to
  24502. * @param width ratio across width from 0 to 1
  24503. * @param height ratio up height from 0 to 1
  24504. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24505. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24506. * @returns impostor the soft imposter
  24507. */
  24508. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24509. /**
  24510. * Add a hook to a rope impostor
  24511. * @param otherImpostor rigid impostor to anchor to
  24512. * @param length ratio across rope from 0 to 1
  24513. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24514. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24515. * @returns impostor the rope imposter
  24516. */
  24517. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24518. /**
  24519. * Will keep this body still, in a sleep mode.
  24520. * @returns the physics imposter
  24521. */
  24522. sleep(): PhysicsImpostor;
  24523. /**
  24524. * Wake the body up.
  24525. * @returns The physics imposter
  24526. */
  24527. wakeUp(): PhysicsImpostor;
  24528. /**
  24529. * Clones the physics imposter
  24530. * @param newObject The physics imposter clones to this physics-enabled object
  24531. * @returns A nullable physics imposter
  24532. */
  24533. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24534. /**
  24535. * Disposes the physics imposter
  24536. */
  24537. dispose(): void;
  24538. /**
  24539. * Sets the delta position
  24540. * @param position The delta position amount
  24541. */
  24542. setDeltaPosition(position: Vector3): void;
  24543. /**
  24544. * Sets the delta rotation
  24545. * @param rotation The delta rotation amount
  24546. */
  24547. setDeltaRotation(rotation: Quaternion): void;
  24548. /**
  24549. * Gets the box size of the physics imposter and stores the result in the input parameter
  24550. * @param result Stores the box size
  24551. * @returns The physics imposter
  24552. */
  24553. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24554. /**
  24555. * Gets the radius of the physics imposter
  24556. * @returns Radius of the physics imposter
  24557. */
  24558. getRadius(): number;
  24559. /**
  24560. * Sync a bone with this impostor
  24561. * @param bone The bone to sync to the impostor.
  24562. * @param boneMesh The mesh that the bone is influencing.
  24563. * @param jointPivot The pivot of the joint / bone in local space.
  24564. * @param distToJoint Optional distance from the impostor to the joint.
  24565. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24566. */
  24567. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24568. /**
  24569. * Sync impostor to a bone
  24570. * @param bone The bone that the impostor will be synced to.
  24571. * @param boneMesh The mesh that the bone is influencing.
  24572. * @param jointPivot The pivot of the joint / bone in local space.
  24573. * @param distToJoint Optional distance from the impostor to the joint.
  24574. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24575. * @param boneAxis Optional vector3 axis the bone is aligned with
  24576. */
  24577. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24578. /**
  24579. * No-Imposter type
  24580. */
  24581. static NoImpostor: number;
  24582. /**
  24583. * Sphere-Imposter type
  24584. */
  24585. static SphereImpostor: number;
  24586. /**
  24587. * Box-Imposter type
  24588. */
  24589. static BoxImpostor: number;
  24590. /**
  24591. * Plane-Imposter type
  24592. */
  24593. static PlaneImpostor: number;
  24594. /**
  24595. * Mesh-imposter type
  24596. */
  24597. static MeshImpostor: number;
  24598. /**
  24599. * Capsule-Impostor type (Ammo.js plugin only)
  24600. */
  24601. static CapsuleImpostor: number;
  24602. /**
  24603. * Cylinder-Imposter type
  24604. */
  24605. static CylinderImpostor: number;
  24606. /**
  24607. * Particle-Imposter type
  24608. */
  24609. static ParticleImpostor: number;
  24610. /**
  24611. * Heightmap-Imposter type
  24612. */
  24613. static HeightmapImpostor: number;
  24614. /**
  24615. * ConvexHull-Impostor type (Ammo.js plugin only)
  24616. */
  24617. static ConvexHullImpostor: number;
  24618. /**
  24619. * Custom-Imposter type (Ammo.js plugin only)
  24620. */
  24621. static CustomImpostor: number;
  24622. /**
  24623. * Rope-Imposter type
  24624. */
  24625. static RopeImpostor: number;
  24626. /**
  24627. * Cloth-Imposter type
  24628. */
  24629. static ClothImpostor: number;
  24630. /**
  24631. * Softbody-Imposter type
  24632. */
  24633. static SoftbodyImpostor: number;
  24634. }
  24635. }
  24636. declare module "babylonjs/Meshes/mesh" {
  24637. import { Observable } from "babylonjs/Misc/observable";
  24638. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24639. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24640. import { Camera } from "babylonjs/Cameras/camera";
  24641. import { Scene } from "babylonjs/scene";
  24642. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24643. import { Color4 } from "babylonjs/Maths/math.color";
  24644. import { Engine } from "babylonjs/Engines/engine";
  24645. import { Node } from "babylonjs/node";
  24646. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24647. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24648. import { Buffer } from "babylonjs/Meshes/buffer";
  24649. import { Geometry } from "babylonjs/Meshes/geometry";
  24650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24651. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24652. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24653. import { Effect } from "babylonjs/Materials/effect";
  24654. import { Material } from "babylonjs/Materials/material";
  24655. import { Skeleton } from "babylonjs/Bones/skeleton";
  24656. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24657. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24658. import { Path3D } from "babylonjs/Maths/math.path";
  24659. import { Plane } from "babylonjs/Maths/math.plane";
  24660. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24661. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24662. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24663. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24664. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24665. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24666. /**
  24667. * @hidden
  24668. **/
  24669. export class _CreationDataStorage {
  24670. closePath?: boolean;
  24671. closeArray?: boolean;
  24672. idx: number[];
  24673. dashSize: number;
  24674. gapSize: number;
  24675. path3D: Path3D;
  24676. pathArray: Vector3[][];
  24677. arc: number;
  24678. radius: number;
  24679. cap: number;
  24680. tessellation: number;
  24681. }
  24682. /**
  24683. * @hidden
  24684. **/
  24685. class _InstanceDataStorage {
  24686. visibleInstances: any;
  24687. batchCache: _InstancesBatch;
  24688. instancesBufferSize: number;
  24689. instancesBuffer: Nullable<Buffer>;
  24690. instancesData: Float32Array;
  24691. overridenInstanceCount: number;
  24692. isFrozen: boolean;
  24693. previousBatch: Nullable<_InstancesBatch>;
  24694. hardwareInstancedRendering: boolean;
  24695. sideOrientation: number;
  24696. manualUpdate: boolean;
  24697. }
  24698. /**
  24699. * @hidden
  24700. **/
  24701. export class _InstancesBatch {
  24702. mustReturn: boolean;
  24703. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24704. renderSelf: boolean[];
  24705. hardwareInstancedRendering: boolean[];
  24706. }
  24707. /**
  24708. * Class used to represent renderable models
  24709. */
  24710. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24711. /**
  24712. * Mesh side orientation : usually the external or front surface
  24713. */
  24714. static readonly FRONTSIDE: number;
  24715. /**
  24716. * Mesh side orientation : usually the internal or back surface
  24717. */
  24718. static readonly BACKSIDE: number;
  24719. /**
  24720. * Mesh side orientation : both internal and external or front and back surfaces
  24721. */
  24722. static readonly DOUBLESIDE: number;
  24723. /**
  24724. * Mesh side orientation : by default, `FRONTSIDE`
  24725. */
  24726. static readonly DEFAULTSIDE: number;
  24727. /**
  24728. * Mesh cap setting : no cap
  24729. */
  24730. static readonly NO_CAP: number;
  24731. /**
  24732. * Mesh cap setting : one cap at the beginning of the mesh
  24733. */
  24734. static readonly CAP_START: number;
  24735. /**
  24736. * Mesh cap setting : one cap at the end of the mesh
  24737. */
  24738. static readonly CAP_END: number;
  24739. /**
  24740. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24741. */
  24742. static readonly CAP_ALL: number;
  24743. /**
  24744. * Mesh pattern setting : no flip or rotate
  24745. */
  24746. static readonly NO_FLIP: number;
  24747. /**
  24748. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24749. */
  24750. static readonly FLIP_TILE: number;
  24751. /**
  24752. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24753. */
  24754. static readonly ROTATE_TILE: number;
  24755. /**
  24756. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24757. */
  24758. static readonly FLIP_ROW: number;
  24759. /**
  24760. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24761. */
  24762. static readonly ROTATE_ROW: number;
  24763. /**
  24764. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24765. */
  24766. static readonly FLIP_N_ROTATE_TILE: number;
  24767. /**
  24768. * Mesh pattern setting : rotate pattern and rotate
  24769. */
  24770. static readonly FLIP_N_ROTATE_ROW: number;
  24771. /**
  24772. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24773. */
  24774. static readonly CENTER: number;
  24775. /**
  24776. * Mesh tile positioning : part tiles on left
  24777. */
  24778. static readonly LEFT: number;
  24779. /**
  24780. * Mesh tile positioning : part tiles on right
  24781. */
  24782. static readonly RIGHT: number;
  24783. /**
  24784. * Mesh tile positioning : part tiles on top
  24785. */
  24786. static readonly TOP: number;
  24787. /**
  24788. * Mesh tile positioning : part tiles on bottom
  24789. */
  24790. static readonly BOTTOM: number;
  24791. /**
  24792. * Gets the default side orientation.
  24793. * @param orientation the orientation to value to attempt to get
  24794. * @returns the default orientation
  24795. * @hidden
  24796. */
  24797. static _GetDefaultSideOrientation(orientation?: number): number;
  24798. private _internalMeshDataInfo;
  24799. /**
  24800. * An event triggered before rendering the mesh
  24801. */
  24802. get onBeforeRenderObservable(): Observable<Mesh>;
  24803. /**
  24804. * An event triggered before binding the mesh
  24805. */
  24806. get onBeforeBindObservable(): Observable<Mesh>;
  24807. /**
  24808. * An event triggered after rendering the mesh
  24809. */
  24810. get onAfterRenderObservable(): Observable<Mesh>;
  24811. /**
  24812. * An event triggered before drawing the mesh
  24813. */
  24814. get onBeforeDrawObservable(): Observable<Mesh>;
  24815. private _onBeforeDrawObserver;
  24816. /**
  24817. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24818. */
  24819. set onBeforeDraw(callback: () => void);
  24820. get hasInstances(): boolean;
  24821. /**
  24822. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24823. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24824. */
  24825. delayLoadState: number;
  24826. /**
  24827. * Gets the list of instances created from this mesh
  24828. * it is not supposed to be modified manually.
  24829. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24830. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24831. */
  24832. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24833. /**
  24834. * Gets the file containing delay loading data for this mesh
  24835. */
  24836. delayLoadingFile: string;
  24837. /** @hidden */
  24838. _binaryInfo: any;
  24839. /**
  24840. * User defined function used to change how LOD level selection is done
  24841. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24842. */
  24843. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24844. /**
  24845. * Gets or sets the morph target manager
  24846. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24847. */
  24848. get morphTargetManager(): Nullable<MorphTargetManager>;
  24849. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24850. /** @hidden */
  24851. _creationDataStorage: Nullable<_CreationDataStorage>;
  24852. /** @hidden */
  24853. _geometry: Nullable<Geometry>;
  24854. /** @hidden */
  24855. _delayInfo: Array<string>;
  24856. /** @hidden */
  24857. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24858. /** @hidden */
  24859. _instanceDataStorage: _InstanceDataStorage;
  24860. private _effectiveMaterial;
  24861. /** @hidden */
  24862. _shouldGenerateFlatShading: boolean;
  24863. /** @hidden */
  24864. _originalBuilderSideOrientation: number;
  24865. /**
  24866. * Use this property to change the original side orientation defined at construction time
  24867. */
  24868. overrideMaterialSideOrientation: Nullable<number>;
  24869. /**
  24870. * Gets the source mesh (the one used to clone this one from)
  24871. */
  24872. get source(): Nullable<Mesh>;
  24873. /**
  24874. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24875. */
  24876. get isUnIndexed(): boolean;
  24877. set isUnIndexed(value: boolean);
  24878. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24879. get worldMatrixInstancedBuffer(): Float32Array;
  24880. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24881. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24882. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24883. /**
  24884. * @constructor
  24885. * @param name The value used by scene.getMeshByName() to do a lookup.
  24886. * @param scene The scene to add this mesh to.
  24887. * @param parent The parent of this mesh, if it has one
  24888. * @param source An optional Mesh from which geometry is shared, cloned.
  24889. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24890. * When false, achieved by calling a clone(), also passing False.
  24891. * This will make creation of children, recursive.
  24892. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24893. */
  24894. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24895. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24896. doNotInstantiate: boolean;
  24897. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24898. /**
  24899. * Gets the class name
  24900. * @returns the string "Mesh".
  24901. */
  24902. getClassName(): string;
  24903. /** @hidden */
  24904. get _isMesh(): boolean;
  24905. /**
  24906. * Returns a description of this mesh
  24907. * @param fullDetails define if full details about this mesh must be used
  24908. * @returns a descriptive string representing this mesh
  24909. */
  24910. toString(fullDetails?: boolean): string;
  24911. /** @hidden */
  24912. _unBindEffect(): void;
  24913. /**
  24914. * Gets a boolean indicating if this mesh has LOD
  24915. */
  24916. get hasLODLevels(): boolean;
  24917. /**
  24918. * Gets the list of MeshLODLevel associated with the current mesh
  24919. * @returns an array of MeshLODLevel
  24920. */
  24921. getLODLevels(): MeshLODLevel[];
  24922. private _sortLODLevels;
  24923. /**
  24924. * Add a mesh as LOD level triggered at the given distance.
  24925. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24926. * @param distance The distance from the center of the object to show this level
  24927. * @param mesh The mesh to be added as LOD level (can be null)
  24928. * @return This mesh (for chaining)
  24929. */
  24930. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24931. /**
  24932. * Returns the LOD level mesh at the passed distance or null if not found.
  24933. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24934. * @param distance The distance from the center of the object to show this level
  24935. * @returns a Mesh or `null`
  24936. */
  24937. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24938. /**
  24939. * Remove a mesh from the LOD array
  24940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24941. * @param mesh defines the mesh to be removed
  24942. * @return This mesh (for chaining)
  24943. */
  24944. removeLODLevel(mesh: Mesh): Mesh;
  24945. /**
  24946. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24948. * @param camera defines the camera to use to compute distance
  24949. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24950. * @return This mesh (for chaining)
  24951. */
  24952. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24953. /**
  24954. * Gets the mesh internal Geometry object
  24955. */
  24956. get geometry(): Nullable<Geometry>;
  24957. /**
  24958. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24959. * @returns the total number of vertices
  24960. */
  24961. getTotalVertices(): number;
  24962. /**
  24963. * Returns the content of an associated vertex buffer
  24964. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24965. * - VertexBuffer.PositionKind
  24966. * - VertexBuffer.UVKind
  24967. * - VertexBuffer.UV2Kind
  24968. * - VertexBuffer.UV3Kind
  24969. * - VertexBuffer.UV4Kind
  24970. * - VertexBuffer.UV5Kind
  24971. * - VertexBuffer.UV6Kind
  24972. * - VertexBuffer.ColorKind
  24973. * - VertexBuffer.MatricesIndicesKind
  24974. * - VertexBuffer.MatricesIndicesExtraKind
  24975. * - VertexBuffer.MatricesWeightsKind
  24976. * - VertexBuffer.MatricesWeightsExtraKind
  24977. * @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
  24978. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24979. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24980. */
  24981. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24982. /**
  24983. * Returns the mesh VertexBuffer object from the requested `kind`
  24984. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24985. * - VertexBuffer.PositionKind
  24986. * - VertexBuffer.NormalKind
  24987. * - VertexBuffer.UVKind
  24988. * - VertexBuffer.UV2Kind
  24989. * - VertexBuffer.UV3Kind
  24990. * - VertexBuffer.UV4Kind
  24991. * - VertexBuffer.UV5Kind
  24992. * - VertexBuffer.UV6Kind
  24993. * - VertexBuffer.ColorKind
  24994. * - VertexBuffer.MatricesIndicesKind
  24995. * - VertexBuffer.MatricesIndicesExtraKind
  24996. * - VertexBuffer.MatricesWeightsKind
  24997. * - VertexBuffer.MatricesWeightsExtraKind
  24998. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24999. */
  25000. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25001. /**
  25002. * Tests if a specific vertex buffer is associated with this mesh
  25003. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25004. * - VertexBuffer.PositionKind
  25005. * - VertexBuffer.NormalKind
  25006. * - VertexBuffer.UVKind
  25007. * - VertexBuffer.UV2Kind
  25008. * - VertexBuffer.UV3Kind
  25009. * - VertexBuffer.UV4Kind
  25010. * - VertexBuffer.UV5Kind
  25011. * - VertexBuffer.UV6Kind
  25012. * - VertexBuffer.ColorKind
  25013. * - VertexBuffer.MatricesIndicesKind
  25014. * - VertexBuffer.MatricesIndicesExtraKind
  25015. * - VertexBuffer.MatricesWeightsKind
  25016. * - VertexBuffer.MatricesWeightsExtraKind
  25017. * @returns a boolean
  25018. */
  25019. isVerticesDataPresent(kind: string): boolean;
  25020. /**
  25021. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25022. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25023. * - VertexBuffer.PositionKind
  25024. * - VertexBuffer.UVKind
  25025. * - VertexBuffer.UV2Kind
  25026. * - VertexBuffer.UV3Kind
  25027. * - VertexBuffer.UV4Kind
  25028. * - VertexBuffer.UV5Kind
  25029. * - VertexBuffer.UV6Kind
  25030. * - VertexBuffer.ColorKind
  25031. * - VertexBuffer.MatricesIndicesKind
  25032. * - VertexBuffer.MatricesIndicesExtraKind
  25033. * - VertexBuffer.MatricesWeightsKind
  25034. * - VertexBuffer.MatricesWeightsExtraKind
  25035. * @returns a boolean
  25036. */
  25037. isVertexBufferUpdatable(kind: string): boolean;
  25038. /**
  25039. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25040. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25041. * - VertexBuffer.PositionKind
  25042. * - VertexBuffer.NormalKind
  25043. * - VertexBuffer.UVKind
  25044. * - VertexBuffer.UV2Kind
  25045. * - VertexBuffer.UV3Kind
  25046. * - VertexBuffer.UV4Kind
  25047. * - VertexBuffer.UV5Kind
  25048. * - VertexBuffer.UV6Kind
  25049. * - VertexBuffer.ColorKind
  25050. * - VertexBuffer.MatricesIndicesKind
  25051. * - VertexBuffer.MatricesIndicesExtraKind
  25052. * - VertexBuffer.MatricesWeightsKind
  25053. * - VertexBuffer.MatricesWeightsExtraKind
  25054. * @returns an array of strings
  25055. */
  25056. getVerticesDataKinds(): string[];
  25057. /**
  25058. * Returns a positive integer : the total number of indices in this mesh geometry.
  25059. * @returns the numner of indices or zero if the mesh has no geometry.
  25060. */
  25061. getTotalIndices(): number;
  25062. /**
  25063. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25064. * @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.
  25065. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25066. * @returns the indices array or an empty array if the mesh has no geometry
  25067. */
  25068. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25069. get isBlocked(): boolean;
  25070. /**
  25071. * Determine if the current mesh is ready to be rendered
  25072. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25073. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25074. * @returns true if all associated assets are ready (material, textures, shaders)
  25075. */
  25076. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25077. /**
  25078. * 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.
  25079. */
  25080. get areNormalsFrozen(): boolean;
  25081. /**
  25082. * 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.
  25083. * @returns the current mesh
  25084. */
  25085. freezeNormals(): Mesh;
  25086. /**
  25087. * 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
  25088. * @returns the current mesh
  25089. */
  25090. unfreezeNormals(): Mesh;
  25091. /**
  25092. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25093. */
  25094. set overridenInstanceCount(count: number);
  25095. /** @hidden */
  25096. _preActivate(): Mesh;
  25097. /** @hidden */
  25098. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25099. /** @hidden */
  25100. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25101. /**
  25102. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25103. * This means the mesh underlying bounding box and sphere are recomputed.
  25104. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25105. * @returns the current mesh
  25106. */
  25107. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25108. /** @hidden */
  25109. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25110. /**
  25111. * This function will subdivide the mesh into multiple submeshes
  25112. * @param count defines the expected number of submeshes
  25113. */
  25114. subdivide(count: number): void;
  25115. /**
  25116. * Copy a FloatArray into a specific associated vertex buffer
  25117. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25118. * - VertexBuffer.PositionKind
  25119. * - VertexBuffer.UVKind
  25120. * - VertexBuffer.UV2Kind
  25121. * - VertexBuffer.UV3Kind
  25122. * - VertexBuffer.UV4Kind
  25123. * - VertexBuffer.UV5Kind
  25124. * - VertexBuffer.UV6Kind
  25125. * - VertexBuffer.ColorKind
  25126. * - VertexBuffer.MatricesIndicesKind
  25127. * - VertexBuffer.MatricesIndicesExtraKind
  25128. * - VertexBuffer.MatricesWeightsKind
  25129. * - VertexBuffer.MatricesWeightsExtraKind
  25130. * @param data defines the data source
  25131. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25132. * @param stride defines the data stride size (can be null)
  25133. * @returns the current mesh
  25134. */
  25135. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25136. /**
  25137. * Delete a vertex buffer associated with this mesh
  25138. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25139. * - VertexBuffer.PositionKind
  25140. * - VertexBuffer.UVKind
  25141. * - VertexBuffer.UV2Kind
  25142. * - VertexBuffer.UV3Kind
  25143. * - VertexBuffer.UV4Kind
  25144. * - VertexBuffer.UV5Kind
  25145. * - VertexBuffer.UV6Kind
  25146. * - VertexBuffer.ColorKind
  25147. * - VertexBuffer.MatricesIndicesKind
  25148. * - VertexBuffer.MatricesIndicesExtraKind
  25149. * - VertexBuffer.MatricesWeightsKind
  25150. * - VertexBuffer.MatricesWeightsExtraKind
  25151. */
  25152. removeVerticesData(kind: string): void;
  25153. /**
  25154. * Flags an associated vertex buffer as updatable
  25155. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25156. * - VertexBuffer.PositionKind
  25157. * - VertexBuffer.UVKind
  25158. * - VertexBuffer.UV2Kind
  25159. * - VertexBuffer.UV3Kind
  25160. * - VertexBuffer.UV4Kind
  25161. * - VertexBuffer.UV5Kind
  25162. * - VertexBuffer.UV6Kind
  25163. * - VertexBuffer.ColorKind
  25164. * - VertexBuffer.MatricesIndicesKind
  25165. * - VertexBuffer.MatricesIndicesExtraKind
  25166. * - VertexBuffer.MatricesWeightsKind
  25167. * - VertexBuffer.MatricesWeightsExtraKind
  25168. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25169. */
  25170. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25171. /**
  25172. * Sets the mesh global Vertex Buffer
  25173. * @param buffer defines the buffer to use
  25174. * @returns the current mesh
  25175. */
  25176. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25177. /**
  25178. * Update a specific associated vertex buffer
  25179. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25180. * - VertexBuffer.PositionKind
  25181. * - VertexBuffer.UVKind
  25182. * - VertexBuffer.UV2Kind
  25183. * - VertexBuffer.UV3Kind
  25184. * - VertexBuffer.UV4Kind
  25185. * - VertexBuffer.UV5Kind
  25186. * - VertexBuffer.UV6Kind
  25187. * - VertexBuffer.ColorKind
  25188. * - VertexBuffer.MatricesIndicesKind
  25189. * - VertexBuffer.MatricesIndicesExtraKind
  25190. * - VertexBuffer.MatricesWeightsKind
  25191. * - VertexBuffer.MatricesWeightsExtraKind
  25192. * @param data defines the data source
  25193. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25194. * @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)
  25195. * @returns the current mesh
  25196. */
  25197. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25198. /**
  25199. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25200. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25201. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25202. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25203. * @returns the current mesh
  25204. */
  25205. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25206. /**
  25207. * Creates a un-shared specific occurence of the geometry for the mesh.
  25208. * @returns the current mesh
  25209. */
  25210. makeGeometryUnique(): Mesh;
  25211. /**
  25212. * Set the index buffer of this mesh
  25213. * @param indices defines the source data
  25214. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25215. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25216. * @returns the current mesh
  25217. */
  25218. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25219. /**
  25220. * Update the current index buffer
  25221. * @param indices defines the source data
  25222. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25223. * @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)
  25224. * @returns the current mesh
  25225. */
  25226. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25227. /**
  25228. * Invert the geometry to move from a right handed system to a left handed one.
  25229. * @returns the current mesh
  25230. */
  25231. toLeftHanded(): Mesh;
  25232. /** @hidden */
  25233. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25234. /** @hidden */
  25235. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25236. /**
  25237. * Registers for this mesh a javascript function called just before the rendering process
  25238. * @param func defines the function to call before rendering this mesh
  25239. * @returns the current mesh
  25240. */
  25241. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25242. /**
  25243. * Disposes a previously registered javascript function called before the rendering
  25244. * @param func defines the function to remove
  25245. * @returns the current mesh
  25246. */
  25247. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25248. /**
  25249. * Registers for this mesh a javascript function called just after the rendering is complete
  25250. * @param func defines the function to call after rendering this mesh
  25251. * @returns the current mesh
  25252. */
  25253. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25254. /**
  25255. * Disposes a previously registered javascript function called after the rendering.
  25256. * @param func defines the function to remove
  25257. * @returns the current mesh
  25258. */
  25259. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25260. /** @hidden */
  25261. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25262. /** @hidden */
  25263. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25264. /** @hidden */
  25265. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25266. /** @hidden */
  25267. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25268. /** @hidden */
  25269. _rebuild(): void;
  25270. /** @hidden */
  25271. _freeze(): void;
  25272. /** @hidden */
  25273. _unFreeze(): void;
  25274. /**
  25275. * 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
  25276. * @param subMesh defines the subMesh to render
  25277. * @param enableAlphaMode defines if alpha mode can be changed
  25278. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25279. * @returns the current mesh
  25280. */
  25281. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25282. private _onBeforeDraw;
  25283. /**
  25284. * Renormalize the mesh and patch it up if there are no weights
  25285. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25286. * However in the case of zero weights then we set just a single influence to 1.
  25287. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25288. */
  25289. cleanMatrixWeights(): void;
  25290. private normalizeSkinFourWeights;
  25291. private normalizeSkinWeightsAndExtra;
  25292. /**
  25293. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25294. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25295. * the user know there was an issue with importing the mesh
  25296. * @returns a validation object with skinned, valid and report string
  25297. */
  25298. validateSkinning(): {
  25299. skinned: boolean;
  25300. valid: boolean;
  25301. report: string;
  25302. };
  25303. /** @hidden */
  25304. _checkDelayState(): Mesh;
  25305. private _queueLoad;
  25306. /**
  25307. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25308. * A mesh is in the frustum if its bounding box intersects the frustum
  25309. * @param frustumPlanes defines the frustum to test
  25310. * @returns true if the mesh is in the frustum planes
  25311. */
  25312. isInFrustum(frustumPlanes: Plane[]): boolean;
  25313. /**
  25314. * Sets the mesh material by the material or multiMaterial `id` property
  25315. * @param id is a string identifying the material or the multiMaterial
  25316. * @returns the current mesh
  25317. */
  25318. setMaterialByID(id: string): Mesh;
  25319. /**
  25320. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25321. * @returns an array of IAnimatable
  25322. */
  25323. getAnimatables(): IAnimatable[];
  25324. /**
  25325. * Modifies the mesh geometry according to the passed transformation matrix.
  25326. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25327. * The mesh normals are modified using the same transformation.
  25328. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25329. * @param transform defines the transform matrix to use
  25330. * @see http://doc.babylonjs.com/resources/baking_transformations
  25331. * @returns the current mesh
  25332. */
  25333. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25334. /**
  25335. * Modifies the mesh geometry according to its own current World Matrix.
  25336. * The mesh World Matrix is then reset.
  25337. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25338. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25339. * @see http://doc.babylonjs.com/resources/baking_transformations
  25340. * @returns the current mesh
  25341. */
  25342. bakeCurrentTransformIntoVertices(): Mesh;
  25343. /** @hidden */
  25344. get _positions(): Nullable<Vector3[]>;
  25345. /** @hidden */
  25346. _resetPointsArrayCache(): Mesh;
  25347. /** @hidden */
  25348. _generatePointsArray(): boolean;
  25349. /**
  25350. * Returns a new Mesh object generated from the current mesh properties.
  25351. * This method must not get confused with createInstance()
  25352. * @param name is a string, the name given to the new mesh
  25353. * @param newParent can be any Node object (default `null`)
  25354. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25355. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25356. * @returns a new mesh
  25357. */
  25358. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25359. /**
  25360. * Releases resources associated with this mesh.
  25361. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25362. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25363. */
  25364. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25365. /** @hidden */
  25366. _disposeInstanceSpecificData(): void;
  25367. /**
  25368. * Modifies the mesh geometry according to a displacement map.
  25369. * 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.
  25370. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25371. * @param url is a string, the URL from the image file is to be downloaded.
  25372. * @param minHeight is the lower limit of the displacement.
  25373. * @param maxHeight is the upper limit of the displacement.
  25374. * @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.
  25375. * @param uvOffset is an optional vector2 used to offset UV.
  25376. * @param uvScale is an optional vector2 used to scale UV.
  25377. * @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.
  25378. * @returns the Mesh.
  25379. */
  25380. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25381. /**
  25382. * Modifies the mesh geometry according to a displacementMap buffer.
  25383. * 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.
  25384. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25385. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25386. * @param heightMapWidth is the width of the buffer image.
  25387. * @param heightMapHeight is the height of the buffer image.
  25388. * @param minHeight is the lower limit of the displacement.
  25389. * @param maxHeight is the upper limit of the displacement.
  25390. * @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.
  25391. * @param uvOffset is an optional vector2 used to offset UV.
  25392. * @param uvScale is an optional vector2 used to scale UV.
  25393. * @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.
  25394. * @returns the Mesh.
  25395. */
  25396. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25397. /**
  25398. * Modify the mesh to get a flat shading rendering.
  25399. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25400. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25401. * @returns current mesh
  25402. */
  25403. convertToFlatShadedMesh(): Mesh;
  25404. /**
  25405. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25406. * In other words, more vertices, no more indices and a single bigger VBO.
  25407. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25408. * @returns current mesh
  25409. */
  25410. convertToUnIndexedMesh(): Mesh;
  25411. /**
  25412. * Inverses facet orientations.
  25413. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25414. * @param flipNormals will also inverts the normals
  25415. * @returns current mesh
  25416. */
  25417. flipFaces(flipNormals?: boolean): Mesh;
  25418. /**
  25419. * Increase the number of facets and hence vertices in a mesh
  25420. * Vertex normals are interpolated from existing vertex normals
  25421. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25422. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25423. */
  25424. increaseVertices(numberPerEdge: number): void;
  25425. /**
  25426. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25427. * This will undo any application of covertToFlatShadedMesh
  25428. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25429. */
  25430. forceSharedVertices(): void;
  25431. /** @hidden */
  25432. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25433. /** @hidden */
  25434. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25435. /**
  25436. * Creates a new InstancedMesh object from the mesh model.
  25437. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25438. * @param name defines the name of the new instance
  25439. * @returns a new InstancedMesh
  25440. */
  25441. createInstance(name: string): InstancedMesh;
  25442. /**
  25443. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25444. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25445. * @returns the current mesh
  25446. */
  25447. synchronizeInstances(): Mesh;
  25448. /**
  25449. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25450. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25451. * This should be used together with the simplification to avoid disappearing triangles.
  25452. * @param successCallback an optional success callback to be called after the optimization finished.
  25453. * @returns the current mesh
  25454. */
  25455. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25456. /**
  25457. * Serialize current mesh
  25458. * @param serializationObject defines the object which will receive the serialization data
  25459. */
  25460. serialize(serializationObject: any): void;
  25461. /** @hidden */
  25462. _syncGeometryWithMorphTargetManager(): void;
  25463. /** @hidden */
  25464. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25465. /**
  25466. * Returns a new Mesh object parsed from the source provided.
  25467. * @param parsedMesh is the source
  25468. * @param scene defines the hosting scene
  25469. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25470. * @returns a new Mesh
  25471. */
  25472. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25473. /**
  25474. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25475. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25476. * @param name defines the name of the mesh to create
  25477. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25478. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25479. * @param closePath creates a seam between the first and the last points of each path of the path array
  25480. * @param offset is taken in account only if the `pathArray` is containing a single path
  25481. * @param scene defines the hosting scene
  25482. * @param updatable defines if the mesh must be flagged as updatable
  25483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25484. * @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)
  25485. * @returns a new Mesh
  25486. */
  25487. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25488. /**
  25489. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25490. * @param name defines the name of the mesh to create
  25491. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25492. * @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
  25493. * @param scene defines the hosting scene
  25494. * @param updatable defines if the mesh must be flagged as updatable
  25495. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25496. * @returns a new Mesh
  25497. */
  25498. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25499. /**
  25500. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25501. * @param name defines the name of the mesh to create
  25502. * @param size sets the size (float) of each box side (default 1)
  25503. * @param scene defines the hosting scene
  25504. * @param updatable defines if the mesh must be flagged as updatable
  25505. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25506. * @returns a new Mesh
  25507. */
  25508. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25509. /**
  25510. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25511. * @param name defines the name of the mesh to create
  25512. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25513. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25514. * @param scene defines the hosting scene
  25515. * @param updatable defines if the mesh must be flagged as updatable
  25516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25517. * @returns a new Mesh
  25518. */
  25519. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25520. /**
  25521. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25522. * @param name defines the name of the mesh to create
  25523. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25524. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25525. * @param scene defines the hosting scene
  25526. * @returns a new Mesh
  25527. */
  25528. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25529. /**
  25530. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25531. * @param name defines the name of the mesh to create
  25532. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25533. * @param diameterTop set the top cap diameter (floats, default 1)
  25534. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25535. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25536. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25537. * @param scene defines the hosting scene
  25538. * @param updatable defines if the mesh must be flagged as updatable
  25539. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25540. * @returns a new Mesh
  25541. */
  25542. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25543. /**
  25544. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25545. * @param name defines the name of the mesh to create
  25546. * @param diameter sets the diameter size (float) of the torus (default 1)
  25547. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25548. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25549. * @param scene defines the hosting scene
  25550. * @param updatable defines if the mesh must be flagged as updatable
  25551. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25552. * @returns a new Mesh
  25553. */
  25554. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25555. /**
  25556. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25557. * @param name defines the name of the mesh to create
  25558. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25559. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25560. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25561. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25562. * @param p the number of windings on X axis (positive integers, default 2)
  25563. * @param q the number of windings on Y axis (positive integers, default 3)
  25564. * @param scene defines the hosting scene
  25565. * @param updatable defines if the mesh must be flagged as updatable
  25566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25567. * @returns a new Mesh
  25568. */
  25569. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25570. /**
  25571. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25572. * @param name defines the name of the mesh to create
  25573. * @param points is an array successive Vector3
  25574. * @param scene defines the hosting scene
  25575. * @param updatable defines if the mesh must be flagged as updatable
  25576. * @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).
  25577. * @returns a new Mesh
  25578. */
  25579. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25580. /**
  25581. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25582. * @param name defines the name of the mesh to create
  25583. * @param points is an array successive Vector3
  25584. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25585. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25586. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25587. * @param scene defines the hosting scene
  25588. * @param updatable defines if the mesh must be flagged as updatable
  25589. * @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)
  25590. * @returns a new Mesh
  25591. */
  25592. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25593. /**
  25594. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25595. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25596. * 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.
  25597. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25598. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25599. * Remember you can only change the shape positions, not their number when updating a polygon.
  25600. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25601. * @param name defines the name of the mesh to create
  25602. * @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
  25603. * @param scene defines the hosting scene
  25604. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25605. * @param updatable defines if the mesh must be flagged as updatable
  25606. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25607. * @param earcutInjection can be used to inject your own earcut reference
  25608. * @returns a new Mesh
  25609. */
  25610. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25611. /**
  25612. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25613. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25614. * @param name defines the name of the mesh to create
  25615. * @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
  25616. * @param depth defines the height of extrusion
  25617. * @param scene defines the hosting scene
  25618. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25619. * @param updatable defines if the mesh must be flagged as updatable
  25620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25621. * @param earcutInjection can be used to inject your own earcut reference
  25622. * @returns a new Mesh
  25623. */
  25624. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25625. /**
  25626. * Creates an extruded shape mesh.
  25627. * 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
  25628. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25629. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25630. * @param name defines the name of the mesh to create
  25631. * @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
  25632. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25633. * @param scale is the value to scale the shape
  25634. * @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
  25635. * @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
  25636. * @param scene defines the hosting scene
  25637. * @param updatable defines if the mesh must be flagged as updatable
  25638. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25639. * @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)
  25640. * @returns a new Mesh
  25641. */
  25642. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25643. /**
  25644. * Creates an custom extruded shape mesh.
  25645. * The custom extrusion is a parametric shape.
  25646. * It has no predefined shape. Its final shape will depend on the input parameters.
  25647. * Please consider using the same method from the MeshBuilder class instead
  25648. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25649. * @param name defines the name of the mesh to create
  25650. * @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
  25651. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25652. * @param scaleFunction is a custom Javascript function called on each path point
  25653. * @param rotationFunction is a custom Javascript function called on each path point
  25654. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25655. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25656. * @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
  25657. * @param scene defines the hosting scene
  25658. * @param updatable defines if the mesh must be flagged as updatable
  25659. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25660. * @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)
  25661. * @returns a new Mesh
  25662. */
  25663. 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;
  25664. /**
  25665. * Creates lathe mesh.
  25666. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25667. * Please consider using the same method from the MeshBuilder class instead
  25668. * @param name defines the name of the mesh to create
  25669. * @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
  25670. * @param radius is the radius value of the lathe
  25671. * @param tessellation is the side number of the lathe.
  25672. * @param scene defines the hosting scene
  25673. * @param updatable defines if the mesh must be flagged as updatable
  25674. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25675. * @returns a new Mesh
  25676. */
  25677. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25678. /**
  25679. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25680. * @param name defines the name of the mesh to create
  25681. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25682. * @param scene defines the hosting scene
  25683. * @param updatable defines if the mesh must be flagged as updatable
  25684. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25685. * @returns a new Mesh
  25686. */
  25687. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25688. /**
  25689. * Creates a ground mesh.
  25690. * Please consider using the same method from the MeshBuilder class instead
  25691. * @param name defines the name of the mesh to create
  25692. * @param width set the width of the ground
  25693. * @param height set the height of the ground
  25694. * @param subdivisions sets the number of subdivisions per side
  25695. * @param scene defines the hosting scene
  25696. * @param updatable defines if the mesh must be flagged as updatable
  25697. * @returns a new Mesh
  25698. */
  25699. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25700. /**
  25701. * Creates a tiled ground mesh.
  25702. * Please consider using the same method from the MeshBuilder class instead
  25703. * @param name defines the name of the mesh to create
  25704. * @param xmin set the ground minimum X coordinate
  25705. * @param zmin set the ground minimum Y coordinate
  25706. * @param xmax set the ground maximum X coordinate
  25707. * @param zmax set the ground maximum Z coordinate
  25708. * @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
  25709. * @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
  25710. * @param scene defines the hosting scene
  25711. * @param updatable defines if the mesh must be flagged as updatable
  25712. * @returns a new Mesh
  25713. */
  25714. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25715. w: number;
  25716. h: number;
  25717. }, precision: {
  25718. w: number;
  25719. h: number;
  25720. }, scene: Scene, updatable?: boolean): Mesh;
  25721. /**
  25722. * Creates a ground mesh from a height map.
  25723. * Please consider using the same method from the MeshBuilder class instead
  25724. * @see http://doc.babylonjs.com/babylon101/height_map
  25725. * @param name defines the name of the mesh to create
  25726. * @param url sets the URL of the height map image resource
  25727. * @param width set the ground width size
  25728. * @param height set the ground height size
  25729. * @param subdivisions sets the number of subdivision per side
  25730. * @param minHeight is the minimum altitude on the ground
  25731. * @param maxHeight is the maximum altitude on the ground
  25732. * @param scene defines the hosting scene
  25733. * @param updatable defines if the mesh must be flagged as updatable
  25734. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25735. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25736. * @returns a new Mesh
  25737. */
  25738. 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;
  25739. /**
  25740. * Creates a tube mesh.
  25741. * The tube is a parametric shape.
  25742. * It has no predefined shape. Its final shape will depend on the input parameters.
  25743. * Please consider using the same method from the MeshBuilder class instead
  25744. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25745. * @param name defines the name of the mesh to create
  25746. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25747. * @param radius sets the tube radius size
  25748. * @param tessellation is the number of sides on the tubular surface
  25749. * @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
  25750. * @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
  25751. * @param scene defines the hosting scene
  25752. * @param updatable defines if the mesh must be flagged as updatable
  25753. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25754. * @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)
  25755. * @returns a new Mesh
  25756. */
  25757. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25758. (i: number, distance: number): number;
  25759. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25760. /**
  25761. * Creates a polyhedron mesh.
  25762. * Please consider using the same method from the MeshBuilder class instead.
  25763. * * 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
  25764. * * The parameter `size` (positive float, default 1) sets the polygon size
  25765. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25766. * * 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`
  25767. * * 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
  25768. * * 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)`)
  25769. * * 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
  25770. * * 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
  25771. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25772. * * If you create a double-sided mesh, you can choose what parts of 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
  25773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25774. * @param name defines the name of the mesh to create
  25775. * @param options defines the options used to create the mesh
  25776. * @param scene defines the hosting scene
  25777. * @returns a new Mesh
  25778. */
  25779. static CreatePolyhedron(name: string, options: {
  25780. type?: number;
  25781. size?: number;
  25782. sizeX?: number;
  25783. sizeY?: number;
  25784. sizeZ?: number;
  25785. custom?: any;
  25786. faceUV?: Vector4[];
  25787. faceColors?: Color4[];
  25788. updatable?: boolean;
  25789. sideOrientation?: number;
  25790. }, scene: Scene): Mesh;
  25791. /**
  25792. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25793. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25794. * * 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`)
  25795. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25796. * * 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
  25797. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25798. * * If you create a double-sided mesh, you can choose what parts of 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
  25799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25800. * @param name defines the name of the mesh
  25801. * @param options defines the options used to create the mesh
  25802. * @param scene defines the hosting scene
  25803. * @returns a new Mesh
  25804. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25805. */
  25806. static CreateIcoSphere(name: string, options: {
  25807. radius?: number;
  25808. flat?: boolean;
  25809. subdivisions?: number;
  25810. sideOrientation?: number;
  25811. updatable?: boolean;
  25812. }, scene: Scene): Mesh;
  25813. /**
  25814. * Creates a decal mesh.
  25815. * Please consider using the same method from the MeshBuilder class instead.
  25816. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25817. * @param name defines the name of the mesh
  25818. * @param sourceMesh defines the mesh receiving the decal
  25819. * @param position sets the position of the decal in world coordinates
  25820. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25821. * @param size sets the decal scaling
  25822. * @param angle sets the angle to rotate the decal
  25823. * @returns a new Mesh
  25824. */
  25825. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25826. /**
  25827. * Prepare internal position array for software CPU skinning
  25828. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25829. */
  25830. setPositionsForCPUSkinning(): Float32Array;
  25831. /**
  25832. * Prepare internal normal array for software CPU skinning
  25833. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25834. */
  25835. setNormalsForCPUSkinning(): Float32Array;
  25836. /**
  25837. * Updates the vertex buffer by applying transformation from the bones
  25838. * @param skeleton defines the skeleton to apply to current mesh
  25839. * @returns the current mesh
  25840. */
  25841. applySkeleton(skeleton: Skeleton): Mesh;
  25842. /**
  25843. * 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
  25844. * @param meshes defines the list of meshes to scan
  25845. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25846. */
  25847. static MinMax(meshes: AbstractMesh[]): {
  25848. min: Vector3;
  25849. max: Vector3;
  25850. };
  25851. /**
  25852. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25853. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25854. * @returns a vector3
  25855. */
  25856. static Center(meshesOrMinMaxVector: {
  25857. min: Vector3;
  25858. max: Vector3;
  25859. } | AbstractMesh[]): Vector3;
  25860. /**
  25861. * Merge the array of meshes into a single mesh for performance reasons.
  25862. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25863. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25864. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25865. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25866. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25867. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25868. * @returns a new mesh
  25869. */
  25870. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25871. /** @hidden */
  25872. addInstance(instance: InstancedMesh): void;
  25873. /** @hidden */
  25874. removeInstance(instance: InstancedMesh): void;
  25875. }
  25876. }
  25877. declare module "babylonjs/Cameras/camera" {
  25878. import { SmartArray } from "babylonjs/Misc/smartArray";
  25879. import { Observable } from "babylonjs/Misc/observable";
  25880. import { Nullable } from "babylonjs/types";
  25881. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25882. import { Scene } from "babylonjs/scene";
  25883. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25884. import { Node } from "babylonjs/node";
  25885. import { Mesh } from "babylonjs/Meshes/mesh";
  25886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25887. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25888. import { Viewport } from "babylonjs/Maths/math.viewport";
  25889. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25891. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25892. import { Ray } from "babylonjs/Culling/ray";
  25893. /**
  25894. * This is the base class of all the camera used in the application.
  25895. * @see http://doc.babylonjs.com/features/cameras
  25896. */
  25897. export class Camera extends Node {
  25898. /** @hidden */
  25899. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25900. /**
  25901. * This is the default projection mode used by the cameras.
  25902. * It helps recreating a feeling of perspective and better appreciate depth.
  25903. * This is the best way to simulate real life cameras.
  25904. */
  25905. static readonly PERSPECTIVE_CAMERA: number;
  25906. /**
  25907. * This helps creating camera with an orthographic mode.
  25908. * 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.
  25909. */
  25910. static readonly ORTHOGRAPHIC_CAMERA: number;
  25911. /**
  25912. * This is the default FOV mode for perspective cameras.
  25913. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25914. */
  25915. static readonly FOVMODE_VERTICAL_FIXED: number;
  25916. /**
  25917. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25918. */
  25919. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25920. /**
  25921. * This specifies ther is no need for a camera rig.
  25922. * Basically only one eye is rendered corresponding to the camera.
  25923. */
  25924. static readonly RIG_MODE_NONE: number;
  25925. /**
  25926. * Simulates a camera Rig with one blue eye and one red eye.
  25927. * This can be use with 3d blue and red glasses.
  25928. */
  25929. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25930. /**
  25931. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25932. */
  25933. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25934. /**
  25935. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25936. */
  25937. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25938. /**
  25939. * Defines that both eyes of the camera will be rendered over under each other.
  25940. */
  25941. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25942. /**
  25943. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25944. */
  25945. static readonly RIG_MODE_VR: number;
  25946. /**
  25947. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25948. */
  25949. static readonly RIG_MODE_WEBVR: number;
  25950. /**
  25951. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25952. */
  25953. static readonly RIG_MODE_CUSTOM: number;
  25954. /**
  25955. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25956. */
  25957. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25958. /**
  25959. * Define the input manager associated with the camera.
  25960. */
  25961. inputs: CameraInputsManager<Camera>;
  25962. /** @hidden */
  25963. _position: Vector3;
  25964. /**
  25965. * Define the current local position of the camera in the scene
  25966. */
  25967. get position(): Vector3;
  25968. set position(newPosition: Vector3);
  25969. /**
  25970. * The vector the camera should consider as up.
  25971. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25972. */
  25973. upVector: Vector3;
  25974. /**
  25975. * Define the current limit on the left side for an orthographic camera
  25976. * In scene unit
  25977. */
  25978. orthoLeft: Nullable<number>;
  25979. /**
  25980. * Define the current limit on the right side for an orthographic camera
  25981. * In scene unit
  25982. */
  25983. orthoRight: Nullable<number>;
  25984. /**
  25985. * Define the current limit on the bottom side for an orthographic camera
  25986. * In scene unit
  25987. */
  25988. orthoBottom: Nullable<number>;
  25989. /**
  25990. * Define the current limit on the top side for an orthographic camera
  25991. * In scene unit
  25992. */
  25993. orthoTop: Nullable<number>;
  25994. /**
  25995. * Field Of View is set in Radians. (default is 0.8)
  25996. */
  25997. fov: number;
  25998. /**
  25999. * Define the minimum distance the camera can see from.
  26000. * This is important to note that the depth buffer are not infinite and the closer it starts
  26001. * the more your scene might encounter depth fighting issue.
  26002. */
  26003. minZ: number;
  26004. /**
  26005. * Define the maximum distance the camera can see to.
  26006. * This is important to note that the depth buffer are not infinite and the further it end
  26007. * the more your scene might encounter depth fighting issue.
  26008. */
  26009. maxZ: number;
  26010. /**
  26011. * Define the default inertia of the camera.
  26012. * This helps giving a smooth feeling to the camera movement.
  26013. */
  26014. inertia: number;
  26015. /**
  26016. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26017. */
  26018. mode: number;
  26019. /**
  26020. * Define wether the camera is intermediate.
  26021. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26022. */
  26023. isIntermediate: boolean;
  26024. /**
  26025. * Define the viewport of the camera.
  26026. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26027. */
  26028. viewport: Viewport;
  26029. /**
  26030. * Restricts the camera to viewing objects with the same layerMask.
  26031. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26032. */
  26033. layerMask: number;
  26034. /**
  26035. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26036. */
  26037. fovMode: number;
  26038. /**
  26039. * Rig mode of the camera.
  26040. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26041. * This is normally controlled byt the camera themselves as internal use.
  26042. */
  26043. cameraRigMode: number;
  26044. /**
  26045. * Defines the distance between both "eyes" in case of a RIG
  26046. */
  26047. interaxialDistance: number;
  26048. /**
  26049. * Defines if stereoscopic rendering is done side by side or over under.
  26050. */
  26051. isStereoscopicSideBySide: boolean;
  26052. /**
  26053. * 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
  26054. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26055. * else in the scene. (Eg. security camera)
  26056. *
  26057. * 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)
  26058. */
  26059. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26060. /**
  26061. * When set, the camera will render to this render target instead of the default canvas
  26062. *
  26063. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26064. */
  26065. outputRenderTarget: Nullable<RenderTargetTexture>;
  26066. /**
  26067. * Observable triggered when the camera view matrix has changed.
  26068. */
  26069. onViewMatrixChangedObservable: Observable<Camera>;
  26070. /**
  26071. * Observable triggered when the camera Projection matrix has changed.
  26072. */
  26073. onProjectionMatrixChangedObservable: Observable<Camera>;
  26074. /**
  26075. * Observable triggered when the inputs have been processed.
  26076. */
  26077. onAfterCheckInputsObservable: Observable<Camera>;
  26078. /**
  26079. * Observable triggered when reset has been called and applied to the camera.
  26080. */
  26081. onRestoreStateObservable: Observable<Camera>;
  26082. /** @hidden */
  26083. _cameraRigParams: any;
  26084. /** @hidden */
  26085. _rigCameras: Camera[];
  26086. /** @hidden */
  26087. _rigPostProcess: Nullable<PostProcess>;
  26088. protected _webvrViewMatrix: Matrix;
  26089. /** @hidden */
  26090. _skipRendering: boolean;
  26091. /** @hidden */
  26092. _projectionMatrix: Matrix;
  26093. /** @hidden */
  26094. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26095. /** @hidden */
  26096. _activeMeshes: SmartArray<AbstractMesh>;
  26097. protected _globalPosition: Vector3;
  26098. /** @hidden */
  26099. _computedViewMatrix: Matrix;
  26100. private _doNotComputeProjectionMatrix;
  26101. private _transformMatrix;
  26102. private _frustumPlanes;
  26103. private _refreshFrustumPlanes;
  26104. private _storedFov;
  26105. private _stateStored;
  26106. /**
  26107. * Instantiates a new camera object.
  26108. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26109. * @see http://doc.babylonjs.com/features/cameras
  26110. * @param name Defines the name of the camera in the scene
  26111. * @param position Defines the position of the camera
  26112. * @param scene Defines the scene the camera belongs too
  26113. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26114. */
  26115. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26116. /**
  26117. * Store current camera state (fov, position, etc..)
  26118. * @returns the camera
  26119. */
  26120. storeState(): Camera;
  26121. /**
  26122. * Restores the camera state values if it has been stored. You must call storeState() first
  26123. */
  26124. protected _restoreStateValues(): boolean;
  26125. /**
  26126. * Restored camera state. You must call storeState() first.
  26127. * @returns true if restored and false otherwise
  26128. */
  26129. restoreState(): boolean;
  26130. /**
  26131. * Gets the class name of the camera.
  26132. * @returns the class name
  26133. */
  26134. getClassName(): string;
  26135. /** @hidden */
  26136. readonly _isCamera: boolean;
  26137. /**
  26138. * Gets a string representation of the camera useful for debug purpose.
  26139. * @param fullDetails Defines that a more verboe level of logging is required
  26140. * @returns the string representation
  26141. */
  26142. toString(fullDetails?: boolean): string;
  26143. /**
  26144. * Gets the current world space position of the camera.
  26145. */
  26146. get globalPosition(): Vector3;
  26147. /**
  26148. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26149. * @returns the active meshe list
  26150. */
  26151. getActiveMeshes(): SmartArray<AbstractMesh>;
  26152. /**
  26153. * Check wether a mesh is part of the current active mesh list of the camera
  26154. * @param mesh Defines the mesh to check
  26155. * @returns true if active, false otherwise
  26156. */
  26157. isActiveMesh(mesh: Mesh): boolean;
  26158. /**
  26159. * Is this camera ready to be used/rendered
  26160. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26161. * @return true if the camera is ready
  26162. */
  26163. isReady(completeCheck?: boolean): boolean;
  26164. /** @hidden */
  26165. _initCache(): void;
  26166. /** @hidden */
  26167. _updateCache(ignoreParentClass?: boolean): void;
  26168. /** @hidden */
  26169. _isSynchronized(): boolean;
  26170. /** @hidden */
  26171. _isSynchronizedViewMatrix(): boolean;
  26172. /** @hidden */
  26173. _isSynchronizedProjectionMatrix(): boolean;
  26174. /**
  26175. * Attach the input controls to a specific dom element to get the input from.
  26176. * @param element Defines the element the controls should be listened from
  26177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26178. */
  26179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26180. /**
  26181. * Detach the current controls from the specified dom element.
  26182. * @param element Defines the element to stop listening the inputs from
  26183. */
  26184. detachControl(element: HTMLElement): void;
  26185. /**
  26186. * Update the camera state according to the different inputs gathered during the frame.
  26187. */
  26188. update(): void;
  26189. /** @hidden */
  26190. _checkInputs(): void;
  26191. /** @hidden */
  26192. get rigCameras(): Camera[];
  26193. /**
  26194. * Gets the post process used by the rig cameras
  26195. */
  26196. get rigPostProcess(): Nullable<PostProcess>;
  26197. /**
  26198. * Internal, gets the first post proces.
  26199. * @returns the first post process to be run on this camera.
  26200. */
  26201. _getFirstPostProcess(): Nullable<PostProcess>;
  26202. private _cascadePostProcessesToRigCams;
  26203. /**
  26204. * Attach a post process to the camera.
  26205. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26206. * @param postProcess The post process to attach to the camera
  26207. * @param insertAt The position of the post process in case several of them are in use in the scene
  26208. * @returns the position the post process has been inserted at
  26209. */
  26210. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26211. /**
  26212. * Detach a post process to the camera.
  26213. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26214. * @param postProcess The post process to detach from the camera
  26215. */
  26216. detachPostProcess(postProcess: PostProcess): void;
  26217. /**
  26218. * Gets the current world matrix of the camera
  26219. */
  26220. getWorldMatrix(): Matrix;
  26221. /** @hidden */
  26222. _getViewMatrix(): Matrix;
  26223. /**
  26224. * Gets the current view matrix of the camera.
  26225. * @param force forces the camera to recompute the matrix without looking at the cached state
  26226. * @returns the view matrix
  26227. */
  26228. getViewMatrix(force?: boolean): Matrix;
  26229. /**
  26230. * Freeze the projection matrix.
  26231. * It will prevent the cache check of the camera projection compute and can speed up perf
  26232. * if no parameter of the camera are meant to change
  26233. * @param projection Defines manually a projection if necessary
  26234. */
  26235. freezeProjectionMatrix(projection?: Matrix): void;
  26236. /**
  26237. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26238. */
  26239. unfreezeProjectionMatrix(): void;
  26240. /**
  26241. * Gets the current projection matrix of the camera.
  26242. * @param force forces the camera to recompute the matrix without looking at the cached state
  26243. * @returns the projection matrix
  26244. */
  26245. getProjectionMatrix(force?: boolean): Matrix;
  26246. /**
  26247. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26248. * @returns a Matrix
  26249. */
  26250. getTransformationMatrix(): Matrix;
  26251. private _updateFrustumPlanes;
  26252. /**
  26253. * Checks if a cullable object (mesh...) is in the camera frustum
  26254. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26255. * @param target The object to check
  26256. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26257. * @returns true if the object is in frustum otherwise false
  26258. */
  26259. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26260. /**
  26261. * Checks if a cullable object (mesh...) is in the camera frustum
  26262. * Unlike isInFrustum this cheks the full bounding box
  26263. * @param target The object to check
  26264. * @returns true if the object is in frustum otherwise false
  26265. */
  26266. isCompletelyInFrustum(target: ICullable): boolean;
  26267. /**
  26268. * Gets a ray in the forward direction from the camera.
  26269. * @param length Defines the length of the ray to create
  26270. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26271. * @param origin Defines the start point of the ray which defaults to the camera position
  26272. * @returns the forward ray
  26273. */
  26274. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26275. /**
  26276. * Releases resources associated with this node.
  26277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26279. */
  26280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26281. /** @hidden */
  26282. _isLeftCamera: boolean;
  26283. /**
  26284. * Gets the left camera of a rig setup in case of Rigged Camera
  26285. */
  26286. get isLeftCamera(): boolean;
  26287. /** @hidden */
  26288. _isRightCamera: boolean;
  26289. /**
  26290. * Gets the right camera of a rig setup in case of Rigged Camera
  26291. */
  26292. get isRightCamera(): boolean;
  26293. /**
  26294. * Gets the left camera of a rig setup in case of Rigged Camera
  26295. */
  26296. get leftCamera(): Nullable<FreeCamera>;
  26297. /**
  26298. * Gets the right camera of a rig setup in case of Rigged Camera
  26299. */
  26300. get rightCamera(): Nullable<FreeCamera>;
  26301. /**
  26302. * Gets the left camera target of a rig setup in case of Rigged Camera
  26303. * @returns the target position
  26304. */
  26305. getLeftTarget(): Nullable<Vector3>;
  26306. /**
  26307. * Gets the right camera target of a rig setup in case of Rigged Camera
  26308. * @returns the target position
  26309. */
  26310. getRightTarget(): Nullable<Vector3>;
  26311. /**
  26312. * @hidden
  26313. */
  26314. setCameraRigMode(mode: number, rigParams: any): void;
  26315. /** @hidden */
  26316. static _setStereoscopicRigMode(camera: Camera): void;
  26317. /** @hidden */
  26318. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26319. /** @hidden */
  26320. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26321. /** @hidden */
  26322. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26323. /** @hidden */
  26324. _getVRProjectionMatrix(): Matrix;
  26325. protected _updateCameraRotationMatrix(): void;
  26326. protected _updateWebVRCameraRotationMatrix(): void;
  26327. /**
  26328. * This function MUST be overwritten by the different WebVR cameras available.
  26329. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26330. * @hidden
  26331. */
  26332. _getWebVRProjectionMatrix(): Matrix;
  26333. /**
  26334. * This function MUST be overwritten by the different WebVR cameras available.
  26335. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26336. * @hidden
  26337. */
  26338. _getWebVRViewMatrix(): Matrix;
  26339. /** @hidden */
  26340. setCameraRigParameter(name: string, value: any): void;
  26341. /**
  26342. * needs to be overridden by children so sub has required properties to be copied
  26343. * @hidden
  26344. */
  26345. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26346. /**
  26347. * May need to be overridden by children
  26348. * @hidden
  26349. */
  26350. _updateRigCameras(): void;
  26351. /** @hidden */
  26352. _setupInputs(): void;
  26353. /**
  26354. * Serialiaze the camera setup to a json represention
  26355. * @returns the JSON representation
  26356. */
  26357. serialize(): any;
  26358. /**
  26359. * Clones the current camera.
  26360. * @param name The cloned camera name
  26361. * @returns the cloned camera
  26362. */
  26363. clone(name: string): Camera;
  26364. /**
  26365. * Gets the direction of the camera relative to a given local axis.
  26366. * @param localAxis Defines the reference axis to provide a relative direction.
  26367. * @return the direction
  26368. */
  26369. getDirection(localAxis: Vector3): Vector3;
  26370. /**
  26371. * Returns the current camera absolute rotation
  26372. */
  26373. get absoluteRotation(): Quaternion;
  26374. /**
  26375. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26376. * @param localAxis Defines the reference axis to provide a relative direction.
  26377. * @param result Defines the vector to store the result in
  26378. */
  26379. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26380. /**
  26381. * Gets a camera constructor for a given camera type
  26382. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26383. * @param name The name of the camera the result will be able to instantiate
  26384. * @param scene The scene the result will construct the camera in
  26385. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26386. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26387. * @returns a factory method to construc the camera
  26388. */
  26389. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26390. /**
  26391. * Compute the world matrix of the camera.
  26392. * @returns the camera world matrix
  26393. */
  26394. computeWorldMatrix(): Matrix;
  26395. /**
  26396. * Parse a JSON and creates the camera from the parsed information
  26397. * @param parsedCamera The JSON to parse
  26398. * @param scene The scene to instantiate the camera in
  26399. * @returns the newly constructed camera
  26400. */
  26401. static Parse(parsedCamera: any, scene: Scene): Camera;
  26402. }
  26403. }
  26404. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26405. import { Nullable } from "babylonjs/types";
  26406. import { Scene } from "babylonjs/scene";
  26407. import { Vector4 } from "babylonjs/Maths/math.vector";
  26408. import { Mesh } from "babylonjs/Meshes/mesh";
  26409. /**
  26410. * Class containing static functions to help procedurally build meshes
  26411. */
  26412. export class DiscBuilder {
  26413. /**
  26414. * Creates a plane polygonal mesh. By default, this is a disc
  26415. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26416. * * 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
  26417. * * 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
  26418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26421. * @param name defines the name of the mesh
  26422. * @param options defines the options used to create the mesh
  26423. * @param scene defines the hosting scene
  26424. * @returns the plane polygonal mesh
  26425. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26426. */
  26427. static CreateDisc(name: string, options: {
  26428. radius?: number;
  26429. tessellation?: number;
  26430. arc?: number;
  26431. updatable?: boolean;
  26432. sideOrientation?: number;
  26433. frontUVs?: Vector4;
  26434. backUVs?: Vector4;
  26435. }, scene?: Nullable<Scene>): Mesh;
  26436. }
  26437. }
  26438. declare module "babylonjs/Materials/fresnelParameters" {
  26439. import { Color3 } from "babylonjs/Maths/math.color";
  26440. /**
  26441. * This represents all the required information to add a fresnel effect on a material:
  26442. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26443. */
  26444. export class FresnelParameters {
  26445. private _isEnabled;
  26446. /**
  26447. * Define if the fresnel effect is enable or not.
  26448. */
  26449. get isEnabled(): boolean;
  26450. set isEnabled(value: boolean);
  26451. /**
  26452. * Define the color used on edges (grazing angle)
  26453. */
  26454. leftColor: Color3;
  26455. /**
  26456. * Define the color used on center
  26457. */
  26458. rightColor: Color3;
  26459. /**
  26460. * Define bias applied to computed fresnel term
  26461. */
  26462. bias: number;
  26463. /**
  26464. * Defined the power exponent applied to fresnel term
  26465. */
  26466. power: number;
  26467. /**
  26468. * Clones the current fresnel and its valuues
  26469. * @returns a clone fresnel configuration
  26470. */
  26471. clone(): FresnelParameters;
  26472. /**
  26473. * Serializes the current fresnel parameters to a JSON representation.
  26474. * @return the JSON serialization
  26475. */
  26476. serialize(): any;
  26477. /**
  26478. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26479. * @param parsedFresnelParameters Define the JSON representation
  26480. * @returns the parsed parameters
  26481. */
  26482. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26483. }
  26484. }
  26485. declare module "babylonjs/Materials/pushMaterial" {
  26486. import { Nullable } from "babylonjs/types";
  26487. import { Scene } from "babylonjs/scene";
  26488. import { Matrix } from "babylonjs/Maths/math.vector";
  26489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26490. import { Mesh } from "babylonjs/Meshes/mesh";
  26491. import { Material } from "babylonjs/Materials/material";
  26492. import { Effect } from "babylonjs/Materials/effect";
  26493. /**
  26494. * Base class of materials working in push mode in babylon JS
  26495. * @hidden
  26496. */
  26497. export class PushMaterial extends Material {
  26498. protected _activeEffect: Effect;
  26499. protected _normalMatrix: Matrix;
  26500. /**
  26501. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26502. * This means that the material can keep using a previous shader while a new one is being compiled.
  26503. * This is mostly used when shader parallel compilation is supported (true by default)
  26504. */
  26505. allowShaderHotSwapping: boolean;
  26506. constructor(name: string, scene: Scene);
  26507. getEffect(): Effect;
  26508. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26509. /**
  26510. * Binds the given world matrix to the active effect
  26511. *
  26512. * @param world the matrix to bind
  26513. */
  26514. bindOnlyWorldMatrix(world: Matrix): void;
  26515. /**
  26516. * Binds the given normal matrix to the active effect
  26517. *
  26518. * @param normalMatrix the matrix to bind
  26519. */
  26520. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26521. bind(world: Matrix, mesh?: Mesh): void;
  26522. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26523. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26524. }
  26525. }
  26526. declare module "babylonjs/Materials/materialFlags" {
  26527. /**
  26528. * This groups all the flags used to control the materials channel.
  26529. */
  26530. export class MaterialFlags {
  26531. private static _DiffuseTextureEnabled;
  26532. /**
  26533. * Are diffuse textures enabled in the application.
  26534. */
  26535. static get DiffuseTextureEnabled(): boolean;
  26536. static set DiffuseTextureEnabled(value: boolean);
  26537. private static _AmbientTextureEnabled;
  26538. /**
  26539. * Are ambient textures enabled in the application.
  26540. */
  26541. static get AmbientTextureEnabled(): boolean;
  26542. static set AmbientTextureEnabled(value: boolean);
  26543. private static _OpacityTextureEnabled;
  26544. /**
  26545. * Are opacity textures enabled in the application.
  26546. */
  26547. static get OpacityTextureEnabled(): boolean;
  26548. static set OpacityTextureEnabled(value: boolean);
  26549. private static _ReflectionTextureEnabled;
  26550. /**
  26551. * Are reflection textures enabled in the application.
  26552. */
  26553. static get ReflectionTextureEnabled(): boolean;
  26554. static set ReflectionTextureEnabled(value: boolean);
  26555. private static _EmissiveTextureEnabled;
  26556. /**
  26557. * Are emissive textures enabled in the application.
  26558. */
  26559. static get EmissiveTextureEnabled(): boolean;
  26560. static set EmissiveTextureEnabled(value: boolean);
  26561. private static _SpecularTextureEnabled;
  26562. /**
  26563. * Are specular textures enabled in the application.
  26564. */
  26565. static get SpecularTextureEnabled(): boolean;
  26566. static set SpecularTextureEnabled(value: boolean);
  26567. private static _BumpTextureEnabled;
  26568. /**
  26569. * Are bump textures enabled in the application.
  26570. */
  26571. static get BumpTextureEnabled(): boolean;
  26572. static set BumpTextureEnabled(value: boolean);
  26573. private static _LightmapTextureEnabled;
  26574. /**
  26575. * Are lightmap textures enabled in the application.
  26576. */
  26577. static get LightmapTextureEnabled(): boolean;
  26578. static set LightmapTextureEnabled(value: boolean);
  26579. private static _RefractionTextureEnabled;
  26580. /**
  26581. * Are refraction textures enabled in the application.
  26582. */
  26583. static get RefractionTextureEnabled(): boolean;
  26584. static set RefractionTextureEnabled(value: boolean);
  26585. private static _ColorGradingTextureEnabled;
  26586. /**
  26587. * Are color grading textures enabled in the application.
  26588. */
  26589. static get ColorGradingTextureEnabled(): boolean;
  26590. static set ColorGradingTextureEnabled(value: boolean);
  26591. private static _FresnelEnabled;
  26592. /**
  26593. * Are fresnels enabled in the application.
  26594. */
  26595. static get FresnelEnabled(): boolean;
  26596. static set FresnelEnabled(value: boolean);
  26597. private static _ClearCoatTextureEnabled;
  26598. /**
  26599. * Are clear coat textures enabled in the application.
  26600. */
  26601. static get ClearCoatTextureEnabled(): boolean;
  26602. static set ClearCoatTextureEnabled(value: boolean);
  26603. private static _ClearCoatBumpTextureEnabled;
  26604. /**
  26605. * Are clear coat bump textures enabled in the application.
  26606. */
  26607. static get ClearCoatBumpTextureEnabled(): boolean;
  26608. static set ClearCoatBumpTextureEnabled(value: boolean);
  26609. private static _ClearCoatTintTextureEnabled;
  26610. /**
  26611. * Are clear coat tint textures enabled in the application.
  26612. */
  26613. static get ClearCoatTintTextureEnabled(): boolean;
  26614. static set ClearCoatTintTextureEnabled(value: boolean);
  26615. private static _SheenTextureEnabled;
  26616. /**
  26617. * Are sheen textures enabled in the application.
  26618. */
  26619. static get SheenTextureEnabled(): boolean;
  26620. static set SheenTextureEnabled(value: boolean);
  26621. private static _AnisotropicTextureEnabled;
  26622. /**
  26623. * Are anisotropic textures enabled in the application.
  26624. */
  26625. static get AnisotropicTextureEnabled(): boolean;
  26626. static set AnisotropicTextureEnabled(value: boolean);
  26627. private static _ThicknessTextureEnabled;
  26628. /**
  26629. * Are thickness textures enabled in the application.
  26630. */
  26631. static get ThicknessTextureEnabled(): boolean;
  26632. static set ThicknessTextureEnabled(value: boolean);
  26633. }
  26634. }
  26635. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26636. /** @hidden */
  26637. export var defaultFragmentDeclaration: {
  26638. name: string;
  26639. shader: string;
  26640. };
  26641. }
  26642. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26643. /** @hidden */
  26644. export var defaultUboDeclaration: {
  26645. name: string;
  26646. shader: string;
  26647. };
  26648. }
  26649. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26650. /** @hidden */
  26651. export var lightFragmentDeclaration: {
  26652. name: string;
  26653. shader: string;
  26654. };
  26655. }
  26656. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26657. /** @hidden */
  26658. export var lightUboDeclaration: {
  26659. name: string;
  26660. shader: string;
  26661. };
  26662. }
  26663. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26664. /** @hidden */
  26665. export var lightsFragmentFunctions: {
  26666. name: string;
  26667. shader: string;
  26668. };
  26669. }
  26670. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26671. /** @hidden */
  26672. export var shadowsFragmentFunctions: {
  26673. name: string;
  26674. shader: string;
  26675. };
  26676. }
  26677. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26678. /** @hidden */
  26679. export var fresnelFunction: {
  26680. name: string;
  26681. shader: string;
  26682. };
  26683. }
  26684. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26685. /** @hidden */
  26686. export var reflectionFunction: {
  26687. name: string;
  26688. shader: string;
  26689. };
  26690. }
  26691. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26692. /** @hidden */
  26693. export var bumpFragmentFunctions: {
  26694. name: string;
  26695. shader: string;
  26696. };
  26697. }
  26698. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26699. /** @hidden */
  26700. export var logDepthDeclaration: {
  26701. name: string;
  26702. shader: string;
  26703. };
  26704. }
  26705. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26706. /** @hidden */
  26707. export var bumpFragment: {
  26708. name: string;
  26709. shader: string;
  26710. };
  26711. }
  26712. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26713. /** @hidden */
  26714. export var depthPrePass: {
  26715. name: string;
  26716. shader: string;
  26717. };
  26718. }
  26719. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26720. /** @hidden */
  26721. export var lightFragment: {
  26722. name: string;
  26723. shader: string;
  26724. };
  26725. }
  26726. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26727. /** @hidden */
  26728. export var logDepthFragment: {
  26729. name: string;
  26730. shader: string;
  26731. };
  26732. }
  26733. declare module "babylonjs/Shaders/default.fragment" {
  26734. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26735. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26736. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26737. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26738. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26739. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26740. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26741. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26742. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26743. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26744. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26745. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26746. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26747. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26748. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26749. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26750. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26751. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26752. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26753. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26754. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26755. /** @hidden */
  26756. export var defaultPixelShader: {
  26757. name: string;
  26758. shader: string;
  26759. };
  26760. }
  26761. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26762. /** @hidden */
  26763. export var defaultVertexDeclaration: {
  26764. name: string;
  26765. shader: string;
  26766. };
  26767. }
  26768. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26769. /** @hidden */
  26770. export var bumpVertexDeclaration: {
  26771. name: string;
  26772. shader: string;
  26773. };
  26774. }
  26775. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26776. /** @hidden */
  26777. export var bumpVertex: {
  26778. name: string;
  26779. shader: string;
  26780. };
  26781. }
  26782. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26783. /** @hidden */
  26784. export var fogVertex: {
  26785. name: string;
  26786. shader: string;
  26787. };
  26788. }
  26789. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26790. /** @hidden */
  26791. export var shadowsVertex: {
  26792. name: string;
  26793. shader: string;
  26794. };
  26795. }
  26796. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26797. /** @hidden */
  26798. export var pointCloudVertex: {
  26799. name: string;
  26800. shader: string;
  26801. };
  26802. }
  26803. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26804. /** @hidden */
  26805. export var logDepthVertex: {
  26806. name: string;
  26807. shader: string;
  26808. };
  26809. }
  26810. declare module "babylonjs/Shaders/default.vertex" {
  26811. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26812. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26813. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26814. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26815. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26816. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26817. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26818. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26819. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26820. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26821. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26822. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26823. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26824. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26825. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26826. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26827. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26828. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26829. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26830. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26831. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26832. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26833. /** @hidden */
  26834. export var defaultVertexShader: {
  26835. name: string;
  26836. shader: string;
  26837. };
  26838. }
  26839. declare module "babylonjs/Materials/standardMaterial" {
  26840. import { SmartArray } from "babylonjs/Misc/smartArray";
  26841. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26842. import { Nullable } from "babylonjs/types";
  26843. import { Scene } from "babylonjs/scene";
  26844. import { Matrix } from "babylonjs/Maths/math.vector";
  26845. import { Color3 } from "babylonjs/Maths/math.color";
  26846. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26848. import { Mesh } from "babylonjs/Meshes/mesh";
  26849. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26850. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26851. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26852. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26853. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26856. import "babylonjs/Shaders/default.fragment";
  26857. import "babylonjs/Shaders/default.vertex";
  26858. /** @hidden */
  26859. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26860. MAINUV1: boolean;
  26861. MAINUV2: boolean;
  26862. DIFFUSE: boolean;
  26863. DIFFUSEDIRECTUV: number;
  26864. AMBIENT: boolean;
  26865. AMBIENTDIRECTUV: number;
  26866. OPACITY: boolean;
  26867. OPACITYDIRECTUV: number;
  26868. OPACITYRGB: boolean;
  26869. REFLECTION: boolean;
  26870. EMISSIVE: boolean;
  26871. EMISSIVEDIRECTUV: number;
  26872. SPECULAR: boolean;
  26873. SPECULARDIRECTUV: number;
  26874. BUMP: boolean;
  26875. BUMPDIRECTUV: number;
  26876. PARALLAX: boolean;
  26877. PARALLAXOCCLUSION: boolean;
  26878. SPECULAROVERALPHA: boolean;
  26879. CLIPPLANE: boolean;
  26880. CLIPPLANE2: boolean;
  26881. CLIPPLANE3: boolean;
  26882. CLIPPLANE4: boolean;
  26883. ALPHATEST: boolean;
  26884. DEPTHPREPASS: boolean;
  26885. ALPHAFROMDIFFUSE: boolean;
  26886. POINTSIZE: boolean;
  26887. FOG: boolean;
  26888. SPECULARTERM: boolean;
  26889. DIFFUSEFRESNEL: boolean;
  26890. OPACITYFRESNEL: boolean;
  26891. REFLECTIONFRESNEL: boolean;
  26892. REFRACTIONFRESNEL: boolean;
  26893. EMISSIVEFRESNEL: boolean;
  26894. FRESNEL: boolean;
  26895. NORMAL: boolean;
  26896. UV1: boolean;
  26897. UV2: boolean;
  26898. VERTEXCOLOR: boolean;
  26899. VERTEXALPHA: boolean;
  26900. NUM_BONE_INFLUENCERS: number;
  26901. BonesPerMesh: number;
  26902. BONETEXTURE: boolean;
  26903. INSTANCES: boolean;
  26904. GLOSSINESS: boolean;
  26905. ROUGHNESS: boolean;
  26906. EMISSIVEASILLUMINATION: boolean;
  26907. LINKEMISSIVEWITHDIFFUSE: boolean;
  26908. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26909. LIGHTMAP: boolean;
  26910. LIGHTMAPDIRECTUV: number;
  26911. OBJECTSPACE_NORMALMAP: boolean;
  26912. USELIGHTMAPASSHADOWMAP: boolean;
  26913. REFLECTIONMAP_3D: boolean;
  26914. REFLECTIONMAP_SPHERICAL: boolean;
  26915. REFLECTIONMAP_PLANAR: boolean;
  26916. REFLECTIONMAP_CUBIC: boolean;
  26917. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26918. REFLECTIONMAP_PROJECTION: boolean;
  26919. REFLECTIONMAP_SKYBOX: boolean;
  26920. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26921. REFLECTIONMAP_EXPLICIT: boolean;
  26922. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26923. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26924. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26925. INVERTCUBICMAP: boolean;
  26926. LOGARITHMICDEPTH: boolean;
  26927. REFRACTION: boolean;
  26928. REFRACTIONMAP_3D: boolean;
  26929. REFLECTIONOVERALPHA: boolean;
  26930. TWOSIDEDLIGHTING: boolean;
  26931. SHADOWFLOAT: boolean;
  26932. MORPHTARGETS: boolean;
  26933. MORPHTARGETS_NORMAL: boolean;
  26934. MORPHTARGETS_TANGENT: boolean;
  26935. MORPHTARGETS_UV: boolean;
  26936. NUM_MORPH_INFLUENCERS: number;
  26937. NONUNIFORMSCALING: boolean;
  26938. PREMULTIPLYALPHA: boolean;
  26939. IMAGEPROCESSING: boolean;
  26940. VIGNETTE: boolean;
  26941. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26942. VIGNETTEBLENDMODEOPAQUE: boolean;
  26943. TONEMAPPING: boolean;
  26944. TONEMAPPING_ACES: boolean;
  26945. CONTRAST: boolean;
  26946. COLORCURVES: boolean;
  26947. COLORGRADING: boolean;
  26948. COLORGRADING3D: boolean;
  26949. SAMPLER3DGREENDEPTH: boolean;
  26950. SAMPLER3DBGRMAP: boolean;
  26951. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26952. MULTIVIEW: boolean;
  26953. /**
  26954. * If the reflection texture on this material is in linear color space
  26955. * @hidden
  26956. */
  26957. IS_REFLECTION_LINEAR: boolean;
  26958. /**
  26959. * If the refraction texture on this material is in linear color space
  26960. * @hidden
  26961. */
  26962. IS_REFRACTION_LINEAR: boolean;
  26963. EXPOSURE: boolean;
  26964. constructor();
  26965. setReflectionMode(modeToEnable: string): void;
  26966. }
  26967. /**
  26968. * This is the default material used in Babylon. It is the best trade off between quality
  26969. * and performances.
  26970. * @see http://doc.babylonjs.com/babylon101/materials
  26971. */
  26972. export class StandardMaterial extends PushMaterial {
  26973. private _diffuseTexture;
  26974. /**
  26975. * The basic texture of the material as viewed under a light.
  26976. */
  26977. diffuseTexture: Nullable<BaseTexture>;
  26978. private _ambientTexture;
  26979. /**
  26980. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26981. */
  26982. ambientTexture: Nullable<BaseTexture>;
  26983. private _opacityTexture;
  26984. /**
  26985. * Define the transparency of the material from a texture.
  26986. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26987. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26988. */
  26989. opacityTexture: Nullable<BaseTexture>;
  26990. private _reflectionTexture;
  26991. /**
  26992. * Define the texture used to display the reflection.
  26993. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26994. */
  26995. reflectionTexture: Nullable<BaseTexture>;
  26996. private _emissiveTexture;
  26997. /**
  26998. * Define texture of the material as if self lit.
  26999. * This will be mixed in the final result even in the absence of light.
  27000. */
  27001. emissiveTexture: Nullable<BaseTexture>;
  27002. private _specularTexture;
  27003. /**
  27004. * Define how the color and intensity of the highlight given by the light in the material.
  27005. */
  27006. specularTexture: Nullable<BaseTexture>;
  27007. private _bumpTexture;
  27008. /**
  27009. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27010. * 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.
  27011. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27012. */
  27013. bumpTexture: Nullable<BaseTexture>;
  27014. private _lightmapTexture;
  27015. /**
  27016. * Complex lighting can be computationally expensive to compute at runtime.
  27017. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27018. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27019. */
  27020. lightmapTexture: Nullable<BaseTexture>;
  27021. private _refractionTexture;
  27022. /**
  27023. * Define the texture used to display the refraction.
  27024. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27025. */
  27026. refractionTexture: Nullable<BaseTexture>;
  27027. /**
  27028. * The color of the material lit by the environmental background lighting.
  27029. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27030. */
  27031. ambientColor: Color3;
  27032. /**
  27033. * The basic color of the material as viewed under a light.
  27034. */
  27035. diffuseColor: Color3;
  27036. /**
  27037. * Define how the color and intensity of the highlight given by the light in the material.
  27038. */
  27039. specularColor: Color3;
  27040. /**
  27041. * Define the color of the material as if self lit.
  27042. * This will be mixed in the final result even in the absence of light.
  27043. */
  27044. emissiveColor: Color3;
  27045. /**
  27046. * Defines how sharp are the highlights in the material.
  27047. * The bigger the value the sharper giving a more glossy feeling to the result.
  27048. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27049. */
  27050. specularPower: number;
  27051. private _useAlphaFromDiffuseTexture;
  27052. /**
  27053. * Does the transparency come from the diffuse texture alpha channel.
  27054. */
  27055. useAlphaFromDiffuseTexture: boolean;
  27056. private _useEmissiveAsIllumination;
  27057. /**
  27058. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27059. */
  27060. useEmissiveAsIllumination: boolean;
  27061. private _linkEmissiveWithDiffuse;
  27062. /**
  27063. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27064. * the emissive level when the final color is close to one.
  27065. */
  27066. linkEmissiveWithDiffuse: boolean;
  27067. private _useSpecularOverAlpha;
  27068. /**
  27069. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27070. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27071. */
  27072. useSpecularOverAlpha: boolean;
  27073. private _useReflectionOverAlpha;
  27074. /**
  27075. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27076. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27077. */
  27078. useReflectionOverAlpha: boolean;
  27079. private _disableLighting;
  27080. /**
  27081. * Does lights from the scene impacts this material.
  27082. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27083. */
  27084. disableLighting: boolean;
  27085. private _useObjectSpaceNormalMap;
  27086. /**
  27087. * Allows using an object space normal map (instead of tangent space).
  27088. */
  27089. useObjectSpaceNormalMap: boolean;
  27090. private _useParallax;
  27091. /**
  27092. * Is parallax enabled or not.
  27093. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27094. */
  27095. useParallax: boolean;
  27096. private _useParallaxOcclusion;
  27097. /**
  27098. * Is parallax occlusion enabled or not.
  27099. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27100. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27101. */
  27102. useParallaxOcclusion: boolean;
  27103. /**
  27104. * 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.
  27105. */
  27106. parallaxScaleBias: number;
  27107. private _roughness;
  27108. /**
  27109. * Helps to define how blurry the reflections should appears in the material.
  27110. */
  27111. roughness: number;
  27112. /**
  27113. * In case of refraction, define the value of the index of refraction.
  27114. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27115. */
  27116. indexOfRefraction: number;
  27117. /**
  27118. * Invert the refraction texture alongside the y axis.
  27119. * It can be useful with procedural textures or probe for instance.
  27120. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27121. */
  27122. invertRefractionY: boolean;
  27123. /**
  27124. * Defines the alpha limits in alpha test mode.
  27125. */
  27126. alphaCutOff: number;
  27127. private _useLightmapAsShadowmap;
  27128. /**
  27129. * In case of light mapping, define whether the map contains light or shadow informations.
  27130. */
  27131. useLightmapAsShadowmap: boolean;
  27132. private _diffuseFresnelParameters;
  27133. /**
  27134. * Define the diffuse fresnel parameters of the material.
  27135. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27136. */
  27137. diffuseFresnelParameters: FresnelParameters;
  27138. private _opacityFresnelParameters;
  27139. /**
  27140. * Define the opacity fresnel parameters of the material.
  27141. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27142. */
  27143. opacityFresnelParameters: FresnelParameters;
  27144. private _reflectionFresnelParameters;
  27145. /**
  27146. * Define the reflection fresnel parameters of the material.
  27147. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27148. */
  27149. reflectionFresnelParameters: FresnelParameters;
  27150. private _refractionFresnelParameters;
  27151. /**
  27152. * Define the refraction fresnel parameters of the material.
  27153. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27154. */
  27155. refractionFresnelParameters: FresnelParameters;
  27156. private _emissiveFresnelParameters;
  27157. /**
  27158. * Define the emissive fresnel parameters of the material.
  27159. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27160. */
  27161. emissiveFresnelParameters: FresnelParameters;
  27162. private _useReflectionFresnelFromSpecular;
  27163. /**
  27164. * If true automatically deducts the fresnels values from the material specularity.
  27165. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27166. */
  27167. useReflectionFresnelFromSpecular: boolean;
  27168. private _useGlossinessFromSpecularMapAlpha;
  27169. /**
  27170. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27171. */
  27172. useGlossinessFromSpecularMapAlpha: boolean;
  27173. private _maxSimultaneousLights;
  27174. /**
  27175. * Defines the maximum number of lights that can be used in the material
  27176. */
  27177. maxSimultaneousLights: number;
  27178. private _invertNormalMapX;
  27179. /**
  27180. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27181. */
  27182. invertNormalMapX: boolean;
  27183. private _invertNormalMapY;
  27184. /**
  27185. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27186. */
  27187. invertNormalMapY: boolean;
  27188. private _twoSidedLighting;
  27189. /**
  27190. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27191. */
  27192. twoSidedLighting: boolean;
  27193. /**
  27194. * Default configuration related to image processing available in the standard Material.
  27195. */
  27196. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27197. /**
  27198. * Gets the image processing configuration used either in this material.
  27199. */
  27200. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27201. /**
  27202. * Sets the Default image processing configuration used either in the this material.
  27203. *
  27204. * If sets to null, the scene one is in use.
  27205. */
  27206. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27207. /**
  27208. * Keep track of the image processing observer to allow dispose and replace.
  27209. */
  27210. private _imageProcessingObserver;
  27211. /**
  27212. * Attaches a new image processing configuration to the Standard Material.
  27213. * @param configuration
  27214. */
  27215. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27216. /**
  27217. * Gets wether the color curves effect is enabled.
  27218. */
  27219. get cameraColorCurvesEnabled(): boolean;
  27220. /**
  27221. * Sets wether the color curves effect is enabled.
  27222. */
  27223. set cameraColorCurvesEnabled(value: boolean);
  27224. /**
  27225. * Gets wether the color grading effect is enabled.
  27226. */
  27227. get cameraColorGradingEnabled(): boolean;
  27228. /**
  27229. * Gets wether the color grading effect is enabled.
  27230. */
  27231. set cameraColorGradingEnabled(value: boolean);
  27232. /**
  27233. * Gets wether tonemapping is enabled or not.
  27234. */
  27235. get cameraToneMappingEnabled(): boolean;
  27236. /**
  27237. * Sets wether tonemapping is enabled or not
  27238. */
  27239. set cameraToneMappingEnabled(value: boolean);
  27240. /**
  27241. * The camera exposure used on this material.
  27242. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27243. * This corresponds to a photographic exposure.
  27244. */
  27245. get cameraExposure(): number;
  27246. /**
  27247. * The camera exposure used on this material.
  27248. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27249. * This corresponds to a photographic exposure.
  27250. */
  27251. set cameraExposure(value: number);
  27252. /**
  27253. * Gets The camera contrast used on this material.
  27254. */
  27255. get cameraContrast(): number;
  27256. /**
  27257. * Sets The camera contrast used on this material.
  27258. */
  27259. set cameraContrast(value: number);
  27260. /**
  27261. * Gets the Color Grading 2D Lookup Texture.
  27262. */
  27263. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27264. /**
  27265. * Sets the Color Grading 2D Lookup Texture.
  27266. */
  27267. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27268. /**
  27269. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27270. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27271. * 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;
  27272. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27273. */
  27274. get cameraColorCurves(): Nullable<ColorCurves>;
  27275. /**
  27276. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27277. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27278. * 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;
  27279. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27280. */
  27281. set cameraColorCurves(value: Nullable<ColorCurves>);
  27282. /**
  27283. * Custom callback helping to override the default shader used in the material.
  27284. */
  27285. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27286. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27287. protected _worldViewProjectionMatrix: Matrix;
  27288. protected _globalAmbientColor: Color3;
  27289. protected _useLogarithmicDepth: boolean;
  27290. protected _rebuildInParallel: boolean;
  27291. /**
  27292. * Instantiates a new standard material.
  27293. * This is the default material used in Babylon. It is the best trade off between quality
  27294. * and performances.
  27295. * @see http://doc.babylonjs.com/babylon101/materials
  27296. * @param name Define the name of the material in the scene
  27297. * @param scene Define the scene the material belong to
  27298. */
  27299. constructor(name: string, scene: Scene);
  27300. /**
  27301. * Gets a boolean indicating that current material needs to register RTT
  27302. */
  27303. get hasRenderTargetTextures(): boolean;
  27304. /**
  27305. * Gets the current class name of the material e.g. "StandardMaterial"
  27306. * Mainly use in serialization.
  27307. * @returns the class name
  27308. */
  27309. getClassName(): string;
  27310. /**
  27311. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27312. * You can try switching to logarithmic depth.
  27313. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27314. */
  27315. get useLogarithmicDepth(): boolean;
  27316. set useLogarithmicDepth(value: boolean);
  27317. /**
  27318. * Specifies if the material will require alpha blending
  27319. * @returns a boolean specifying if alpha blending is needed
  27320. */
  27321. needAlphaBlending(): boolean;
  27322. /**
  27323. * Specifies if this material should be rendered in alpha test mode
  27324. * @returns a boolean specifying if an alpha test is needed.
  27325. */
  27326. needAlphaTesting(): boolean;
  27327. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27328. /**
  27329. * Get the texture used for alpha test purpose.
  27330. * @returns the diffuse texture in case of the standard material.
  27331. */
  27332. getAlphaTestTexture(): Nullable<BaseTexture>;
  27333. /**
  27334. * Get if the submesh is ready to be used and all its information available.
  27335. * Child classes can use it to update shaders
  27336. * @param mesh defines the mesh to check
  27337. * @param subMesh defines which submesh to check
  27338. * @param useInstances specifies that instances should be used
  27339. * @returns a boolean indicating that the submesh is ready or not
  27340. */
  27341. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27342. /**
  27343. * Builds the material UBO layouts.
  27344. * Used internally during the effect preparation.
  27345. */
  27346. buildUniformLayout(): void;
  27347. /**
  27348. * Unbinds the material from the mesh
  27349. */
  27350. unbind(): void;
  27351. /**
  27352. * Binds the submesh to this material by preparing the effect and shader to draw
  27353. * @param world defines the world transformation matrix
  27354. * @param mesh defines the mesh containing the submesh
  27355. * @param subMesh defines the submesh to bind the material to
  27356. */
  27357. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27358. /**
  27359. * Get the list of animatables in the material.
  27360. * @returns the list of animatables object used in the material
  27361. */
  27362. getAnimatables(): IAnimatable[];
  27363. /**
  27364. * Gets the active textures from the material
  27365. * @returns an array of textures
  27366. */
  27367. getActiveTextures(): BaseTexture[];
  27368. /**
  27369. * Specifies if the material uses a texture
  27370. * @param texture defines the texture to check against the material
  27371. * @returns a boolean specifying if the material uses the texture
  27372. */
  27373. hasTexture(texture: BaseTexture): boolean;
  27374. /**
  27375. * Disposes the material
  27376. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27377. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27378. */
  27379. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27380. /**
  27381. * Makes a duplicate of the material, and gives it a new name
  27382. * @param name defines the new name for the duplicated material
  27383. * @returns the cloned material
  27384. */
  27385. clone(name: string): StandardMaterial;
  27386. /**
  27387. * Serializes this material in a JSON representation
  27388. * @returns the serialized material object
  27389. */
  27390. serialize(): any;
  27391. /**
  27392. * Creates a standard material from parsed material data
  27393. * @param source defines the JSON representation of the material
  27394. * @param scene defines the hosting scene
  27395. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27396. * @returns a new standard material
  27397. */
  27398. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27399. /**
  27400. * Are diffuse textures enabled in the application.
  27401. */
  27402. static get DiffuseTextureEnabled(): boolean;
  27403. static set DiffuseTextureEnabled(value: boolean);
  27404. /**
  27405. * Are ambient textures enabled in the application.
  27406. */
  27407. static get AmbientTextureEnabled(): boolean;
  27408. static set AmbientTextureEnabled(value: boolean);
  27409. /**
  27410. * Are opacity textures enabled in the application.
  27411. */
  27412. static get OpacityTextureEnabled(): boolean;
  27413. static set OpacityTextureEnabled(value: boolean);
  27414. /**
  27415. * Are reflection textures enabled in the application.
  27416. */
  27417. static get ReflectionTextureEnabled(): boolean;
  27418. static set ReflectionTextureEnabled(value: boolean);
  27419. /**
  27420. * Are emissive textures enabled in the application.
  27421. */
  27422. static get EmissiveTextureEnabled(): boolean;
  27423. static set EmissiveTextureEnabled(value: boolean);
  27424. /**
  27425. * Are specular textures enabled in the application.
  27426. */
  27427. static get SpecularTextureEnabled(): boolean;
  27428. static set SpecularTextureEnabled(value: boolean);
  27429. /**
  27430. * Are bump textures enabled in the application.
  27431. */
  27432. static get BumpTextureEnabled(): boolean;
  27433. static set BumpTextureEnabled(value: boolean);
  27434. /**
  27435. * Are lightmap textures enabled in the application.
  27436. */
  27437. static get LightmapTextureEnabled(): boolean;
  27438. static set LightmapTextureEnabled(value: boolean);
  27439. /**
  27440. * Are refraction textures enabled in the application.
  27441. */
  27442. static get RefractionTextureEnabled(): boolean;
  27443. static set RefractionTextureEnabled(value: boolean);
  27444. /**
  27445. * Are color grading textures enabled in the application.
  27446. */
  27447. static get ColorGradingTextureEnabled(): boolean;
  27448. static set ColorGradingTextureEnabled(value: boolean);
  27449. /**
  27450. * Are fresnels enabled in the application.
  27451. */
  27452. static get FresnelEnabled(): boolean;
  27453. static set FresnelEnabled(value: boolean);
  27454. }
  27455. }
  27456. declare module "babylonjs/Particles/solidParticleSystem" {
  27457. import { Nullable } from "babylonjs/types";
  27458. import { Vector3 } from "babylonjs/Maths/math.vector";
  27459. import { Mesh } from "babylonjs/Meshes/mesh";
  27460. import { Scene, IDisposable } from "babylonjs/scene";
  27461. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27462. import { Material } from "babylonjs/Materials/material";
  27463. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27464. /**
  27465. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27466. *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.
  27467. * The SPS is also a particle system. It provides some methods to manage the particles.
  27468. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27469. *
  27470. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27471. */
  27472. export class SolidParticleSystem implements IDisposable {
  27473. /**
  27474. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27475. * Example : var p = SPS.particles[i];
  27476. */
  27477. particles: SolidParticle[];
  27478. /**
  27479. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27480. */
  27481. nbParticles: number;
  27482. /**
  27483. * If the particles must ever face the camera (default false). Useful for planar particles.
  27484. */
  27485. billboard: boolean;
  27486. /**
  27487. * Recompute normals when adding a shape
  27488. */
  27489. recomputeNormals: boolean;
  27490. /**
  27491. * This a counter ofr your own usage. It's not set by any SPS functions.
  27492. */
  27493. counter: number;
  27494. /**
  27495. * The SPS name. This name is also given to the underlying mesh.
  27496. */
  27497. name: string;
  27498. /**
  27499. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27500. */
  27501. mesh: Mesh;
  27502. /**
  27503. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27504. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27505. */
  27506. vars: any;
  27507. /**
  27508. * This array is populated when the SPS is set as 'pickable'.
  27509. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27510. * Each element of this array is an object `{idx: int, faceId: int}`.
  27511. * `idx` is the picked particle index in the `SPS.particles` array
  27512. * `faceId` is the picked face index counted within this particle.
  27513. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27514. */
  27515. pickedParticles: {
  27516. idx: number;
  27517. faceId: number;
  27518. }[];
  27519. /**
  27520. * This array is populated when `enableDepthSort` is set to true.
  27521. * Each element of this array is an instance of the class DepthSortedParticle.
  27522. */
  27523. depthSortedParticles: DepthSortedParticle[];
  27524. /**
  27525. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27526. * @hidden
  27527. */
  27528. _bSphereOnly: boolean;
  27529. /**
  27530. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27531. * @hidden
  27532. */
  27533. _bSphereRadiusFactor: number;
  27534. private _scene;
  27535. private _positions;
  27536. private _indices;
  27537. private _normals;
  27538. private _colors;
  27539. private _uvs;
  27540. private _indices32;
  27541. private _positions32;
  27542. private _normals32;
  27543. private _fixedNormal32;
  27544. private _colors32;
  27545. private _uvs32;
  27546. private _index;
  27547. private _updatable;
  27548. private _pickable;
  27549. private _isVisibilityBoxLocked;
  27550. private _alwaysVisible;
  27551. private _depthSort;
  27552. private _expandable;
  27553. private _shapeCounter;
  27554. private _copy;
  27555. private _color;
  27556. private _computeParticleColor;
  27557. private _computeParticleTexture;
  27558. private _computeParticleRotation;
  27559. private _computeParticleVertex;
  27560. private _computeBoundingBox;
  27561. private _depthSortParticles;
  27562. private _camera;
  27563. private _mustUnrotateFixedNormals;
  27564. private _particlesIntersect;
  27565. private _needs32Bits;
  27566. private _isNotBuilt;
  27567. private _lastParticleId;
  27568. private _idxOfId;
  27569. private _multimaterialEnabled;
  27570. private _useModelMaterial;
  27571. private _indicesByMaterial;
  27572. private _materialIndexes;
  27573. private _depthSortFunction;
  27574. private _materialSortFunction;
  27575. private _materials;
  27576. private _multimaterial;
  27577. private _materialIndexesById;
  27578. private _defaultMaterial;
  27579. private _autoUpdateSubMeshes;
  27580. /**
  27581. * Creates a SPS (Solid Particle System) object.
  27582. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27583. * @param scene (Scene) is the scene in which the SPS is added.
  27584. * @param options defines the options of the sps e.g.
  27585. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27586. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27587. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27588. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27589. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27590. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27591. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27592. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27593. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27594. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27595. */
  27596. constructor(name: string, scene: Scene, options?: {
  27597. updatable?: boolean;
  27598. isPickable?: boolean;
  27599. enableDepthSort?: boolean;
  27600. particleIntersection?: boolean;
  27601. boundingSphereOnly?: boolean;
  27602. bSphereRadiusFactor?: number;
  27603. expandable?: boolean;
  27604. useModelMaterial?: boolean;
  27605. enableMultiMaterial?: boolean;
  27606. });
  27607. /**
  27608. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27609. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27610. * @returns the created mesh
  27611. */
  27612. buildMesh(): Mesh;
  27613. /**
  27614. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27615. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27616. * Thus the particles generated from `digest()` have their property `position` set yet.
  27617. * @param mesh ( Mesh ) is the mesh to be digested
  27618. * @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
  27619. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27620. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27621. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27622. * @returns the current SPS
  27623. */
  27624. digest(mesh: Mesh, options?: {
  27625. facetNb?: number;
  27626. number?: number;
  27627. delta?: number;
  27628. storage?: [];
  27629. }): SolidParticleSystem;
  27630. /**
  27631. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27632. * @hidden
  27633. */
  27634. private _unrotateFixedNormals;
  27635. /**
  27636. * Resets the temporary working copy particle
  27637. * @hidden
  27638. */
  27639. private _resetCopy;
  27640. /**
  27641. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27642. * @param p the current index in the positions array to be updated
  27643. * @param ind the current index in the indices array
  27644. * @param shape a Vector3 array, the shape geometry
  27645. * @param positions the positions array to be updated
  27646. * @param meshInd the shape indices array
  27647. * @param indices the indices array to be updated
  27648. * @param meshUV the shape uv array
  27649. * @param uvs the uv array to be updated
  27650. * @param meshCol the shape color array
  27651. * @param colors the color array to be updated
  27652. * @param meshNor the shape normals array
  27653. * @param normals the normals array to be updated
  27654. * @param idx the particle index
  27655. * @param idxInShape the particle index in its shape
  27656. * @param options the addShape() method passed options
  27657. * @model the particle model
  27658. * @hidden
  27659. */
  27660. private _meshBuilder;
  27661. /**
  27662. * Returns a shape Vector3 array from positions float array
  27663. * @param positions float array
  27664. * @returns a vector3 array
  27665. * @hidden
  27666. */
  27667. private _posToShape;
  27668. /**
  27669. * Returns a shapeUV array from a float uvs (array deep copy)
  27670. * @param uvs as a float array
  27671. * @returns a shapeUV array
  27672. * @hidden
  27673. */
  27674. private _uvsToShapeUV;
  27675. /**
  27676. * Adds a new particle object in the particles array
  27677. * @param idx particle index in particles array
  27678. * @param id particle id
  27679. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27680. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27681. * @param model particle ModelShape object
  27682. * @param shapeId model shape identifier
  27683. * @param idxInShape index of the particle in the current model
  27684. * @param bInfo model bounding info object
  27685. * @param storage target storage array, if any
  27686. * @hidden
  27687. */
  27688. private _addParticle;
  27689. /**
  27690. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27691. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27692. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27693. * @param nb (positive integer) the number of particles to be created from this model
  27694. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27695. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27696. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27697. * @returns the number of shapes in the system
  27698. */
  27699. addShape(mesh: Mesh, nb: number, options?: {
  27700. positionFunction?: any;
  27701. vertexFunction?: any;
  27702. storage?: [];
  27703. }): number;
  27704. /**
  27705. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27706. * @hidden
  27707. */
  27708. private _rebuildParticle;
  27709. /**
  27710. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27711. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27712. * @returns the SPS.
  27713. */
  27714. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27715. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27716. * Returns an array with the removed particles.
  27717. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27718. * The SPS can't be empty so at least one particle needs to remain in place.
  27719. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27720. * @param start index of the first particle to remove
  27721. * @param end index of the last particle to remove (included)
  27722. * @returns an array populated with the removed particles
  27723. */
  27724. removeParticles(start: number, end: number): SolidParticle[];
  27725. /**
  27726. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27727. * @param solidParticleArray an array populated with Solid Particles objects
  27728. * @returns the SPS
  27729. */
  27730. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27731. /**
  27732. * Creates a new particle and modifies the SPS mesh geometry :
  27733. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27734. * - calls _addParticle() to populate the particle array
  27735. * factorized code from addShape() and insertParticlesFromArray()
  27736. * @param idx particle index in the particles array
  27737. * @param i particle index in its shape
  27738. * @param modelShape particle ModelShape object
  27739. * @param shape shape vertex array
  27740. * @param meshInd shape indices array
  27741. * @param meshUV shape uv array
  27742. * @param meshCol shape color array
  27743. * @param meshNor shape normals array
  27744. * @param bbInfo shape bounding info
  27745. * @param storage target particle storage
  27746. * @options addShape() passed options
  27747. * @hidden
  27748. */
  27749. private _insertNewParticle;
  27750. /**
  27751. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27752. * This method calls `updateParticle()` for each particle of the SPS.
  27753. * For an animated SPS, it is usually called within the render loop.
  27754. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27755. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27756. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27757. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27758. * @returns the SPS.
  27759. */
  27760. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27761. /**
  27762. * Disposes the SPS.
  27763. */
  27764. dispose(): void;
  27765. /**
  27766. * Returns a SolidParticle object from its identifier : particle.id
  27767. * @param id (integer) the particle Id
  27768. * @returns the searched particle or null if not found in the SPS.
  27769. */
  27770. getParticleById(id: number): Nullable<SolidParticle>;
  27771. /**
  27772. * Returns a new array populated with the particles having the passed shapeId.
  27773. * @param shapeId (integer) the shape identifier
  27774. * @returns a new solid particle array
  27775. */
  27776. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27777. /**
  27778. * Populates the passed array "ref" with the particles having the passed shapeId.
  27779. * @param shapeId the shape identifier
  27780. * @returns the SPS
  27781. * @param ref
  27782. */
  27783. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27784. /**
  27785. * Computes the required SubMeshes according the materials assigned to the particles.
  27786. * @returns the solid particle system.
  27787. * Does nothing if called before the SPS mesh is built.
  27788. */
  27789. computeSubMeshes(): SolidParticleSystem;
  27790. /**
  27791. * Sorts the solid particles by material when MultiMaterial is enabled.
  27792. * Updates the indices32 array.
  27793. * Updates the indicesByMaterial array.
  27794. * Updates the mesh indices array.
  27795. * @returns the SPS
  27796. * @hidden
  27797. */
  27798. private _sortParticlesByMaterial;
  27799. /**
  27800. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27801. * @hidden
  27802. */
  27803. private _setMaterialIndexesById;
  27804. /**
  27805. * Returns an array with unique values of Materials from the passed array
  27806. * @param array the material array to be checked and filtered
  27807. * @hidden
  27808. */
  27809. private _filterUniqueMaterialId;
  27810. /**
  27811. * Sets a new Standard Material as _defaultMaterial if not already set.
  27812. * @hidden
  27813. */
  27814. private _setDefaultMaterial;
  27815. /**
  27816. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27817. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27818. * @returns the SPS.
  27819. */
  27820. refreshVisibleSize(): SolidParticleSystem;
  27821. /**
  27822. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27823. * @param size the size (float) of the visibility box
  27824. * note : this doesn't lock the SPS mesh bounding box.
  27825. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27826. */
  27827. setVisibilityBox(size: number): void;
  27828. /**
  27829. * Gets whether the SPS as always visible or not
  27830. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27831. */
  27832. get isAlwaysVisible(): boolean;
  27833. /**
  27834. * Sets the SPS as always visible or not
  27835. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27836. */
  27837. set isAlwaysVisible(val: boolean);
  27838. /**
  27839. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27840. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27841. */
  27842. set isVisibilityBoxLocked(val: boolean);
  27843. /**
  27844. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27845. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27846. */
  27847. get isVisibilityBoxLocked(): boolean;
  27848. /**
  27849. * Tells to `setParticles()` to compute the particle rotations or not.
  27850. * Default value : true. The SPS is faster when it's set to false.
  27851. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27852. */
  27853. set computeParticleRotation(val: boolean);
  27854. /**
  27855. * Tells to `setParticles()` to compute the particle colors or not.
  27856. * Default value : true. The SPS is faster when it's set to false.
  27857. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27858. */
  27859. set computeParticleColor(val: boolean);
  27860. set computeParticleTexture(val: boolean);
  27861. /**
  27862. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27863. * Default value : false. The SPS is faster when it's set to false.
  27864. * Note : the particle custom vertex positions aren't stored values.
  27865. */
  27866. set computeParticleVertex(val: boolean);
  27867. /**
  27868. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27869. */
  27870. set computeBoundingBox(val: boolean);
  27871. /**
  27872. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27873. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27874. * Default : `true`
  27875. */
  27876. set depthSortParticles(val: boolean);
  27877. /**
  27878. * Gets if `setParticles()` computes the particle rotations or not.
  27879. * Default value : true. The SPS is faster when it's set to false.
  27880. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27881. */
  27882. get computeParticleRotation(): boolean;
  27883. /**
  27884. * Gets if `setParticles()` computes the particle colors or not.
  27885. * Default value : true. The SPS is faster when it's set to false.
  27886. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27887. */
  27888. get computeParticleColor(): boolean;
  27889. /**
  27890. * Gets if `setParticles()` computes the particle textures or not.
  27891. * Default value : true. The SPS is faster when it's set to false.
  27892. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27893. */
  27894. get computeParticleTexture(): boolean;
  27895. /**
  27896. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27897. * Default value : false. The SPS is faster when it's set to false.
  27898. * Note : the particle custom vertex positions aren't stored values.
  27899. */
  27900. get computeParticleVertex(): boolean;
  27901. /**
  27902. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27903. */
  27904. get computeBoundingBox(): boolean;
  27905. /**
  27906. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27907. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27908. * Default : `true`
  27909. */
  27910. get depthSortParticles(): boolean;
  27911. /**
  27912. * Gets if the SPS is created as expandable at construction time.
  27913. * Default : `false`
  27914. */
  27915. get expandable(): boolean;
  27916. /**
  27917. * Gets if the SPS supports the Multi Materials
  27918. */
  27919. get multimaterialEnabled(): boolean;
  27920. /**
  27921. * Gets if the SPS uses the model materials for its own multimaterial.
  27922. */
  27923. get useModelMaterial(): boolean;
  27924. /**
  27925. * The SPS used material array.
  27926. */
  27927. get materials(): Material[];
  27928. /**
  27929. * Sets the SPS MultiMaterial from the passed materials.
  27930. * Note : the passed array is internally copied and not used then by reference.
  27931. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27932. */
  27933. setMultiMaterial(materials: Material[]): void;
  27934. /**
  27935. * The SPS computed multimaterial object
  27936. */
  27937. get multimaterial(): MultiMaterial;
  27938. set multimaterial(mm: MultiMaterial);
  27939. /**
  27940. * If the subMeshes must be updated on the next call to setParticles()
  27941. */
  27942. get autoUpdateSubMeshes(): boolean;
  27943. set autoUpdateSubMeshes(val: boolean);
  27944. /**
  27945. * This function does nothing. It may be overwritten to set all the particle first values.
  27946. * The SPS doesn't call this function, you may have to call it by your own.
  27947. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27948. */
  27949. initParticles(): void;
  27950. /**
  27951. * This function does nothing. It may be overwritten to recycle a particle.
  27952. * The SPS doesn't call this function, you may have to call it by your own.
  27953. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27954. * @param particle The particle to recycle
  27955. * @returns the recycled particle
  27956. */
  27957. recycleParticle(particle: SolidParticle): SolidParticle;
  27958. /**
  27959. * Updates a particle : this function should be overwritten by the user.
  27960. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27961. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27962. * @example : just set a particle position or velocity and recycle conditions
  27963. * @param particle The particle to update
  27964. * @returns the updated particle
  27965. */
  27966. updateParticle(particle: SolidParticle): SolidParticle;
  27967. /**
  27968. * Updates a vertex of a particle : it can be overwritten by the user.
  27969. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27970. * @param particle the current particle
  27971. * @param vertex the current index of the current particle
  27972. * @param pt the index of the current vertex in the particle shape
  27973. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27974. * @example : just set a vertex particle position
  27975. * @returns the updated vertex
  27976. */
  27977. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27978. /**
  27979. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27980. * This does nothing and may be overwritten by the user.
  27981. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27982. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27983. * @param update the boolean update value actually passed to setParticles()
  27984. */
  27985. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27986. /**
  27987. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27988. * This will be passed three parameters.
  27989. * This does nothing and may be overwritten by the user.
  27990. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27991. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27992. * @param update the boolean update value actually passed to setParticles()
  27993. */
  27994. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27995. }
  27996. }
  27997. declare module "babylonjs/Particles/solidParticle" {
  27998. import { Nullable } from "babylonjs/types";
  27999. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28000. import { Color4 } from "babylonjs/Maths/math.color";
  28001. import { Mesh } from "babylonjs/Meshes/mesh";
  28002. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28003. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28004. import { Plane } from "babylonjs/Maths/math.plane";
  28005. import { Material } from "babylonjs/Materials/material";
  28006. /**
  28007. * Represents one particle of a solid particle system.
  28008. */
  28009. export class SolidParticle {
  28010. /**
  28011. * particle global index
  28012. */
  28013. idx: number;
  28014. /**
  28015. * particle identifier
  28016. */
  28017. id: number;
  28018. /**
  28019. * The color of the particle
  28020. */
  28021. color: Nullable<Color4>;
  28022. /**
  28023. * The world space position of the particle.
  28024. */
  28025. position: Vector3;
  28026. /**
  28027. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28028. */
  28029. rotation: Vector3;
  28030. /**
  28031. * The world space rotation quaternion of the particle.
  28032. */
  28033. rotationQuaternion: Nullable<Quaternion>;
  28034. /**
  28035. * The scaling of the particle.
  28036. */
  28037. scaling: Vector3;
  28038. /**
  28039. * The uvs of the particle.
  28040. */
  28041. uvs: Vector4;
  28042. /**
  28043. * The current speed of the particle.
  28044. */
  28045. velocity: Vector3;
  28046. /**
  28047. * The pivot point in the particle local space.
  28048. */
  28049. pivot: Vector3;
  28050. /**
  28051. * Must the particle be translated from its pivot point in its local space ?
  28052. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28053. * Default : false
  28054. */
  28055. translateFromPivot: boolean;
  28056. /**
  28057. * Is the particle active or not ?
  28058. */
  28059. alive: boolean;
  28060. /**
  28061. * Is the particle visible or not ?
  28062. */
  28063. isVisible: boolean;
  28064. /**
  28065. * Index of this particle in the global "positions" array (Internal use)
  28066. * @hidden
  28067. */
  28068. _pos: number;
  28069. /**
  28070. * @hidden Index of this particle in the global "indices" array (Internal use)
  28071. */
  28072. _ind: number;
  28073. /**
  28074. * @hidden ModelShape of this particle (Internal use)
  28075. */
  28076. _model: ModelShape;
  28077. /**
  28078. * ModelShape id of this particle
  28079. */
  28080. shapeId: number;
  28081. /**
  28082. * Index of the particle in its shape id
  28083. */
  28084. idxInShape: number;
  28085. /**
  28086. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28087. */
  28088. _modelBoundingInfo: BoundingInfo;
  28089. /**
  28090. * @hidden Particle BoundingInfo object (Internal use)
  28091. */
  28092. _boundingInfo: BoundingInfo;
  28093. /**
  28094. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28095. */
  28096. _sps: SolidParticleSystem;
  28097. /**
  28098. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28099. */
  28100. _stillInvisible: boolean;
  28101. /**
  28102. * @hidden Last computed particle rotation matrix
  28103. */
  28104. _rotationMatrix: number[];
  28105. /**
  28106. * Parent particle Id, if any.
  28107. * Default null.
  28108. */
  28109. parentId: Nullable<number>;
  28110. /**
  28111. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28112. */
  28113. materialIndex: Nullable<number>;
  28114. /**
  28115. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28116. * The possible values are :
  28117. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28118. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28119. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28120. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28121. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28122. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28123. * */
  28124. cullingStrategy: number;
  28125. /**
  28126. * @hidden Internal global position in the SPS.
  28127. */
  28128. _globalPosition: Vector3;
  28129. /**
  28130. * Creates a Solid Particle object.
  28131. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28132. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28133. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28134. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28135. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28136. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28137. * @param shapeId (integer) is the model shape identifier in the SPS.
  28138. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28139. * @param sps defines the sps it is associated to
  28140. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28141. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28142. */
  28143. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28144. /**
  28145. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28146. * @param target the particle target
  28147. * @returns the current particle
  28148. */
  28149. copyToRef(target: SolidParticle): SolidParticle;
  28150. /**
  28151. * Legacy support, changed scale to scaling
  28152. */
  28153. get scale(): Vector3;
  28154. /**
  28155. * Legacy support, changed scale to scaling
  28156. */
  28157. set scale(scale: Vector3);
  28158. /**
  28159. * Legacy support, changed quaternion to rotationQuaternion
  28160. */
  28161. get quaternion(): Nullable<Quaternion>;
  28162. /**
  28163. * Legacy support, changed quaternion to rotationQuaternion
  28164. */
  28165. set quaternion(q: Nullable<Quaternion>);
  28166. /**
  28167. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28168. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28169. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28170. * @returns true if it intersects
  28171. */
  28172. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28173. /**
  28174. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28175. * A particle is in the frustum if its bounding box intersects the frustum
  28176. * @param frustumPlanes defines the frustum to test
  28177. * @returns true if the particle is in the frustum planes
  28178. */
  28179. isInFrustum(frustumPlanes: Plane[]): boolean;
  28180. /**
  28181. * get the rotation matrix of the particle
  28182. * @hidden
  28183. */
  28184. getRotationMatrix(m: Matrix): void;
  28185. }
  28186. /**
  28187. * Represents the shape of the model used by one particle of a solid particle system.
  28188. * SPS internal tool, don't use it manually.
  28189. */
  28190. export class ModelShape {
  28191. /**
  28192. * The shape id
  28193. * @hidden
  28194. */
  28195. shapeID: number;
  28196. /**
  28197. * flat array of model positions (internal use)
  28198. * @hidden
  28199. */
  28200. _shape: Vector3[];
  28201. /**
  28202. * flat array of model UVs (internal use)
  28203. * @hidden
  28204. */
  28205. _shapeUV: number[];
  28206. /**
  28207. * color array of the model
  28208. * @hidden
  28209. */
  28210. _shapeColors: number[];
  28211. /**
  28212. * indices array of the model
  28213. * @hidden
  28214. */
  28215. _indices: number[];
  28216. /**
  28217. * normals array of the model
  28218. * @hidden
  28219. */
  28220. _normals: number[];
  28221. /**
  28222. * length of the shape in the model indices array (internal use)
  28223. * @hidden
  28224. */
  28225. _indicesLength: number;
  28226. /**
  28227. * Custom position function (internal use)
  28228. * @hidden
  28229. */
  28230. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28231. /**
  28232. * Custom vertex function (internal use)
  28233. * @hidden
  28234. */
  28235. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28236. /**
  28237. * Model material (internal use)
  28238. * @hidden
  28239. */
  28240. _material: Nullable<Material>;
  28241. /**
  28242. * 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.
  28243. * SPS internal tool, don't use it manually.
  28244. * @hidden
  28245. */
  28246. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28247. }
  28248. /**
  28249. * Represents a Depth Sorted Particle in the solid particle system.
  28250. * @hidden
  28251. */
  28252. export class DepthSortedParticle {
  28253. /**
  28254. * Index of the particle in the "indices" array
  28255. */
  28256. ind: number;
  28257. /**
  28258. * Length of the particle shape in the "indices" array
  28259. */
  28260. indicesLength: number;
  28261. /**
  28262. * Squared distance from the particle to the camera
  28263. */
  28264. sqDistance: number;
  28265. /**
  28266. * Material index when used with MultiMaterials
  28267. */
  28268. materialIndex: number;
  28269. /**
  28270. * Creates a new sorted particle
  28271. * @param materialIndex
  28272. */
  28273. constructor(ind: number, indLength: number, materialIndex: number);
  28274. }
  28275. }
  28276. declare module "babylonjs/Collisions/meshCollisionData" {
  28277. import { Collider } from "babylonjs/Collisions/collider";
  28278. import { Vector3 } from "babylonjs/Maths/math.vector";
  28279. import { Nullable } from "babylonjs/types";
  28280. import { Observer } from "babylonjs/Misc/observable";
  28281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28282. /**
  28283. * @hidden
  28284. */
  28285. export class _MeshCollisionData {
  28286. _checkCollisions: boolean;
  28287. _collisionMask: number;
  28288. _collisionGroup: number;
  28289. _collider: Nullable<Collider>;
  28290. _oldPositionForCollisions: Vector3;
  28291. _diffPositionForCollisions: Vector3;
  28292. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28293. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28294. }
  28295. }
  28296. declare module "babylonjs/Meshes/abstractMesh" {
  28297. import { Observable } from "babylonjs/Misc/observable";
  28298. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28299. import { Camera } from "babylonjs/Cameras/camera";
  28300. import { Scene, IDisposable } from "babylonjs/scene";
  28301. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28302. import { Node } from "babylonjs/node";
  28303. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28306. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28307. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28308. import { Material } from "babylonjs/Materials/material";
  28309. import { Light } from "babylonjs/Lights/light";
  28310. import { Skeleton } from "babylonjs/Bones/skeleton";
  28311. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28312. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28313. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28314. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28315. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28316. import { Plane } from "babylonjs/Maths/math.plane";
  28317. import { Ray } from "babylonjs/Culling/ray";
  28318. import { Collider } from "babylonjs/Collisions/collider";
  28319. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28320. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28321. /** @hidden */
  28322. class _FacetDataStorage {
  28323. facetPositions: Vector3[];
  28324. facetNormals: Vector3[];
  28325. facetPartitioning: number[][];
  28326. facetNb: number;
  28327. partitioningSubdivisions: number;
  28328. partitioningBBoxRatio: number;
  28329. facetDataEnabled: boolean;
  28330. facetParameters: any;
  28331. bbSize: Vector3;
  28332. subDiv: {
  28333. max: number;
  28334. X: number;
  28335. Y: number;
  28336. Z: number;
  28337. };
  28338. facetDepthSort: boolean;
  28339. facetDepthSortEnabled: boolean;
  28340. depthSortedIndices: IndicesArray;
  28341. depthSortedFacets: {
  28342. ind: number;
  28343. sqDistance: number;
  28344. }[];
  28345. facetDepthSortFunction: (f1: {
  28346. ind: number;
  28347. sqDistance: number;
  28348. }, f2: {
  28349. ind: number;
  28350. sqDistance: number;
  28351. }) => number;
  28352. facetDepthSortFrom: Vector3;
  28353. facetDepthSortOrigin: Vector3;
  28354. invertedMatrix: Matrix;
  28355. }
  28356. /**
  28357. * @hidden
  28358. **/
  28359. class _InternalAbstractMeshDataInfo {
  28360. _hasVertexAlpha: boolean;
  28361. _useVertexColors: boolean;
  28362. _numBoneInfluencers: number;
  28363. _applyFog: boolean;
  28364. _receiveShadows: boolean;
  28365. _facetData: _FacetDataStorage;
  28366. _visibility: number;
  28367. _skeleton: Nullable<Skeleton>;
  28368. _layerMask: number;
  28369. _computeBonesUsingShaders: boolean;
  28370. _isActive: boolean;
  28371. _onlyForInstances: boolean;
  28372. _isActiveIntermediate: boolean;
  28373. _onlyForInstancesIntermediate: boolean;
  28374. _actAsRegularMesh: boolean;
  28375. }
  28376. /**
  28377. * Class used to store all common mesh properties
  28378. */
  28379. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28380. /** No occlusion */
  28381. static OCCLUSION_TYPE_NONE: number;
  28382. /** Occlusion set to optimisitic */
  28383. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28384. /** Occlusion set to strict */
  28385. static OCCLUSION_TYPE_STRICT: number;
  28386. /** Use an accurante occlusion algorithm */
  28387. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28388. /** Use a conservative occlusion algorithm */
  28389. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28390. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28391. * Test order :
  28392. * Is the bounding sphere outside the frustum ?
  28393. * If not, are the bounding box vertices outside the frustum ?
  28394. * It not, then the cullable object is in the frustum.
  28395. */
  28396. static readonly CULLINGSTRATEGY_STANDARD: number;
  28397. /** Culling strategy : Bounding Sphere Only.
  28398. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28399. * It's also less accurate than the standard because some not visible objects can still be selected.
  28400. * Test : is the bounding sphere outside the frustum ?
  28401. * If not, then the cullable object is in the frustum.
  28402. */
  28403. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28404. /** Culling strategy : Optimistic Inclusion.
  28405. * This in an inclusion test first, then the standard exclusion test.
  28406. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28407. * 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.
  28408. * Anyway, it's as accurate as the standard strategy.
  28409. * Test :
  28410. * Is the cullable object bounding sphere center in the frustum ?
  28411. * If not, apply the default culling strategy.
  28412. */
  28413. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28414. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28415. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28416. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28417. * 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.
  28418. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28419. * Test :
  28420. * Is the cullable object bounding sphere center in the frustum ?
  28421. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28422. */
  28423. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28424. /**
  28425. * No billboard
  28426. */
  28427. static get BILLBOARDMODE_NONE(): number;
  28428. /** Billboard on X axis */
  28429. static get BILLBOARDMODE_X(): number;
  28430. /** Billboard on Y axis */
  28431. static get BILLBOARDMODE_Y(): number;
  28432. /** Billboard on Z axis */
  28433. static get BILLBOARDMODE_Z(): number;
  28434. /** Billboard on all axes */
  28435. static get BILLBOARDMODE_ALL(): number;
  28436. /** Billboard on using position instead of orientation */
  28437. static get BILLBOARDMODE_USE_POSITION(): number;
  28438. /** @hidden */
  28439. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28440. /**
  28441. * The culling strategy to use to check whether the mesh must be rendered or not.
  28442. * This value can be changed at any time and will be used on the next render mesh selection.
  28443. * The possible values are :
  28444. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28445. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28446. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28447. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28448. * Please read each static variable documentation to get details about the culling process.
  28449. * */
  28450. cullingStrategy: number;
  28451. /**
  28452. * Gets the number of facets in the mesh
  28453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28454. */
  28455. get facetNb(): number;
  28456. /**
  28457. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28459. */
  28460. get partitioningSubdivisions(): number;
  28461. set partitioningSubdivisions(nb: number);
  28462. /**
  28463. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28464. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28466. */
  28467. get partitioningBBoxRatio(): number;
  28468. set partitioningBBoxRatio(ratio: number);
  28469. /**
  28470. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28471. * Works only for updatable meshes.
  28472. * Doesn't work with multi-materials
  28473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28474. */
  28475. get mustDepthSortFacets(): boolean;
  28476. set mustDepthSortFacets(sort: boolean);
  28477. /**
  28478. * The location (Vector3) where the facet depth sort must be computed from.
  28479. * By default, the active camera position.
  28480. * Used only when facet depth sort is enabled
  28481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28482. */
  28483. get facetDepthSortFrom(): Vector3;
  28484. set facetDepthSortFrom(location: Vector3);
  28485. /**
  28486. * gets a boolean indicating if facetData is enabled
  28487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28488. */
  28489. get isFacetDataEnabled(): boolean;
  28490. /** @hidden */
  28491. _updateNonUniformScalingState(value: boolean): boolean;
  28492. /**
  28493. * An event triggered when this mesh collides with another one
  28494. */
  28495. onCollideObservable: Observable<AbstractMesh>;
  28496. /** Set a function to call when this mesh collides with another one */
  28497. set onCollide(callback: () => void);
  28498. /**
  28499. * An event triggered when the collision's position changes
  28500. */
  28501. onCollisionPositionChangeObservable: Observable<Vector3>;
  28502. /** Set a function to call when the collision's position changes */
  28503. set onCollisionPositionChange(callback: () => void);
  28504. /**
  28505. * An event triggered when material is changed
  28506. */
  28507. onMaterialChangedObservable: Observable<AbstractMesh>;
  28508. /**
  28509. * Gets or sets the orientation for POV movement & rotation
  28510. */
  28511. definedFacingForward: boolean;
  28512. /** @hidden */
  28513. _occlusionQuery: Nullable<WebGLQuery>;
  28514. /** @hidden */
  28515. _renderingGroup: Nullable<RenderingGroup>;
  28516. /**
  28517. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28518. */
  28519. get visibility(): number;
  28520. /**
  28521. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28522. */
  28523. set visibility(value: number);
  28524. /** Gets or sets the alpha index used to sort transparent meshes
  28525. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28526. */
  28527. alphaIndex: number;
  28528. /**
  28529. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28530. */
  28531. isVisible: boolean;
  28532. /**
  28533. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28534. */
  28535. isPickable: boolean;
  28536. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28537. showSubMeshesBoundingBox: boolean;
  28538. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28539. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28540. */
  28541. isBlocker: boolean;
  28542. /**
  28543. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28544. */
  28545. enablePointerMoveEvents: boolean;
  28546. /**
  28547. * Specifies the rendering group id for this mesh (0 by default)
  28548. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28549. */
  28550. renderingGroupId: number;
  28551. private _material;
  28552. /** Gets or sets current material */
  28553. get material(): Nullable<Material>;
  28554. set material(value: Nullable<Material>);
  28555. /**
  28556. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28557. * @see http://doc.babylonjs.com/babylon101/shadows
  28558. */
  28559. get receiveShadows(): boolean;
  28560. set receiveShadows(value: boolean);
  28561. /** Defines color to use when rendering outline */
  28562. outlineColor: Color3;
  28563. /** Define width to use when rendering outline */
  28564. outlineWidth: number;
  28565. /** Defines color to use when rendering overlay */
  28566. overlayColor: Color3;
  28567. /** Defines alpha to use when rendering overlay */
  28568. overlayAlpha: number;
  28569. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28570. get hasVertexAlpha(): boolean;
  28571. set hasVertexAlpha(value: boolean);
  28572. /** 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) */
  28573. get useVertexColors(): boolean;
  28574. set useVertexColors(value: boolean);
  28575. /**
  28576. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28577. */
  28578. get computeBonesUsingShaders(): boolean;
  28579. set computeBonesUsingShaders(value: boolean);
  28580. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28581. get numBoneInfluencers(): number;
  28582. set numBoneInfluencers(value: number);
  28583. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28584. get applyFog(): boolean;
  28585. set applyFog(value: boolean);
  28586. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28587. useOctreeForRenderingSelection: boolean;
  28588. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28589. useOctreeForPicking: boolean;
  28590. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28591. useOctreeForCollisions: boolean;
  28592. /**
  28593. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28594. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28595. */
  28596. get layerMask(): number;
  28597. set layerMask(value: number);
  28598. /**
  28599. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28600. */
  28601. alwaysSelectAsActiveMesh: boolean;
  28602. /**
  28603. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28604. */
  28605. doNotSyncBoundingInfo: boolean;
  28606. /**
  28607. * Gets or sets the current action manager
  28608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28609. */
  28610. actionManager: Nullable<AbstractActionManager>;
  28611. private _meshCollisionData;
  28612. /**
  28613. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28614. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28615. */
  28616. ellipsoid: Vector3;
  28617. /**
  28618. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28619. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28620. */
  28621. ellipsoidOffset: Vector3;
  28622. /**
  28623. * Gets or sets a collision mask used to mask collisions (default is -1).
  28624. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28625. */
  28626. get collisionMask(): number;
  28627. set collisionMask(mask: number);
  28628. /**
  28629. * Gets or sets the current collision group mask (-1 by default).
  28630. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28631. */
  28632. get collisionGroup(): number;
  28633. set collisionGroup(mask: number);
  28634. /**
  28635. * Defines edge width used when edgesRenderer is enabled
  28636. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28637. */
  28638. edgesWidth: number;
  28639. /**
  28640. * Defines edge color used when edgesRenderer is enabled
  28641. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28642. */
  28643. edgesColor: Color4;
  28644. /** @hidden */
  28645. _edgesRenderer: Nullable<IEdgesRenderer>;
  28646. /** @hidden */
  28647. _masterMesh: Nullable<AbstractMesh>;
  28648. /** @hidden */
  28649. _boundingInfo: Nullable<BoundingInfo>;
  28650. /** @hidden */
  28651. _renderId: number;
  28652. /**
  28653. * Gets or sets the list of subMeshes
  28654. * @see http://doc.babylonjs.com/how_to/multi_materials
  28655. */
  28656. subMeshes: SubMesh[];
  28657. /** @hidden */
  28658. _intersectionsInProgress: AbstractMesh[];
  28659. /** @hidden */
  28660. _unIndexed: boolean;
  28661. /** @hidden */
  28662. _lightSources: Light[];
  28663. /** Gets the list of lights affecting that mesh */
  28664. get lightSources(): Light[];
  28665. /** @hidden */
  28666. get _positions(): Nullable<Vector3[]>;
  28667. /** @hidden */
  28668. _waitingData: {
  28669. lods: Nullable<any>;
  28670. actions: Nullable<any>;
  28671. freezeWorldMatrix: Nullable<boolean>;
  28672. };
  28673. /** @hidden */
  28674. _bonesTransformMatrices: Nullable<Float32Array>;
  28675. /** @hidden */
  28676. _transformMatrixTexture: Nullable<RawTexture>;
  28677. /**
  28678. * Gets or sets a skeleton to apply skining transformations
  28679. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28680. */
  28681. set skeleton(value: Nullable<Skeleton>);
  28682. get skeleton(): Nullable<Skeleton>;
  28683. /**
  28684. * An event triggered when the mesh is rebuilt.
  28685. */
  28686. onRebuildObservable: Observable<AbstractMesh>;
  28687. /**
  28688. * Creates a new AbstractMesh
  28689. * @param name defines the name of the mesh
  28690. * @param scene defines the hosting scene
  28691. */
  28692. constructor(name: string, scene?: Nullable<Scene>);
  28693. /**
  28694. * Returns the string "AbstractMesh"
  28695. * @returns "AbstractMesh"
  28696. */
  28697. getClassName(): string;
  28698. /**
  28699. * Gets a string representation of the current mesh
  28700. * @param fullDetails defines a boolean indicating if full details must be included
  28701. * @returns a string representation of the current mesh
  28702. */
  28703. toString(fullDetails?: boolean): string;
  28704. /**
  28705. * @hidden
  28706. */
  28707. protected _getEffectiveParent(): Nullable<Node>;
  28708. /** @hidden */
  28709. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28710. /** @hidden */
  28711. _rebuild(): void;
  28712. /** @hidden */
  28713. _resyncLightSources(): void;
  28714. /** @hidden */
  28715. _resyncLightSource(light: Light): void;
  28716. /** @hidden */
  28717. _unBindEffect(): void;
  28718. /** @hidden */
  28719. _removeLightSource(light: Light, dispose: boolean): void;
  28720. private _markSubMeshesAsDirty;
  28721. /** @hidden */
  28722. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28723. /** @hidden */
  28724. _markSubMeshesAsAttributesDirty(): void;
  28725. /** @hidden */
  28726. _markSubMeshesAsMiscDirty(): void;
  28727. /**
  28728. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28729. */
  28730. get scaling(): Vector3;
  28731. set scaling(newScaling: Vector3);
  28732. /**
  28733. * Returns true if the mesh is blocked. Implemented by child classes
  28734. */
  28735. get isBlocked(): boolean;
  28736. /**
  28737. * Returns the mesh itself by default. Implemented by child classes
  28738. * @param camera defines the camera to use to pick the right LOD level
  28739. * @returns the currentAbstractMesh
  28740. */
  28741. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28742. /**
  28743. * Returns 0 by default. Implemented by child classes
  28744. * @returns an integer
  28745. */
  28746. getTotalVertices(): number;
  28747. /**
  28748. * Returns a positive integer : the total number of indices in this mesh geometry.
  28749. * @returns the numner of indices or zero if the mesh has no geometry.
  28750. */
  28751. getTotalIndices(): number;
  28752. /**
  28753. * Returns null by default. Implemented by child classes
  28754. * @returns null
  28755. */
  28756. getIndices(): Nullable<IndicesArray>;
  28757. /**
  28758. * Returns the array of the requested vertex data kind. Implemented by child classes
  28759. * @param kind defines the vertex data kind to use
  28760. * @returns null
  28761. */
  28762. getVerticesData(kind: string): Nullable<FloatArray>;
  28763. /**
  28764. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28765. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28766. * Note that a new underlying VertexBuffer object is created each call.
  28767. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28768. * @param kind defines vertex data kind:
  28769. * * VertexBuffer.PositionKind
  28770. * * VertexBuffer.UVKind
  28771. * * VertexBuffer.UV2Kind
  28772. * * VertexBuffer.UV3Kind
  28773. * * VertexBuffer.UV4Kind
  28774. * * VertexBuffer.UV5Kind
  28775. * * VertexBuffer.UV6Kind
  28776. * * VertexBuffer.ColorKind
  28777. * * VertexBuffer.MatricesIndicesKind
  28778. * * VertexBuffer.MatricesIndicesExtraKind
  28779. * * VertexBuffer.MatricesWeightsKind
  28780. * * VertexBuffer.MatricesWeightsExtraKind
  28781. * @param data defines the data source
  28782. * @param updatable defines if the data must be flagged as updatable (or static)
  28783. * @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
  28784. * @returns the current mesh
  28785. */
  28786. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28787. /**
  28788. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28789. * If the mesh has no geometry, it is simply returned as it is.
  28790. * @param kind defines vertex data kind:
  28791. * * VertexBuffer.PositionKind
  28792. * * VertexBuffer.UVKind
  28793. * * VertexBuffer.UV2Kind
  28794. * * VertexBuffer.UV3Kind
  28795. * * VertexBuffer.UV4Kind
  28796. * * VertexBuffer.UV5Kind
  28797. * * VertexBuffer.UV6Kind
  28798. * * VertexBuffer.ColorKind
  28799. * * VertexBuffer.MatricesIndicesKind
  28800. * * VertexBuffer.MatricesIndicesExtraKind
  28801. * * VertexBuffer.MatricesWeightsKind
  28802. * * VertexBuffer.MatricesWeightsExtraKind
  28803. * @param data defines the data source
  28804. * @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
  28805. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28806. * @returns the current mesh
  28807. */
  28808. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28809. /**
  28810. * Sets the mesh indices,
  28811. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28812. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28813. * @param totalVertices Defines the total number of vertices
  28814. * @returns the current mesh
  28815. */
  28816. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28817. /**
  28818. * Gets a boolean indicating if specific vertex data is present
  28819. * @param kind defines the vertex data kind to use
  28820. * @returns true is data kind is present
  28821. */
  28822. isVerticesDataPresent(kind: string): boolean;
  28823. /**
  28824. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28825. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28826. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28827. * @returns a BoundingInfo
  28828. */
  28829. getBoundingInfo(): BoundingInfo;
  28830. /**
  28831. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28832. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28833. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28834. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28835. * @returns the current mesh
  28836. */
  28837. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28838. /**
  28839. * Overwrite the current bounding info
  28840. * @param boundingInfo defines the new bounding info
  28841. * @returns the current mesh
  28842. */
  28843. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28844. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28845. get useBones(): boolean;
  28846. /** @hidden */
  28847. _preActivate(): void;
  28848. /** @hidden */
  28849. _preActivateForIntermediateRendering(renderId: number): void;
  28850. /** @hidden */
  28851. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28852. /** @hidden */
  28853. _postActivate(): void;
  28854. /** @hidden */
  28855. _freeze(): void;
  28856. /** @hidden */
  28857. _unFreeze(): void;
  28858. /**
  28859. * Gets the current world matrix
  28860. * @returns a Matrix
  28861. */
  28862. getWorldMatrix(): Matrix;
  28863. /** @hidden */
  28864. _getWorldMatrixDeterminant(): number;
  28865. /**
  28866. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28867. */
  28868. get isAnInstance(): boolean;
  28869. /**
  28870. * Gets a boolean indicating if this mesh has instances
  28871. */
  28872. get hasInstances(): boolean;
  28873. /**
  28874. * Perform relative position change from the point of view of behind the front of the mesh.
  28875. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28876. * Supports definition of mesh facing forward or backward
  28877. * @param amountRight defines the distance on the right axis
  28878. * @param amountUp defines the distance on the up axis
  28879. * @param amountForward defines the distance on the forward axis
  28880. * @returns the current mesh
  28881. */
  28882. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28883. /**
  28884. * Calculate relative position change from the point of view of behind the front of the mesh.
  28885. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28886. * Supports definition of mesh facing forward or backward
  28887. * @param amountRight defines the distance on the right axis
  28888. * @param amountUp defines the distance on the up axis
  28889. * @param amountForward defines the distance on the forward axis
  28890. * @returns the new displacement vector
  28891. */
  28892. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28893. /**
  28894. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28895. * Supports definition of mesh facing forward or backward
  28896. * @param flipBack defines the flip
  28897. * @param twirlClockwise defines the twirl
  28898. * @param tiltRight defines the tilt
  28899. * @returns the current mesh
  28900. */
  28901. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28902. /**
  28903. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28904. * Supports definition of mesh facing forward or backward.
  28905. * @param flipBack defines the flip
  28906. * @param twirlClockwise defines the twirl
  28907. * @param tiltRight defines the tilt
  28908. * @returns the new rotation vector
  28909. */
  28910. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28911. /**
  28912. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28913. * This means the mesh underlying bounding box and sphere are recomputed.
  28914. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28915. * @returns the current mesh
  28916. */
  28917. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28918. /** @hidden */
  28919. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28920. /** @hidden */
  28921. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28922. /** @hidden */
  28923. _updateBoundingInfo(): AbstractMesh;
  28924. /** @hidden */
  28925. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28926. /** @hidden */
  28927. protected _afterComputeWorldMatrix(): void;
  28928. /** @hidden */
  28929. get _effectiveMesh(): AbstractMesh;
  28930. /**
  28931. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28932. * A mesh is in the frustum if its bounding box intersects the frustum
  28933. * @param frustumPlanes defines the frustum to test
  28934. * @returns true if the mesh is in the frustum planes
  28935. */
  28936. isInFrustum(frustumPlanes: Plane[]): boolean;
  28937. /**
  28938. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28939. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28940. * @param frustumPlanes defines the frustum to test
  28941. * @returns true if the mesh is completely in the frustum planes
  28942. */
  28943. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28944. /**
  28945. * True if the mesh intersects another mesh or a SolidParticle object
  28946. * @param mesh defines a target mesh or SolidParticle to test
  28947. * @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)
  28948. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28949. * @returns true if there is an intersection
  28950. */
  28951. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28952. /**
  28953. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28954. * @param point defines the point to test
  28955. * @returns true if there is an intersection
  28956. */
  28957. intersectsPoint(point: Vector3): boolean;
  28958. /**
  28959. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28960. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28961. */
  28962. get checkCollisions(): boolean;
  28963. set checkCollisions(collisionEnabled: boolean);
  28964. /**
  28965. * Gets Collider object used to compute collisions (not physics)
  28966. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28967. */
  28968. get collider(): Nullable<Collider>;
  28969. /**
  28970. * Move the mesh using collision engine
  28971. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28972. * @param displacement defines the requested displacement vector
  28973. * @returns the current mesh
  28974. */
  28975. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28976. private _onCollisionPositionChange;
  28977. /** @hidden */
  28978. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28979. /** @hidden */
  28980. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28981. /** @hidden */
  28982. _checkCollision(collider: Collider): AbstractMesh;
  28983. /** @hidden */
  28984. _generatePointsArray(): boolean;
  28985. /**
  28986. * Checks if the passed Ray intersects with the mesh
  28987. * @param ray defines the ray to use
  28988. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28989. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28990. * @returns the picking info
  28991. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28992. */
  28993. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28994. /**
  28995. * Clones the current mesh
  28996. * @param name defines the mesh name
  28997. * @param newParent defines the new mesh parent
  28998. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28999. * @returns the new mesh
  29000. */
  29001. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29002. /**
  29003. * Disposes all the submeshes of the current meshnp
  29004. * @returns the current mesh
  29005. */
  29006. releaseSubMeshes(): AbstractMesh;
  29007. /**
  29008. * Releases resources associated with this abstract mesh.
  29009. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29010. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29011. */
  29012. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29013. /**
  29014. * Adds the passed mesh as a child to the current mesh
  29015. * @param mesh defines the child mesh
  29016. * @returns the current mesh
  29017. */
  29018. addChild(mesh: AbstractMesh): AbstractMesh;
  29019. /**
  29020. * Removes the passed mesh from the current mesh children list
  29021. * @param mesh defines the child mesh
  29022. * @returns the current mesh
  29023. */
  29024. removeChild(mesh: AbstractMesh): AbstractMesh;
  29025. /** @hidden */
  29026. private _initFacetData;
  29027. /**
  29028. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29029. * This method can be called within the render loop.
  29030. * 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
  29031. * @returns the current mesh
  29032. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29033. */
  29034. updateFacetData(): AbstractMesh;
  29035. /**
  29036. * Returns the facetLocalNormals array.
  29037. * The normals are expressed in the mesh local spac
  29038. * @returns an array of Vector3
  29039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29040. */
  29041. getFacetLocalNormals(): Vector3[];
  29042. /**
  29043. * Returns the facetLocalPositions array.
  29044. * The facet positions are expressed in the mesh local space
  29045. * @returns an array of Vector3
  29046. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29047. */
  29048. getFacetLocalPositions(): Vector3[];
  29049. /**
  29050. * Returns the facetLocalPartioning array
  29051. * @returns an array of array of numbers
  29052. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29053. */
  29054. getFacetLocalPartitioning(): number[][];
  29055. /**
  29056. * Returns the i-th facet position in the world system.
  29057. * This method allocates a new Vector3 per call
  29058. * @param i defines the facet index
  29059. * @returns a new Vector3
  29060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29061. */
  29062. getFacetPosition(i: number): Vector3;
  29063. /**
  29064. * Sets the reference Vector3 with the i-th facet position in the world system
  29065. * @param i defines the facet index
  29066. * @param ref defines the target vector
  29067. * @returns the current mesh
  29068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29069. */
  29070. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29071. /**
  29072. * Returns the i-th facet normal in the world system.
  29073. * This method allocates a new Vector3 per call
  29074. * @param i defines the facet index
  29075. * @returns a new Vector3
  29076. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29077. */
  29078. getFacetNormal(i: number): Vector3;
  29079. /**
  29080. * Sets the reference Vector3 with the i-th facet normal in the world system
  29081. * @param i defines the facet index
  29082. * @param ref defines the target vector
  29083. * @returns the current mesh
  29084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29085. */
  29086. getFacetNormalToRef(i: number, ref: Vector3): this;
  29087. /**
  29088. * 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)
  29089. * @param x defines x coordinate
  29090. * @param y defines y coordinate
  29091. * @param z defines z coordinate
  29092. * @returns the array of facet indexes
  29093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29094. */
  29095. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29096. /**
  29097. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29098. * @param projected sets as the (x,y,z) world projection on the facet
  29099. * @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
  29100. * @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
  29101. * @param x defines x coordinate
  29102. * @param y defines y coordinate
  29103. * @param z defines z coordinate
  29104. * @returns the face index if found (or null instead)
  29105. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29106. */
  29107. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29108. /**
  29109. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29110. * @param projected sets as the (x,y,z) local projection on the facet
  29111. * @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
  29112. * @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
  29113. * @param x defines x coordinate
  29114. * @param y defines y coordinate
  29115. * @param z defines z coordinate
  29116. * @returns the face index if found (or null instead)
  29117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29118. */
  29119. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29120. /**
  29121. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29122. * @returns the parameters
  29123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29124. */
  29125. getFacetDataParameters(): any;
  29126. /**
  29127. * Disables the feature FacetData and frees the related memory
  29128. * @returns the current mesh
  29129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29130. */
  29131. disableFacetData(): AbstractMesh;
  29132. /**
  29133. * Updates the AbstractMesh indices array
  29134. * @param indices defines the data source
  29135. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29136. * @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)
  29137. * @returns the current mesh
  29138. */
  29139. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29140. /**
  29141. * Creates new normals data for the mesh
  29142. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29143. * @returns the current mesh
  29144. */
  29145. createNormals(updatable: boolean): AbstractMesh;
  29146. /**
  29147. * Align the mesh with a normal
  29148. * @param normal defines the normal to use
  29149. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29150. * @returns the current mesh
  29151. */
  29152. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29153. /** @hidden */
  29154. _checkOcclusionQuery(): boolean;
  29155. /**
  29156. * Disables the mesh edge rendering mode
  29157. * @returns the currentAbstractMesh
  29158. */
  29159. disableEdgesRendering(): AbstractMesh;
  29160. /**
  29161. * Enables the edge rendering mode on the mesh.
  29162. * This mode makes the mesh edges visible
  29163. * @param epsilon defines the maximal distance between two angles to detect a face
  29164. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29165. * @returns the currentAbstractMesh
  29166. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29167. */
  29168. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29169. }
  29170. }
  29171. declare module "babylonjs/Actions/actionEvent" {
  29172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29173. import { Nullable } from "babylonjs/types";
  29174. import { Sprite } from "babylonjs/Sprites/sprite";
  29175. import { Scene } from "babylonjs/scene";
  29176. import { Vector2 } from "babylonjs/Maths/math.vector";
  29177. /**
  29178. * Interface used to define ActionEvent
  29179. */
  29180. export interface IActionEvent {
  29181. /** The mesh or sprite that triggered the action */
  29182. source: any;
  29183. /** The X mouse cursor position at the time of the event */
  29184. pointerX: number;
  29185. /** The Y mouse cursor position at the time of the event */
  29186. pointerY: number;
  29187. /** The mesh that is currently pointed at (can be null) */
  29188. meshUnderPointer: Nullable<AbstractMesh>;
  29189. /** the original (browser) event that triggered the ActionEvent */
  29190. sourceEvent?: any;
  29191. /** additional data for the event */
  29192. additionalData?: any;
  29193. }
  29194. /**
  29195. * ActionEvent is the event being sent when an action is triggered.
  29196. */
  29197. export class ActionEvent implements IActionEvent {
  29198. /** The mesh or sprite that triggered the action */
  29199. source: any;
  29200. /** The X mouse cursor position at the time of the event */
  29201. pointerX: number;
  29202. /** The Y mouse cursor position at the time of the event */
  29203. pointerY: number;
  29204. /** The mesh that is currently pointed at (can be null) */
  29205. meshUnderPointer: Nullable<AbstractMesh>;
  29206. /** the original (browser) event that triggered the ActionEvent */
  29207. sourceEvent?: any;
  29208. /** additional data for the event */
  29209. additionalData?: any;
  29210. /**
  29211. * Creates a new ActionEvent
  29212. * @param source The mesh or sprite that triggered the action
  29213. * @param pointerX The X mouse cursor position at the time of the event
  29214. * @param pointerY The Y mouse cursor position at the time of the event
  29215. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29216. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29217. * @param additionalData additional data for the event
  29218. */
  29219. constructor(
  29220. /** The mesh or sprite that triggered the action */
  29221. source: any,
  29222. /** The X mouse cursor position at the time of the event */
  29223. pointerX: number,
  29224. /** The Y mouse cursor position at the time of the event */
  29225. pointerY: number,
  29226. /** The mesh that is currently pointed at (can be null) */
  29227. meshUnderPointer: Nullable<AbstractMesh>,
  29228. /** the original (browser) event that triggered the ActionEvent */
  29229. sourceEvent?: any,
  29230. /** additional data for the event */
  29231. additionalData?: any);
  29232. /**
  29233. * Helper function to auto-create an ActionEvent from a source mesh.
  29234. * @param source The source mesh that triggered the event
  29235. * @param evt The original (browser) event
  29236. * @param additionalData additional data for the event
  29237. * @returns the new ActionEvent
  29238. */
  29239. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29240. /**
  29241. * Helper function to auto-create an ActionEvent from a source sprite
  29242. * @param source The source sprite that triggered the event
  29243. * @param scene Scene associated with the sprite
  29244. * @param evt The original (browser) event
  29245. * @param additionalData additional data for the event
  29246. * @returns the new ActionEvent
  29247. */
  29248. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29249. /**
  29250. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29251. * @param scene the scene where the event occurred
  29252. * @param evt The original (browser) event
  29253. * @returns the new ActionEvent
  29254. */
  29255. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29256. /**
  29257. * Helper function to auto-create an ActionEvent from a primitive
  29258. * @param prim defines the target primitive
  29259. * @param pointerPos defines the pointer position
  29260. * @param evt The original (browser) event
  29261. * @param additionalData additional data for the event
  29262. * @returns the new ActionEvent
  29263. */
  29264. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29265. }
  29266. }
  29267. declare module "babylonjs/Actions/abstractActionManager" {
  29268. import { IDisposable } from "babylonjs/scene";
  29269. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29270. import { IAction } from "babylonjs/Actions/action";
  29271. import { Nullable } from "babylonjs/types";
  29272. /**
  29273. * Abstract class used to decouple action Manager from scene and meshes.
  29274. * Do not instantiate.
  29275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29276. */
  29277. export abstract class AbstractActionManager implements IDisposable {
  29278. /** Gets the list of active triggers */
  29279. static Triggers: {
  29280. [key: string]: number;
  29281. };
  29282. /** Gets the cursor to use when hovering items */
  29283. hoverCursor: string;
  29284. /** Gets the list of actions */
  29285. actions: IAction[];
  29286. /**
  29287. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29288. */
  29289. isRecursive: boolean;
  29290. /**
  29291. * Releases all associated resources
  29292. */
  29293. abstract dispose(): void;
  29294. /**
  29295. * Does this action manager has pointer triggers
  29296. */
  29297. abstract get hasPointerTriggers(): boolean;
  29298. /**
  29299. * Does this action manager has pick triggers
  29300. */
  29301. abstract get hasPickTriggers(): boolean;
  29302. /**
  29303. * Process a specific trigger
  29304. * @param trigger defines the trigger to process
  29305. * @param evt defines the event details to be processed
  29306. */
  29307. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29308. /**
  29309. * Does this action manager handles actions of any of the given triggers
  29310. * @param triggers defines the triggers to be tested
  29311. * @return a boolean indicating whether one (or more) of the triggers is handled
  29312. */
  29313. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29314. /**
  29315. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29316. * speed.
  29317. * @param triggerA defines the trigger to be tested
  29318. * @param triggerB defines the trigger to be tested
  29319. * @return a boolean indicating whether one (or more) of the triggers is handled
  29320. */
  29321. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29322. /**
  29323. * Does this action manager handles actions of a given trigger
  29324. * @param trigger defines the trigger to be tested
  29325. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29326. * @return whether the trigger is handled
  29327. */
  29328. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29329. /**
  29330. * Serialize this manager to a JSON object
  29331. * @param name defines the property name to store this manager
  29332. * @returns a JSON representation of this manager
  29333. */
  29334. abstract serialize(name: string): any;
  29335. /**
  29336. * Registers an action to this action manager
  29337. * @param action defines the action to be registered
  29338. * @return the action amended (prepared) after registration
  29339. */
  29340. abstract registerAction(action: IAction): Nullable<IAction>;
  29341. /**
  29342. * Unregisters an action to this action manager
  29343. * @param action defines the action to be unregistered
  29344. * @return a boolean indicating whether the action has been unregistered
  29345. */
  29346. abstract unregisterAction(action: IAction): Boolean;
  29347. /**
  29348. * Does exist one action manager with at least one trigger
  29349. **/
  29350. static get HasTriggers(): boolean;
  29351. /**
  29352. * Does exist one action manager with at least one pick trigger
  29353. **/
  29354. static get HasPickTriggers(): boolean;
  29355. /**
  29356. * Does exist one action manager that handles actions of a given trigger
  29357. * @param trigger defines the trigger to be tested
  29358. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29359. **/
  29360. static HasSpecificTrigger(trigger: number): boolean;
  29361. }
  29362. }
  29363. declare module "babylonjs/node" {
  29364. import { Scene } from "babylonjs/scene";
  29365. import { Nullable } from "babylonjs/types";
  29366. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29367. import { Engine } from "babylonjs/Engines/engine";
  29368. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29369. import { Observable } from "babylonjs/Misc/observable";
  29370. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29371. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29372. import { Animatable } from "babylonjs/Animations/animatable";
  29373. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29374. import { Animation } from "babylonjs/Animations/animation";
  29375. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29377. /**
  29378. * Defines how a node can be built from a string name.
  29379. */
  29380. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29381. /**
  29382. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29383. */
  29384. export class Node implements IBehaviorAware<Node> {
  29385. /** @hidden */
  29386. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29387. private static _NodeConstructors;
  29388. /**
  29389. * Add a new node constructor
  29390. * @param type defines the type name of the node to construct
  29391. * @param constructorFunc defines the constructor function
  29392. */
  29393. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29394. /**
  29395. * Returns a node constructor based on type name
  29396. * @param type defines the type name
  29397. * @param name defines the new node name
  29398. * @param scene defines the hosting scene
  29399. * @param options defines optional options to transmit to constructors
  29400. * @returns the new constructor or null
  29401. */
  29402. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29403. /**
  29404. * Gets or sets the name of the node
  29405. */
  29406. name: string;
  29407. /**
  29408. * Gets or sets the id of the node
  29409. */
  29410. id: string;
  29411. /**
  29412. * Gets or sets the unique id of the node
  29413. */
  29414. uniqueId: number;
  29415. /**
  29416. * Gets or sets a string used to store user defined state for the node
  29417. */
  29418. state: string;
  29419. /**
  29420. * Gets or sets an object used to store user defined information for the node
  29421. */
  29422. metadata: any;
  29423. /**
  29424. * For internal use only. Please do not use.
  29425. */
  29426. reservedDataStore: any;
  29427. /**
  29428. * List of inspectable custom properties (used by the Inspector)
  29429. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29430. */
  29431. inspectableCustomProperties: IInspectable[];
  29432. private _doNotSerialize;
  29433. /**
  29434. * Gets or sets a boolean used to define if the node must be serialized
  29435. */
  29436. get doNotSerialize(): boolean;
  29437. set doNotSerialize(value: boolean);
  29438. /** @hidden */
  29439. _isDisposed: boolean;
  29440. /**
  29441. * Gets a list of Animations associated with the node
  29442. */
  29443. animations: import("babylonjs/Animations/animation").Animation[];
  29444. protected _ranges: {
  29445. [name: string]: Nullable<AnimationRange>;
  29446. };
  29447. /**
  29448. * Callback raised when the node is ready to be used
  29449. */
  29450. onReady: Nullable<(node: Node) => void>;
  29451. private _isEnabled;
  29452. private _isParentEnabled;
  29453. private _isReady;
  29454. /** @hidden */
  29455. _currentRenderId: number;
  29456. private _parentUpdateId;
  29457. /** @hidden */
  29458. _childUpdateId: number;
  29459. /** @hidden */
  29460. _waitingParentId: Nullable<string>;
  29461. /** @hidden */
  29462. _scene: Scene;
  29463. /** @hidden */
  29464. _cache: any;
  29465. private _parentNode;
  29466. private _children;
  29467. /** @hidden */
  29468. _worldMatrix: Matrix;
  29469. /** @hidden */
  29470. _worldMatrixDeterminant: number;
  29471. /** @hidden */
  29472. _worldMatrixDeterminantIsDirty: boolean;
  29473. /** @hidden */
  29474. private _sceneRootNodesIndex;
  29475. /**
  29476. * Gets a boolean indicating if the node has been disposed
  29477. * @returns true if the node was disposed
  29478. */
  29479. isDisposed(): boolean;
  29480. /**
  29481. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29482. * @see https://doc.babylonjs.com/how_to/parenting
  29483. */
  29484. set parent(parent: Nullable<Node>);
  29485. get parent(): Nullable<Node>;
  29486. /** @hidden */
  29487. _addToSceneRootNodes(): void;
  29488. /** @hidden */
  29489. _removeFromSceneRootNodes(): void;
  29490. private _animationPropertiesOverride;
  29491. /**
  29492. * Gets or sets the animation properties override
  29493. */
  29494. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29495. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29496. /**
  29497. * Gets a string idenfifying the name of the class
  29498. * @returns "Node" string
  29499. */
  29500. getClassName(): string;
  29501. /** @hidden */
  29502. readonly _isNode: boolean;
  29503. /**
  29504. * An event triggered when the mesh is disposed
  29505. */
  29506. onDisposeObservable: Observable<Node>;
  29507. private _onDisposeObserver;
  29508. /**
  29509. * Sets a callback that will be raised when the node will be disposed
  29510. */
  29511. set onDispose(callback: () => void);
  29512. /**
  29513. * Creates a new Node
  29514. * @param name the name and id to be given to this node
  29515. * @param scene the scene this node will be added to
  29516. */
  29517. constructor(name: string, scene?: Nullable<Scene>);
  29518. /**
  29519. * Gets the scene of the node
  29520. * @returns a scene
  29521. */
  29522. getScene(): Scene;
  29523. /**
  29524. * Gets the engine of the node
  29525. * @returns a Engine
  29526. */
  29527. getEngine(): Engine;
  29528. private _behaviors;
  29529. /**
  29530. * Attach a behavior to the node
  29531. * @see http://doc.babylonjs.com/features/behaviour
  29532. * @param behavior defines the behavior to attach
  29533. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29534. * @returns the current Node
  29535. */
  29536. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29537. /**
  29538. * Remove an attached behavior
  29539. * @see http://doc.babylonjs.com/features/behaviour
  29540. * @param behavior defines the behavior to attach
  29541. * @returns the current Node
  29542. */
  29543. removeBehavior(behavior: Behavior<Node>): Node;
  29544. /**
  29545. * Gets the list of attached behaviors
  29546. * @see http://doc.babylonjs.com/features/behaviour
  29547. */
  29548. get behaviors(): Behavior<Node>[];
  29549. /**
  29550. * Gets an attached behavior by name
  29551. * @param name defines the name of the behavior to look for
  29552. * @see http://doc.babylonjs.com/features/behaviour
  29553. * @returns null if behavior was not found else the requested behavior
  29554. */
  29555. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29556. /**
  29557. * Returns the latest update of the World matrix
  29558. * @returns a Matrix
  29559. */
  29560. getWorldMatrix(): Matrix;
  29561. /** @hidden */
  29562. _getWorldMatrixDeterminant(): number;
  29563. /**
  29564. * Returns directly the latest state of the mesh World matrix.
  29565. * A Matrix is returned.
  29566. */
  29567. get worldMatrixFromCache(): Matrix;
  29568. /** @hidden */
  29569. _initCache(): void;
  29570. /** @hidden */
  29571. updateCache(force?: boolean): void;
  29572. /** @hidden */
  29573. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29574. /** @hidden */
  29575. _updateCache(ignoreParentClass?: boolean): void;
  29576. /** @hidden */
  29577. _isSynchronized(): boolean;
  29578. /** @hidden */
  29579. _markSyncedWithParent(): void;
  29580. /** @hidden */
  29581. isSynchronizedWithParent(): boolean;
  29582. /** @hidden */
  29583. isSynchronized(): boolean;
  29584. /**
  29585. * Is this node ready to be used/rendered
  29586. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29587. * @return true if the node is ready
  29588. */
  29589. isReady(completeCheck?: boolean): boolean;
  29590. /**
  29591. * Is this node enabled?
  29592. * 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
  29593. * @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
  29594. * @return whether this node (and its parent) is enabled
  29595. */
  29596. isEnabled(checkAncestors?: boolean): boolean;
  29597. /** @hidden */
  29598. protected _syncParentEnabledState(): void;
  29599. /**
  29600. * Set the enabled state of this node
  29601. * @param value defines the new enabled state
  29602. */
  29603. setEnabled(value: boolean): void;
  29604. /**
  29605. * Is this node a descendant of the given node?
  29606. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29607. * @param ancestor defines the parent node to inspect
  29608. * @returns a boolean indicating if this node is a descendant of the given node
  29609. */
  29610. isDescendantOf(ancestor: Node): boolean;
  29611. /** @hidden */
  29612. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29613. /**
  29614. * Will return all nodes that have this node as ascendant
  29615. * @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
  29616. * @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
  29617. * @return all children nodes of all types
  29618. */
  29619. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29620. /**
  29621. * Get all child-meshes of this node
  29622. * @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)
  29623. * @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
  29624. * @returns an array of AbstractMesh
  29625. */
  29626. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29627. /**
  29628. * Get all direct children of this node
  29629. * @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
  29630. * @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)
  29631. * @returns an array of Node
  29632. */
  29633. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29634. /** @hidden */
  29635. _setReady(state: boolean): void;
  29636. /**
  29637. * Get an animation by name
  29638. * @param name defines the name of the animation to look for
  29639. * @returns null if not found else the requested animation
  29640. */
  29641. getAnimationByName(name: string): Nullable<Animation>;
  29642. /**
  29643. * Creates an animation range for this node
  29644. * @param name defines the name of the range
  29645. * @param from defines the starting key
  29646. * @param to defines the end key
  29647. */
  29648. createAnimationRange(name: string, from: number, to: number): void;
  29649. /**
  29650. * Delete a specific animation range
  29651. * @param name defines the name of the range to delete
  29652. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29653. */
  29654. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29655. /**
  29656. * Get an animation range by name
  29657. * @param name defines the name of the animation range to look for
  29658. * @returns null if not found else the requested animation range
  29659. */
  29660. getAnimationRange(name: string): Nullable<AnimationRange>;
  29661. /**
  29662. * Gets the list of all animation ranges defined on this node
  29663. * @returns an array
  29664. */
  29665. getAnimationRanges(): Nullable<AnimationRange>[];
  29666. /**
  29667. * Will start the animation sequence
  29668. * @param name defines the range frames for animation sequence
  29669. * @param loop defines if the animation should loop (false by default)
  29670. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29671. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29672. * @returns the object created for this animation. If range does not exist, it will return null
  29673. */
  29674. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29675. /**
  29676. * Serialize animation ranges into a JSON compatible object
  29677. * @returns serialization object
  29678. */
  29679. serializeAnimationRanges(): any;
  29680. /**
  29681. * Computes the world matrix of the node
  29682. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29683. * @returns the world matrix
  29684. */
  29685. computeWorldMatrix(force?: boolean): Matrix;
  29686. /**
  29687. * Releases resources associated with this node.
  29688. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29689. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29690. */
  29691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29692. /**
  29693. * Parse animation range data from a serialization object and store them into a given node
  29694. * @param node defines where to store the animation ranges
  29695. * @param parsedNode defines the serialization object to read data from
  29696. * @param scene defines the hosting scene
  29697. */
  29698. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29699. /**
  29700. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29701. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29702. * @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
  29703. * @returns the new bounding vectors
  29704. */
  29705. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29706. min: Vector3;
  29707. max: Vector3;
  29708. };
  29709. }
  29710. }
  29711. declare module "babylonjs/Animations/animation" {
  29712. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29713. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29714. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29715. import { Nullable } from "babylonjs/types";
  29716. import { Scene } from "babylonjs/scene";
  29717. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29718. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29719. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29720. import { Node } from "babylonjs/node";
  29721. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29722. import { Size } from "babylonjs/Maths/math.size";
  29723. import { Animatable } from "babylonjs/Animations/animatable";
  29724. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29725. /**
  29726. * @hidden
  29727. */
  29728. export class _IAnimationState {
  29729. key: number;
  29730. repeatCount: number;
  29731. workValue?: any;
  29732. loopMode?: number;
  29733. offsetValue?: any;
  29734. highLimitValue?: any;
  29735. }
  29736. /**
  29737. * Class used to store any kind of animation
  29738. */
  29739. export class Animation {
  29740. /**Name of the animation */
  29741. name: string;
  29742. /**Property to animate */
  29743. targetProperty: string;
  29744. /**The frames per second of the animation */
  29745. framePerSecond: number;
  29746. /**The data type of the animation */
  29747. dataType: number;
  29748. /**The loop mode of the animation */
  29749. loopMode?: number | undefined;
  29750. /**Specifies if blending should be enabled */
  29751. enableBlending?: boolean | undefined;
  29752. /**
  29753. * Use matrix interpolation instead of using direct key value when animating matrices
  29754. */
  29755. static AllowMatricesInterpolation: boolean;
  29756. /**
  29757. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29758. */
  29759. static AllowMatrixDecomposeForInterpolation: boolean;
  29760. /**
  29761. * Stores the key frames of the animation
  29762. */
  29763. private _keys;
  29764. /**
  29765. * Stores the easing function of the animation
  29766. */
  29767. private _easingFunction;
  29768. /**
  29769. * @hidden Internal use only
  29770. */
  29771. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29772. /**
  29773. * The set of event that will be linked to this animation
  29774. */
  29775. private _events;
  29776. /**
  29777. * Stores an array of target property paths
  29778. */
  29779. targetPropertyPath: string[];
  29780. /**
  29781. * Stores the blending speed of the animation
  29782. */
  29783. blendingSpeed: number;
  29784. /**
  29785. * Stores the animation ranges for the animation
  29786. */
  29787. private _ranges;
  29788. /**
  29789. * @hidden Internal use
  29790. */
  29791. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29792. /**
  29793. * Sets up an animation
  29794. * @param property The property to animate
  29795. * @param animationType The animation type to apply
  29796. * @param framePerSecond The frames per second of the animation
  29797. * @param easingFunction The easing function used in the animation
  29798. * @returns The created animation
  29799. */
  29800. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29801. /**
  29802. * Create and start an animation on a node
  29803. * @param name defines the name of the global animation that will be run on all nodes
  29804. * @param node defines the root node where the animation will take place
  29805. * @param targetProperty defines property to animate
  29806. * @param framePerSecond defines the number of frame per second yo use
  29807. * @param totalFrame defines the number of frames in total
  29808. * @param from defines the initial value
  29809. * @param to defines the final value
  29810. * @param loopMode defines which loop mode you want to use (off by default)
  29811. * @param easingFunction defines the easing function to use (linear by default)
  29812. * @param onAnimationEnd defines the callback to call when animation end
  29813. * @returns the animatable created for this animation
  29814. */
  29815. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29816. /**
  29817. * Create and start an animation on a node and its descendants
  29818. * @param name defines the name of the global animation that will be run on all nodes
  29819. * @param node defines the root node where the animation will take place
  29820. * @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
  29821. * @param targetProperty defines property to animate
  29822. * @param framePerSecond defines the number of frame per second to use
  29823. * @param totalFrame defines the number of frames in total
  29824. * @param from defines the initial value
  29825. * @param to defines the final value
  29826. * @param loopMode defines which loop mode you want to use (off by default)
  29827. * @param easingFunction defines the easing function to use (linear by default)
  29828. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29829. * @returns the list of animatables created for all nodes
  29830. * @example https://www.babylonjs-playground.com/#MH0VLI
  29831. */
  29832. 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[]>;
  29833. /**
  29834. * Creates a new animation, merges it with the existing animations and starts it
  29835. * @param name Name of the animation
  29836. * @param node Node which contains the scene that begins the animations
  29837. * @param targetProperty Specifies which property to animate
  29838. * @param framePerSecond The frames per second of the animation
  29839. * @param totalFrame The total number of frames
  29840. * @param from The frame at the beginning of the animation
  29841. * @param to The frame at the end of the animation
  29842. * @param loopMode Specifies the loop mode of the animation
  29843. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29844. * @param onAnimationEnd Callback to run once the animation is complete
  29845. * @returns Nullable animation
  29846. */
  29847. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29848. /**
  29849. * Transition property of an host to the target Value
  29850. * @param property The property to transition
  29851. * @param targetValue The target Value of the property
  29852. * @param host The object where the property to animate belongs
  29853. * @param scene Scene used to run the animation
  29854. * @param frameRate Framerate (in frame/s) to use
  29855. * @param transition The transition type we want to use
  29856. * @param duration The duration of the animation, in milliseconds
  29857. * @param onAnimationEnd Callback trigger at the end of the animation
  29858. * @returns Nullable animation
  29859. */
  29860. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29861. /**
  29862. * Return the array of runtime animations currently using this animation
  29863. */
  29864. get runtimeAnimations(): RuntimeAnimation[];
  29865. /**
  29866. * Specifies if any of the runtime animations are currently running
  29867. */
  29868. get hasRunningRuntimeAnimations(): boolean;
  29869. /**
  29870. * Initializes the animation
  29871. * @param name Name of the animation
  29872. * @param targetProperty Property to animate
  29873. * @param framePerSecond The frames per second of the animation
  29874. * @param dataType The data type of the animation
  29875. * @param loopMode The loop mode of the animation
  29876. * @param enableBlending Specifies if blending should be enabled
  29877. */
  29878. constructor(
  29879. /**Name of the animation */
  29880. name: string,
  29881. /**Property to animate */
  29882. targetProperty: string,
  29883. /**The frames per second of the animation */
  29884. framePerSecond: number,
  29885. /**The data type of the animation */
  29886. dataType: number,
  29887. /**The loop mode of the animation */
  29888. loopMode?: number | undefined,
  29889. /**Specifies if blending should be enabled */
  29890. enableBlending?: boolean | undefined);
  29891. /**
  29892. * Converts the animation to a string
  29893. * @param fullDetails support for multiple levels of logging within scene loading
  29894. * @returns String form of the animation
  29895. */
  29896. toString(fullDetails?: boolean): string;
  29897. /**
  29898. * Add an event to this animation
  29899. * @param event Event to add
  29900. */
  29901. addEvent(event: AnimationEvent): void;
  29902. /**
  29903. * Remove all events found at the given frame
  29904. * @param frame The frame to remove events from
  29905. */
  29906. removeEvents(frame: number): void;
  29907. /**
  29908. * Retrieves all the events from the animation
  29909. * @returns Events from the animation
  29910. */
  29911. getEvents(): AnimationEvent[];
  29912. /**
  29913. * Creates an animation range
  29914. * @param name Name of the animation range
  29915. * @param from Starting frame of the animation range
  29916. * @param to Ending frame of the animation
  29917. */
  29918. createRange(name: string, from: number, to: number): void;
  29919. /**
  29920. * Deletes an animation range by name
  29921. * @param name Name of the animation range to delete
  29922. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29923. */
  29924. deleteRange(name: string, deleteFrames?: boolean): void;
  29925. /**
  29926. * Gets the animation range by name, or null if not defined
  29927. * @param name Name of the animation range
  29928. * @returns Nullable animation range
  29929. */
  29930. getRange(name: string): Nullable<AnimationRange>;
  29931. /**
  29932. * Gets the key frames from the animation
  29933. * @returns The key frames of the animation
  29934. */
  29935. getKeys(): Array<IAnimationKey>;
  29936. /**
  29937. * Gets the highest frame rate of the animation
  29938. * @returns Highest frame rate of the animation
  29939. */
  29940. getHighestFrame(): number;
  29941. /**
  29942. * Gets the easing function of the animation
  29943. * @returns Easing function of the animation
  29944. */
  29945. getEasingFunction(): IEasingFunction;
  29946. /**
  29947. * Sets the easing function of the animation
  29948. * @param easingFunction A custom mathematical formula for animation
  29949. */
  29950. setEasingFunction(easingFunction: EasingFunction): void;
  29951. /**
  29952. * Interpolates a scalar linearly
  29953. * @param startValue Start value of the animation curve
  29954. * @param endValue End value of the animation curve
  29955. * @param gradient Scalar amount to interpolate
  29956. * @returns Interpolated scalar value
  29957. */
  29958. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29959. /**
  29960. * Interpolates a scalar cubically
  29961. * @param startValue Start value of the animation curve
  29962. * @param outTangent End tangent of the animation
  29963. * @param endValue End value of the animation curve
  29964. * @param inTangent Start tangent of the animation curve
  29965. * @param gradient Scalar amount to interpolate
  29966. * @returns Interpolated scalar value
  29967. */
  29968. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29969. /**
  29970. * Interpolates a quaternion using a spherical linear interpolation
  29971. * @param startValue Start value of the animation curve
  29972. * @param endValue End value of the animation curve
  29973. * @param gradient Scalar amount to interpolate
  29974. * @returns Interpolated quaternion value
  29975. */
  29976. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29977. /**
  29978. * Interpolates a quaternion cubically
  29979. * @param startValue Start value of the animation curve
  29980. * @param outTangent End tangent of the animation curve
  29981. * @param endValue End value of the animation curve
  29982. * @param inTangent Start tangent of the animation curve
  29983. * @param gradient Scalar amount to interpolate
  29984. * @returns Interpolated quaternion value
  29985. */
  29986. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29987. /**
  29988. * Interpolates a Vector3 linearl
  29989. * @param startValue Start value of the animation curve
  29990. * @param endValue End value of the animation curve
  29991. * @param gradient Scalar amount to interpolate
  29992. * @returns Interpolated scalar value
  29993. */
  29994. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29995. /**
  29996. * Interpolates a Vector3 cubically
  29997. * @param startValue Start value of the animation curve
  29998. * @param outTangent End tangent of the animation
  29999. * @param endValue End value of the animation curve
  30000. * @param inTangent Start tangent of the animation curve
  30001. * @param gradient Scalar amount to interpolate
  30002. * @returns InterpolatedVector3 value
  30003. */
  30004. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30005. /**
  30006. * Interpolates a Vector2 linearly
  30007. * @param startValue Start value of the animation curve
  30008. * @param endValue End value of the animation curve
  30009. * @param gradient Scalar amount to interpolate
  30010. * @returns Interpolated Vector2 value
  30011. */
  30012. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30013. /**
  30014. * Interpolates a Vector2 cubically
  30015. * @param startValue Start value of the animation curve
  30016. * @param outTangent End tangent of the animation
  30017. * @param endValue End value of the animation curve
  30018. * @param inTangent Start tangent of the animation curve
  30019. * @param gradient Scalar amount to interpolate
  30020. * @returns Interpolated Vector2 value
  30021. */
  30022. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30023. /**
  30024. * Interpolates a size linearly
  30025. * @param startValue Start value of the animation curve
  30026. * @param endValue End value of the animation curve
  30027. * @param gradient Scalar amount to interpolate
  30028. * @returns Interpolated Size value
  30029. */
  30030. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30031. /**
  30032. * Interpolates a Color3 linearly
  30033. * @param startValue Start value of the animation curve
  30034. * @param endValue End value of the animation curve
  30035. * @param gradient Scalar amount to interpolate
  30036. * @returns Interpolated Color3 value
  30037. */
  30038. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30039. /**
  30040. * Interpolates a Color4 linearly
  30041. * @param startValue Start value of the animation curve
  30042. * @param endValue End value of the animation curve
  30043. * @param gradient Scalar amount to interpolate
  30044. * @returns Interpolated Color3 value
  30045. */
  30046. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30047. /**
  30048. * @hidden Internal use only
  30049. */
  30050. _getKeyValue(value: any): any;
  30051. /**
  30052. * @hidden Internal use only
  30053. */
  30054. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30055. /**
  30056. * Defines the function to use to interpolate matrices
  30057. * @param startValue defines the start matrix
  30058. * @param endValue defines the end matrix
  30059. * @param gradient defines the gradient between both matrices
  30060. * @param result defines an optional target matrix where to store the interpolation
  30061. * @returns the interpolated matrix
  30062. */
  30063. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30064. /**
  30065. * Makes a copy of the animation
  30066. * @returns Cloned animation
  30067. */
  30068. clone(): Animation;
  30069. /**
  30070. * Sets the key frames of the animation
  30071. * @param values The animation key frames to set
  30072. */
  30073. setKeys(values: Array<IAnimationKey>): void;
  30074. /**
  30075. * Serializes the animation to an object
  30076. * @returns Serialized object
  30077. */
  30078. serialize(): any;
  30079. /**
  30080. * Float animation type
  30081. */
  30082. static readonly ANIMATIONTYPE_FLOAT: number;
  30083. /**
  30084. * Vector3 animation type
  30085. */
  30086. static readonly ANIMATIONTYPE_VECTOR3: number;
  30087. /**
  30088. * Quaternion animation type
  30089. */
  30090. static readonly ANIMATIONTYPE_QUATERNION: number;
  30091. /**
  30092. * Matrix animation type
  30093. */
  30094. static readonly ANIMATIONTYPE_MATRIX: number;
  30095. /**
  30096. * Color3 animation type
  30097. */
  30098. static readonly ANIMATIONTYPE_COLOR3: number;
  30099. /**
  30100. * Color3 animation type
  30101. */
  30102. static readonly ANIMATIONTYPE_COLOR4: number;
  30103. /**
  30104. * Vector2 animation type
  30105. */
  30106. static readonly ANIMATIONTYPE_VECTOR2: number;
  30107. /**
  30108. * Size animation type
  30109. */
  30110. static readonly ANIMATIONTYPE_SIZE: number;
  30111. /**
  30112. * Relative Loop Mode
  30113. */
  30114. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30115. /**
  30116. * Cycle Loop Mode
  30117. */
  30118. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30119. /**
  30120. * Constant Loop Mode
  30121. */
  30122. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30123. /** @hidden */
  30124. static _UniversalLerp(left: any, right: any, amount: number): any;
  30125. /**
  30126. * Parses an animation object and creates an animation
  30127. * @param parsedAnimation Parsed animation object
  30128. * @returns Animation object
  30129. */
  30130. static Parse(parsedAnimation: any): Animation;
  30131. /**
  30132. * Appends the serialized animations from the source animations
  30133. * @param source Source containing the animations
  30134. * @param destination Target to store the animations
  30135. */
  30136. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30137. }
  30138. }
  30139. declare module "babylonjs/Animations/animatable.interface" {
  30140. import { Nullable } from "babylonjs/types";
  30141. import { Animation } from "babylonjs/Animations/animation";
  30142. /**
  30143. * Interface containing an array of animations
  30144. */
  30145. export interface IAnimatable {
  30146. /**
  30147. * Array of animations
  30148. */
  30149. animations: Nullable<Array<Animation>>;
  30150. }
  30151. }
  30152. declare module "babylonjs/Misc/decorators" {
  30153. import { Nullable } from "babylonjs/types";
  30154. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30155. import { Scene } from "babylonjs/scene";
  30156. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30157. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30158. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30159. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30160. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30161. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30162. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30163. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30164. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30168. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30169. /**
  30170. * Decorator used to define property that can be serialized as reference to a camera
  30171. * @param sourceName defines the name of the property to decorate
  30172. */
  30173. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30174. /**
  30175. * Class used to help serialization objects
  30176. */
  30177. export class SerializationHelper {
  30178. /** @hidden */
  30179. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30180. /** @hidden */
  30181. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30182. /** @hidden */
  30183. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30184. /** @hidden */
  30185. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30186. /**
  30187. * Appends the serialized animations from the source animations
  30188. * @param source Source containing the animations
  30189. * @param destination Target to store the animations
  30190. */
  30191. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30192. /**
  30193. * Static function used to serialized a specific entity
  30194. * @param entity defines the entity to serialize
  30195. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30196. * @returns a JSON compatible object representing the serialization of the entity
  30197. */
  30198. static Serialize<T>(entity: T, serializationObject?: any): any;
  30199. /**
  30200. * Creates a new entity from a serialization data object
  30201. * @param creationFunction defines a function used to instanciated the new entity
  30202. * @param source defines the source serialization data
  30203. * @param scene defines the hosting scene
  30204. * @param rootUrl defines the root url for resources
  30205. * @returns a new entity
  30206. */
  30207. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30208. /**
  30209. * Clones an object
  30210. * @param creationFunction defines the function used to instanciate the new object
  30211. * @param source defines the source object
  30212. * @returns the cloned object
  30213. */
  30214. static Clone<T>(creationFunction: () => T, source: T): T;
  30215. /**
  30216. * Instanciates a new object based on a source one (some data will be shared between both object)
  30217. * @param creationFunction defines the function used to instanciate the new object
  30218. * @param source defines the source object
  30219. * @returns the new object
  30220. */
  30221. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30222. }
  30223. }
  30224. declare module "babylonjs/Misc/guid" {
  30225. /**
  30226. * Class used to manipulate GUIDs
  30227. */
  30228. export class GUID {
  30229. /**
  30230. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30231. * Be aware Math.random() could cause collisions, but:
  30232. * "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"
  30233. * @returns a pseudo random id
  30234. */
  30235. static RandomId(): string;
  30236. }
  30237. }
  30238. declare module "babylonjs/Materials/Textures/baseTexture" {
  30239. import { Observable } from "babylonjs/Misc/observable";
  30240. import { Nullable } from "babylonjs/types";
  30241. import { Scene } from "babylonjs/scene";
  30242. import { Matrix } from "babylonjs/Maths/math.vector";
  30243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30244. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30245. import { ISize } from "babylonjs/Maths/math.size";
  30246. /**
  30247. * Base class of all the textures in babylon.
  30248. * It groups all the common properties the materials, post process, lights... might need
  30249. * in order to make a correct use of the texture.
  30250. */
  30251. export class BaseTexture implements IAnimatable {
  30252. /**
  30253. * Default anisotropic filtering level for the application.
  30254. * It is set to 4 as a good tradeoff between perf and quality.
  30255. */
  30256. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30257. /**
  30258. * Gets or sets the unique id of the texture
  30259. */
  30260. uniqueId: number;
  30261. /**
  30262. * Define the name of the texture.
  30263. */
  30264. name: string;
  30265. /**
  30266. * Gets or sets an object used to store user defined information.
  30267. */
  30268. metadata: any;
  30269. /**
  30270. * For internal use only. Please do not use.
  30271. */
  30272. reservedDataStore: any;
  30273. private _hasAlpha;
  30274. /**
  30275. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30276. */
  30277. set hasAlpha(value: boolean);
  30278. get hasAlpha(): boolean;
  30279. /**
  30280. * Defines if the alpha value should be determined via the rgb values.
  30281. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30282. */
  30283. getAlphaFromRGB: boolean;
  30284. /**
  30285. * Intensity or strength of the texture.
  30286. * It is commonly used by materials to fine tune the intensity of the texture
  30287. */
  30288. level: number;
  30289. /**
  30290. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30291. * This is part of the texture as textures usually maps to one uv set.
  30292. */
  30293. coordinatesIndex: number;
  30294. private _coordinatesMode;
  30295. /**
  30296. * How a texture is mapped.
  30297. *
  30298. * | Value | Type | Description |
  30299. * | ----- | ----------------------------------- | ----------- |
  30300. * | 0 | EXPLICIT_MODE | |
  30301. * | 1 | SPHERICAL_MODE | |
  30302. * | 2 | PLANAR_MODE | |
  30303. * | 3 | CUBIC_MODE | |
  30304. * | 4 | PROJECTION_MODE | |
  30305. * | 5 | SKYBOX_MODE | |
  30306. * | 6 | INVCUBIC_MODE | |
  30307. * | 7 | EQUIRECTANGULAR_MODE | |
  30308. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30309. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30310. */
  30311. set coordinatesMode(value: number);
  30312. get coordinatesMode(): number;
  30313. /**
  30314. * | Value | Type | Description |
  30315. * | ----- | ------------------ | ----------- |
  30316. * | 0 | CLAMP_ADDRESSMODE | |
  30317. * | 1 | WRAP_ADDRESSMODE | |
  30318. * | 2 | MIRROR_ADDRESSMODE | |
  30319. */
  30320. wrapU: number;
  30321. /**
  30322. * | Value | Type | Description |
  30323. * | ----- | ------------------ | ----------- |
  30324. * | 0 | CLAMP_ADDRESSMODE | |
  30325. * | 1 | WRAP_ADDRESSMODE | |
  30326. * | 2 | MIRROR_ADDRESSMODE | |
  30327. */
  30328. wrapV: number;
  30329. /**
  30330. * | Value | Type | Description |
  30331. * | ----- | ------------------ | ----------- |
  30332. * | 0 | CLAMP_ADDRESSMODE | |
  30333. * | 1 | WRAP_ADDRESSMODE | |
  30334. * | 2 | MIRROR_ADDRESSMODE | |
  30335. */
  30336. wrapR: number;
  30337. /**
  30338. * With compliant hardware and browser (supporting anisotropic filtering)
  30339. * this defines the level of anisotropic filtering in the texture.
  30340. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30341. */
  30342. anisotropicFilteringLevel: number;
  30343. /**
  30344. * Define if the texture is a cube texture or if false a 2d texture.
  30345. */
  30346. get isCube(): boolean;
  30347. set isCube(value: boolean);
  30348. /**
  30349. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30350. */
  30351. get is3D(): boolean;
  30352. set is3D(value: boolean);
  30353. /**
  30354. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30355. */
  30356. get is2DArray(): boolean;
  30357. set is2DArray(value: boolean);
  30358. /**
  30359. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30360. * HDR texture are usually stored in linear space.
  30361. * This only impacts the PBR and Background materials
  30362. */
  30363. gammaSpace: boolean;
  30364. /**
  30365. * Gets or sets whether or not the texture contains RGBD data.
  30366. */
  30367. get isRGBD(): boolean;
  30368. set isRGBD(value: boolean);
  30369. /**
  30370. * Is Z inverted in the texture (useful in a cube texture).
  30371. */
  30372. invertZ: boolean;
  30373. /**
  30374. * Are mip maps generated for this texture or not.
  30375. */
  30376. get noMipmap(): boolean;
  30377. /**
  30378. * @hidden
  30379. */
  30380. lodLevelInAlpha: boolean;
  30381. /**
  30382. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30383. */
  30384. get lodGenerationOffset(): number;
  30385. set lodGenerationOffset(value: number);
  30386. /**
  30387. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30388. */
  30389. get lodGenerationScale(): number;
  30390. set lodGenerationScale(value: number);
  30391. /**
  30392. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30393. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30394. * average roughness values.
  30395. */
  30396. get linearSpecularLOD(): boolean;
  30397. set linearSpecularLOD(value: boolean);
  30398. /**
  30399. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30400. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30401. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30402. */
  30403. get irradianceTexture(): Nullable<BaseTexture>;
  30404. set irradianceTexture(value: Nullable<BaseTexture>);
  30405. /**
  30406. * Define if the texture is a render target.
  30407. */
  30408. isRenderTarget: boolean;
  30409. /**
  30410. * Define the unique id of the texture in the scene.
  30411. */
  30412. get uid(): string;
  30413. /**
  30414. * Return a string representation of the texture.
  30415. * @returns the texture as a string
  30416. */
  30417. toString(): string;
  30418. /**
  30419. * Get the class name of the texture.
  30420. * @returns "BaseTexture"
  30421. */
  30422. getClassName(): string;
  30423. /**
  30424. * Define the list of animation attached to the texture.
  30425. */
  30426. animations: import("babylonjs/Animations/animation").Animation[];
  30427. /**
  30428. * An event triggered when the texture is disposed.
  30429. */
  30430. onDisposeObservable: Observable<BaseTexture>;
  30431. private _onDisposeObserver;
  30432. /**
  30433. * Callback triggered when the texture has been disposed.
  30434. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30435. */
  30436. set onDispose(callback: () => void);
  30437. /**
  30438. * Define the current state of the loading sequence when in delayed load mode.
  30439. */
  30440. delayLoadState: number;
  30441. private _scene;
  30442. /** @hidden */
  30443. _texture: Nullable<InternalTexture>;
  30444. private _uid;
  30445. /**
  30446. * Define if the texture is preventinga material to render or not.
  30447. * If not and the texture is not ready, the engine will use a default black texture instead.
  30448. */
  30449. get isBlocking(): boolean;
  30450. /**
  30451. * Instantiates a new BaseTexture.
  30452. * Base class of all the textures in babylon.
  30453. * It groups all the common properties the materials, post process, lights... might need
  30454. * in order to make a correct use of the texture.
  30455. * @param scene Define the scene the texture blongs to
  30456. */
  30457. constructor(scene: Nullable<Scene>);
  30458. /**
  30459. * Get the scene the texture belongs to.
  30460. * @returns the scene or null if undefined
  30461. */
  30462. getScene(): Nullable<Scene>;
  30463. /**
  30464. * Get the texture transform matrix used to offset tile the texture for istance.
  30465. * @returns the transformation matrix
  30466. */
  30467. getTextureMatrix(): Matrix;
  30468. /**
  30469. * Get the texture reflection matrix used to rotate/transform the reflection.
  30470. * @returns the reflection matrix
  30471. */
  30472. getReflectionTextureMatrix(): Matrix;
  30473. /**
  30474. * Get the underlying lower level texture from Babylon.
  30475. * @returns the insternal texture
  30476. */
  30477. getInternalTexture(): Nullable<InternalTexture>;
  30478. /**
  30479. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30480. * @returns true if ready or not blocking
  30481. */
  30482. isReadyOrNotBlocking(): boolean;
  30483. /**
  30484. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30485. * @returns true if fully ready
  30486. */
  30487. isReady(): boolean;
  30488. private _cachedSize;
  30489. /**
  30490. * Get the size of the texture.
  30491. * @returns the texture size.
  30492. */
  30493. getSize(): ISize;
  30494. /**
  30495. * Get the base size of the texture.
  30496. * It can be different from the size if the texture has been resized for POT for instance
  30497. * @returns the base size
  30498. */
  30499. getBaseSize(): ISize;
  30500. /**
  30501. * Update the sampling mode of the texture.
  30502. * Default is Trilinear mode.
  30503. *
  30504. * | Value | Type | Description |
  30505. * | ----- | ------------------ | ----------- |
  30506. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30507. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30508. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30509. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30510. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30511. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30512. * | 7 | NEAREST_LINEAR | |
  30513. * | 8 | NEAREST_NEAREST | |
  30514. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30515. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30516. * | 11 | LINEAR_LINEAR | |
  30517. * | 12 | LINEAR_NEAREST | |
  30518. *
  30519. * > _mag_: magnification filter (close to the viewer)
  30520. * > _min_: minification filter (far from the viewer)
  30521. * > _mip_: filter used between mip map levels
  30522. *@param samplingMode Define the new sampling mode of the texture
  30523. */
  30524. updateSamplingMode(samplingMode: number): void;
  30525. /**
  30526. * Scales the texture if is `canRescale()`
  30527. * @param ratio the resize factor we want to use to rescale
  30528. */
  30529. scale(ratio: number): void;
  30530. /**
  30531. * Get if the texture can rescale.
  30532. */
  30533. get canRescale(): boolean;
  30534. /** @hidden */
  30535. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30536. /** @hidden */
  30537. _rebuild(): void;
  30538. /**
  30539. * Triggers the load sequence in delayed load mode.
  30540. */
  30541. delayLoad(): void;
  30542. /**
  30543. * Clones the texture.
  30544. * @returns the cloned texture
  30545. */
  30546. clone(): Nullable<BaseTexture>;
  30547. /**
  30548. * Get the texture underlying type (INT, FLOAT...)
  30549. */
  30550. get textureType(): number;
  30551. /**
  30552. * Get the texture underlying format (RGB, RGBA...)
  30553. */
  30554. get textureFormat(): number;
  30555. /**
  30556. * Indicates that textures need to be re-calculated for all materials
  30557. */
  30558. protected _markAllSubMeshesAsTexturesDirty(): void;
  30559. /**
  30560. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30561. * This will returns an RGBA array buffer containing either in values (0-255) or
  30562. * float values (0-1) depending of the underlying buffer type.
  30563. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30564. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30565. * @param buffer defines a user defined buffer to fill with data (can be null)
  30566. * @returns The Array buffer containing the pixels data.
  30567. */
  30568. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30569. /**
  30570. * Release and destroy the underlying lower level texture aka internalTexture.
  30571. */
  30572. releaseInternalTexture(): void;
  30573. /** @hidden */
  30574. get _lodTextureHigh(): Nullable<BaseTexture>;
  30575. /** @hidden */
  30576. get _lodTextureMid(): Nullable<BaseTexture>;
  30577. /** @hidden */
  30578. get _lodTextureLow(): Nullable<BaseTexture>;
  30579. /**
  30580. * Dispose the texture and release its associated resources.
  30581. */
  30582. dispose(): void;
  30583. /**
  30584. * Serialize the texture into a JSON representation that can be parsed later on.
  30585. * @returns the JSON representation of the texture
  30586. */
  30587. serialize(): any;
  30588. /**
  30589. * Helper function to be called back once a list of texture contains only ready textures.
  30590. * @param textures Define the list of textures to wait for
  30591. * @param callback Define the callback triggered once the entire list will be ready
  30592. */
  30593. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30594. }
  30595. }
  30596. declare module "babylonjs/Materials/effect" {
  30597. import { Observable } from "babylonjs/Misc/observable";
  30598. import { Nullable } from "babylonjs/types";
  30599. import { IDisposable } from "babylonjs/scene";
  30600. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30601. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30602. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30603. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30604. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30605. import { Engine } from "babylonjs/Engines/engine";
  30606. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30608. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30609. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30610. /**
  30611. * Options to be used when creating an effect.
  30612. */
  30613. export interface IEffectCreationOptions {
  30614. /**
  30615. * Atrributes that will be used in the shader.
  30616. */
  30617. attributes: string[];
  30618. /**
  30619. * Uniform varible names that will be set in the shader.
  30620. */
  30621. uniformsNames: string[];
  30622. /**
  30623. * Uniform buffer variable names that will be set in the shader.
  30624. */
  30625. uniformBuffersNames: string[];
  30626. /**
  30627. * Sampler texture variable names that will be set in the shader.
  30628. */
  30629. samplers: string[];
  30630. /**
  30631. * Define statements that will be set in the shader.
  30632. */
  30633. defines: any;
  30634. /**
  30635. * Possible fallbacks for this effect to improve performance when needed.
  30636. */
  30637. fallbacks: Nullable<IEffectFallbacks>;
  30638. /**
  30639. * Callback that will be called when the shader is compiled.
  30640. */
  30641. onCompiled: Nullable<(effect: Effect) => void>;
  30642. /**
  30643. * Callback that will be called if an error occurs during shader compilation.
  30644. */
  30645. onError: Nullable<(effect: Effect, errors: string) => void>;
  30646. /**
  30647. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30648. */
  30649. indexParameters?: any;
  30650. /**
  30651. * Max number of lights that can be used in the shader.
  30652. */
  30653. maxSimultaneousLights?: number;
  30654. /**
  30655. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30656. */
  30657. transformFeedbackVaryings?: Nullable<string[]>;
  30658. }
  30659. /**
  30660. * Effect containing vertex and fragment shader that can be executed on an object.
  30661. */
  30662. export class Effect implements IDisposable {
  30663. /**
  30664. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30665. */
  30666. static ShadersRepository: string;
  30667. /**
  30668. * Name of the effect.
  30669. */
  30670. name: any;
  30671. /**
  30672. * String container all the define statements that should be set on the shader.
  30673. */
  30674. defines: string;
  30675. /**
  30676. * Callback that will be called when the shader is compiled.
  30677. */
  30678. onCompiled: Nullable<(effect: Effect) => void>;
  30679. /**
  30680. * Callback that will be called if an error occurs during shader compilation.
  30681. */
  30682. onError: Nullable<(effect: Effect, errors: string) => void>;
  30683. /**
  30684. * Callback that will be called when effect is bound.
  30685. */
  30686. onBind: Nullable<(effect: Effect) => void>;
  30687. /**
  30688. * Unique ID of the effect.
  30689. */
  30690. uniqueId: number;
  30691. /**
  30692. * Observable that will be called when the shader is compiled.
  30693. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30694. */
  30695. onCompileObservable: Observable<Effect>;
  30696. /**
  30697. * Observable that will be called if an error occurs during shader compilation.
  30698. */
  30699. onErrorObservable: Observable<Effect>;
  30700. /** @hidden */
  30701. _onBindObservable: Nullable<Observable<Effect>>;
  30702. /**
  30703. * Observable that will be called when effect is bound.
  30704. */
  30705. get onBindObservable(): Observable<Effect>;
  30706. /** @hidden */
  30707. _bonesComputationForcedToCPU: boolean;
  30708. private static _uniqueIdSeed;
  30709. private _engine;
  30710. private _uniformBuffersNames;
  30711. private _uniformsNames;
  30712. private _samplerList;
  30713. private _samplers;
  30714. private _isReady;
  30715. private _compilationError;
  30716. private _allFallbacksProcessed;
  30717. private _attributesNames;
  30718. private _attributes;
  30719. private _attributeLocationByName;
  30720. private _uniforms;
  30721. /**
  30722. * Key for the effect.
  30723. * @hidden
  30724. */
  30725. _key: string;
  30726. private _indexParameters;
  30727. private _fallbacks;
  30728. private _vertexSourceCode;
  30729. private _fragmentSourceCode;
  30730. private _vertexSourceCodeOverride;
  30731. private _fragmentSourceCodeOverride;
  30732. private _transformFeedbackVaryings;
  30733. /**
  30734. * Compiled shader to webGL program.
  30735. * @hidden
  30736. */
  30737. _pipelineContext: Nullable<IPipelineContext>;
  30738. private _valueCache;
  30739. private static _baseCache;
  30740. /**
  30741. * Instantiates an effect.
  30742. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30743. * @param baseName Name of the effect.
  30744. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30745. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30746. * @param samplers List of sampler variables that will be passed to the shader.
  30747. * @param engine Engine to be used to render the effect
  30748. * @param defines Define statements to be added to the shader.
  30749. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30750. * @param onCompiled Callback that will be called when the shader is compiled.
  30751. * @param onError Callback that will be called if an error occurs during shader compilation.
  30752. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30753. */
  30754. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30755. private _useFinalCode;
  30756. /**
  30757. * Unique key for this effect
  30758. */
  30759. get key(): string;
  30760. /**
  30761. * If the effect has been compiled and prepared.
  30762. * @returns if the effect is compiled and prepared.
  30763. */
  30764. isReady(): boolean;
  30765. private _isReadyInternal;
  30766. /**
  30767. * The engine the effect was initialized with.
  30768. * @returns the engine.
  30769. */
  30770. getEngine(): Engine;
  30771. /**
  30772. * The pipeline context for this effect
  30773. * @returns the associated pipeline context
  30774. */
  30775. getPipelineContext(): Nullable<IPipelineContext>;
  30776. /**
  30777. * The set of names of attribute variables for the shader.
  30778. * @returns An array of attribute names.
  30779. */
  30780. getAttributesNames(): string[];
  30781. /**
  30782. * Returns the attribute at the given index.
  30783. * @param index The index of the attribute.
  30784. * @returns The location of the attribute.
  30785. */
  30786. getAttributeLocation(index: number): number;
  30787. /**
  30788. * Returns the attribute based on the name of the variable.
  30789. * @param name of the attribute to look up.
  30790. * @returns the attribute location.
  30791. */
  30792. getAttributeLocationByName(name: string): number;
  30793. /**
  30794. * The number of attributes.
  30795. * @returns the numnber of attributes.
  30796. */
  30797. getAttributesCount(): number;
  30798. /**
  30799. * Gets the index of a uniform variable.
  30800. * @param uniformName of the uniform to look up.
  30801. * @returns the index.
  30802. */
  30803. getUniformIndex(uniformName: string): number;
  30804. /**
  30805. * Returns the attribute based on the name of the variable.
  30806. * @param uniformName of the uniform to look up.
  30807. * @returns the location of the uniform.
  30808. */
  30809. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30810. /**
  30811. * Returns an array of sampler variable names
  30812. * @returns The array of sampler variable neames.
  30813. */
  30814. getSamplers(): string[];
  30815. /**
  30816. * The error from the last compilation.
  30817. * @returns the error string.
  30818. */
  30819. getCompilationError(): string;
  30820. /**
  30821. * Gets a boolean indicating that all fallbacks were used during compilation
  30822. * @returns true if all fallbacks were used
  30823. */
  30824. allFallbacksProcessed(): boolean;
  30825. /**
  30826. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30827. * @param func The callback to be used.
  30828. */
  30829. executeWhenCompiled(func: (effect: Effect) => void): void;
  30830. private _checkIsReady;
  30831. private _loadShader;
  30832. /**
  30833. * Recompiles the webGL program
  30834. * @param vertexSourceCode The source code for the vertex shader.
  30835. * @param fragmentSourceCode The source code for the fragment shader.
  30836. * @param onCompiled Callback called when completed.
  30837. * @param onError Callback called on error.
  30838. * @hidden
  30839. */
  30840. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30841. /**
  30842. * Prepares the effect
  30843. * @hidden
  30844. */
  30845. _prepareEffect(): void;
  30846. private _processCompilationErrors;
  30847. /**
  30848. * Checks if the effect is supported. (Must be called after compilation)
  30849. */
  30850. get isSupported(): boolean;
  30851. /**
  30852. * Binds a texture to the engine to be used as output of the shader.
  30853. * @param channel Name of the output variable.
  30854. * @param texture Texture to bind.
  30855. * @hidden
  30856. */
  30857. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30858. /**
  30859. * Sets a texture on the engine to be used in the shader.
  30860. * @param channel Name of the sampler variable.
  30861. * @param texture Texture to set.
  30862. */
  30863. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30864. /**
  30865. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30866. * @param channel Name of the sampler variable.
  30867. * @param texture Texture to set.
  30868. */
  30869. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30870. /**
  30871. * Sets an array of textures on the engine to be used in the shader.
  30872. * @param channel Name of the variable.
  30873. * @param textures Textures to set.
  30874. */
  30875. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30876. /**
  30877. * 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)
  30878. * @param channel Name of the sampler variable.
  30879. * @param postProcess Post process to get the input texture from.
  30880. */
  30881. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30882. /**
  30883. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30884. * 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)
  30885. * @param channel Name of the sampler variable.
  30886. * @param postProcess Post process to get the output texture from.
  30887. */
  30888. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30889. /** @hidden */
  30890. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30891. /** @hidden */
  30892. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30893. /** @hidden */
  30894. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30895. /** @hidden */
  30896. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30897. /**
  30898. * Binds a buffer to a uniform.
  30899. * @param buffer Buffer to bind.
  30900. * @param name Name of the uniform variable to bind to.
  30901. */
  30902. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30903. /**
  30904. * Binds block to a uniform.
  30905. * @param blockName Name of the block to bind.
  30906. * @param index Index to bind.
  30907. */
  30908. bindUniformBlock(blockName: string, index: number): void;
  30909. /**
  30910. * Sets an interger value on a uniform variable.
  30911. * @param uniformName Name of the variable.
  30912. * @param value Value to be set.
  30913. * @returns this effect.
  30914. */
  30915. setInt(uniformName: string, value: number): Effect;
  30916. /**
  30917. * Sets an int array on a uniform variable.
  30918. * @param uniformName Name of the variable.
  30919. * @param array array to be set.
  30920. * @returns this effect.
  30921. */
  30922. setIntArray(uniformName: string, array: Int32Array): Effect;
  30923. /**
  30924. * 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)
  30925. * @param uniformName Name of the variable.
  30926. * @param array array to be set.
  30927. * @returns this effect.
  30928. */
  30929. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30930. /**
  30931. * 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)
  30932. * @param uniformName Name of the variable.
  30933. * @param array array to be set.
  30934. * @returns this effect.
  30935. */
  30936. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30937. /**
  30938. * 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)
  30939. * @param uniformName Name of the variable.
  30940. * @param array array to be set.
  30941. * @returns this effect.
  30942. */
  30943. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30944. /**
  30945. * Sets an float array on a uniform variable.
  30946. * @param uniformName Name of the variable.
  30947. * @param array array to be set.
  30948. * @returns this effect.
  30949. */
  30950. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30951. /**
  30952. * 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)
  30953. * @param uniformName Name of the variable.
  30954. * @param array array to be set.
  30955. * @returns this effect.
  30956. */
  30957. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30958. /**
  30959. * 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)
  30960. * @param uniformName Name of the variable.
  30961. * @param array array to be set.
  30962. * @returns this effect.
  30963. */
  30964. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30965. /**
  30966. * 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)
  30967. * @param uniformName Name of the variable.
  30968. * @param array array to be set.
  30969. * @returns this effect.
  30970. */
  30971. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30972. /**
  30973. * Sets an array on a uniform variable.
  30974. * @param uniformName Name of the variable.
  30975. * @param array array to be set.
  30976. * @returns this effect.
  30977. */
  30978. setArray(uniformName: string, array: number[]): Effect;
  30979. /**
  30980. * 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)
  30981. * @param uniformName Name of the variable.
  30982. * @param array array to be set.
  30983. * @returns this effect.
  30984. */
  30985. setArray2(uniformName: string, array: number[]): Effect;
  30986. /**
  30987. * 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)
  30988. * @param uniformName Name of the variable.
  30989. * @param array array to be set.
  30990. * @returns this effect.
  30991. */
  30992. setArray3(uniformName: string, array: number[]): Effect;
  30993. /**
  30994. * 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)
  30995. * @param uniformName Name of the variable.
  30996. * @param array array to be set.
  30997. * @returns this effect.
  30998. */
  30999. setArray4(uniformName: string, array: number[]): Effect;
  31000. /**
  31001. * Sets matrices on a uniform variable.
  31002. * @param uniformName Name of the variable.
  31003. * @param matrices matrices to be set.
  31004. * @returns this effect.
  31005. */
  31006. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31007. /**
  31008. * Sets matrix on a uniform variable.
  31009. * @param uniformName Name of the variable.
  31010. * @param matrix matrix to be set.
  31011. * @returns this effect.
  31012. */
  31013. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31014. /**
  31015. * 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)
  31016. * @param uniformName Name of the variable.
  31017. * @param matrix matrix to be set.
  31018. * @returns this effect.
  31019. */
  31020. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31021. /**
  31022. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31023. * @param uniformName Name of the variable.
  31024. * @param matrix matrix to be set.
  31025. * @returns this effect.
  31026. */
  31027. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31028. /**
  31029. * Sets a float on a uniform variable.
  31030. * @param uniformName Name of the variable.
  31031. * @param value value to be set.
  31032. * @returns this effect.
  31033. */
  31034. setFloat(uniformName: string, value: number): Effect;
  31035. /**
  31036. * Sets a boolean on a uniform variable.
  31037. * @param uniformName Name of the variable.
  31038. * @param bool value to be set.
  31039. * @returns this effect.
  31040. */
  31041. setBool(uniformName: string, bool: boolean): Effect;
  31042. /**
  31043. * Sets a Vector2 on a uniform variable.
  31044. * @param uniformName Name of the variable.
  31045. * @param vector2 vector2 to be set.
  31046. * @returns this effect.
  31047. */
  31048. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31049. /**
  31050. * Sets a float2 on a uniform variable.
  31051. * @param uniformName Name of the variable.
  31052. * @param x First float in float2.
  31053. * @param y Second float in float2.
  31054. * @returns this effect.
  31055. */
  31056. setFloat2(uniformName: string, x: number, y: number): Effect;
  31057. /**
  31058. * Sets a Vector3 on a uniform variable.
  31059. * @param uniformName Name of the variable.
  31060. * @param vector3 Value to be set.
  31061. * @returns this effect.
  31062. */
  31063. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31064. /**
  31065. * Sets a float3 on a uniform variable.
  31066. * @param uniformName Name of the variable.
  31067. * @param x First float in float3.
  31068. * @param y Second float in float3.
  31069. * @param z Third float in float3.
  31070. * @returns this effect.
  31071. */
  31072. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31073. /**
  31074. * Sets a Vector4 on a uniform variable.
  31075. * @param uniformName Name of the variable.
  31076. * @param vector4 Value to be set.
  31077. * @returns this effect.
  31078. */
  31079. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31080. /**
  31081. * Sets a float4 on a uniform variable.
  31082. * @param uniformName Name of the variable.
  31083. * @param x First float in float4.
  31084. * @param y Second float in float4.
  31085. * @param z Third float in float4.
  31086. * @param w Fourth float in float4.
  31087. * @returns this effect.
  31088. */
  31089. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31090. /**
  31091. * Sets a Color3 on a uniform variable.
  31092. * @param uniformName Name of the variable.
  31093. * @param color3 Value to be set.
  31094. * @returns this effect.
  31095. */
  31096. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31097. /**
  31098. * Sets a Color4 on a uniform variable.
  31099. * @param uniformName Name of the variable.
  31100. * @param color3 Value to be set.
  31101. * @param alpha Alpha value to be set.
  31102. * @returns this effect.
  31103. */
  31104. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31105. /**
  31106. * Sets a Color4 on a uniform variable
  31107. * @param uniformName defines the name of the variable
  31108. * @param color4 defines the value to be set
  31109. * @returns this effect.
  31110. */
  31111. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31112. /** Release all associated resources */
  31113. dispose(): void;
  31114. /**
  31115. * This function will add a new shader to the shader store
  31116. * @param name the name of the shader
  31117. * @param pixelShader optional pixel shader content
  31118. * @param vertexShader optional vertex shader content
  31119. */
  31120. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31121. /**
  31122. * Store of each shader (The can be looked up using effect.key)
  31123. */
  31124. static ShadersStore: {
  31125. [key: string]: string;
  31126. };
  31127. /**
  31128. * Store of each included file for a shader (The can be looked up using effect.key)
  31129. */
  31130. static IncludesShadersStore: {
  31131. [key: string]: string;
  31132. };
  31133. /**
  31134. * Resets the cache of effects.
  31135. */
  31136. static ResetCache(): void;
  31137. }
  31138. }
  31139. declare module "babylonjs/Engines/engineCapabilities" {
  31140. /**
  31141. * Interface used to describe the capabilities of the engine relatively to the current browser
  31142. */
  31143. export interface EngineCapabilities {
  31144. /** Maximum textures units per fragment shader */
  31145. maxTexturesImageUnits: number;
  31146. /** Maximum texture units per vertex shader */
  31147. maxVertexTextureImageUnits: number;
  31148. /** Maximum textures units in the entire pipeline */
  31149. maxCombinedTexturesImageUnits: number;
  31150. /** Maximum texture size */
  31151. maxTextureSize: number;
  31152. /** Maximum texture samples */
  31153. maxSamples?: number;
  31154. /** Maximum cube texture size */
  31155. maxCubemapTextureSize: number;
  31156. /** Maximum render texture size */
  31157. maxRenderTextureSize: number;
  31158. /** Maximum number of vertex attributes */
  31159. maxVertexAttribs: number;
  31160. /** Maximum number of varyings */
  31161. maxVaryingVectors: number;
  31162. /** Maximum number of uniforms per vertex shader */
  31163. maxVertexUniformVectors: number;
  31164. /** Maximum number of uniforms per fragment shader */
  31165. maxFragmentUniformVectors: number;
  31166. /** Defines if standard derivates (dx/dy) are supported */
  31167. standardDerivatives: boolean;
  31168. /** Defines if s3tc texture compression is supported */
  31169. s3tc?: WEBGL_compressed_texture_s3tc;
  31170. /** Defines if pvrtc texture compression is supported */
  31171. pvrtc: any;
  31172. /** Defines if etc1 texture compression is supported */
  31173. etc1: any;
  31174. /** Defines if etc2 texture compression is supported */
  31175. etc2: any;
  31176. /** Defines if astc texture compression is supported */
  31177. astc: any;
  31178. /** Defines if float textures are supported */
  31179. textureFloat: boolean;
  31180. /** Defines if vertex array objects are supported */
  31181. vertexArrayObject: boolean;
  31182. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31183. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31184. /** Gets the maximum level of anisotropy supported */
  31185. maxAnisotropy: number;
  31186. /** Defines if instancing is supported */
  31187. instancedArrays: boolean;
  31188. /** Defines if 32 bits indices are supported */
  31189. uintIndices: boolean;
  31190. /** Defines if high precision shaders are supported */
  31191. highPrecisionShaderSupported: boolean;
  31192. /** Defines if depth reading in the fragment shader is supported */
  31193. fragmentDepthSupported: boolean;
  31194. /** Defines if float texture linear filtering is supported*/
  31195. textureFloatLinearFiltering: boolean;
  31196. /** Defines if rendering to float textures is supported */
  31197. textureFloatRender: boolean;
  31198. /** Defines if half float textures are supported*/
  31199. textureHalfFloat: boolean;
  31200. /** Defines if half float texture linear filtering is supported*/
  31201. textureHalfFloatLinearFiltering: boolean;
  31202. /** Defines if rendering to half float textures is supported */
  31203. textureHalfFloatRender: boolean;
  31204. /** Defines if textureLOD shader command is supported */
  31205. textureLOD: boolean;
  31206. /** Defines if draw buffers extension is supported */
  31207. drawBuffersExtension: boolean;
  31208. /** Defines if depth textures are supported */
  31209. depthTextureExtension: boolean;
  31210. /** Defines if float color buffer are supported */
  31211. colorBufferFloat: boolean;
  31212. /** Gets disjoint timer query extension (null if not supported) */
  31213. timerQuery?: EXT_disjoint_timer_query;
  31214. /** Defines if timestamp can be used with timer query */
  31215. canUseTimestampForTimerQuery: boolean;
  31216. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31217. multiview?: any;
  31218. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31219. oculusMultiview?: any;
  31220. /** Function used to let the system compiles shaders in background */
  31221. parallelShaderCompile?: {
  31222. COMPLETION_STATUS_KHR: number;
  31223. };
  31224. /** Max number of texture samples for MSAA */
  31225. maxMSAASamples: number;
  31226. /** Defines if the blend min max extension is supported */
  31227. blendMinMax: boolean;
  31228. }
  31229. }
  31230. declare module "babylonjs/States/depthCullingState" {
  31231. import { Nullable } from "babylonjs/types";
  31232. /**
  31233. * @hidden
  31234. **/
  31235. export class DepthCullingState {
  31236. private _isDepthTestDirty;
  31237. private _isDepthMaskDirty;
  31238. private _isDepthFuncDirty;
  31239. private _isCullFaceDirty;
  31240. private _isCullDirty;
  31241. private _isZOffsetDirty;
  31242. private _isFrontFaceDirty;
  31243. private _depthTest;
  31244. private _depthMask;
  31245. private _depthFunc;
  31246. private _cull;
  31247. private _cullFace;
  31248. private _zOffset;
  31249. private _frontFace;
  31250. /**
  31251. * Initializes the state.
  31252. */
  31253. constructor();
  31254. get isDirty(): boolean;
  31255. get zOffset(): number;
  31256. set zOffset(value: number);
  31257. get cullFace(): Nullable<number>;
  31258. set cullFace(value: Nullable<number>);
  31259. get cull(): Nullable<boolean>;
  31260. set cull(value: Nullable<boolean>);
  31261. get depthFunc(): Nullable<number>;
  31262. set depthFunc(value: Nullable<number>);
  31263. get depthMask(): boolean;
  31264. set depthMask(value: boolean);
  31265. get depthTest(): boolean;
  31266. set depthTest(value: boolean);
  31267. get frontFace(): Nullable<number>;
  31268. set frontFace(value: Nullable<number>);
  31269. reset(): void;
  31270. apply(gl: WebGLRenderingContext): void;
  31271. }
  31272. }
  31273. declare module "babylonjs/States/stencilState" {
  31274. /**
  31275. * @hidden
  31276. **/
  31277. export class StencilState {
  31278. /** 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 */
  31279. static readonly ALWAYS: number;
  31280. /** Passed to stencilOperation to specify that stencil value must be kept */
  31281. static readonly KEEP: number;
  31282. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31283. static readonly REPLACE: number;
  31284. private _isStencilTestDirty;
  31285. private _isStencilMaskDirty;
  31286. private _isStencilFuncDirty;
  31287. private _isStencilOpDirty;
  31288. private _stencilTest;
  31289. private _stencilMask;
  31290. private _stencilFunc;
  31291. private _stencilFuncRef;
  31292. private _stencilFuncMask;
  31293. private _stencilOpStencilFail;
  31294. private _stencilOpDepthFail;
  31295. private _stencilOpStencilDepthPass;
  31296. get isDirty(): boolean;
  31297. get stencilFunc(): number;
  31298. set stencilFunc(value: number);
  31299. get stencilFuncRef(): number;
  31300. set stencilFuncRef(value: number);
  31301. get stencilFuncMask(): number;
  31302. set stencilFuncMask(value: number);
  31303. get stencilOpStencilFail(): number;
  31304. set stencilOpStencilFail(value: number);
  31305. get stencilOpDepthFail(): number;
  31306. set stencilOpDepthFail(value: number);
  31307. get stencilOpStencilDepthPass(): number;
  31308. set stencilOpStencilDepthPass(value: number);
  31309. get stencilMask(): number;
  31310. set stencilMask(value: number);
  31311. get stencilTest(): boolean;
  31312. set stencilTest(value: boolean);
  31313. constructor();
  31314. reset(): void;
  31315. apply(gl: WebGLRenderingContext): void;
  31316. }
  31317. }
  31318. declare module "babylonjs/States/alphaCullingState" {
  31319. /**
  31320. * @hidden
  31321. **/
  31322. export class AlphaState {
  31323. private _isAlphaBlendDirty;
  31324. private _isBlendFunctionParametersDirty;
  31325. private _isBlendEquationParametersDirty;
  31326. private _isBlendConstantsDirty;
  31327. private _alphaBlend;
  31328. private _blendFunctionParameters;
  31329. private _blendEquationParameters;
  31330. private _blendConstants;
  31331. /**
  31332. * Initializes the state.
  31333. */
  31334. constructor();
  31335. get isDirty(): boolean;
  31336. get alphaBlend(): boolean;
  31337. set alphaBlend(value: boolean);
  31338. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31339. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31340. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31341. reset(): void;
  31342. apply(gl: WebGLRenderingContext): void;
  31343. }
  31344. }
  31345. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31346. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31347. /** @hidden */
  31348. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31349. attributeProcessor(attribute: string): string;
  31350. varyingProcessor(varying: string, isFragment: boolean): string;
  31351. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31352. }
  31353. }
  31354. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31355. /**
  31356. * Interface for attribute information associated with buffer instanciation
  31357. */
  31358. export interface InstancingAttributeInfo {
  31359. /**
  31360. * Name of the GLSL attribute
  31361. * if attribute index is not specified, this is used to retrieve the index from the effect
  31362. */
  31363. attributeName: string;
  31364. /**
  31365. * Index/offset of the attribute in the vertex shader
  31366. * if not specified, this will be computes from the name.
  31367. */
  31368. index?: number;
  31369. /**
  31370. * size of the attribute, 1, 2, 3 or 4
  31371. */
  31372. attributeSize: number;
  31373. /**
  31374. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31375. */
  31376. offset: number;
  31377. /**
  31378. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31379. * default to 1
  31380. */
  31381. divisor?: number;
  31382. /**
  31383. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31384. * default is FLOAT
  31385. */
  31386. attributeType?: number;
  31387. /**
  31388. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31389. */
  31390. normalized?: boolean;
  31391. }
  31392. }
  31393. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31394. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31395. import { Nullable } from "babylonjs/types";
  31396. module "babylonjs/Engines/thinEngine" {
  31397. interface ThinEngine {
  31398. /**
  31399. * Update a video texture
  31400. * @param texture defines the texture to update
  31401. * @param video defines the video element to use
  31402. * @param invertY defines if data must be stored with Y axis inverted
  31403. */
  31404. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31405. }
  31406. }
  31407. }
  31408. declare module "babylonjs/Materials/Textures/videoTexture" {
  31409. import { Observable } from "babylonjs/Misc/observable";
  31410. import { Nullable } from "babylonjs/types";
  31411. import { Scene } from "babylonjs/scene";
  31412. import { Texture } from "babylonjs/Materials/Textures/texture";
  31413. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31414. /**
  31415. * Settings for finer control over video usage
  31416. */
  31417. export interface VideoTextureSettings {
  31418. /**
  31419. * Applies `autoplay` to video, if specified
  31420. */
  31421. autoPlay?: boolean;
  31422. /**
  31423. * Applies `loop` to video, if specified
  31424. */
  31425. loop?: boolean;
  31426. /**
  31427. * Automatically updates internal texture from video at every frame in the render loop
  31428. */
  31429. autoUpdateTexture: boolean;
  31430. /**
  31431. * Image src displayed during the video loading or until the user interacts with the video.
  31432. */
  31433. poster?: string;
  31434. }
  31435. /**
  31436. * If you want to display a video in your scene, this is the special texture for that.
  31437. * This special texture works similar to other textures, with the exception of a few parameters.
  31438. * @see https://doc.babylonjs.com/how_to/video_texture
  31439. */
  31440. export class VideoTexture extends Texture {
  31441. /**
  31442. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31443. */
  31444. readonly autoUpdateTexture: boolean;
  31445. /**
  31446. * The video instance used by the texture internally
  31447. */
  31448. readonly video: HTMLVideoElement;
  31449. private _onUserActionRequestedObservable;
  31450. /**
  31451. * Event triggerd when a dom action is required by the user to play the video.
  31452. * This happens due to recent changes in browser policies preventing video to auto start.
  31453. */
  31454. get onUserActionRequestedObservable(): Observable<Texture>;
  31455. private _generateMipMaps;
  31456. private _engine;
  31457. private _stillImageCaptured;
  31458. private _displayingPosterTexture;
  31459. private _settings;
  31460. private _createInternalTextureOnEvent;
  31461. private _frameId;
  31462. /**
  31463. * Creates a video texture.
  31464. * If you want to display a video in your scene, this is the special texture for that.
  31465. * This special texture works similar to other textures, with the exception of a few parameters.
  31466. * @see https://doc.babylonjs.com/how_to/video_texture
  31467. * @param name optional name, will detect from video source, if not defined
  31468. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31469. * @param scene is obviously the current scene.
  31470. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31471. * @param invertY is false by default but can be used to invert video on Y axis
  31472. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31473. * @param settings allows finer control over video usage
  31474. */
  31475. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31476. private _getName;
  31477. private _getVideo;
  31478. private _createInternalTexture;
  31479. private reset;
  31480. /**
  31481. * @hidden Internal method to initiate `update`.
  31482. */
  31483. _rebuild(): void;
  31484. /**
  31485. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31486. */
  31487. update(): void;
  31488. /**
  31489. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31490. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31491. */
  31492. updateTexture(isVisible: boolean): void;
  31493. protected _updateInternalTexture: () => void;
  31494. /**
  31495. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31496. * @param url New url.
  31497. */
  31498. updateURL(url: string): void;
  31499. /**
  31500. * Dispose the texture and release its associated resources.
  31501. */
  31502. dispose(): void;
  31503. /**
  31504. * Creates a video texture straight from a stream.
  31505. * @param scene Define the scene the texture should be created in
  31506. * @param stream Define the stream the texture should be created from
  31507. * @returns The created video texture as a promise
  31508. */
  31509. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31510. /**
  31511. * Creates a video texture straight from your WebCam video feed.
  31512. * @param scene Define the scene the texture should be created in
  31513. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31514. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31515. * @returns The created video texture as a promise
  31516. */
  31517. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31518. minWidth: number;
  31519. maxWidth: number;
  31520. minHeight: number;
  31521. maxHeight: number;
  31522. deviceId: string;
  31523. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31524. /**
  31525. * Creates a video texture straight from your WebCam video feed.
  31526. * @param scene Define the scene the texture should be created in
  31527. * @param onReady Define a callback to triggered once the texture will be ready
  31528. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31529. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31530. */
  31531. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31532. minWidth: number;
  31533. maxWidth: number;
  31534. minHeight: number;
  31535. maxHeight: number;
  31536. deviceId: string;
  31537. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31538. }
  31539. }
  31540. declare module "babylonjs/Engines/thinEngine" {
  31541. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31542. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31543. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31544. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31545. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31546. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31547. import { Observable } from "babylonjs/Misc/observable";
  31548. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31549. import { StencilState } from "babylonjs/States/stencilState";
  31550. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31551. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31552. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31554. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31555. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31556. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31557. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31558. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31560. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31561. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31562. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31563. /**
  31564. * Defines the interface used by objects working like Scene
  31565. * @hidden
  31566. */
  31567. interface ISceneLike {
  31568. _addPendingData(data: any): void;
  31569. _removePendingData(data: any): void;
  31570. offlineProvider: IOfflineProvider;
  31571. }
  31572. /** Interface defining initialization parameters for Engine class */
  31573. export interface EngineOptions extends WebGLContextAttributes {
  31574. /**
  31575. * Defines if the engine should no exceed a specified device ratio
  31576. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31577. */
  31578. limitDeviceRatio?: number;
  31579. /**
  31580. * Defines if webvr should be enabled automatically
  31581. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31582. */
  31583. autoEnableWebVR?: boolean;
  31584. /**
  31585. * Defines if webgl2 should be turned off even if supported
  31586. * @see http://doc.babylonjs.com/features/webgl2
  31587. */
  31588. disableWebGL2Support?: boolean;
  31589. /**
  31590. * Defines if webaudio should be initialized as well
  31591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31592. */
  31593. audioEngine?: boolean;
  31594. /**
  31595. * Defines if animations should run using a deterministic lock step
  31596. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31597. */
  31598. deterministicLockstep?: boolean;
  31599. /** Defines the maximum steps to use with deterministic lock step mode */
  31600. lockstepMaxSteps?: number;
  31601. /** Defines the seconds between each deterministic lock step */
  31602. timeStep?: number;
  31603. /**
  31604. * Defines that engine should ignore context lost events
  31605. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31606. */
  31607. doNotHandleContextLost?: boolean;
  31608. /**
  31609. * Defines that engine should ignore modifying touch action attribute and style
  31610. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31611. */
  31612. doNotHandleTouchAction?: boolean;
  31613. /**
  31614. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31615. */
  31616. useHighPrecisionFloats?: boolean;
  31617. }
  31618. /**
  31619. * The base engine class (root of all engines)
  31620. */
  31621. export class ThinEngine {
  31622. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31623. static ExceptionList: ({
  31624. key: string;
  31625. capture: string;
  31626. captureConstraint: number;
  31627. targets: string[];
  31628. } | {
  31629. key: string;
  31630. capture: null;
  31631. captureConstraint: null;
  31632. targets: string[];
  31633. })[];
  31634. /** @hidden */
  31635. static _TextureLoaders: IInternalTextureLoader[];
  31636. /**
  31637. * Returns the current npm package of the sdk
  31638. */
  31639. static get NpmPackage(): string;
  31640. /**
  31641. * Returns the current version of the framework
  31642. */
  31643. static get Version(): string;
  31644. /**
  31645. * Returns a string describing the current engine
  31646. */
  31647. get description(): string;
  31648. /**
  31649. * Gets or sets the epsilon value used by collision engine
  31650. */
  31651. static CollisionsEpsilon: number;
  31652. /**
  31653. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31654. */
  31655. static get ShadersRepository(): string;
  31656. static set ShadersRepository(value: string);
  31657. /**
  31658. * Gets or sets the textures that the engine should not attempt to load as compressed
  31659. */
  31660. protected _excludedCompressedTextures: string[];
  31661. /**
  31662. * Filters the compressed texture formats to only include
  31663. * files that are not included in the skippable list
  31664. *
  31665. * @param url the current extension
  31666. * @param textureFormatInUse the current compressed texture format
  31667. * @returns "format" string
  31668. */
  31669. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31670. /** @hidden */
  31671. _shaderProcessor: IShaderProcessor;
  31672. /**
  31673. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31674. */
  31675. forcePOTTextures: boolean;
  31676. /**
  31677. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31678. */
  31679. isFullscreen: boolean;
  31680. /**
  31681. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31682. */
  31683. cullBackFaces: boolean;
  31684. /**
  31685. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31686. */
  31687. renderEvenInBackground: boolean;
  31688. /**
  31689. * Gets or sets a boolean indicating that cache can be kept between frames
  31690. */
  31691. preventCacheWipeBetweenFrames: boolean;
  31692. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31693. validateShaderPrograms: boolean;
  31694. /**
  31695. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31696. * This can provide greater z depth for distant objects.
  31697. */
  31698. useReverseDepthBuffer: boolean;
  31699. /**
  31700. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31701. */
  31702. disableUniformBuffers: boolean;
  31703. /** @hidden */
  31704. _uniformBuffers: UniformBuffer[];
  31705. /**
  31706. * Gets a boolean indicating that the engine supports uniform buffers
  31707. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31708. */
  31709. get supportsUniformBuffers(): boolean;
  31710. /** @hidden */
  31711. _gl: WebGLRenderingContext;
  31712. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31713. protected _windowIsBackground: boolean;
  31714. protected _webGLVersion: number;
  31715. protected _creationOptions: EngineOptions;
  31716. protected _highPrecisionShadersAllowed: boolean;
  31717. /** @hidden */
  31718. get _shouldUseHighPrecisionShader(): boolean;
  31719. /**
  31720. * Gets a boolean indicating that only power of 2 textures are supported
  31721. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31722. */
  31723. get needPOTTextures(): boolean;
  31724. /** @hidden */
  31725. _badOS: boolean;
  31726. /** @hidden */
  31727. _badDesktopOS: boolean;
  31728. private _hardwareScalingLevel;
  31729. /** @hidden */
  31730. _caps: EngineCapabilities;
  31731. private _isStencilEnable;
  31732. private _glVersion;
  31733. private _glRenderer;
  31734. private _glVendor;
  31735. /** @hidden */
  31736. _videoTextureSupported: boolean;
  31737. protected _renderingQueueLaunched: boolean;
  31738. protected _activeRenderLoops: (() => void)[];
  31739. /**
  31740. * Observable signaled when a context lost event is raised
  31741. */
  31742. onContextLostObservable: Observable<ThinEngine>;
  31743. /**
  31744. * Observable signaled when a context restored event is raised
  31745. */
  31746. onContextRestoredObservable: Observable<ThinEngine>;
  31747. private _onContextLost;
  31748. private _onContextRestored;
  31749. protected _contextWasLost: boolean;
  31750. /** @hidden */
  31751. _doNotHandleContextLost: boolean;
  31752. /**
  31753. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31754. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31755. */
  31756. get doNotHandleContextLost(): boolean;
  31757. set doNotHandleContextLost(value: boolean);
  31758. /**
  31759. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31760. */
  31761. disableVertexArrayObjects: boolean;
  31762. /** @hidden */
  31763. protected _colorWrite: boolean;
  31764. /** @hidden */
  31765. protected _colorWriteChanged: boolean;
  31766. /** @hidden */
  31767. protected _depthCullingState: DepthCullingState;
  31768. /** @hidden */
  31769. protected _stencilState: StencilState;
  31770. /** @hidden */
  31771. _alphaState: AlphaState;
  31772. /** @hidden */
  31773. _alphaMode: number;
  31774. /** @hidden */
  31775. _alphaEquation: number;
  31776. /** @hidden */
  31777. _internalTexturesCache: InternalTexture[];
  31778. /** @hidden */
  31779. protected _activeChannel: number;
  31780. private _currentTextureChannel;
  31781. /** @hidden */
  31782. protected _boundTexturesCache: {
  31783. [key: string]: Nullable<InternalTexture>;
  31784. };
  31785. /** @hidden */
  31786. protected _currentEffect: Nullable<Effect>;
  31787. /** @hidden */
  31788. protected _currentProgram: Nullable<WebGLProgram>;
  31789. private _compiledEffects;
  31790. private _vertexAttribArraysEnabled;
  31791. /** @hidden */
  31792. protected _cachedViewport: Nullable<IViewportLike>;
  31793. private _cachedVertexArrayObject;
  31794. /** @hidden */
  31795. protected _cachedVertexBuffers: any;
  31796. /** @hidden */
  31797. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31798. /** @hidden */
  31799. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31800. /** @hidden */
  31801. _currentRenderTarget: Nullable<InternalTexture>;
  31802. private _uintIndicesCurrentlySet;
  31803. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31804. /** @hidden */
  31805. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31806. private _currentBufferPointers;
  31807. private _currentInstanceLocations;
  31808. private _currentInstanceBuffers;
  31809. private _textureUnits;
  31810. /** @hidden */
  31811. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31812. /** @hidden */
  31813. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31814. /** @hidden */
  31815. _boundRenderFunction: any;
  31816. private _vaoRecordInProgress;
  31817. private _mustWipeVertexAttributes;
  31818. private _emptyTexture;
  31819. private _emptyCubeTexture;
  31820. private _emptyTexture3D;
  31821. private _emptyTexture2DArray;
  31822. /** @hidden */
  31823. _frameHandler: number;
  31824. private _nextFreeTextureSlots;
  31825. private _maxSimultaneousTextures;
  31826. private _activeRequests;
  31827. protected _texturesSupported: string[];
  31828. /** @hidden */
  31829. _textureFormatInUse: Nullable<string>;
  31830. protected get _supportsHardwareTextureRescaling(): boolean;
  31831. /**
  31832. * Gets the list of texture formats supported
  31833. */
  31834. get texturesSupported(): Array<string>;
  31835. /**
  31836. * Gets the list of texture formats in use
  31837. */
  31838. get textureFormatInUse(): Nullable<string>;
  31839. /**
  31840. * Gets the current viewport
  31841. */
  31842. get currentViewport(): Nullable<IViewportLike>;
  31843. /**
  31844. * Gets the default empty texture
  31845. */
  31846. get emptyTexture(): InternalTexture;
  31847. /**
  31848. * Gets the default empty 3D texture
  31849. */
  31850. get emptyTexture3D(): InternalTexture;
  31851. /**
  31852. * Gets the default empty 2D array texture
  31853. */
  31854. get emptyTexture2DArray(): InternalTexture;
  31855. /**
  31856. * Gets the default empty cube texture
  31857. */
  31858. get emptyCubeTexture(): InternalTexture;
  31859. /**
  31860. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31861. */
  31862. readonly premultipliedAlpha: boolean;
  31863. /**
  31864. * Observable event triggered before each texture is initialized
  31865. */
  31866. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31867. /**
  31868. * Creates a new engine
  31869. * @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
  31870. * @param antialias defines enable antialiasing (default: false)
  31871. * @param options defines further options to be sent to the getContext() function
  31872. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31873. */
  31874. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31875. private _rebuildInternalTextures;
  31876. private _rebuildEffects;
  31877. /**
  31878. * Gets a boolean indicating if all created effects are ready
  31879. * @returns true if all effects are ready
  31880. */
  31881. areAllEffectsReady(): boolean;
  31882. protected _rebuildBuffers(): void;
  31883. private _initGLContext;
  31884. /**
  31885. * Gets version of the current webGL context
  31886. */
  31887. get webGLVersion(): number;
  31888. /**
  31889. * Gets a string idenfifying the name of the class
  31890. * @returns "Engine" string
  31891. */
  31892. getClassName(): string;
  31893. /**
  31894. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31895. */
  31896. get isStencilEnable(): boolean;
  31897. /** @hidden */
  31898. _prepareWorkingCanvas(): void;
  31899. /**
  31900. * Reset the texture cache to empty state
  31901. */
  31902. resetTextureCache(): void;
  31903. /**
  31904. * Gets an object containing information about the current webGL context
  31905. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31906. */
  31907. getGlInfo(): {
  31908. vendor: string;
  31909. renderer: string;
  31910. version: string;
  31911. };
  31912. /**
  31913. * Defines the hardware scaling level.
  31914. * By default the hardware scaling level is computed from the window device ratio.
  31915. * 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.
  31916. * @param level defines the level to use
  31917. */
  31918. setHardwareScalingLevel(level: number): void;
  31919. /**
  31920. * Gets the current hardware scaling level.
  31921. * By default the hardware scaling level is computed from the window device ratio.
  31922. * 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.
  31923. * @returns a number indicating the current hardware scaling level
  31924. */
  31925. getHardwareScalingLevel(): number;
  31926. /**
  31927. * Gets the list of loaded textures
  31928. * @returns an array containing all loaded textures
  31929. */
  31930. getLoadedTexturesCache(): InternalTexture[];
  31931. /**
  31932. * Gets the object containing all engine capabilities
  31933. * @returns the EngineCapabilities object
  31934. */
  31935. getCaps(): EngineCapabilities;
  31936. /**
  31937. * stop executing a render loop function and remove it from the execution array
  31938. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31939. */
  31940. stopRenderLoop(renderFunction?: () => void): void;
  31941. /** @hidden */
  31942. _renderLoop(): void;
  31943. /**
  31944. * Gets the HTML canvas attached with the current webGL context
  31945. * @returns a HTML canvas
  31946. */
  31947. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31948. /**
  31949. * Gets host window
  31950. * @returns the host window object
  31951. */
  31952. getHostWindow(): Nullable<Window>;
  31953. /**
  31954. * Gets the current render width
  31955. * @param useScreen defines if screen size must be used (or the current render target if any)
  31956. * @returns a number defining the current render width
  31957. */
  31958. getRenderWidth(useScreen?: boolean): number;
  31959. /**
  31960. * Gets the current render height
  31961. * @param useScreen defines if screen size must be used (or the current render target if any)
  31962. * @returns a number defining the current render height
  31963. */
  31964. getRenderHeight(useScreen?: boolean): number;
  31965. /**
  31966. * Can be used to override the current requestAnimationFrame requester.
  31967. * @hidden
  31968. */
  31969. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31970. /**
  31971. * Register and execute a render loop. The engine can have more than one render function
  31972. * @param renderFunction defines the function to continuously execute
  31973. */
  31974. runRenderLoop(renderFunction: () => void): void;
  31975. /**
  31976. * Clear the current render buffer or the current render target (if any is set up)
  31977. * @param color defines the color to use
  31978. * @param backBuffer defines if the back buffer must be cleared
  31979. * @param depth defines if the depth buffer must be cleared
  31980. * @param stencil defines if the stencil buffer must be cleared
  31981. */
  31982. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31983. private _viewportCached;
  31984. /** @hidden */
  31985. _viewport(x: number, y: number, width: number, height: number): void;
  31986. /**
  31987. * Set the WebGL's viewport
  31988. * @param viewport defines the viewport element to be used
  31989. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31990. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31991. */
  31992. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31993. /**
  31994. * Begin a new frame
  31995. */
  31996. beginFrame(): void;
  31997. /**
  31998. * Enf the current frame
  31999. */
  32000. endFrame(): void;
  32001. /**
  32002. * Resize the view according to the canvas' size
  32003. */
  32004. resize(): void;
  32005. /**
  32006. * Force a specific size of the canvas
  32007. * @param width defines the new canvas' width
  32008. * @param height defines the new canvas' height
  32009. */
  32010. setSize(width: number, height: number): void;
  32011. /**
  32012. * Binds the frame buffer to the specified texture.
  32013. * @param texture The texture to render to or null for the default canvas
  32014. * @param faceIndex The face of the texture to render to in case of cube texture
  32015. * @param requiredWidth The width of the target to render to
  32016. * @param requiredHeight The height of the target to render to
  32017. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32018. * @param depthStencilTexture The depth stencil texture to use to render
  32019. * @param lodLevel defines le lod level to bind to the frame buffer
  32020. */
  32021. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  32022. /** @hidden */
  32023. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32024. /**
  32025. * Unbind the current render target texture from the webGL context
  32026. * @param texture defines the render target texture to unbind
  32027. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32028. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32029. */
  32030. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32031. /**
  32032. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32033. */
  32034. flushFramebuffer(): void;
  32035. /**
  32036. * Unbind the current render target and bind the default framebuffer
  32037. */
  32038. restoreDefaultFramebuffer(): void;
  32039. /** @hidden */
  32040. protected _resetVertexBufferBinding(): void;
  32041. /**
  32042. * Creates a vertex buffer
  32043. * @param data the data for the vertex buffer
  32044. * @returns the new WebGL static buffer
  32045. */
  32046. createVertexBuffer(data: DataArray): DataBuffer;
  32047. private _createVertexBuffer;
  32048. /**
  32049. * Creates a dynamic vertex buffer
  32050. * @param data the data for the dynamic vertex buffer
  32051. * @returns the new WebGL dynamic buffer
  32052. */
  32053. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32054. protected _resetIndexBufferBinding(): void;
  32055. /**
  32056. * Creates a new index buffer
  32057. * @param indices defines the content of the index buffer
  32058. * @param updatable defines if the index buffer must be updatable
  32059. * @returns a new webGL buffer
  32060. */
  32061. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32062. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32063. /**
  32064. * Bind a webGL buffer to the webGL context
  32065. * @param buffer defines the buffer to bind
  32066. */
  32067. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32068. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32069. private bindBuffer;
  32070. /**
  32071. * update the bound buffer with the given data
  32072. * @param data defines the data to update
  32073. */
  32074. updateArrayBuffer(data: Float32Array): void;
  32075. private _vertexAttribPointer;
  32076. private _bindIndexBufferWithCache;
  32077. private _bindVertexBuffersAttributes;
  32078. /**
  32079. * Records a vertex array object
  32080. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32081. * @param vertexBuffers defines the list of vertex buffers to store
  32082. * @param indexBuffer defines the index buffer to store
  32083. * @param effect defines the effect to store
  32084. * @returns the new vertex array object
  32085. */
  32086. recordVertexArrayObject(vertexBuffers: {
  32087. [key: string]: VertexBuffer;
  32088. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32089. /**
  32090. * Bind a specific vertex array object
  32091. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32092. * @param vertexArrayObject defines the vertex array object to bind
  32093. * @param indexBuffer defines the index buffer to bind
  32094. */
  32095. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32096. /**
  32097. * Bind webGl buffers directly to the webGL context
  32098. * @param vertexBuffer defines the vertex buffer to bind
  32099. * @param indexBuffer defines the index buffer to bind
  32100. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32101. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32102. * @param effect defines the effect associated with the vertex buffer
  32103. */
  32104. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32105. private _unbindVertexArrayObject;
  32106. /**
  32107. * Bind a list of vertex buffers to the webGL context
  32108. * @param vertexBuffers defines the list of vertex buffers to bind
  32109. * @param indexBuffer defines the index buffer to bind
  32110. * @param effect defines the effect associated with the vertex buffers
  32111. */
  32112. bindBuffers(vertexBuffers: {
  32113. [key: string]: Nullable<VertexBuffer>;
  32114. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32115. /**
  32116. * Unbind all instance attributes
  32117. */
  32118. unbindInstanceAttributes(): void;
  32119. /**
  32120. * Release and free the memory of a vertex array object
  32121. * @param vao defines the vertex array object to delete
  32122. */
  32123. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32124. /** @hidden */
  32125. _releaseBuffer(buffer: DataBuffer): boolean;
  32126. protected _deleteBuffer(buffer: DataBuffer): void;
  32127. /**
  32128. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32129. * @param instancesBuffer defines the webGL buffer to update and bind
  32130. * @param data defines the data to store in the buffer
  32131. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32132. */
  32133. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32134. /**
  32135. * Bind the content of a webGL buffer used with instanciation
  32136. * @param instancesBuffer defines the webGL buffer to bind
  32137. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32138. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32139. */
  32140. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32141. /**
  32142. * Disable the instance attribute corresponding to the name in parameter
  32143. * @param name defines the name of the attribute to disable
  32144. */
  32145. disableInstanceAttributeByName(name: string): void;
  32146. /**
  32147. * Disable the instance attribute corresponding to the location in parameter
  32148. * @param attributeLocation defines the attribute location of the attribute to disable
  32149. */
  32150. disableInstanceAttribute(attributeLocation: number): void;
  32151. /**
  32152. * Disable the attribute corresponding to the location in parameter
  32153. * @param attributeLocation defines the attribute location of the attribute to disable
  32154. */
  32155. disableAttributeByIndex(attributeLocation: number): void;
  32156. /**
  32157. * Send a draw order
  32158. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32159. * @param indexStart defines the starting index
  32160. * @param indexCount defines the number of index to draw
  32161. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32162. */
  32163. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32164. /**
  32165. * Draw a list of points
  32166. * @param verticesStart defines the index of first vertex to draw
  32167. * @param verticesCount defines the count of vertices to draw
  32168. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32169. */
  32170. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32171. /**
  32172. * Draw a list of unindexed primitives
  32173. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32174. * @param verticesStart defines the index of first vertex to draw
  32175. * @param verticesCount defines the count of vertices to draw
  32176. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32177. */
  32178. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32179. /**
  32180. * Draw a list of indexed primitives
  32181. * @param fillMode defines the primitive to use
  32182. * @param indexStart defines the starting index
  32183. * @param indexCount defines the number of index to draw
  32184. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32185. */
  32186. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32187. /**
  32188. * Draw a list of unindexed primitives
  32189. * @param fillMode defines the primitive to use
  32190. * @param verticesStart defines the index of first vertex to draw
  32191. * @param verticesCount defines the count of vertices to draw
  32192. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32193. */
  32194. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32195. private _drawMode;
  32196. /** @hidden */
  32197. protected _reportDrawCall(): void;
  32198. /** @hidden */
  32199. _releaseEffect(effect: Effect): void;
  32200. /** @hidden */
  32201. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32202. /**
  32203. * Create a new effect (used to store vertex/fragment shaders)
  32204. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32205. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32206. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32207. * @param samplers defines an array of string used to represent textures
  32208. * @param defines defines the string containing the defines to use to compile the shaders
  32209. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32210. * @param onCompiled defines a function to call when the effect creation is successful
  32211. * @param onError defines a function to call when the effect creation has failed
  32212. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32213. * @returns the new Effect
  32214. */
  32215. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  32216. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32217. private _compileShader;
  32218. private _compileRawShader;
  32219. /**
  32220. * Directly creates a webGL program
  32221. * @param pipelineContext defines the pipeline context to attach to
  32222. * @param vertexCode defines the vertex shader code to use
  32223. * @param fragmentCode defines the fragment shader code to use
  32224. * @param context defines the webGL context to use (if not set, the current one will be used)
  32225. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32226. * @returns the new webGL program
  32227. */
  32228. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32229. /**
  32230. * Creates a webGL program
  32231. * @param pipelineContext defines the pipeline context to attach to
  32232. * @param vertexCode defines the vertex shader code to use
  32233. * @param fragmentCode defines the fragment shader code to use
  32234. * @param defines defines the string containing the defines to use to compile the shaders
  32235. * @param context defines the webGL context to use (if not set, the current one will be used)
  32236. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32237. * @returns the new webGL program
  32238. */
  32239. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32240. /**
  32241. * Creates a new pipeline context
  32242. * @returns the new pipeline
  32243. */
  32244. createPipelineContext(): IPipelineContext;
  32245. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32246. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32247. /** @hidden */
  32248. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32249. /** @hidden */
  32250. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32251. /** @hidden */
  32252. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32253. /**
  32254. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32255. * @param pipelineContext defines the pipeline context to use
  32256. * @param uniformsNames defines the list of uniform names
  32257. * @returns an array of webGL uniform locations
  32258. */
  32259. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32260. /**
  32261. * Gets the lsit of active attributes for a given webGL program
  32262. * @param pipelineContext defines the pipeline context to use
  32263. * @param attributesNames defines the list of attribute names to get
  32264. * @returns an array of indices indicating the offset of each attribute
  32265. */
  32266. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32267. /**
  32268. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32269. * @param effect defines the effect to activate
  32270. */
  32271. enableEffect(effect: Nullable<Effect>): void;
  32272. /**
  32273. * Set the value of an uniform to a number (int)
  32274. * @param uniform defines the webGL uniform location where to store the value
  32275. * @param value defines the int number to store
  32276. */
  32277. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32278. /**
  32279. * Set the value of an uniform to an array of int32
  32280. * @param uniform defines the webGL uniform location where to store the value
  32281. * @param array defines the array of int32 to store
  32282. */
  32283. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32284. /**
  32285. * Set the value of an uniform to an array of int32 (stored as vec2)
  32286. * @param uniform defines the webGL uniform location where to store the value
  32287. * @param array defines the array of int32 to store
  32288. */
  32289. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32290. /**
  32291. * Set the value of an uniform to an array of int32 (stored as vec3)
  32292. * @param uniform defines the webGL uniform location where to store the value
  32293. * @param array defines the array of int32 to store
  32294. */
  32295. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32296. /**
  32297. * Set the value of an uniform to an array of int32 (stored as vec4)
  32298. * @param uniform defines the webGL uniform location where to store the value
  32299. * @param array defines the array of int32 to store
  32300. */
  32301. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32302. /**
  32303. * Set the value of an uniform to an array of number
  32304. * @param uniform defines the webGL uniform location where to store the value
  32305. * @param array defines the array of number to store
  32306. */
  32307. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32308. /**
  32309. * Set the value of an uniform to an array of number (stored as vec2)
  32310. * @param uniform defines the webGL uniform location where to store the value
  32311. * @param array defines the array of number to store
  32312. */
  32313. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32314. /**
  32315. * Set the value of an uniform to an array of number (stored as vec3)
  32316. * @param uniform defines the webGL uniform location where to store the value
  32317. * @param array defines the array of number to store
  32318. */
  32319. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32320. /**
  32321. * Set the value of an uniform to an array of number (stored as vec4)
  32322. * @param uniform defines the webGL uniform location where to store the value
  32323. * @param array defines the array of number to store
  32324. */
  32325. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32326. /**
  32327. * Set the value of an uniform to an array of float32 (stored as matrices)
  32328. * @param uniform defines the webGL uniform location where to store the value
  32329. * @param matrices defines the array of float32 to store
  32330. */
  32331. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32332. /**
  32333. * Set the value of an uniform to a matrix (3x3)
  32334. * @param uniform defines the webGL uniform location where to store the value
  32335. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32336. */
  32337. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32338. /**
  32339. * Set the value of an uniform to a matrix (2x2)
  32340. * @param uniform defines the webGL uniform location where to store the value
  32341. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32342. */
  32343. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32344. /**
  32345. * Set the value of an uniform to a number (float)
  32346. * @param uniform defines the webGL uniform location where to store the value
  32347. * @param value defines the float number to store
  32348. */
  32349. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32350. /**
  32351. * Set the value of an uniform to a vec2
  32352. * @param uniform defines the webGL uniform location where to store the value
  32353. * @param x defines the 1st component of the value
  32354. * @param y defines the 2nd component of the value
  32355. */
  32356. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32357. /**
  32358. * Set the value of an uniform to a vec3
  32359. * @param uniform defines the webGL uniform location where to store the value
  32360. * @param x defines the 1st component of the value
  32361. * @param y defines the 2nd component of the value
  32362. * @param z defines the 3rd component of the value
  32363. */
  32364. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32365. /**
  32366. * Set the value of an uniform to a vec4
  32367. * @param uniform defines the webGL uniform location where to store the value
  32368. * @param x defines the 1st component of the value
  32369. * @param y defines the 2nd component of the value
  32370. * @param z defines the 3rd component of the value
  32371. * @param w defines the 4th component of the value
  32372. */
  32373. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32374. /**
  32375. * Apply all cached states (depth, culling, stencil and alpha)
  32376. */
  32377. applyStates(): void;
  32378. /**
  32379. * Enable or disable color writing
  32380. * @param enable defines the state to set
  32381. */
  32382. setColorWrite(enable: boolean): void;
  32383. /**
  32384. * Gets a boolean indicating if color writing is enabled
  32385. * @returns the current color writing state
  32386. */
  32387. getColorWrite(): boolean;
  32388. /**
  32389. * Gets the depth culling state manager
  32390. */
  32391. get depthCullingState(): DepthCullingState;
  32392. /**
  32393. * Gets the alpha state manager
  32394. */
  32395. get alphaState(): AlphaState;
  32396. /**
  32397. * Gets the stencil state manager
  32398. */
  32399. get stencilState(): StencilState;
  32400. /**
  32401. * Clears the list of texture accessible through engine.
  32402. * This can help preventing texture load conflict due to name collision.
  32403. */
  32404. clearInternalTexturesCache(): void;
  32405. /**
  32406. * Force the entire cache to be cleared
  32407. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32408. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32409. */
  32410. wipeCaches(bruteForce?: boolean): void;
  32411. /** @hidden */
  32412. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32413. min: number;
  32414. mag: number;
  32415. };
  32416. /** @hidden */
  32417. _createTexture(): WebGLTexture;
  32418. /**
  32419. * Usually called from Texture.ts.
  32420. * Passed information to create a WebGLTexture
  32421. * @param urlArg defines a value which contains one of the following:
  32422. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32423. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32424. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32425. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32426. * @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)
  32427. * @param scene needed for loading to the correct scene
  32428. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32429. * @param onLoad optional callback to be called upon successful completion
  32430. * @param onError optional callback to be called upon failure
  32431. * @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
  32432. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32433. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32434. * @param forcedExtension defines the extension to use to pick the right loader
  32435. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32436. * @param mimeType defines an optional mime type
  32437. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32438. */
  32439. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32440. /**
  32441. * @hidden
  32442. */
  32443. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32444. /**
  32445. * Creates a raw texture
  32446. * @param data defines the data to store in the texture
  32447. * @param width defines the width of the texture
  32448. * @param height defines the height of the texture
  32449. * @param format defines the format of the data
  32450. * @param generateMipMaps defines if the engine should generate the mip levels
  32451. * @param invertY defines if data must be stored with Y axis inverted
  32452. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32453. * @param compression defines the compression used (null by default)
  32454. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32455. * @returns the raw texture inside an InternalTexture
  32456. */
  32457. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32458. /**
  32459. * Creates a new raw cube texture
  32460. * @param data defines the array of data to use to create each face
  32461. * @param size defines the size of the textures
  32462. * @param format defines the format of the data
  32463. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32464. * @param generateMipMaps defines if the engine should generate the mip levels
  32465. * @param invertY defines if data must be stored with Y axis inverted
  32466. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32467. * @param compression defines the compression used (null by default)
  32468. * @returns the cube texture as an InternalTexture
  32469. */
  32470. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32471. /**
  32472. * Creates a new raw 3D texture
  32473. * @param data defines the data used to create the texture
  32474. * @param width defines the width of the texture
  32475. * @param height defines the height of the texture
  32476. * @param depth defines the depth of the texture
  32477. * @param format defines the format of the texture
  32478. * @param generateMipMaps defines if the engine must generate mip levels
  32479. * @param invertY defines if data must be stored with Y axis inverted
  32480. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32481. * @param compression defines the compressed used (can be null)
  32482. * @param textureType defines the compressed used (can be null)
  32483. * @returns a new raw 3D texture (stored in an InternalTexture)
  32484. */
  32485. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32486. /**
  32487. * Creates a new raw 2D array texture
  32488. * @param data defines the data used to create the texture
  32489. * @param width defines the width of the texture
  32490. * @param height defines the height of the texture
  32491. * @param depth defines the number of layers of the texture
  32492. * @param format defines the format of the texture
  32493. * @param generateMipMaps defines if the engine must generate mip levels
  32494. * @param invertY defines if data must be stored with Y axis inverted
  32495. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32496. * @param compression defines the compressed used (can be null)
  32497. * @param textureType defines the compressed used (can be null)
  32498. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32499. */
  32500. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32501. private _unpackFlipYCached;
  32502. /**
  32503. * In case you are sharing the context with other applications, it might
  32504. * be interested to not cache the unpack flip y state to ensure a consistent
  32505. * value would be set.
  32506. */
  32507. enableUnpackFlipYCached: boolean;
  32508. /** @hidden */
  32509. _unpackFlipY(value: boolean): void;
  32510. /** @hidden */
  32511. _getUnpackAlignement(): number;
  32512. private _getTextureTarget;
  32513. /**
  32514. * Update the sampling mode of a given texture
  32515. * @param samplingMode defines the required sampling mode
  32516. * @param texture defines the texture to update
  32517. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32518. */
  32519. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32520. /**
  32521. * Update the sampling mode of a given texture
  32522. * @param texture defines the texture to update
  32523. * @param wrapU defines the texture wrap mode of the u coordinates
  32524. * @param wrapV defines the texture wrap mode of the v coordinates
  32525. * @param wrapR defines the texture wrap mode of the r coordinates
  32526. */
  32527. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32528. /** @hidden */
  32529. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32530. width: number;
  32531. height: number;
  32532. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32533. /** @hidden */
  32534. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32535. /** @hidden */
  32536. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32537. /** @hidden */
  32538. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32539. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32540. private _prepareWebGLTexture;
  32541. /** @hidden */
  32542. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32543. private _getDepthStencilBuffer;
  32544. /** @hidden */
  32545. _releaseFramebufferObjects(texture: InternalTexture): void;
  32546. /** @hidden */
  32547. _releaseTexture(texture: InternalTexture): void;
  32548. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32549. protected _setProgram(program: WebGLProgram): void;
  32550. protected _boundUniforms: {
  32551. [key: number]: WebGLUniformLocation;
  32552. };
  32553. /**
  32554. * Binds an effect to the webGL context
  32555. * @param effect defines the effect to bind
  32556. */
  32557. bindSamplers(effect: Effect): void;
  32558. private _activateCurrentTexture;
  32559. /** @hidden */
  32560. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32561. /** @hidden */
  32562. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32563. /**
  32564. * Unbind all textures from the webGL context
  32565. */
  32566. unbindAllTextures(): void;
  32567. /**
  32568. * Sets a texture to the according uniform.
  32569. * @param channel The texture channel
  32570. * @param uniform The uniform to set
  32571. * @param texture The texture to apply
  32572. */
  32573. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32574. private _bindSamplerUniformToChannel;
  32575. private _getTextureWrapMode;
  32576. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32577. /**
  32578. * Sets an array of texture to the webGL context
  32579. * @param channel defines the channel where the texture array must be set
  32580. * @param uniform defines the associated uniform location
  32581. * @param textures defines the array of textures to bind
  32582. */
  32583. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32584. /** @hidden */
  32585. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32586. private _setTextureParameterFloat;
  32587. private _setTextureParameterInteger;
  32588. /**
  32589. * Unbind all vertex attributes from the webGL context
  32590. */
  32591. unbindAllAttributes(): void;
  32592. /**
  32593. * 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
  32594. */
  32595. releaseEffects(): void;
  32596. /**
  32597. * Dispose and release all associated resources
  32598. */
  32599. dispose(): void;
  32600. /**
  32601. * Attach a new callback raised when context lost event is fired
  32602. * @param callback defines the callback to call
  32603. */
  32604. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32605. /**
  32606. * Attach a new callback raised when context restored event is fired
  32607. * @param callback defines the callback to call
  32608. */
  32609. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32610. /**
  32611. * Get the current error code of the webGL context
  32612. * @returns the error code
  32613. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32614. */
  32615. getError(): number;
  32616. private _canRenderToFloatFramebuffer;
  32617. private _canRenderToHalfFloatFramebuffer;
  32618. private _canRenderToFramebuffer;
  32619. /** @hidden */
  32620. _getWebGLTextureType(type: number): number;
  32621. /** @hidden */
  32622. _getInternalFormat(format: number): number;
  32623. /** @hidden */
  32624. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32625. /** @hidden */
  32626. _getRGBAMultiSampleBufferFormat(type: number): number;
  32627. /** @hidden */
  32628. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  32629. /**
  32630. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32631. * @param x defines the x coordinate of the rectangle where pixels must be read
  32632. * @param y defines the y coordinate of the rectangle where pixels must be read
  32633. * @param width defines the width of the rectangle where pixels must be read
  32634. * @param height defines the height of the rectangle where pixels must be read
  32635. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32636. * @returns a Uint8Array containing RGBA colors
  32637. */
  32638. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32639. private static _isSupported;
  32640. /**
  32641. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32642. * @returns true if the engine can be created
  32643. * @ignorenaming
  32644. */
  32645. static isSupported(): boolean;
  32646. /**
  32647. * Find the next highest power of two.
  32648. * @param x Number to start search from.
  32649. * @return Next highest power of two.
  32650. */
  32651. static CeilingPOT(x: number): number;
  32652. /**
  32653. * Find the next lowest power of two.
  32654. * @param x Number to start search from.
  32655. * @return Next lowest power of two.
  32656. */
  32657. static FloorPOT(x: number): number;
  32658. /**
  32659. * Find the nearest power of two.
  32660. * @param x Number to start search from.
  32661. * @return Next nearest power of two.
  32662. */
  32663. static NearestPOT(x: number): number;
  32664. /**
  32665. * Get the closest exponent of two
  32666. * @param value defines the value to approximate
  32667. * @param max defines the maximum value to return
  32668. * @param mode defines how to define the closest value
  32669. * @returns closest exponent of two of the given value
  32670. */
  32671. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32672. /**
  32673. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32674. * @param func - the function to be called
  32675. * @param requester - the object that will request the next frame. Falls back to window.
  32676. * @returns frame number
  32677. */
  32678. static QueueNewFrame(func: () => void, requester?: any): number;
  32679. /**
  32680. * Gets host document
  32681. * @returns the host document object
  32682. */
  32683. getHostDocument(): Nullable<Document>;
  32684. }
  32685. }
  32686. declare module "babylonjs/Maths/sphericalPolynomial" {
  32687. import { Vector3 } from "babylonjs/Maths/math.vector";
  32688. import { Color3 } from "babylonjs/Maths/math.color";
  32689. /**
  32690. * Class representing spherical harmonics coefficients to the 3rd degree
  32691. */
  32692. export class SphericalHarmonics {
  32693. /**
  32694. * Defines whether or not the harmonics have been prescaled for rendering.
  32695. */
  32696. preScaled: boolean;
  32697. /**
  32698. * The l0,0 coefficients of the spherical harmonics
  32699. */
  32700. l00: Vector3;
  32701. /**
  32702. * The l1,-1 coefficients of the spherical harmonics
  32703. */
  32704. l1_1: Vector3;
  32705. /**
  32706. * The l1,0 coefficients of the spherical harmonics
  32707. */
  32708. l10: Vector3;
  32709. /**
  32710. * The l1,1 coefficients of the spherical harmonics
  32711. */
  32712. l11: Vector3;
  32713. /**
  32714. * The l2,-2 coefficients of the spherical harmonics
  32715. */
  32716. l2_2: Vector3;
  32717. /**
  32718. * The l2,-1 coefficients of the spherical harmonics
  32719. */
  32720. l2_1: Vector3;
  32721. /**
  32722. * The l2,0 coefficients of the spherical harmonics
  32723. */
  32724. l20: Vector3;
  32725. /**
  32726. * The l2,1 coefficients of the spherical harmonics
  32727. */
  32728. l21: Vector3;
  32729. /**
  32730. * The l2,2 coefficients of the spherical harmonics
  32731. */
  32732. l22: Vector3;
  32733. /**
  32734. * Adds a light to the spherical harmonics
  32735. * @param direction the direction of the light
  32736. * @param color the color of the light
  32737. * @param deltaSolidAngle the delta solid angle of the light
  32738. */
  32739. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32740. /**
  32741. * Scales the spherical harmonics by the given amount
  32742. * @param scale the amount to scale
  32743. */
  32744. scaleInPlace(scale: number): void;
  32745. /**
  32746. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32747. *
  32748. * ```
  32749. * E_lm = A_l * L_lm
  32750. * ```
  32751. *
  32752. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32753. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32754. * the scaling factors are given in equation 9.
  32755. */
  32756. convertIncidentRadianceToIrradiance(): void;
  32757. /**
  32758. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32759. *
  32760. * ```
  32761. * L = (1/pi) * E * rho
  32762. * ```
  32763. *
  32764. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32765. */
  32766. convertIrradianceToLambertianRadiance(): void;
  32767. /**
  32768. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32769. * required operations at run time.
  32770. *
  32771. * This is simply done by scaling back the SH with Ylm constants parameter.
  32772. * The trigonometric part being applied by the shader at run time.
  32773. */
  32774. preScaleForRendering(): void;
  32775. /**
  32776. * Constructs a spherical harmonics from an array.
  32777. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32778. * @returns the spherical harmonics
  32779. */
  32780. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32781. /**
  32782. * Gets the spherical harmonics from polynomial
  32783. * @param polynomial the spherical polynomial
  32784. * @returns the spherical harmonics
  32785. */
  32786. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32787. }
  32788. /**
  32789. * Class representing spherical polynomial coefficients to the 3rd degree
  32790. */
  32791. export class SphericalPolynomial {
  32792. private _harmonics;
  32793. /**
  32794. * The spherical harmonics used to create the polynomials.
  32795. */
  32796. get preScaledHarmonics(): SphericalHarmonics;
  32797. /**
  32798. * The x coefficients of the spherical polynomial
  32799. */
  32800. x: Vector3;
  32801. /**
  32802. * The y coefficients of the spherical polynomial
  32803. */
  32804. y: Vector3;
  32805. /**
  32806. * The z coefficients of the spherical polynomial
  32807. */
  32808. z: Vector3;
  32809. /**
  32810. * The xx coefficients of the spherical polynomial
  32811. */
  32812. xx: Vector3;
  32813. /**
  32814. * The yy coefficients of the spherical polynomial
  32815. */
  32816. yy: Vector3;
  32817. /**
  32818. * The zz coefficients of the spherical polynomial
  32819. */
  32820. zz: Vector3;
  32821. /**
  32822. * The xy coefficients of the spherical polynomial
  32823. */
  32824. xy: Vector3;
  32825. /**
  32826. * The yz coefficients of the spherical polynomial
  32827. */
  32828. yz: Vector3;
  32829. /**
  32830. * The zx coefficients of the spherical polynomial
  32831. */
  32832. zx: Vector3;
  32833. /**
  32834. * Adds an ambient color to the spherical polynomial
  32835. * @param color the color to add
  32836. */
  32837. addAmbient(color: Color3): void;
  32838. /**
  32839. * Scales the spherical polynomial by the given amount
  32840. * @param scale the amount to scale
  32841. */
  32842. scaleInPlace(scale: number): void;
  32843. /**
  32844. * Gets the spherical polynomial from harmonics
  32845. * @param harmonics the spherical harmonics
  32846. * @returns the spherical polynomial
  32847. */
  32848. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32849. /**
  32850. * Constructs a spherical polynomial from an array.
  32851. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32852. * @returns the spherical polynomial
  32853. */
  32854. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32855. }
  32856. }
  32857. declare module "babylonjs/Materials/Textures/internalTexture" {
  32858. import { Observable } from "babylonjs/Misc/observable";
  32859. import { Nullable, int } from "babylonjs/types";
  32860. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32862. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32863. /**
  32864. * Defines the source of the internal texture
  32865. */
  32866. export enum InternalTextureSource {
  32867. /**
  32868. * The source of the texture data is unknown
  32869. */
  32870. Unknown = 0,
  32871. /**
  32872. * Texture data comes from an URL
  32873. */
  32874. Url = 1,
  32875. /**
  32876. * Texture data is only used for temporary storage
  32877. */
  32878. Temp = 2,
  32879. /**
  32880. * Texture data comes from raw data (ArrayBuffer)
  32881. */
  32882. Raw = 3,
  32883. /**
  32884. * Texture content is dynamic (video or dynamic texture)
  32885. */
  32886. Dynamic = 4,
  32887. /**
  32888. * Texture content is generated by rendering to it
  32889. */
  32890. RenderTarget = 5,
  32891. /**
  32892. * Texture content is part of a multi render target process
  32893. */
  32894. MultiRenderTarget = 6,
  32895. /**
  32896. * Texture data comes from a cube data file
  32897. */
  32898. Cube = 7,
  32899. /**
  32900. * Texture data comes from a raw cube data
  32901. */
  32902. CubeRaw = 8,
  32903. /**
  32904. * Texture data come from a prefiltered cube data file
  32905. */
  32906. CubePrefiltered = 9,
  32907. /**
  32908. * Texture content is raw 3D data
  32909. */
  32910. Raw3D = 10,
  32911. /**
  32912. * Texture content is raw 2D array data
  32913. */
  32914. Raw2DArray = 11,
  32915. /**
  32916. * Texture content is a depth texture
  32917. */
  32918. Depth = 12,
  32919. /**
  32920. * Texture data comes from a raw cube data encoded with RGBD
  32921. */
  32922. CubeRawRGBD = 13
  32923. }
  32924. /**
  32925. * Class used to store data associated with WebGL texture data for the engine
  32926. * This class should not be used directly
  32927. */
  32928. export class InternalTexture {
  32929. /** @hidden */
  32930. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32931. /**
  32932. * Defines if the texture is ready
  32933. */
  32934. isReady: boolean;
  32935. /**
  32936. * Defines if the texture is a cube texture
  32937. */
  32938. isCube: boolean;
  32939. /**
  32940. * Defines if the texture contains 3D data
  32941. */
  32942. is3D: boolean;
  32943. /**
  32944. * Defines if the texture contains 2D array data
  32945. */
  32946. is2DArray: boolean;
  32947. /**
  32948. * Defines if the texture contains multiview data
  32949. */
  32950. isMultiview: boolean;
  32951. /**
  32952. * Gets the URL used to load this texture
  32953. */
  32954. url: string;
  32955. /**
  32956. * Gets the sampling mode of the texture
  32957. */
  32958. samplingMode: number;
  32959. /**
  32960. * Gets a boolean indicating if the texture needs mipmaps generation
  32961. */
  32962. generateMipMaps: boolean;
  32963. /**
  32964. * Gets the number of samples used by the texture (WebGL2+ only)
  32965. */
  32966. samples: number;
  32967. /**
  32968. * Gets the type of the texture (int, float...)
  32969. */
  32970. type: number;
  32971. /**
  32972. * Gets the format of the texture (RGB, RGBA...)
  32973. */
  32974. format: number;
  32975. /**
  32976. * Observable called when the texture is loaded
  32977. */
  32978. onLoadedObservable: Observable<InternalTexture>;
  32979. /**
  32980. * Gets the width of the texture
  32981. */
  32982. width: number;
  32983. /**
  32984. * Gets the height of the texture
  32985. */
  32986. height: number;
  32987. /**
  32988. * Gets the depth of the texture
  32989. */
  32990. depth: number;
  32991. /**
  32992. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32993. */
  32994. baseWidth: number;
  32995. /**
  32996. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32997. */
  32998. baseHeight: number;
  32999. /**
  33000. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33001. */
  33002. baseDepth: number;
  33003. /**
  33004. * Gets a boolean indicating if the texture is inverted on Y axis
  33005. */
  33006. invertY: boolean;
  33007. /** @hidden */
  33008. _invertVScale: boolean;
  33009. /** @hidden */
  33010. _associatedChannel: number;
  33011. /** @hidden */
  33012. _source: InternalTextureSource;
  33013. /** @hidden */
  33014. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33015. /** @hidden */
  33016. _bufferView: Nullable<ArrayBufferView>;
  33017. /** @hidden */
  33018. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33019. /** @hidden */
  33020. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33021. /** @hidden */
  33022. _size: number;
  33023. /** @hidden */
  33024. _extension: string;
  33025. /** @hidden */
  33026. _files: Nullable<string[]>;
  33027. /** @hidden */
  33028. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33029. /** @hidden */
  33030. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33031. /** @hidden */
  33032. _framebuffer: Nullable<WebGLFramebuffer>;
  33033. /** @hidden */
  33034. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33035. /** @hidden */
  33036. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33037. /** @hidden */
  33038. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33039. /** @hidden */
  33040. _attachments: Nullable<number[]>;
  33041. /** @hidden */
  33042. _cachedCoordinatesMode: Nullable<number>;
  33043. /** @hidden */
  33044. _cachedWrapU: Nullable<number>;
  33045. /** @hidden */
  33046. _cachedWrapV: Nullable<number>;
  33047. /** @hidden */
  33048. _cachedWrapR: Nullable<number>;
  33049. /** @hidden */
  33050. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33051. /** @hidden */
  33052. _isDisabled: boolean;
  33053. /** @hidden */
  33054. _compression: Nullable<string>;
  33055. /** @hidden */
  33056. _generateStencilBuffer: boolean;
  33057. /** @hidden */
  33058. _generateDepthBuffer: boolean;
  33059. /** @hidden */
  33060. _comparisonFunction: number;
  33061. /** @hidden */
  33062. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33063. /** @hidden */
  33064. _lodGenerationScale: number;
  33065. /** @hidden */
  33066. _lodGenerationOffset: number;
  33067. /** @hidden */
  33068. _colorTextureArray: Nullable<WebGLTexture>;
  33069. /** @hidden */
  33070. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33071. /** @hidden */
  33072. _lodTextureHigh: Nullable<BaseTexture>;
  33073. /** @hidden */
  33074. _lodTextureMid: Nullable<BaseTexture>;
  33075. /** @hidden */
  33076. _lodTextureLow: Nullable<BaseTexture>;
  33077. /** @hidden */
  33078. _isRGBD: boolean;
  33079. /** @hidden */
  33080. _linearSpecularLOD: boolean;
  33081. /** @hidden */
  33082. _irradianceTexture: Nullable<BaseTexture>;
  33083. /** @hidden */
  33084. _webGLTexture: Nullable<WebGLTexture>;
  33085. /** @hidden */
  33086. _references: number;
  33087. private _engine;
  33088. /**
  33089. * Gets the Engine the texture belongs to.
  33090. * @returns The babylon engine
  33091. */
  33092. getEngine(): ThinEngine;
  33093. /**
  33094. * Gets the data source type of the texture
  33095. */
  33096. get source(): InternalTextureSource;
  33097. /**
  33098. * Creates a new InternalTexture
  33099. * @param engine defines the engine to use
  33100. * @param source defines the type of data that will be used
  33101. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33102. */
  33103. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33104. /**
  33105. * Increments the number of references (ie. the number of Texture that point to it)
  33106. */
  33107. incrementReferences(): void;
  33108. /**
  33109. * Change the size of the texture (not the size of the content)
  33110. * @param width defines the new width
  33111. * @param height defines the new height
  33112. * @param depth defines the new depth (1 by default)
  33113. */
  33114. updateSize(width: int, height: int, depth?: int): void;
  33115. /** @hidden */
  33116. _rebuild(): void;
  33117. /** @hidden */
  33118. _swapAndDie(target: InternalTexture): void;
  33119. /**
  33120. * Dispose the current allocated resources
  33121. */
  33122. dispose(): void;
  33123. }
  33124. }
  33125. declare module "babylonjs/Audio/analyser" {
  33126. import { Scene } from "babylonjs/scene";
  33127. /**
  33128. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33130. */
  33131. export class Analyser {
  33132. /**
  33133. * Gets or sets the smoothing
  33134. * @ignorenaming
  33135. */
  33136. SMOOTHING: number;
  33137. /**
  33138. * Gets or sets the FFT table size
  33139. * @ignorenaming
  33140. */
  33141. FFT_SIZE: number;
  33142. /**
  33143. * Gets or sets the bar graph amplitude
  33144. * @ignorenaming
  33145. */
  33146. BARGRAPHAMPLITUDE: number;
  33147. /**
  33148. * Gets or sets the position of the debug canvas
  33149. * @ignorenaming
  33150. */
  33151. DEBUGCANVASPOS: {
  33152. x: number;
  33153. y: number;
  33154. };
  33155. /**
  33156. * Gets or sets the debug canvas size
  33157. * @ignorenaming
  33158. */
  33159. DEBUGCANVASSIZE: {
  33160. width: number;
  33161. height: number;
  33162. };
  33163. private _byteFreqs;
  33164. private _byteTime;
  33165. private _floatFreqs;
  33166. private _webAudioAnalyser;
  33167. private _debugCanvas;
  33168. private _debugCanvasContext;
  33169. private _scene;
  33170. private _registerFunc;
  33171. private _audioEngine;
  33172. /**
  33173. * Creates a new analyser
  33174. * @param scene defines hosting scene
  33175. */
  33176. constructor(scene: Scene);
  33177. /**
  33178. * Get the number of data values you will have to play with for the visualization
  33179. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33180. * @returns a number
  33181. */
  33182. getFrequencyBinCount(): number;
  33183. /**
  33184. * Gets the current frequency data as a byte array
  33185. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33186. * @returns a Uint8Array
  33187. */
  33188. getByteFrequencyData(): Uint8Array;
  33189. /**
  33190. * Gets the current waveform as a byte array
  33191. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33192. * @returns a Uint8Array
  33193. */
  33194. getByteTimeDomainData(): Uint8Array;
  33195. /**
  33196. * Gets the current frequency data as a float array
  33197. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33198. * @returns a Float32Array
  33199. */
  33200. getFloatFrequencyData(): Float32Array;
  33201. /**
  33202. * Renders the debug canvas
  33203. */
  33204. drawDebugCanvas(): void;
  33205. /**
  33206. * Stops rendering the debug canvas and removes it
  33207. */
  33208. stopDebugCanvas(): void;
  33209. /**
  33210. * Connects two audio nodes
  33211. * @param inputAudioNode defines first node to connect
  33212. * @param outputAudioNode defines second node to connect
  33213. */
  33214. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33215. /**
  33216. * Releases all associated resources
  33217. */
  33218. dispose(): void;
  33219. }
  33220. }
  33221. declare module "babylonjs/Audio/audioEngine" {
  33222. import { IDisposable } from "babylonjs/scene";
  33223. import { Analyser } from "babylonjs/Audio/analyser";
  33224. import { Nullable } from "babylonjs/types";
  33225. import { Observable } from "babylonjs/Misc/observable";
  33226. /**
  33227. * This represents an audio engine and it is responsible
  33228. * to play, synchronize and analyse sounds throughout the application.
  33229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33230. */
  33231. export interface IAudioEngine extends IDisposable {
  33232. /**
  33233. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33234. */
  33235. readonly canUseWebAudio: boolean;
  33236. /**
  33237. * Gets the current AudioContext if available.
  33238. */
  33239. readonly audioContext: Nullable<AudioContext>;
  33240. /**
  33241. * The master gain node defines the global audio volume of your audio engine.
  33242. */
  33243. readonly masterGain: GainNode;
  33244. /**
  33245. * Gets whether or not mp3 are supported by your browser.
  33246. */
  33247. readonly isMP3supported: boolean;
  33248. /**
  33249. * Gets whether or not ogg are supported by your browser.
  33250. */
  33251. readonly isOGGsupported: boolean;
  33252. /**
  33253. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33254. * @ignoreNaming
  33255. */
  33256. WarnedWebAudioUnsupported: boolean;
  33257. /**
  33258. * Defines if the audio engine relies on a custom unlocked button.
  33259. * In this case, the embedded button will not be displayed.
  33260. */
  33261. useCustomUnlockedButton: boolean;
  33262. /**
  33263. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33264. */
  33265. readonly unlocked: boolean;
  33266. /**
  33267. * Event raised when audio has been unlocked on the browser.
  33268. */
  33269. onAudioUnlockedObservable: Observable<AudioEngine>;
  33270. /**
  33271. * Event raised when audio has been locked on the browser.
  33272. */
  33273. onAudioLockedObservable: Observable<AudioEngine>;
  33274. /**
  33275. * Flags the audio engine in Locked state.
  33276. * This happens due to new browser policies preventing audio to autoplay.
  33277. */
  33278. lock(): void;
  33279. /**
  33280. * Unlocks the audio engine once a user action has been done on the dom.
  33281. * This is helpful to resume play once browser policies have been satisfied.
  33282. */
  33283. unlock(): void;
  33284. }
  33285. /**
  33286. * This represents the default audio engine used in babylon.
  33287. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33289. */
  33290. export class AudioEngine implements IAudioEngine {
  33291. private _audioContext;
  33292. private _audioContextInitialized;
  33293. private _muteButton;
  33294. private _hostElement;
  33295. /**
  33296. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33297. */
  33298. canUseWebAudio: boolean;
  33299. /**
  33300. * The master gain node defines the global audio volume of your audio engine.
  33301. */
  33302. masterGain: GainNode;
  33303. /**
  33304. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33305. * @ignoreNaming
  33306. */
  33307. WarnedWebAudioUnsupported: boolean;
  33308. /**
  33309. * Gets whether or not mp3 are supported by your browser.
  33310. */
  33311. isMP3supported: boolean;
  33312. /**
  33313. * Gets whether or not ogg are supported by your browser.
  33314. */
  33315. isOGGsupported: boolean;
  33316. /**
  33317. * Gets whether audio has been unlocked on the device.
  33318. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33319. * a user interaction has happened.
  33320. */
  33321. unlocked: boolean;
  33322. /**
  33323. * Defines if the audio engine relies on a custom unlocked button.
  33324. * In this case, the embedded button will not be displayed.
  33325. */
  33326. useCustomUnlockedButton: boolean;
  33327. /**
  33328. * Event raised when audio has been unlocked on the browser.
  33329. */
  33330. onAudioUnlockedObservable: Observable<AudioEngine>;
  33331. /**
  33332. * Event raised when audio has been locked on the browser.
  33333. */
  33334. onAudioLockedObservable: Observable<AudioEngine>;
  33335. /**
  33336. * Gets the current AudioContext if available.
  33337. */
  33338. get audioContext(): Nullable<AudioContext>;
  33339. private _connectedAnalyser;
  33340. /**
  33341. * Instantiates a new audio engine.
  33342. *
  33343. * There should be only one per page as some browsers restrict the number
  33344. * of audio contexts you can create.
  33345. * @param hostElement defines the host element where to display the mute icon if necessary
  33346. */
  33347. constructor(hostElement?: Nullable<HTMLElement>);
  33348. /**
  33349. * Flags the audio engine in Locked state.
  33350. * This happens due to new browser policies preventing audio to autoplay.
  33351. */
  33352. lock(): void;
  33353. /**
  33354. * Unlocks the audio engine once a user action has been done on the dom.
  33355. * This is helpful to resume play once browser policies have been satisfied.
  33356. */
  33357. unlock(): void;
  33358. private _resumeAudioContext;
  33359. private _initializeAudioContext;
  33360. private _tryToRun;
  33361. private _triggerRunningState;
  33362. private _triggerSuspendedState;
  33363. private _displayMuteButton;
  33364. private _moveButtonToTopLeft;
  33365. private _onResize;
  33366. private _hideMuteButton;
  33367. /**
  33368. * Destroy and release the resources associated with the audio ccontext.
  33369. */
  33370. dispose(): void;
  33371. /**
  33372. * Gets the global volume sets on the master gain.
  33373. * @returns the global volume if set or -1 otherwise
  33374. */
  33375. getGlobalVolume(): number;
  33376. /**
  33377. * Sets the global volume of your experience (sets on the master gain).
  33378. * @param newVolume Defines the new global volume of the application
  33379. */
  33380. setGlobalVolume(newVolume: number): void;
  33381. /**
  33382. * Connect the audio engine to an audio analyser allowing some amazing
  33383. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33385. * @param analyser The analyser to connect to the engine
  33386. */
  33387. connectToAnalyser(analyser: Analyser): void;
  33388. }
  33389. }
  33390. declare module "babylonjs/Loading/loadingScreen" {
  33391. /**
  33392. * Interface used to present a loading screen while loading a scene
  33393. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33394. */
  33395. export interface ILoadingScreen {
  33396. /**
  33397. * Function called to display the loading screen
  33398. */
  33399. displayLoadingUI: () => void;
  33400. /**
  33401. * Function called to hide the loading screen
  33402. */
  33403. hideLoadingUI: () => void;
  33404. /**
  33405. * Gets or sets the color to use for the background
  33406. */
  33407. loadingUIBackgroundColor: string;
  33408. /**
  33409. * Gets or sets the text to display while loading
  33410. */
  33411. loadingUIText: string;
  33412. }
  33413. /**
  33414. * Class used for the default loading screen
  33415. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33416. */
  33417. export class DefaultLoadingScreen implements ILoadingScreen {
  33418. private _renderingCanvas;
  33419. private _loadingText;
  33420. private _loadingDivBackgroundColor;
  33421. private _loadingDiv;
  33422. private _loadingTextDiv;
  33423. /** Gets or sets the logo url to use for the default loading screen */
  33424. static DefaultLogoUrl: string;
  33425. /** Gets or sets the spinner url to use for the default loading screen */
  33426. static DefaultSpinnerUrl: string;
  33427. /**
  33428. * Creates a new default loading screen
  33429. * @param _renderingCanvas defines the canvas used to render the scene
  33430. * @param _loadingText defines the default text to display
  33431. * @param _loadingDivBackgroundColor defines the default background color
  33432. */
  33433. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33434. /**
  33435. * Function called to display the loading screen
  33436. */
  33437. displayLoadingUI(): void;
  33438. /**
  33439. * Function called to hide the loading screen
  33440. */
  33441. hideLoadingUI(): void;
  33442. /**
  33443. * Gets or sets the text to display while loading
  33444. */
  33445. set loadingUIText(text: string);
  33446. get loadingUIText(): string;
  33447. /**
  33448. * Gets or sets the color to use for the background
  33449. */
  33450. get loadingUIBackgroundColor(): string;
  33451. set loadingUIBackgroundColor(color: string);
  33452. private _resizeLoadingUI;
  33453. }
  33454. }
  33455. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33456. /**
  33457. * Interface for any object that can request an animation frame
  33458. */
  33459. export interface ICustomAnimationFrameRequester {
  33460. /**
  33461. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33462. */
  33463. renderFunction?: Function;
  33464. /**
  33465. * Called to request the next frame to render to
  33466. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33467. */
  33468. requestAnimationFrame: Function;
  33469. /**
  33470. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33471. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33472. */
  33473. requestID?: number;
  33474. }
  33475. }
  33476. declare module "babylonjs/Misc/performanceMonitor" {
  33477. /**
  33478. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33479. */
  33480. export class PerformanceMonitor {
  33481. private _enabled;
  33482. private _rollingFrameTime;
  33483. private _lastFrameTimeMs;
  33484. /**
  33485. * constructor
  33486. * @param frameSampleSize The number of samples required to saturate the sliding window
  33487. */
  33488. constructor(frameSampleSize?: number);
  33489. /**
  33490. * Samples current frame
  33491. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33492. */
  33493. sampleFrame(timeMs?: number): void;
  33494. /**
  33495. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33496. */
  33497. get averageFrameTime(): number;
  33498. /**
  33499. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33500. */
  33501. get averageFrameTimeVariance(): number;
  33502. /**
  33503. * Returns the frame time of the most recent frame
  33504. */
  33505. get instantaneousFrameTime(): number;
  33506. /**
  33507. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33508. */
  33509. get averageFPS(): number;
  33510. /**
  33511. * Returns the average framerate in frames per second using the most recent frame time
  33512. */
  33513. get instantaneousFPS(): number;
  33514. /**
  33515. * Returns true if enough samples have been taken to completely fill the sliding window
  33516. */
  33517. get isSaturated(): boolean;
  33518. /**
  33519. * Enables contributions to the sliding window sample set
  33520. */
  33521. enable(): void;
  33522. /**
  33523. * Disables contributions to the sliding window sample set
  33524. * Samples will not be interpolated over the disabled period
  33525. */
  33526. disable(): void;
  33527. /**
  33528. * Returns true if sampling is enabled
  33529. */
  33530. get isEnabled(): boolean;
  33531. /**
  33532. * Resets performance monitor
  33533. */
  33534. reset(): void;
  33535. }
  33536. /**
  33537. * RollingAverage
  33538. *
  33539. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33540. */
  33541. export class RollingAverage {
  33542. /**
  33543. * Current average
  33544. */
  33545. average: number;
  33546. /**
  33547. * Current variance
  33548. */
  33549. variance: number;
  33550. protected _samples: Array<number>;
  33551. protected _sampleCount: number;
  33552. protected _pos: number;
  33553. protected _m2: number;
  33554. /**
  33555. * constructor
  33556. * @param length The number of samples required to saturate the sliding window
  33557. */
  33558. constructor(length: number);
  33559. /**
  33560. * Adds a sample to the sample set
  33561. * @param v The sample value
  33562. */
  33563. add(v: number): void;
  33564. /**
  33565. * Returns previously added values or null if outside of history or outside the sliding window domain
  33566. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33567. * @return Value previously recorded with add() or null if outside of range
  33568. */
  33569. history(i: number): number;
  33570. /**
  33571. * Returns true if enough samples have been taken to completely fill the sliding window
  33572. * @return true if sample-set saturated
  33573. */
  33574. isSaturated(): boolean;
  33575. /**
  33576. * Resets the rolling average (equivalent to 0 samples taken so far)
  33577. */
  33578. reset(): void;
  33579. /**
  33580. * Wraps a value around the sample range boundaries
  33581. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33582. * @return Wrapped position in sample range
  33583. */
  33584. protected _wrapPosition(i: number): number;
  33585. }
  33586. }
  33587. declare module "babylonjs/Misc/perfCounter" {
  33588. /**
  33589. * This class is used to track a performance counter which is number based.
  33590. * The user has access to many properties which give statistics of different nature.
  33591. *
  33592. * The implementer can track two kinds of Performance Counter: time and count.
  33593. * 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.
  33594. * 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.
  33595. */
  33596. export class PerfCounter {
  33597. /**
  33598. * Gets or sets a global boolean to turn on and off all the counters
  33599. */
  33600. static Enabled: boolean;
  33601. /**
  33602. * Returns the smallest value ever
  33603. */
  33604. get min(): number;
  33605. /**
  33606. * Returns the biggest value ever
  33607. */
  33608. get max(): number;
  33609. /**
  33610. * Returns the average value since the performance counter is running
  33611. */
  33612. get average(): number;
  33613. /**
  33614. * Returns the average value of the last second the counter was monitored
  33615. */
  33616. get lastSecAverage(): number;
  33617. /**
  33618. * Returns the current value
  33619. */
  33620. get current(): number;
  33621. /**
  33622. * Gets the accumulated total
  33623. */
  33624. get total(): number;
  33625. /**
  33626. * Gets the total value count
  33627. */
  33628. get count(): number;
  33629. /**
  33630. * Creates a new counter
  33631. */
  33632. constructor();
  33633. /**
  33634. * Call this method to start monitoring a new frame.
  33635. * 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.
  33636. */
  33637. fetchNewFrame(): void;
  33638. /**
  33639. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33640. * @param newCount the count value to add to the monitored count
  33641. * @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.
  33642. */
  33643. addCount(newCount: number, fetchResult: boolean): void;
  33644. /**
  33645. * Start monitoring this performance counter
  33646. */
  33647. beginMonitoring(): void;
  33648. /**
  33649. * Compute the time lapsed since the previous beginMonitoring() call.
  33650. * @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
  33651. */
  33652. endMonitoring(newFrame?: boolean): void;
  33653. private _fetchResult;
  33654. private _startMonitoringTime;
  33655. private _min;
  33656. private _max;
  33657. private _average;
  33658. private _current;
  33659. private _totalValueCount;
  33660. private _totalAccumulated;
  33661. private _lastSecAverage;
  33662. private _lastSecAccumulated;
  33663. private _lastSecTime;
  33664. private _lastSecValueCount;
  33665. }
  33666. }
  33667. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33668. module "babylonjs/Engines/thinEngine" {
  33669. interface ThinEngine {
  33670. /**
  33671. * Sets alpha constants used by some alpha blending modes
  33672. * @param r defines the red component
  33673. * @param g defines the green component
  33674. * @param b defines the blue component
  33675. * @param a defines the alpha component
  33676. */
  33677. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33678. /**
  33679. * Sets the current alpha mode
  33680. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33681. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33682. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33683. */
  33684. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33685. /**
  33686. * Gets the current alpha mode
  33687. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33688. * @returns the current alpha mode
  33689. */
  33690. getAlphaMode(): number;
  33691. /**
  33692. * Sets the current alpha equation
  33693. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33694. */
  33695. setAlphaEquation(equation: number): void;
  33696. /**
  33697. * Gets the current alpha equation.
  33698. * @returns the current alpha equation
  33699. */
  33700. getAlphaEquation(): number;
  33701. }
  33702. }
  33703. }
  33704. declare module "babylonjs/Engines/engine" {
  33705. import { Observable } from "babylonjs/Misc/observable";
  33706. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33707. import { Scene } from "babylonjs/scene";
  33708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33709. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33710. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33711. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33712. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33713. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33714. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33715. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33716. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33717. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33718. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33719. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33720. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33721. import "babylonjs/Engines/Extensions/engine.alpha";
  33722. import { Material } from "babylonjs/Materials/material";
  33723. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33724. /**
  33725. * Defines the interface used by display changed events
  33726. */
  33727. export interface IDisplayChangedEventArgs {
  33728. /** Gets the vrDisplay object (if any) */
  33729. vrDisplay: Nullable<any>;
  33730. /** Gets a boolean indicating if webVR is supported */
  33731. vrSupported: boolean;
  33732. }
  33733. /**
  33734. * Defines the interface used by objects containing a viewport (like a camera)
  33735. */
  33736. interface IViewportOwnerLike {
  33737. /**
  33738. * Gets or sets the viewport
  33739. */
  33740. viewport: IViewportLike;
  33741. }
  33742. /**
  33743. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33744. */
  33745. export class Engine extends ThinEngine {
  33746. /** Defines that alpha blending is disabled */
  33747. static readonly ALPHA_DISABLE: number;
  33748. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33749. static readonly ALPHA_ADD: number;
  33750. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33751. static readonly ALPHA_COMBINE: number;
  33752. /** Defines that alpha blending to DEST - SRC * DEST */
  33753. static readonly ALPHA_SUBTRACT: number;
  33754. /** Defines that alpha blending to SRC * DEST */
  33755. static readonly ALPHA_MULTIPLY: number;
  33756. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33757. static readonly ALPHA_MAXIMIZED: number;
  33758. /** Defines that alpha blending to SRC + DEST */
  33759. static readonly ALPHA_ONEONE: number;
  33760. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33761. static readonly ALPHA_PREMULTIPLIED: number;
  33762. /**
  33763. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33764. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33765. */
  33766. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33767. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33768. static readonly ALPHA_INTERPOLATE: number;
  33769. /**
  33770. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33771. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33772. */
  33773. static readonly ALPHA_SCREENMODE: number;
  33774. /** Defines that the ressource is not delayed*/
  33775. static readonly DELAYLOADSTATE_NONE: number;
  33776. /** Defines that the ressource was successfully delay loaded */
  33777. static readonly DELAYLOADSTATE_LOADED: number;
  33778. /** Defines that the ressource is currently delay loading */
  33779. static readonly DELAYLOADSTATE_LOADING: number;
  33780. /** Defines that the ressource is delayed and has not started loading */
  33781. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33782. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33783. static readonly NEVER: number;
  33784. /** 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 */
  33785. static readonly ALWAYS: number;
  33786. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33787. static readonly LESS: number;
  33788. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33789. static readonly EQUAL: number;
  33790. /** 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 */
  33791. static readonly LEQUAL: number;
  33792. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33793. static readonly GREATER: number;
  33794. /** 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 */
  33795. static readonly GEQUAL: number;
  33796. /** 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 */
  33797. static readonly NOTEQUAL: number;
  33798. /** Passed to stencilOperation to specify that stencil value must be kept */
  33799. static readonly KEEP: number;
  33800. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33801. static readonly REPLACE: number;
  33802. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33803. static readonly INCR: number;
  33804. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33805. static readonly DECR: number;
  33806. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33807. static readonly INVERT: number;
  33808. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33809. static readonly INCR_WRAP: number;
  33810. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33811. static readonly DECR_WRAP: number;
  33812. /** Texture is not repeating outside of 0..1 UVs */
  33813. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33814. /** Texture is repeating outside of 0..1 UVs */
  33815. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33816. /** Texture is repeating and mirrored */
  33817. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33818. /** ALPHA */
  33819. static readonly TEXTUREFORMAT_ALPHA: number;
  33820. /** LUMINANCE */
  33821. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33822. /** LUMINANCE_ALPHA */
  33823. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33824. /** RGB */
  33825. static readonly TEXTUREFORMAT_RGB: number;
  33826. /** RGBA */
  33827. static readonly TEXTUREFORMAT_RGBA: number;
  33828. /** RED */
  33829. static readonly TEXTUREFORMAT_RED: number;
  33830. /** RED (2nd reference) */
  33831. static readonly TEXTUREFORMAT_R: number;
  33832. /** RG */
  33833. static readonly TEXTUREFORMAT_RG: number;
  33834. /** RED_INTEGER */
  33835. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33836. /** RED_INTEGER (2nd reference) */
  33837. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33838. /** RG_INTEGER */
  33839. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33840. /** RGB_INTEGER */
  33841. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33842. /** RGBA_INTEGER */
  33843. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33844. /** UNSIGNED_BYTE */
  33845. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33846. /** UNSIGNED_BYTE (2nd reference) */
  33847. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33848. /** FLOAT */
  33849. static readonly TEXTURETYPE_FLOAT: number;
  33850. /** HALF_FLOAT */
  33851. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33852. /** BYTE */
  33853. static readonly TEXTURETYPE_BYTE: number;
  33854. /** SHORT */
  33855. static readonly TEXTURETYPE_SHORT: number;
  33856. /** UNSIGNED_SHORT */
  33857. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33858. /** INT */
  33859. static readonly TEXTURETYPE_INT: number;
  33860. /** UNSIGNED_INT */
  33861. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33862. /** UNSIGNED_SHORT_4_4_4_4 */
  33863. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33864. /** UNSIGNED_SHORT_5_5_5_1 */
  33865. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33866. /** UNSIGNED_SHORT_5_6_5 */
  33867. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33868. /** UNSIGNED_INT_2_10_10_10_REV */
  33869. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33870. /** UNSIGNED_INT_24_8 */
  33871. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33872. /** UNSIGNED_INT_10F_11F_11F_REV */
  33873. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33874. /** UNSIGNED_INT_5_9_9_9_REV */
  33875. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33876. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33877. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33878. /** nearest is mag = nearest and min = nearest and mip = linear */
  33879. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33880. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33881. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33882. /** Trilinear is mag = linear and min = linear and mip = linear */
  33883. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33884. /** nearest is mag = nearest and min = nearest and mip = linear */
  33885. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33886. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33887. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33888. /** Trilinear is mag = linear and min = linear and mip = linear */
  33889. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33890. /** mag = nearest and min = nearest and mip = nearest */
  33891. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33892. /** mag = nearest and min = linear and mip = nearest */
  33893. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33894. /** mag = nearest and min = linear and mip = linear */
  33895. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33896. /** mag = nearest and min = linear and mip = none */
  33897. static readonly TEXTURE_NEAREST_LINEAR: number;
  33898. /** mag = nearest and min = nearest and mip = none */
  33899. static readonly TEXTURE_NEAREST_NEAREST: number;
  33900. /** mag = linear and min = nearest and mip = nearest */
  33901. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33902. /** mag = linear and min = nearest and mip = linear */
  33903. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33904. /** mag = linear and min = linear and mip = none */
  33905. static readonly TEXTURE_LINEAR_LINEAR: number;
  33906. /** mag = linear and min = nearest and mip = none */
  33907. static readonly TEXTURE_LINEAR_NEAREST: number;
  33908. /** Explicit coordinates mode */
  33909. static readonly TEXTURE_EXPLICIT_MODE: number;
  33910. /** Spherical coordinates mode */
  33911. static readonly TEXTURE_SPHERICAL_MODE: number;
  33912. /** Planar coordinates mode */
  33913. static readonly TEXTURE_PLANAR_MODE: number;
  33914. /** Cubic coordinates mode */
  33915. static readonly TEXTURE_CUBIC_MODE: number;
  33916. /** Projection coordinates mode */
  33917. static readonly TEXTURE_PROJECTION_MODE: number;
  33918. /** Skybox coordinates mode */
  33919. static readonly TEXTURE_SKYBOX_MODE: number;
  33920. /** Inverse Cubic coordinates mode */
  33921. static readonly TEXTURE_INVCUBIC_MODE: number;
  33922. /** Equirectangular coordinates mode */
  33923. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33924. /** Equirectangular Fixed coordinates mode */
  33925. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33926. /** Equirectangular Fixed Mirrored coordinates mode */
  33927. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33928. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33929. static readonly SCALEMODE_FLOOR: number;
  33930. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33931. static readonly SCALEMODE_NEAREST: number;
  33932. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33933. static readonly SCALEMODE_CEILING: number;
  33934. /**
  33935. * Returns the current npm package of the sdk
  33936. */
  33937. static get NpmPackage(): string;
  33938. /**
  33939. * Returns the current version of the framework
  33940. */
  33941. static get Version(): string;
  33942. /** Gets the list of created engines */
  33943. static get Instances(): Engine[];
  33944. /**
  33945. * Gets the latest created engine
  33946. */
  33947. static get LastCreatedEngine(): Nullable<Engine>;
  33948. /**
  33949. * Gets the latest created scene
  33950. */
  33951. static get LastCreatedScene(): Nullable<Scene>;
  33952. /**
  33953. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33954. * @param flag defines which part of the materials must be marked as dirty
  33955. * @param predicate defines a predicate used to filter which materials should be affected
  33956. */
  33957. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33958. /**
  33959. * Method called to create the default loading screen.
  33960. * This can be overriden in your own app.
  33961. * @param canvas The rendering canvas element
  33962. * @returns The loading screen
  33963. */
  33964. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33965. /**
  33966. * Method called to create the default rescale post process on each engine.
  33967. */
  33968. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33969. /**
  33970. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33971. **/
  33972. enableOfflineSupport: boolean;
  33973. /**
  33974. * 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)
  33975. **/
  33976. disableManifestCheck: boolean;
  33977. /**
  33978. * Gets the list of created scenes
  33979. */
  33980. scenes: Scene[];
  33981. /**
  33982. * Event raised when a new scene is created
  33983. */
  33984. onNewSceneAddedObservable: Observable<Scene>;
  33985. /**
  33986. * Gets the list of created postprocesses
  33987. */
  33988. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33989. /**
  33990. * Gets a boolean indicating if the pointer is currently locked
  33991. */
  33992. isPointerLock: boolean;
  33993. /**
  33994. * Observable event triggered each time the rendering canvas is resized
  33995. */
  33996. onResizeObservable: Observable<Engine>;
  33997. /**
  33998. * Observable event triggered each time the canvas loses focus
  33999. */
  34000. onCanvasBlurObservable: Observable<Engine>;
  34001. /**
  34002. * Observable event triggered each time the canvas gains focus
  34003. */
  34004. onCanvasFocusObservable: Observable<Engine>;
  34005. /**
  34006. * Observable event triggered each time the canvas receives pointerout event
  34007. */
  34008. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34009. /**
  34010. * Observable raised when the engine begins a new frame
  34011. */
  34012. onBeginFrameObservable: Observable<Engine>;
  34013. /**
  34014. * If set, will be used to request the next animation frame for the render loop
  34015. */
  34016. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34017. /**
  34018. * Observable raised when the engine ends the current frame
  34019. */
  34020. onEndFrameObservable: Observable<Engine>;
  34021. /**
  34022. * Observable raised when the engine is about to compile a shader
  34023. */
  34024. onBeforeShaderCompilationObservable: Observable<Engine>;
  34025. /**
  34026. * Observable raised when the engine has jsut compiled a shader
  34027. */
  34028. onAfterShaderCompilationObservable: Observable<Engine>;
  34029. /**
  34030. * Gets the audio engine
  34031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34032. * @ignorenaming
  34033. */
  34034. static audioEngine: IAudioEngine;
  34035. /**
  34036. * Default AudioEngine factory responsible of creating the Audio Engine.
  34037. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34038. */
  34039. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34040. /**
  34041. * Default offline support factory responsible of creating a tool used to store data locally.
  34042. * By default, this will create a Database object if the workload has been embedded.
  34043. */
  34044. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34045. private _loadingScreen;
  34046. private _pointerLockRequested;
  34047. private _dummyFramebuffer;
  34048. private _rescalePostProcess;
  34049. private _deterministicLockstep;
  34050. private _lockstepMaxSteps;
  34051. private _timeStep;
  34052. protected get _supportsHardwareTextureRescaling(): boolean;
  34053. private _fps;
  34054. private _deltaTime;
  34055. /** @hidden */
  34056. _drawCalls: PerfCounter;
  34057. /**
  34058. * Turn this value on if you want to pause FPS computation when in background
  34059. */
  34060. disablePerformanceMonitorInBackground: boolean;
  34061. private _performanceMonitor;
  34062. /**
  34063. * Gets the performance monitor attached to this engine
  34064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34065. */
  34066. get performanceMonitor(): PerformanceMonitor;
  34067. private _onFocus;
  34068. private _onBlur;
  34069. private _onCanvasPointerOut;
  34070. private _onCanvasBlur;
  34071. private _onCanvasFocus;
  34072. private _onFullscreenChange;
  34073. private _onPointerLockChange;
  34074. /**
  34075. * Gets the HTML element used to attach event listeners
  34076. * @returns a HTML element
  34077. */
  34078. getInputElement(): Nullable<HTMLElement>;
  34079. /**
  34080. * Creates a new engine
  34081. * @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
  34082. * @param antialias defines enable antialiasing (default: false)
  34083. * @param options defines further options to be sent to the getContext() function
  34084. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34085. */
  34086. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34087. /**
  34088. * Gets current aspect ratio
  34089. * @param viewportOwner defines the camera to use to get the aspect ratio
  34090. * @param useScreen defines if screen size must be used (or the current render target if any)
  34091. * @returns a number defining the aspect ratio
  34092. */
  34093. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34094. /**
  34095. * Gets current screen aspect ratio
  34096. * @returns a number defining the aspect ratio
  34097. */
  34098. getScreenAspectRatio(): number;
  34099. /**
  34100. * Gets the client rect of the HTML canvas attached with the current webGL context
  34101. * @returns a client rectanglee
  34102. */
  34103. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34104. /**
  34105. * Gets the client rect of the HTML element used for events
  34106. * @returns a client rectanglee
  34107. */
  34108. getInputElementClientRect(): Nullable<ClientRect>;
  34109. /**
  34110. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34111. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34112. * @returns true if engine is in deterministic lock step mode
  34113. */
  34114. isDeterministicLockStep(): boolean;
  34115. /**
  34116. * Gets the max steps when engine is running in deterministic lock step
  34117. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34118. * @returns the max steps
  34119. */
  34120. getLockstepMaxSteps(): number;
  34121. /**
  34122. * Returns the time in ms between steps when using deterministic lock step.
  34123. * @returns time step in (ms)
  34124. */
  34125. getTimeStep(): number;
  34126. /**
  34127. * Force the mipmap generation for the given render target texture
  34128. * @param texture defines the render target texture to use
  34129. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34130. */
  34131. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34132. /** States */
  34133. /**
  34134. * Set various states to the webGL context
  34135. * @param culling defines backface culling state
  34136. * @param zOffset defines the value to apply to zOffset (0 by default)
  34137. * @param force defines if states must be applied even if cache is up to date
  34138. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34139. */
  34140. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34141. /**
  34142. * Set the z offset to apply to current rendering
  34143. * @param value defines the offset to apply
  34144. */
  34145. setZOffset(value: number): void;
  34146. /**
  34147. * Gets the current value of the zOffset
  34148. * @returns the current zOffset state
  34149. */
  34150. getZOffset(): number;
  34151. /**
  34152. * Enable or disable depth buffering
  34153. * @param enable defines the state to set
  34154. */
  34155. setDepthBuffer(enable: boolean): void;
  34156. /**
  34157. * Gets a boolean indicating if depth writing is enabled
  34158. * @returns the current depth writing state
  34159. */
  34160. getDepthWrite(): boolean;
  34161. /**
  34162. * Enable or disable depth writing
  34163. * @param enable defines the state to set
  34164. */
  34165. setDepthWrite(enable: boolean): void;
  34166. /**
  34167. * Gets a boolean indicating if stencil buffer is enabled
  34168. * @returns the current stencil buffer state
  34169. */
  34170. getStencilBuffer(): boolean;
  34171. /**
  34172. * Enable or disable the stencil buffer
  34173. * @param enable defines if the stencil buffer must be enabled or disabled
  34174. */
  34175. setStencilBuffer(enable: boolean): void;
  34176. /**
  34177. * Gets the current stencil mask
  34178. * @returns a number defining the new stencil mask to use
  34179. */
  34180. getStencilMask(): number;
  34181. /**
  34182. * Sets the current stencil mask
  34183. * @param mask defines the new stencil mask to use
  34184. */
  34185. setStencilMask(mask: number): void;
  34186. /**
  34187. * Gets the current stencil function
  34188. * @returns a number defining the stencil function to use
  34189. */
  34190. getStencilFunction(): number;
  34191. /**
  34192. * Gets the current stencil reference value
  34193. * @returns a number defining the stencil reference value to use
  34194. */
  34195. getStencilFunctionReference(): number;
  34196. /**
  34197. * Gets the current stencil mask
  34198. * @returns a number defining the stencil mask to use
  34199. */
  34200. getStencilFunctionMask(): number;
  34201. /**
  34202. * Sets the current stencil function
  34203. * @param stencilFunc defines the new stencil function to use
  34204. */
  34205. setStencilFunction(stencilFunc: number): void;
  34206. /**
  34207. * Sets the current stencil reference
  34208. * @param reference defines the new stencil reference to use
  34209. */
  34210. setStencilFunctionReference(reference: number): void;
  34211. /**
  34212. * Sets the current stencil mask
  34213. * @param mask defines the new stencil mask to use
  34214. */
  34215. setStencilFunctionMask(mask: number): void;
  34216. /**
  34217. * Gets the current stencil operation when stencil fails
  34218. * @returns a number defining stencil operation to use when stencil fails
  34219. */
  34220. getStencilOperationFail(): number;
  34221. /**
  34222. * Gets the current stencil operation when depth fails
  34223. * @returns a number defining stencil operation to use when depth fails
  34224. */
  34225. getStencilOperationDepthFail(): number;
  34226. /**
  34227. * Gets the current stencil operation when stencil passes
  34228. * @returns a number defining stencil operation to use when stencil passes
  34229. */
  34230. getStencilOperationPass(): number;
  34231. /**
  34232. * Sets the stencil operation to use when stencil fails
  34233. * @param operation defines the stencil operation to use when stencil fails
  34234. */
  34235. setStencilOperationFail(operation: number): void;
  34236. /**
  34237. * Sets the stencil operation to use when depth fails
  34238. * @param operation defines the stencil operation to use when depth fails
  34239. */
  34240. setStencilOperationDepthFail(operation: number): void;
  34241. /**
  34242. * Sets the stencil operation to use when stencil passes
  34243. * @param operation defines the stencil operation to use when stencil passes
  34244. */
  34245. setStencilOperationPass(operation: number): void;
  34246. /**
  34247. * Sets a boolean indicating if the dithering state is enabled or disabled
  34248. * @param value defines the dithering state
  34249. */
  34250. setDitheringState(value: boolean): void;
  34251. /**
  34252. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34253. * @param value defines the rasterizer state
  34254. */
  34255. setRasterizerState(value: boolean): void;
  34256. /**
  34257. * Gets the current depth function
  34258. * @returns a number defining the depth function
  34259. */
  34260. getDepthFunction(): Nullable<number>;
  34261. /**
  34262. * Sets the current depth function
  34263. * @param depthFunc defines the function to use
  34264. */
  34265. setDepthFunction(depthFunc: number): void;
  34266. /**
  34267. * Sets the current depth function to GREATER
  34268. */
  34269. setDepthFunctionToGreater(): void;
  34270. /**
  34271. * Sets the current depth function to GEQUAL
  34272. */
  34273. setDepthFunctionToGreaterOrEqual(): void;
  34274. /**
  34275. * Sets the current depth function to LESS
  34276. */
  34277. setDepthFunctionToLess(): void;
  34278. /**
  34279. * Sets the current depth function to LEQUAL
  34280. */
  34281. setDepthFunctionToLessOrEqual(): void;
  34282. private _cachedStencilBuffer;
  34283. private _cachedStencilFunction;
  34284. private _cachedStencilMask;
  34285. private _cachedStencilOperationPass;
  34286. private _cachedStencilOperationFail;
  34287. private _cachedStencilOperationDepthFail;
  34288. private _cachedStencilReference;
  34289. /**
  34290. * Caches the the state of the stencil buffer
  34291. */
  34292. cacheStencilState(): void;
  34293. /**
  34294. * Restores the state of the stencil buffer
  34295. */
  34296. restoreStencilState(): void;
  34297. /**
  34298. * Directly set the WebGL Viewport
  34299. * @param x defines the x coordinate of the viewport (in screen space)
  34300. * @param y defines the y coordinate of the viewport (in screen space)
  34301. * @param width defines the width of the viewport (in screen space)
  34302. * @param height defines the height of the viewport (in screen space)
  34303. * @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
  34304. */
  34305. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34306. /**
  34307. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34308. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34309. * @param y defines the y-coordinate of the corner of the clear rectangle
  34310. * @param width defines the width of the clear rectangle
  34311. * @param height defines the height of the clear rectangle
  34312. * @param clearColor defines the clear color
  34313. */
  34314. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34315. /**
  34316. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34317. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34318. * @param y defines the y-coordinate of the corner of the clear rectangle
  34319. * @param width defines the width of the clear rectangle
  34320. * @param height defines the height of the clear rectangle
  34321. */
  34322. enableScissor(x: number, y: number, width: number, height: number): void;
  34323. /**
  34324. * Disable previously set scissor test rectangle
  34325. */
  34326. disableScissor(): void;
  34327. protected _reportDrawCall(): void;
  34328. /**
  34329. * Initializes a webVR display and starts listening to display change events
  34330. * The onVRDisplayChangedObservable will be notified upon these changes
  34331. * @returns The onVRDisplayChangedObservable
  34332. */
  34333. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34334. /** @hidden */
  34335. _prepareVRComponent(): void;
  34336. /** @hidden */
  34337. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34338. /** @hidden */
  34339. _submitVRFrame(): void;
  34340. /**
  34341. * Call this function to leave webVR mode
  34342. * Will do nothing if webVR is not supported or if there is no webVR device
  34343. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34344. */
  34345. disableVR(): void;
  34346. /**
  34347. * Gets a boolean indicating that the system is in VR mode and is presenting
  34348. * @returns true if VR mode is engaged
  34349. */
  34350. isVRPresenting(): boolean;
  34351. /** @hidden */
  34352. _requestVRFrame(): void;
  34353. /** @hidden */
  34354. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34355. /**
  34356. * Gets the source code of the vertex shader associated with a specific webGL program
  34357. * @param program defines the program to use
  34358. * @returns a string containing the source code of the vertex shader associated with the program
  34359. */
  34360. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34361. /**
  34362. * Gets the source code of the fragment shader associated with a specific webGL program
  34363. * @param program defines the program to use
  34364. * @returns a string containing the source code of the fragment shader associated with the program
  34365. */
  34366. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34367. /**
  34368. * Sets a depth stencil texture from a render target to the according uniform.
  34369. * @param channel The texture channel
  34370. * @param uniform The uniform to set
  34371. * @param texture The render target texture containing the depth stencil texture to apply
  34372. */
  34373. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34374. /**
  34375. * Sets a texture to the webGL context from a postprocess
  34376. * @param channel defines the channel to use
  34377. * @param postProcess defines the source postprocess
  34378. */
  34379. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34380. /**
  34381. * Binds the output of the passed in post process to the texture channel specified
  34382. * @param channel The channel the texture should be bound to
  34383. * @param postProcess The post process which's output should be bound
  34384. */
  34385. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34386. /** @hidden */
  34387. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34388. protected _rebuildBuffers(): void;
  34389. /** @hidden */
  34390. _renderFrame(): void;
  34391. _renderLoop(): void;
  34392. /** @hidden */
  34393. _renderViews(): boolean;
  34394. /**
  34395. * Toggle full screen mode
  34396. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34397. */
  34398. switchFullscreen(requestPointerLock: boolean): void;
  34399. /**
  34400. * Enters full screen mode
  34401. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34402. */
  34403. enterFullscreen(requestPointerLock: boolean): void;
  34404. /**
  34405. * Exits full screen mode
  34406. */
  34407. exitFullscreen(): void;
  34408. /**
  34409. * Enters Pointerlock mode
  34410. */
  34411. enterPointerlock(): void;
  34412. /**
  34413. * Exits Pointerlock mode
  34414. */
  34415. exitPointerlock(): void;
  34416. /**
  34417. * Begin a new frame
  34418. */
  34419. beginFrame(): void;
  34420. /**
  34421. * Enf the current frame
  34422. */
  34423. endFrame(): void;
  34424. resize(): void;
  34425. /**
  34426. * Set the compressed texture format to use, based on the formats you have, and the formats
  34427. * supported by the hardware / browser.
  34428. *
  34429. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34430. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34431. * to API arguments needed to compressed textures. This puts the burden on the container
  34432. * generator to house the arcane code for determining these for current & future formats.
  34433. *
  34434. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34435. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34436. *
  34437. * Note: The result of this call is not taken into account when a texture is base64.
  34438. *
  34439. * @param formatsAvailable defines the list of those format families you have created
  34440. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34441. *
  34442. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34443. * @returns The extension selected.
  34444. */
  34445. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34446. /**
  34447. * Set the compressed texture extensions or file names to skip.
  34448. *
  34449. * @param skippedFiles defines the list of those texture files you want to skip
  34450. * Example: [".dds", ".env", "myfile.png"]
  34451. */
  34452. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34453. /**
  34454. * Force a specific size of the canvas
  34455. * @param width defines the new canvas' width
  34456. * @param height defines the new canvas' height
  34457. */
  34458. setSize(width: number, height: number): void;
  34459. /**
  34460. * Updates a dynamic vertex buffer.
  34461. * @param vertexBuffer the vertex buffer to update
  34462. * @param data the data used to update the vertex buffer
  34463. * @param byteOffset the byte offset of the data
  34464. * @param byteLength the byte length of the data
  34465. */
  34466. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34467. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34468. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34469. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34470. _releaseTexture(texture: InternalTexture): void;
  34471. /**
  34472. * @hidden
  34473. * Rescales a texture
  34474. * @param source input texutre
  34475. * @param destination destination texture
  34476. * @param scene scene to use to render the resize
  34477. * @param internalFormat format to use when resizing
  34478. * @param onComplete callback to be called when resize has completed
  34479. */
  34480. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34481. /**
  34482. * Gets the current framerate
  34483. * @returns a number representing the framerate
  34484. */
  34485. getFps(): number;
  34486. /**
  34487. * Gets the time spent between current and previous frame
  34488. * @returns a number representing the delta time in ms
  34489. */
  34490. getDeltaTime(): number;
  34491. private _measureFps;
  34492. /** @hidden */
  34493. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34494. /**
  34495. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34496. * @param renderTarget The render target to set the frame buffer for
  34497. */
  34498. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34499. /**
  34500. * Update a dynamic index buffer
  34501. * @param indexBuffer defines the target index buffer
  34502. * @param indices defines the data to update
  34503. * @param offset defines the offset in the target index buffer where update should start
  34504. */
  34505. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34506. /**
  34507. * Updates the sample count of a render target texture
  34508. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34509. * @param texture defines the texture to update
  34510. * @param samples defines the sample count to set
  34511. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34512. */
  34513. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34514. /**
  34515. * Updates a depth texture Comparison Mode and Function.
  34516. * If the comparison Function is equal to 0, the mode will be set to none.
  34517. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34518. * @param texture The texture to set the comparison function for
  34519. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34520. */
  34521. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34522. /**
  34523. * Creates a webGL buffer to use with instanciation
  34524. * @param capacity defines the size of the buffer
  34525. * @returns the webGL buffer
  34526. */
  34527. createInstancesBuffer(capacity: number): DataBuffer;
  34528. /**
  34529. * Delete a webGL buffer used with instanciation
  34530. * @param buffer defines the webGL buffer to delete
  34531. */
  34532. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34533. /** @hidden */
  34534. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34535. dispose(): void;
  34536. private _disableTouchAction;
  34537. /**
  34538. * Display the loading screen
  34539. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34540. */
  34541. displayLoadingUI(): void;
  34542. /**
  34543. * Hide the loading screen
  34544. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34545. */
  34546. hideLoadingUI(): void;
  34547. /**
  34548. * Gets the current loading screen object
  34549. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34550. */
  34551. get loadingScreen(): ILoadingScreen;
  34552. /**
  34553. * Sets the current loading screen object
  34554. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34555. */
  34556. set loadingScreen(loadingScreen: ILoadingScreen);
  34557. /**
  34558. * Sets the current loading screen text
  34559. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34560. */
  34561. set loadingUIText(text: string);
  34562. /**
  34563. * Sets the current loading screen background color
  34564. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34565. */
  34566. set loadingUIBackgroundColor(color: string);
  34567. /** Pointerlock and fullscreen */
  34568. /**
  34569. * Ask the browser to promote the current element to pointerlock mode
  34570. * @param element defines the DOM element to promote
  34571. */
  34572. static _RequestPointerlock(element: HTMLElement): void;
  34573. /**
  34574. * Asks the browser to exit pointerlock mode
  34575. */
  34576. static _ExitPointerlock(): void;
  34577. /**
  34578. * Ask the browser to promote the current element to fullscreen rendering mode
  34579. * @param element defines the DOM element to promote
  34580. */
  34581. static _RequestFullscreen(element: HTMLElement): void;
  34582. /**
  34583. * Asks the browser to exit fullscreen mode
  34584. */
  34585. static _ExitFullscreen(): void;
  34586. }
  34587. }
  34588. declare module "babylonjs/Engines/engineStore" {
  34589. import { Nullable } from "babylonjs/types";
  34590. import { Engine } from "babylonjs/Engines/engine";
  34591. import { Scene } from "babylonjs/scene";
  34592. /**
  34593. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34594. * during the life time of the application.
  34595. */
  34596. export class EngineStore {
  34597. /** Gets the list of created engines */
  34598. static Instances: import("babylonjs/Engines/engine").Engine[];
  34599. /** @hidden */
  34600. static _LastCreatedScene: Nullable<Scene>;
  34601. /**
  34602. * Gets the latest created engine
  34603. */
  34604. static get LastCreatedEngine(): Nullable<Engine>;
  34605. /**
  34606. * Gets the latest created scene
  34607. */
  34608. static get LastCreatedScene(): Nullable<Scene>;
  34609. /**
  34610. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34611. * @ignorenaming
  34612. */
  34613. static UseFallbackTexture: boolean;
  34614. /**
  34615. * Texture content used if a texture cannot loaded
  34616. * @ignorenaming
  34617. */
  34618. static FallbackTexture: string;
  34619. }
  34620. }
  34621. declare module "babylonjs/Misc/promise" {
  34622. /**
  34623. * Helper class that provides a small promise polyfill
  34624. */
  34625. export class PromisePolyfill {
  34626. /**
  34627. * Static function used to check if the polyfill is required
  34628. * If this is the case then the function will inject the polyfill to window.Promise
  34629. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34630. */
  34631. static Apply(force?: boolean): void;
  34632. }
  34633. }
  34634. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34635. /**
  34636. * Interface for screenshot methods with describe argument called `size` as object with options
  34637. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34638. */
  34639. export interface IScreenshotSize {
  34640. /**
  34641. * number in pixels for canvas height
  34642. */
  34643. height?: number;
  34644. /**
  34645. * multiplier allowing render at a higher or lower resolution
  34646. * If value is defined then height and width will be ignored and taken from camera
  34647. */
  34648. precision?: number;
  34649. /**
  34650. * number in pixels for canvas width
  34651. */
  34652. width?: number;
  34653. }
  34654. }
  34655. declare module "babylonjs/Misc/tools" {
  34656. import { Nullable, float } from "babylonjs/types";
  34657. import { DomManagement } from "babylonjs/Misc/domManagement";
  34658. import { WebRequest } from "babylonjs/Misc/webRequest";
  34659. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34660. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34661. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34662. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34663. import { Camera } from "babylonjs/Cameras/camera";
  34664. import { Engine } from "babylonjs/Engines/engine";
  34665. interface IColor4Like {
  34666. r: float;
  34667. g: float;
  34668. b: float;
  34669. a: float;
  34670. }
  34671. /**
  34672. * Class containing a set of static utilities functions
  34673. */
  34674. export class Tools {
  34675. /**
  34676. * Gets or sets the base URL to use to load assets
  34677. */
  34678. static get BaseUrl(): string;
  34679. static set BaseUrl(value: string);
  34680. /**
  34681. * Enable/Disable Custom HTTP Request Headers globally.
  34682. * default = false
  34683. * @see CustomRequestHeaders
  34684. */
  34685. static UseCustomRequestHeaders: boolean;
  34686. /**
  34687. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34688. * i.e. when loading files, where the server/service expects an Authorization header
  34689. */
  34690. static CustomRequestHeaders: {
  34691. [key: string]: string;
  34692. };
  34693. /**
  34694. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34695. */
  34696. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34697. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34698. /**
  34699. * Default behaviour for cors in the application.
  34700. * It can be a string if the expected behavior is identical in the entire app.
  34701. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34702. */
  34703. static CorsBehavior: string | ((url: string | string[]) => string);
  34704. /**
  34705. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34706. * @ignorenaming
  34707. */
  34708. static get UseFallbackTexture(): boolean;
  34709. static set UseFallbackTexture(value: boolean);
  34710. /**
  34711. * Use this object to register external classes like custom textures or material
  34712. * to allow the laoders to instantiate them
  34713. */
  34714. static get RegisteredExternalClasses(): {
  34715. [key: string]: Object;
  34716. };
  34717. static set RegisteredExternalClasses(classes: {
  34718. [key: string]: Object;
  34719. });
  34720. /**
  34721. * Texture content used if a texture cannot loaded
  34722. * @ignorenaming
  34723. */
  34724. static get fallbackTexture(): string;
  34725. static set fallbackTexture(value: string);
  34726. /**
  34727. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34728. * @param u defines the coordinate on X axis
  34729. * @param v defines the coordinate on Y axis
  34730. * @param width defines the width of the source data
  34731. * @param height defines the height of the source data
  34732. * @param pixels defines the source byte array
  34733. * @param color defines the output color
  34734. */
  34735. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34736. /**
  34737. * Interpolates between a and b via alpha
  34738. * @param a The lower value (returned when alpha = 0)
  34739. * @param b The upper value (returned when alpha = 1)
  34740. * @param alpha The interpolation-factor
  34741. * @return The mixed value
  34742. */
  34743. static Mix(a: number, b: number, alpha: number): number;
  34744. /**
  34745. * Tries to instantiate a new object from a given class name
  34746. * @param className defines the class name to instantiate
  34747. * @returns the new object or null if the system was not able to do the instantiation
  34748. */
  34749. static Instantiate(className: string): any;
  34750. /**
  34751. * Provides a slice function that will work even on IE
  34752. * @param data defines the array to slice
  34753. * @param start defines the start of the data (optional)
  34754. * @param end defines the end of the data (optional)
  34755. * @returns the new sliced array
  34756. */
  34757. static Slice<T>(data: T, start?: number, end?: number): T;
  34758. /**
  34759. * Polyfill for setImmediate
  34760. * @param action defines the action to execute after the current execution block
  34761. */
  34762. static SetImmediate(action: () => void): void;
  34763. /**
  34764. * Function indicating if a number is an exponent of 2
  34765. * @param value defines the value to test
  34766. * @returns true if the value is an exponent of 2
  34767. */
  34768. static IsExponentOfTwo(value: number): boolean;
  34769. private static _tmpFloatArray;
  34770. /**
  34771. * Returns the nearest 32-bit single precision float representation of a Number
  34772. * @param value A Number. If the parameter is of a different type, it will get converted
  34773. * to a number or to NaN if it cannot be converted
  34774. * @returns number
  34775. */
  34776. static FloatRound(value: number): number;
  34777. /**
  34778. * Extracts the filename from a path
  34779. * @param path defines the path to use
  34780. * @returns the filename
  34781. */
  34782. static GetFilename(path: string): string;
  34783. /**
  34784. * Extracts the "folder" part of a path (everything before the filename).
  34785. * @param uri The URI to extract the info from
  34786. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34787. * @returns The "folder" part of the path
  34788. */
  34789. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34790. /**
  34791. * Extracts text content from a DOM element hierarchy
  34792. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34793. */
  34794. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34795. /**
  34796. * Convert an angle in radians to degrees
  34797. * @param angle defines the angle to convert
  34798. * @returns the angle in degrees
  34799. */
  34800. static ToDegrees(angle: number): number;
  34801. /**
  34802. * Convert an angle in degrees to radians
  34803. * @param angle defines the angle to convert
  34804. * @returns the angle in radians
  34805. */
  34806. static ToRadians(angle: number): number;
  34807. /**
  34808. * Returns an array if obj is not an array
  34809. * @param obj defines the object to evaluate as an array
  34810. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34811. * @returns either obj directly if obj is an array or a new array containing obj
  34812. */
  34813. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34814. /**
  34815. * Gets the pointer prefix to use
  34816. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34817. */
  34818. static GetPointerPrefix(): string;
  34819. /**
  34820. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34821. * @param url define the url we are trying
  34822. * @param element define the dom element where to configure the cors policy
  34823. */
  34824. static SetCorsBehavior(url: string | string[], element: {
  34825. crossOrigin: string | null;
  34826. }): void;
  34827. /**
  34828. * Removes unwanted characters from an url
  34829. * @param url defines the url to clean
  34830. * @returns the cleaned url
  34831. */
  34832. static CleanUrl(url: string): string;
  34833. /**
  34834. * Gets or sets a function used to pre-process url before using them to load assets
  34835. */
  34836. static get PreprocessUrl(): (url: string) => string;
  34837. static set PreprocessUrl(processor: (url: string) => string);
  34838. /**
  34839. * Loads an image as an HTMLImageElement.
  34840. * @param input url string, ArrayBuffer, or Blob to load
  34841. * @param onLoad callback called when the image successfully loads
  34842. * @param onError callback called when the image fails to load
  34843. * @param offlineProvider offline provider for caching
  34844. * @param mimeType optional mime type
  34845. * @returns the HTMLImageElement of the loaded image
  34846. */
  34847. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34848. /**
  34849. * Loads a file from a url
  34850. * @param url url string, ArrayBuffer, or Blob to load
  34851. * @param onSuccess callback called when the file successfully loads
  34852. * @param onProgress callback called while file is loading (if the server supports this mode)
  34853. * @param offlineProvider defines the offline provider for caching
  34854. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34855. * @param onError callback called when the file fails to load
  34856. * @returns a file request object
  34857. */
  34858. 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;
  34859. /**
  34860. * Loads a file from a url
  34861. * @param url the file url to load
  34862. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34863. */
  34864. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34865. /**
  34866. * Load a script (identified by an url). When the url returns, the
  34867. * content of this file is added into a new script element, attached to the DOM (body element)
  34868. * @param scriptUrl defines the url of the script to laod
  34869. * @param onSuccess defines the callback called when the script is loaded
  34870. * @param onError defines the callback to call if an error occurs
  34871. * @param scriptId defines the id of the script element
  34872. */
  34873. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34874. /**
  34875. * Load an asynchronous script (identified by an url). When the url returns, the
  34876. * content of this file is added into a new script element, attached to the DOM (body element)
  34877. * @param scriptUrl defines the url of the script to laod
  34878. * @param scriptId defines the id of the script element
  34879. * @returns a promise request object
  34880. */
  34881. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34882. /**
  34883. * Loads a file from a blob
  34884. * @param fileToLoad defines the blob to use
  34885. * @param callback defines the callback to call when data is loaded
  34886. * @param progressCallback defines the callback to call during loading process
  34887. * @returns a file request object
  34888. */
  34889. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34890. /**
  34891. * Reads a file from a File object
  34892. * @param file defines the file to load
  34893. * @param onSuccess defines the callback to call when data is loaded
  34894. * @param onProgress defines the callback to call during loading process
  34895. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34896. * @param onError defines the callback to call when an error occurs
  34897. * @returns a file request object
  34898. */
  34899. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34900. /**
  34901. * Creates a data url from a given string content
  34902. * @param content defines the content to convert
  34903. * @returns the new data url link
  34904. */
  34905. static FileAsURL(content: string): string;
  34906. /**
  34907. * Format the given number to a specific decimal format
  34908. * @param value defines the number to format
  34909. * @param decimals defines the number of decimals to use
  34910. * @returns the formatted string
  34911. */
  34912. static Format(value: number, decimals?: number): string;
  34913. /**
  34914. * Tries to copy an object by duplicating every property
  34915. * @param source defines the source object
  34916. * @param destination defines the target object
  34917. * @param doNotCopyList defines a list of properties to avoid
  34918. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34919. */
  34920. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34921. /**
  34922. * Gets a boolean indicating if the given object has no own property
  34923. * @param obj defines the object to test
  34924. * @returns true if object has no own property
  34925. */
  34926. static IsEmpty(obj: any): boolean;
  34927. /**
  34928. * Function used to register events at window level
  34929. * @param windowElement defines the Window object to use
  34930. * @param events defines the events to register
  34931. */
  34932. static RegisterTopRootEvents(windowElement: Window, events: {
  34933. name: string;
  34934. handler: Nullable<(e: FocusEvent) => any>;
  34935. }[]): void;
  34936. /**
  34937. * Function used to unregister events from window level
  34938. * @param windowElement defines the Window object to use
  34939. * @param events defines the events to unregister
  34940. */
  34941. static UnregisterTopRootEvents(windowElement: Window, events: {
  34942. name: string;
  34943. handler: Nullable<(e: FocusEvent) => any>;
  34944. }[]): void;
  34945. /**
  34946. * @ignore
  34947. */
  34948. static _ScreenshotCanvas: HTMLCanvasElement;
  34949. /**
  34950. * Dumps the current bound framebuffer
  34951. * @param width defines the rendering width
  34952. * @param height defines the rendering height
  34953. * @param engine defines the hosting engine
  34954. * @param successCallback defines the callback triggered once the data are available
  34955. * @param mimeType defines the mime type of the result
  34956. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34957. */
  34958. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34959. /**
  34960. * Converts the canvas data to blob.
  34961. * This acts as a polyfill for browsers not supporting the to blob function.
  34962. * @param canvas Defines the canvas to extract the data from
  34963. * @param successCallback Defines the callback triggered once the data are available
  34964. * @param mimeType Defines the mime type of the result
  34965. */
  34966. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34967. /**
  34968. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34969. * @param successCallback defines the callback triggered once the data are available
  34970. * @param mimeType defines the mime type of the result
  34971. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34972. */
  34973. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34974. /**
  34975. * Downloads a blob in the browser
  34976. * @param blob defines the blob to download
  34977. * @param fileName defines the name of the downloaded file
  34978. */
  34979. static Download(blob: Blob, fileName: string): void;
  34980. /**
  34981. * Captures a screenshot of the current rendering
  34982. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34983. * @param engine defines the rendering engine
  34984. * @param camera defines the source camera
  34985. * @param size This parameter can be set to a single number or to an object with the
  34986. * following (optional) properties: precision, width, height. If a single number is passed,
  34987. * it will be used for both width and height. If an object is passed, the screenshot size
  34988. * will be derived from the parameters. The precision property is a multiplier allowing
  34989. * rendering at a higher or lower resolution
  34990. * @param successCallback defines the callback receives a single parameter which contains the
  34991. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34992. * src parameter of an <img> to display it
  34993. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34994. * Check your browser for supported MIME types
  34995. */
  34996. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34997. /**
  34998. * Captures a screenshot of the current rendering
  34999. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35000. * @param engine defines the rendering engine
  35001. * @param camera defines the source camera
  35002. * @param size This parameter can be set to a single number or to an object with the
  35003. * following (optional) properties: precision, width, height. If a single number is passed,
  35004. * it will be used for both width and height. If an object is passed, the screenshot size
  35005. * will be derived from the parameters. The precision property is a multiplier allowing
  35006. * rendering at a higher or lower resolution
  35007. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35008. * Check your browser for supported MIME types
  35009. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35010. * to the src parameter of an <img> to display it
  35011. */
  35012. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35013. /**
  35014. * Generates an image screenshot from the specified camera.
  35015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35016. * @param engine The engine to use for rendering
  35017. * @param camera The camera to use for rendering
  35018. * @param size This parameter can be set to a single number or to an object with the
  35019. * following (optional) properties: precision, width, height. If a single number is passed,
  35020. * it will be used for both width and height. If an object is passed, the screenshot size
  35021. * will be derived from the parameters. The precision property is a multiplier allowing
  35022. * rendering at a higher or lower resolution
  35023. * @param successCallback The callback receives a single parameter which contains the
  35024. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35025. * src parameter of an <img> to display it
  35026. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35027. * Check your browser for supported MIME types
  35028. * @param samples Texture samples (default: 1)
  35029. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35030. * @param fileName A name for for the downloaded file.
  35031. */
  35032. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35033. /**
  35034. * Generates an image screenshot from the specified camera.
  35035. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35036. * @param engine The engine to use for rendering
  35037. * @param camera The camera to use for rendering
  35038. * @param size This parameter can be set to a single number or to an object with the
  35039. * following (optional) properties: precision, width, height. If a single number is passed,
  35040. * it will be used for both width and height. If an object is passed, the screenshot size
  35041. * will be derived from the parameters. The precision property is a multiplier allowing
  35042. * rendering at a higher or lower resolution
  35043. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35044. * Check your browser for supported MIME types
  35045. * @param samples Texture samples (default: 1)
  35046. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35047. * @param fileName A name for for the downloaded file.
  35048. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35049. * to the src parameter of an <img> to display it
  35050. */
  35051. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35052. /**
  35053. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35054. * Be aware Math.random() could cause collisions, but:
  35055. * "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"
  35056. * @returns a pseudo random id
  35057. */
  35058. static RandomId(): string;
  35059. /**
  35060. * Test if the given uri is a base64 string
  35061. * @param uri The uri to test
  35062. * @return True if the uri is a base64 string or false otherwise
  35063. */
  35064. static IsBase64(uri: string): boolean;
  35065. /**
  35066. * Decode the given base64 uri.
  35067. * @param uri The uri to decode
  35068. * @return The decoded base64 data.
  35069. */
  35070. static DecodeBase64(uri: string): ArrayBuffer;
  35071. /**
  35072. * Gets the absolute url.
  35073. * @param url the input url
  35074. * @return the absolute url
  35075. */
  35076. static GetAbsoluteUrl(url: string): string;
  35077. /**
  35078. * No log
  35079. */
  35080. static readonly NoneLogLevel: number;
  35081. /**
  35082. * Only message logs
  35083. */
  35084. static readonly MessageLogLevel: number;
  35085. /**
  35086. * Only warning logs
  35087. */
  35088. static readonly WarningLogLevel: number;
  35089. /**
  35090. * Only error logs
  35091. */
  35092. static readonly ErrorLogLevel: number;
  35093. /**
  35094. * All logs
  35095. */
  35096. static readonly AllLogLevel: number;
  35097. /**
  35098. * Gets a value indicating the number of loading errors
  35099. * @ignorenaming
  35100. */
  35101. static get errorsCount(): number;
  35102. /**
  35103. * Callback called when a new log is added
  35104. */
  35105. static OnNewCacheEntry: (entry: string) => void;
  35106. /**
  35107. * Log a message to the console
  35108. * @param message defines the message to log
  35109. */
  35110. static Log(message: string): void;
  35111. /**
  35112. * Write a warning message to the console
  35113. * @param message defines the message to log
  35114. */
  35115. static Warn(message: string): void;
  35116. /**
  35117. * Write an error message to the console
  35118. * @param message defines the message to log
  35119. */
  35120. static Error(message: string): void;
  35121. /**
  35122. * Gets current log cache (list of logs)
  35123. */
  35124. static get LogCache(): string;
  35125. /**
  35126. * Clears the log cache
  35127. */
  35128. static ClearLogCache(): void;
  35129. /**
  35130. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35131. */
  35132. static set LogLevels(level: number);
  35133. /**
  35134. * Checks if the window object exists
  35135. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35136. */
  35137. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35138. /**
  35139. * No performance log
  35140. */
  35141. static readonly PerformanceNoneLogLevel: number;
  35142. /**
  35143. * Use user marks to log performance
  35144. */
  35145. static readonly PerformanceUserMarkLogLevel: number;
  35146. /**
  35147. * Log performance to the console
  35148. */
  35149. static readonly PerformanceConsoleLogLevel: number;
  35150. private static _performance;
  35151. /**
  35152. * Sets the current performance log level
  35153. */
  35154. static set PerformanceLogLevel(level: number);
  35155. private static _StartPerformanceCounterDisabled;
  35156. private static _EndPerformanceCounterDisabled;
  35157. private static _StartUserMark;
  35158. private static _EndUserMark;
  35159. private static _StartPerformanceConsole;
  35160. private static _EndPerformanceConsole;
  35161. /**
  35162. * Starts a performance counter
  35163. */
  35164. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35165. /**
  35166. * Ends a specific performance coutner
  35167. */
  35168. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35169. /**
  35170. * Gets either window.performance.now() if supported or Date.now() else
  35171. */
  35172. static get Now(): number;
  35173. /**
  35174. * This method will return the name of the class used to create the instance of the given object.
  35175. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35176. * @param object the object to get the class name from
  35177. * @param isType defines if the object is actually a type
  35178. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35179. */
  35180. static GetClassName(object: any, isType?: boolean): string;
  35181. /**
  35182. * Gets the first element of an array satisfying a given predicate
  35183. * @param array defines the array to browse
  35184. * @param predicate defines the predicate to use
  35185. * @returns null if not found or the element
  35186. */
  35187. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35188. /**
  35189. * This method will return the name of the full name of the class, including its owning module (if any).
  35190. * 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).
  35191. * @param object the object to get the class name from
  35192. * @param isType defines if the object is actually a type
  35193. * @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.
  35194. * @ignorenaming
  35195. */
  35196. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35197. /**
  35198. * Returns a promise that resolves after the given amount of time.
  35199. * @param delay Number of milliseconds to delay
  35200. * @returns Promise that resolves after the given amount of time
  35201. */
  35202. static DelayAsync(delay: number): Promise<void>;
  35203. }
  35204. /**
  35205. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35206. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35207. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35208. * @param name The name of the class, case should be preserved
  35209. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35210. */
  35211. export function className(name: string, module?: string): (target: Object) => void;
  35212. /**
  35213. * An implementation of a loop for asynchronous functions.
  35214. */
  35215. export class AsyncLoop {
  35216. /**
  35217. * Defines the number of iterations for the loop
  35218. */
  35219. iterations: number;
  35220. /**
  35221. * Defines the current index of the loop.
  35222. */
  35223. index: number;
  35224. private _done;
  35225. private _fn;
  35226. private _successCallback;
  35227. /**
  35228. * Constructor.
  35229. * @param iterations the number of iterations.
  35230. * @param func the function to run each iteration
  35231. * @param successCallback the callback that will be called upon succesful execution
  35232. * @param offset starting offset.
  35233. */
  35234. constructor(
  35235. /**
  35236. * Defines the number of iterations for the loop
  35237. */
  35238. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35239. /**
  35240. * Execute the next iteration. Must be called after the last iteration was finished.
  35241. */
  35242. executeNext(): void;
  35243. /**
  35244. * Break the loop and run the success callback.
  35245. */
  35246. breakLoop(): void;
  35247. /**
  35248. * Create and run an async loop.
  35249. * @param iterations the number of iterations.
  35250. * @param fn the function to run each iteration
  35251. * @param successCallback the callback that will be called upon succesful execution
  35252. * @param offset starting offset.
  35253. * @returns the created async loop object
  35254. */
  35255. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35256. /**
  35257. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35258. * @param iterations total number of iterations
  35259. * @param syncedIterations number of synchronous iterations in each async iteration.
  35260. * @param fn the function to call each iteration.
  35261. * @param callback a success call back that will be called when iterating stops.
  35262. * @param breakFunction a break condition (optional)
  35263. * @param timeout timeout settings for the setTimeout function. default - 0.
  35264. * @returns the created async loop object
  35265. */
  35266. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35267. }
  35268. }
  35269. declare module "babylonjs/Misc/stringDictionary" {
  35270. import { Nullable } from "babylonjs/types";
  35271. /**
  35272. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35273. * The underlying implementation relies on an associative array to ensure the best performances.
  35274. * The value can be anything including 'null' but except 'undefined'
  35275. */
  35276. export class StringDictionary<T> {
  35277. /**
  35278. * This will clear this dictionary and copy the content from the 'source' one.
  35279. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35280. * @param source the dictionary to take the content from and copy to this dictionary
  35281. */
  35282. copyFrom(source: StringDictionary<T>): void;
  35283. /**
  35284. * Get a value based from its key
  35285. * @param key the given key to get the matching value from
  35286. * @return the value if found, otherwise undefined is returned
  35287. */
  35288. get(key: string): T | undefined;
  35289. /**
  35290. * Get a value from its key or add it if it doesn't exist.
  35291. * This method will ensure you that a given key/data will be present in the dictionary.
  35292. * @param key the given key to get the matching value from
  35293. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35294. * The factory will only be invoked if there's no data for the given key.
  35295. * @return the value corresponding to the key.
  35296. */
  35297. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35298. /**
  35299. * Get a value from its key if present in the dictionary otherwise add it
  35300. * @param key the key to get the value from
  35301. * @param val if there's no such key/value pair in the dictionary add it with this value
  35302. * @return the value corresponding to the key
  35303. */
  35304. getOrAdd(key: string, val: T): T;
  35305. /**
  35306. * Check if there's a given key in the dictionary
  35307. * @param key the key to check for
  35308. * @return true if the key is present, false otherwise
  35309. */
  35310. contains(key: string): boolean;
  35311. /**
  35312. * Add a new key and its corresponding value
  35313. * @param key the key to add
  35314. * @param value the value corresponding to the key
  35315. * @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
  35316. */
  35317. add(key: string, value: T): boolean;
  35318. /**
  35319. * Update a specific value associated to a key
  35320. * @param key defines the key to use
  35321. * @param value defines the value to store
  35322. * @returns true if the value was updated (or false if the key was not found)
  35323. */
  35324. set(key: string, value: T): boolean;
  35325. /**
  35326. * Get the element of the given key and remove it from the dictionary
  35327. * @param key defines the key to search
  35328. * @returns the value associated with the key or null if not found
  35329. */
  35330. getAndRemove(key: string): Nullable<T>;
  35331. /**
  35332. * Remove a key/value from the dictionary.
  35333. * @param key the key to remove
  35334. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35335. */
  35336. remove(key: string): boolean;
  35337. /**
  35338. * Clear the whole content of the dictionary
  35339. */
  35340. clear(): void;
  35341. /**
  35342. * Gets the current count
  35343. */
  35344. get count(): number;
  35345. /**
  35346. * Execute a callback on each key/val of the dictionary.
  35347. * Note that you can remove any element in this dictionary in the callback implementation
  35348. * @param callback the callback to execute on a given key/value pair
  35349. */
  35350. forEach(callback: (key: string, val: T) => void): void;
  35351. /**
  35352. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35353. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35354. * Note that you can remove any element in this dictionary in the callback implementation
  35355. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35356. * @returns the first item
  35357. */
  35358. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35359. private _count;
  35360. private _data;
  35361. }
  35362. }
  35363. declare module "babylonjs/Collisions/collisionCoordinator" {
  35364. import { Nullable } from "babylonjs/types";
  35365. import { Scene } from "babylonjs/scene";
  35366. import { Vector3 } from "babylonjs/Maths/math.vector";
  35367. import { Collider } from "babylonjs/Collisions/collider";
  35368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35369. /** @hidden */
  35370. export interface ICollisionCoordinator {
  35371. createCollider(): Collider;
  35372. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35373. init(scene: Scene): void;
  35374. }
  35375. /** @hidden */
  35376. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35377. private _scene;
  35378. private _scaledPosition;
  35379. private _scaledVelocity;
  35380. private _finalPosition;
  35381. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35382. createCollider(): Collider;
  35383. init(scene: Scene): void;
  35384. private _collideWithWorld;
  35385. }
  35386. }
  35387. declare module "babylonjs/Inputs/scene.inputManager" {
  35388. import { Nullable } from "babylonjs/types";
  35389. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35390. import { Vector2 } from "babylonjs/Maths/math.vector";
  35391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35392. import { Scene } from "babylonjs/scene";
  35393. /**
  35394. * Class used to manage all inputs for the scene.
  35395. */
  35396. export class InputManager {
  35397. /** The distance in pixel that you have to move to prevent some events */
  35398. static DragMovementThreshold: number;
  35399. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35400. static LongPressDelay: number;
  35401. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35402. static DoubleClickDelay: number;
  35403. /** If you need to check double click without raising a single click at first click, enable this flag */
  35404. static ExclusiveDoubleClickMode: boolean;
  35405. private _wheelEventName;
  35406. private _onPointerMove;
  35407. private _onPointerDown;
  35408. private _onPointerUp;
  35409. private _initClickEvent;
  35410. private _initActionManager;
  35411. private _delayedSimpleClick;
  35412. private _delayedSimpleClickTimeout;
  35413. private _previousDelayedSimpleClickTimeout;
  35414. private _meshPickProceed;
  35415. private _previousButtonPressed;
  35416. private _currentPickResult;
  35417. private _previousPickResult;
  35418. private _totalPointersPressed;
  35419. private _doubleClickOccured;
  35420. private _pointerOverMesh;
  35421. private _pickedDownMesh;
  35422. private _pickedUpMesh;
  35423. private _pointerX;
  35424. private _pointerY;
  35425. private _unTranslatedPointerX;
  35426. private _unTranslatedPointerY;
  35427. private _startingPointerPosition;
  35428. private _previousStartingPointerPosition;
  35429. private _startingPointerTime;
  35430. private _previousStartingPointerTime;
  35431. private _pointerCaptures;
  35432. private _onKeyDown;
  35433. private _onKeyUp;
  35434. private _onCanvasFocusObserver;
  35435. private _onCanvasBlurObserver;
  35436. private _scene;
  35437. /**
  35438. * Creates a new InputManager
  35439. * @param scene defines the hosting scene
  35440. */
  35441. constructor(scene: Scene);
  35442. /**
  35443. * Gets the mesh that is currently under the pointer
  35444. */
  35445. get meshUnderPointer(): Nullable<AbstractMesh>;
  35446. /**
  35447. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35448. */
  35449. get unTranslatedPointer(): Vector2;
  35450. /**
  35451. * Gets or sets the current on-screen X position of the pointer
  35452. */
  35453. get pointerX(): number;
  35454. set pointerX(value: number);
  35455. /**
  35456. * Gets or sets the current on-screen Y position of the pointer
  35457. */
  35458. get pointerY(): number;
  35459. set pointerY(value: number);
  35460. private _updatePointerPosition;
  35461. private _processPointerMove;
  35462. private _setRayOnPointerInfo;
  35463. private _checkPrePointerObservable;
  35464. /**
  35465. * Use this method to simulate a pointer move on a mesh
  35466. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35467. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35468. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35469. */
  35470. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35471. /**
  35472. * Use this method to simulate a pointer down on a mesh
  35473. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35474. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35475. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35476. */
  35477. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35478. private _processPointerDown;
  35479. /** @hidden */
  35480. _isPointerSwiping(): boolean;
  35481. /**
  35482. * Use this method to simulate a pointer up on a mesh
  35483. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35484. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35485. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35486. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35487. */
  35488. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35489. private _processPointerUp;
  35490. /**
  35491. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35492. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35493. * @returns true if the pointer was captured
  35494. */
  35495. isPointerCaptured(pointerId?: number): boolean;
  35496. /**
  35497. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35498. * @param attachUp defines if you want to attach events to pointerup
  35499. * @param attachDown defines if you want to attach events to pointerdown
  35500. * @param attachMove defines if you want to attach events to pointermove
  35501. */
  35502. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35503. /**
  35504. * Detaches all event handlers
  35505. */
  35506. detachControl(): void;
  35507. /**
  35508. * Force the value of meshUnderPointer
  35509. * @param mesh defines the mesh to use
  35510. */
  35511. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35512. /**
  35513. * Gets the mesh under the pointer
  35514. * @returns a Mesh or null if no mesh is under the pointer
  35515. */
  35516. getPointerOverMesh(): Nullable<AbstractMesh>;
  35517. }
  35518. }
  35519. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35520. /**
  35521. * Helper class used to generate session unique ID
  35522. */
  35523. export class UniqueIdGenerator {
  35524. private static _UniqueIdCounter;
  35525. /**
  35526. * Gets an unique (relatively to the current scene) Id
  35527. */
  35528. static get UniqueId(): number;
  35529. }
  35530. }
  35531. declare module "babylonjs/Animations/animationGroup" {
  35532. import { Animatable } from "babylonjs/Animations/animatable";
  35533. import { Animation } from "babylonjs/Animations/animation";
  35534. import { Scene, IDisposable } from "babylonjs/scene";
  35535. import { Observable } from "babylonjs/Misc/observable";
  35536. import { Nullable } from "babylonjs/types";
  35537. import "babylonjs/Animations/animatable";
  35538. /**
  35539. * This class defines the direct association between an animation and a target
  35540. */
  35541. export class TargetedAnimation {
  35542. /**
  35543. * Animation to perform
  35544. */
  35545. animation: Animation;
  35546. /**
  35547. * Target to animate
  35548. */
  35549. target: any;
  35550. /**
  35551. * Serialize the object
  35552. * @returns the JSON object representing the current entity
  35553. */
  35554. serialize(): any;
  35555. }
  35556. /**
  35557. * Use this class to create coordinated animations on multiple targets
  35558. */
  35559. export class AnimationGroup implements IDisposable {
  35560. /** The name of the animation group */
  35561. name: string;
  35562. private _scene;
  35563. private _targetedAnimations;
  35564. private _animatables;
  35565. private _from;
  35566. private _to;
  35567. private _isStarted;
  35568. private _isPaused;
  35569. private _speedRatio;
  35570. private _loopAnimation;
  35571. /**
  35572. * Gets or sets the unique id of the node
  35573. */
  35574. uniqueId: number;
  35575. /**
  35576. * This observable will notify when one animation have ended
  35577. */
  35578. onAnimationEndObservable: Observable<TargetedAnimation>;
  35579. /**
  35580. * Observer raised when one animation loops
  35581. */
  35582. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35583. /**
  35584. * Observer raised when all animations have looped
  35585. */
  35586. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35587. /**
  35588. * This observable will notify when all animations have ended.
  35589. */
  35590. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35591. /**
  35592. * This observable will notify when all animations have paused.
  35593. */
  35594. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35595. /**
  35596. * This observable will notify when all animations are playing.
  35597. */
  35598. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35599. /**
  35600. * Gets the first frame
  35601. */
  35602. get from(): number;
  35603. /**
  35604. * Gets the last frame
  35605. */
  35606. get to(): number;
  35607. /**
  35608. * Define if the animations are started
  35609. */
  35610. get isStarted(): boolean;
  35611. /**
  35612. * Gets a value indicating that the current group is playing
  35613. */
  35614. get isPlaying(): boolean;
  35615. /**
  35616. * Gets or sets the speed ratio to use for all animations
  35617. */
  35618. get speedRatio(): number;
  35619. /**
  35620. * Gets or sets the speed ratio to use for all animations
  35621. */
  35622. set speedRatio(value: number);
  35623. /**
  35624. * Gets or sets if all animations should loop or not
  35625. */
  35626. get loopAnimation(): boolean;
  35627. set loopAnimation(value: boolean);
  35628. /**
  35629. * Gets the targeted animations for this animation group
  35630. */
  35631. get targetedAnimations(): Array<TargetedAnimation>;
  35632. /**
  35633. * returning the list of animatables controlled by this animation group.
  35634. */
  35635. get animatables(): Array<Animatable>;
  35636. /**
  35637. * Instantiates a new Animation Group.
  35638. * This helps managing several animations at once.
  35639. * @see http://doc.babylonjs.com/how_to/group
  35640. * @param name Defines the name of the group
  35641. * @param scene Defines the scene the group belongs to
  35642. */
  35643. constructor(
  35644. /** The name of the animation group */
  35645. name: string, scene?: Nullable<Scene>);
  35646. /**
  35647. * Add an animation (with its target) in the group
  35648. * @param animation defines the animation we want to add
  35649. * @param target defines the target of the animation
  35650. * @returns the TargetedAnimation object
  35651. */
  35652. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35653. /**
  35654. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35655. * It can add constant keys at begin or end
  35656. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35657. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35658. * @returns the animation group
  35659. */
  35660. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35661. private _animationLoopCount;
  35662. private _animationLoopFlags;
  35663. private _processLoop;
  35664. /**
  35665. * Start all animations on given targets
  35666. * @param loop defines if animations must loop
  35667. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35668. * @param from defines the from key (optional)
  35669. * @param to defines the to key (optional)
  35670. * @returns the current animation group
  35671. */
  35672. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35673. /**
  35674. * Pause all animations
  35675. * @returns the animation group
  35676. */
  35677. pause(): AnimationGroup;
  35678. /**
  35679. * Play all animations to initial state
  35680. * This function will start() the animations if they were not started or will restart() them if they were paused
  35681. * @param loop defines if animations must loop
  35682. * @returns the animation group
  35683. */
  35684. play(loop?: boolean): AnimationGroup;
  35685. /**
  35686. * Reset all animations to initial state
  35687. * @returns the animation group
  35688. */
  35689. reset(): AnimationGroup;
  35690. /**
  35691. * Restart animations from key 0
  35692. * @returns the animation group
  35693. */
  35694. restart(): AnimationGroup;
  35695. /**
  35696. * Stop all animations
  35697. * @returns the animation group
  35698. */
  35699. stop(): AnimationGroup;
  35700. /**
  35701. * Set animation weight for all animatables
  35702. * @param weight defines the weight to use
  35703. * @return the animationGroup
  35704. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35705. */
  35706. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35707. /**
  35708. * Synchronize and normalize all animatables with a source animatable
  35709. * @param root defines the root animatable to synchronize with
  35710. * @return the animationGroup
  35711. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35712. */
  35713. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35714. /**
  35715. * Goes to a specific frame in this animation group
  35716. * @param frame the frame number to go to
  35717. * @return the animationGroup
  35718. */
  35719. goToFrame(frame: number): AnimationGroup;
  35720. /**
  35721. * Dispose all associated resources
  35722. */
  35723. dispose(): void;
  35724. private _checkAnimationGroupEnded;
  35725. /**
  35726. * Clone the current animation group and returns a copy
  35727. * @param newName defines the name of the new group
  35728. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35729. * @returns the new aniamtion group
  35730. */
  35731. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35732. /**
  35733. * Serializes the animationGroup to an object
  35734. * @returns Serialized object
  35735. */
  35736. serialize(): any;
  35737. /**
  35738. * Returns a new AnimationGroup object parsed from the source provided.
  35739. * @param parsedAnimationGroup defines the source
  35740. * @param scene defines the scene that will receive the animationGroup
  35741. * @returns a new AnimationGroup
  35742. */
  35743. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35744. /**
  35745. * Returns the string "AnimationGroup"
  35746. * @returns "AnimationGroup"
  35747. */
  35748. getClassName(): string;
  35749. /**
  35750. * Creates a detailled string about the object
  35751. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35752. * @returns a string representing the object
  35753. */
  35754. toString(fullDetails?: boolean): string;
  35755. }
  35756. }
  35757. declare module "babylonjs/scene" {
  35758. import { Nullable } from "babylonjs/types";
  35759. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35760. import { Observable } from "babylonjs/Misc/observable";
  35761. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35762. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35763. import { Geometry } from "babylonjs/Meshes/geometry";
  35764. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35765. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35767. import { Mesh } from "babylonjs/Meshes/mesh";
  35768. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35769. import { Bone } from "babylonjs/Bones/bone";
  35770. import { Skeleton } from "babylonjs/Bones/skeleton";
  35771. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35772. import { Camera } from "babylonjs/Cameras/camera";
  35773. import { AbstractScene } from "babylonjs/abstractScene";
  35774. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35775. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35776. import { Material } from "babylonjs/Materials/material";
  35777. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35778. import { Effect } from "babylonjs/Materials/effect";
  35779. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35780. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35781. import { Light } from "babylonjs/Lights/light";
  35782. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35783. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35784. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35785. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35786. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35787. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35788. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35789. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35790. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35791. import { Engine } from "babylonjs/Engines/engine";
  35792. import { Node } from "babylonjs/node";
  35793. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35794. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35795. import { WebRequest } from "babylonjs/Misc/webRequest";
  35796. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35797. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35798. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35799. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35800. import { Plane } from "babylonjs/Maths/math.plane";
  35801. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35802. import { Ray } from "babylonjs/Culling/ray";
  35803. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35804. import { Animation } from "babylonjs/Animations/animation";
  35805. import { Animatable } from "babylonjs/Animations/animatable";
  35806. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35807. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35808. import { Collider } from "babylonjs/Collisions/collider";
  35809. /**
  35810. * Define an interface for all classes that will hold resources
  35811. */
  35812. export interface IDisposable {
  35813. /**
  35814. * Releases all held resources
  35815. */
  35816. dispose(): void;
  35817. }
  35818. /** Interface defining initialization parameters for Scene class */
  35819. export interface SceneOptions {
  35820. /**
  35821. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35822. * It will improve performance when the number of geometries becomes important.
  35823. */
  35824. useGeometryUniqueIdsMap?: boolean;
  35825. /**
  35826. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35827. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35828. */
  35829. useMaterialMeshMap?: boolean;
  35830. /**
  35831. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35832. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35833. */
  35834. useClonedMeshhMap?: boolean;
  35835. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35836. virtual?: boolean;
  35837. }
  35838. /**
  35839. * Represents a scene to be rendered by the engine.
  35840. * @see http://doc.babylonjs.com/features/scene
  35841. */
  35842. export class Scene extends AbstractScene implements IAnimatable {
  35843. /** The fog is deactivated */
  35844. static readonly FOGMODE_NONE: number;
  35845. /** The fog density is following an exponential function */
  35846. static readonly FOGMODE_EXP: number;
  35847. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35848. static readonly FOGMODE_EXP2: number;
  35849. /** The fog density is following a linear function. */
  35850. static readonly FOGMODE_LINEAR: number;
  35851. /**
  35852. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35853. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35854. */
  35855. static MinDeltaTime: number;
  35856. /**
  35857. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35858. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35859. */
  35860. static MaxDeltaTime: number;
  35861. /**
  35862. * Factory used to create the default material.
  35863. * @param name The name of the material to create
  35864. * @param scene The scene to create the material for
  35865. * @returns The default material
  35866. */
  35867. static DefaultMaterialFactory(scene: Scene): Material;
  35868. /**
  35869. * Factory used to create the a collision coordinator.
  35870. * @returns The collision coordinator
  35871. */
  35872. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35873. /** @hidden */
  35874. _inputManager: InputManager;
  35875. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35876. cameraToUseForPointers: Nullable<Camera>;
  35877. /** @hidden */
  35878. readonly _isScene: boolean;
  35879. /**
  35880. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35881. */
  35882. autoClear: boolean;
  35883. /**
  35884. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35885. */
  35886. autoClearDepthAndStencil: boolean;
  35887. /**
  35888. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35889. */
  35890. clearColor: Color4;
  35891. /**
  35892. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35893. */
  35894. ambientColor: Color3;
  35895. /**
  35896. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35897. * It should only be one of the following (if not the default embedded one):
  35898. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35899. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35900. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35901. * The material properties need to be setup according to the type of texture in use.
  35902. */
  35903. environmentBRDFTexture: BaseTexture;
  35904. /** @hidden */
  35905. protected _environmentTexture: Nullable<BaseTexture>;
  35906. /**
  35907. * Texture used in all pbr material as the reflection texture.
  35908. * As in the majority of the scene they are the same (exception for multi room and so on),
  35909. * this is easier to reference from here than from all the materials.
  35910. */
  35911. get environmentTexture(): Nullable<BaseTexture>;
  35912. /**
  35913. * Texture used in all pbr material as the reflection texture.
  35914. * As in the majority of the scene they are the same (exception for multi room and so on),
  35915. * this is easier to set here than in all the materials.
  35916. */
  35917. set environmentTexture(value: Nullable<BaseTexture>);
  35918. /** @hidden */
  35919. protected _environmentIntensity: number;
  35920. /**
  35921. * Intensity of the environment in all pbr material.
  35922. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35923. * As in the majority of the scene they are the same (exception for multi room and so on),
  35924. * this is easier to reference from here than from all the materials.
  35925. */
  35926. get environmentIntensity(): number;
  35927. /**
  35928. * Intensity of the environment in all pbr material.
  35929. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35930. * As in the majority of the scene they are the same (exception for multi room and so on),
  35931. * this is easier to set here than in all the materials.
  35932. */
  35933. set environmentIntensity(value: number);
  35934. /** @hidden */
  35935. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35936. /**
  35937. * Default image processing configuration used either in the rendering
  35938. * Forward main pass or through the imageProcessingPostProcess if present.
  35939. * As in the majority of the scene they are the same (exception for multi camera),
  35940. * this is easier to reference from here than from all the materials and post process.
  35941. *
  35942. * No setter as we it is a shared configuration, you can set the values instead.
  35943. */
  35944. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35945. private _forceWireframe;
  35946. /**
  35947. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35948. */
  35949. set forceWireframe(value: boolean);
  35950. get forceWireframe(): boolean;
  35951. private _forcePointsCloud;
  35952. /**
  35953. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35954. */
  35955. set forcePointsCloud(value: boolean);
  35956. get forcePointsCloud(): boolean;
  35957. /**
  35958. * Gets or sets the active clipplane 1
  35959. */
  35960. clipPlane: Nullable<Plane>;
  35961. /**
  35962. * Gets or sets the active clipplane 2
  35963. */
  35964. clipPlane2: Nullable<Plane>;
  35965. /**
  35966. * Gets or sets the active clipplane 3
  35967. */
  35968. clipPlane3: Nullable<Plane>;
  35969. /**
  35970. * Gets or sets the active clipplane 4
  35971. */
  35972. clipPlane4: Nullable<Plane>;
  35973. /**
  35974. * Gets or sets a boolean indicating if animations are enabled
  35975. */
  35976. animationsEnabled: boolean;
  35977. private _animationPropertiesOverride;
  35978. /**
  35979. * Gets or sets the animation properties override
  35980. */
  35981. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35982. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35983. /**
  35984. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35985. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35986. */
  35987. useConstantAnimationDeltaTime: boolean;
  35988. /**
  35989. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35990. * Please note that it requires to run a ray cast through the scene on every frame
  35991. */
  35992. constantlyUpdateMeshUnderPointer: boolean;
  35993. /**
  35994. * Defines the HTML cursor to use when hovering over interactive elements
  35995. */
  35996. hoverCursor: string;
  35997. /**
  35998. * Defines the HTML default cursor to use (empty by default)
  35999. */
  36000. defaultCursor: string;
  36001. /**
  36002. * Defines wether cursors are handled by the scene.
  36003. */
  36004. doNotHandleCursors: boolean;
  36005. /**
  36006. * This is used to call preventDefault() on pointer down
  36007. * in order to block unwanted artifacts like system double clicks
  36008. */
  36009. preventDefaultOnPointerDown: boolean;
  36010. /**
  36011. * This is used to call preventDefault() on pointer up
  36012. * in order to block unwanted artifacts like system double clicks
  36013. */
  36014. preventDefaultOnPointerUp: boolean;
  36015. /**
  36016. * Gets or sets user defined metadata
  36017. */
  36018. metadata: any;
  36019. /**
  36020. * For internal use only. Please do not use.
  36021. */
  36022. reservedDataStore: any;
  36023. /**
  36024. * Gets the name of the plugin used to load this scene (null by default)
  36025. */
  36026. loadingPluginName: string;
  36027. /**
  36028. * Use this array to add regular expressions used to disable offline support for specific urls
  36029. */
  36030. disableOfflineSupportExceptionRules: RegExp[];
  36031. /**
  36032. * An event triggered when the scene is disposed.
  36033. */
  36034. onDisposeObservable: Observable<Scene>;
  36035. private _onDisposeObserver;
  36036. /** Sets a function to be executed when this scene is disposed. */
  36037. set onDispose(callback: () => void);
  36038. /**
  36039. * An event triggered before rendering the scene (right after animations and physics)
  36040. */
  36041. onBeforeRenderObservable: Observable<Scene>;
  36042. private _onBeforeRenderObserver;
  36043. /** Sets a function to be executed before rendering this scene */
  36044. set beforeRender(callback: Nullable<() => void>);
  36045. /**
  36046. * An event triggered after rendering the scene
  36047. */
  36048. onAfterRenderObservable: Observable<Scene>;
  36049. /**
  36050. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36051. */
  36052. onAfterRenderCameraObservable: Observable<Camera>;
  36053. private _onAfterRenderObserver;
  36054. /** Sets a function to be executed after rendering this scene */
  36055. set afterRender(callback: Nullable<() => void>);
  36056. /**
  36057. * An event triggered before animating the scene
  36058. */
  36059. onBeforeAnimationsObservable: Observable<Scene>;
  36060. /**
  36061. * An event triggered after animations processing
  36062. */
  36063. onAfterAnimationsObservable: Observable<Scene>;
  36064. /**
  36065. * An event triggered before draw calls are ready to be sent
  36066. */
  36067. onBeforeDrawPhaseObservable: Observable<Scene>;
  36068. /**
  36069. * An event triggered after draw calls have been sent
  36070. */
  36071. onAfterDrawPhaseObservable: Observable<Scene>;
  36072. /**
  36073. * An event triggered when the scene is ready
  36074. */
  36075. onReadyObservable: Observable<Scene>;
  36076. /**
  36077. * An event triggered before rendering a camera
  36078. */
  36079. onBeforeCameraRenderObservable: Observable<Camera>;
  36080. private _onBeforeCameraRenderObserver;
  36081. /** Sets a function to be executed before rendering a camera*/
  36082. set beforeCameraRender(callback: () => void);
  36083. /**
  36084. * An event triggered after rendering a camera
  36085. */
  36086. onAfterCameraRenderObservable: Observable<Camera>;
  36087. private _onAfterCameraRenderObserver;
  36088. /** Sets a function to be executed after rendering a camera*/
  36089. set afterCameraRender(callback: () => void);
  36090. /**
  36091. * An event triggered when active meshes evaluation is about to start
  36092. */
  36093. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36094. /**
  36095. * An event triggered when active meshes evaluation is done
  36096. */
  36097. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36098. /**
  36099. * An event triggered when particles rendering is about to start
  36100. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36101. */
  36102. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36103. /**
  36104. * An event triggered when particles rendering is done
  36105. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36106. */
  36107. onAfterParticlesRenderingObservable: Observable<Scene>;
  36108. /**
  36109. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36110. */
  36111. onDataLoadedObservable: Observable<Scene>;
  36112. /**
  36113. * An event triggered when a camera is created
  36114. */
  36115. onNewCameraAddedObservable: Observable<Camera>;
  36116. /**
  36117. * An event triggered when a camera is removed
  36118. */
  36119. onCameraRemovedObservable: Observable<Camera>;
  36120. /**
  36121. * An event triggered when a light is created
  36122. */
  36123. onNewLightAddedObservable: Observable<Light>;
  36124. /**
  36125. * An event triggered when a light is removed
  36126. */
  36127. onLightRemovedObservable: Observable<Light>;
  36128. /**
  36129. * An event triggered when a geometry is created
  36130. */
  36131. onNewGeometryAddedObservable: Observable<Geometry>;
  36132. /**
  36133. * An event triggered when a geometry is removed
  36134. */
  36135. onGeometryRemovedObservable: Observable<Geometry>;
  36136. /**
  36137. * An event triggered when a transform node is created
  36138. */
  36139. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36140. /**
  36141. * An event triggered when a transform node is removed
  36142. */
  36143. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36144. /**
  36145. * An event triggered when a mesh is created
  36146. */
  36147. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36148. /**
  36149. * An event triggered when a mesh is removed
  36150. */
  36151. onMeshRemovedObservable: Observable<AbstractMesh>;
  36152. /**
  36153. * An event triggered when a skeleton is created
  36154. */
  36155. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36156. /**
  36157. * An event triggered when a skeleton is removed
  36158. */
  36159. onSkeletonRemovedObservable: Observable<Skeleton>;
  36160. /**
  36161. * An event triggered when a material is created
  36162. */
  36163. onNewMaterialAddedObservable: Observable<Material>;
  36164. /**
  36165. * An event triggered when a material is removed
  36166. */
  36167. onMaterialRemovedObservable: Observable<Material>;
  36168. /**
  36169. * An event triggered when a texture is created
  36170. */
  36171. onNewTextureAddedObservable: Observable<BaseTexture>;
  36172. /**
  36173. * An event triggered when a texture is removed
  36174. */
  36175. onTextureRemovedObservable: Observable<BaseTexture>;
  36176. /**
  36177. * An event triggered when render targets are about to be rendered
  36178. * Can happen multiple times per frame.
  36179. */
  36180. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36181. /**
  36182. * An event triggered when render targets were rendered.
  36183. * Can happen multiple times per frame.
  36184. */
  36185. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36186. /**
  36187. * An event triggered before calculating deterministic simulation step
  36188. */
  36189. onBeforeStepObservable: Observable<Scene>;
  36190. /**
  36191. * An event triggered after calculating deterministic simulation step
  36192. */
  36193. onAfterStepObservable: Observable<Scene>;
  36194. /**
  36195. * An event triggered when the activeCamera property is updated
  36196. */
  36197. onActiveCameraChanged: Observable<Scene>;
  36198. /**
  36199. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36200. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36201. * 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)
  36202. */
  36203. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36204. /**
  36205. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36206. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36207. * 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)
  36208. */
  36209. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36210. /**
  36211. * This Observable will when a mesh has been imported into the scene.
  36212. */
  36213. onMeshImportedObservable: Observable<AbstractMesh>;
  36214. /**
  36215. * This Observable will when an animation file has been imported into the scene.
  36216. */
  36217. onAnimationFileImportedObservable: Observable<Scene>;
  36218. /**
  36219. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36220. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36221. */
  36222. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36223. /** @hidden */
  36224. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36225. /**
  36226. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36227. */
  36228. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36229. /**
  36230. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36231. */
  36232. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36233. /**
  36234. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36235. */
  36236. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36237. /** Callback called when a pointer move is detected */
  36238. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36239. /** Callback called when a pointer down is detected */
  36240. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36241. /** Callback called when a pointer up is detected */
  36242. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36243. /** Callback called when a pointer pick is detected */
  36244. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36245. /**
  36246. * 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).
  36247. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36248. */
  36249. onPrePointerObservable: Observable<PointerInfoPre>;
  36250. /**
  36251. * Observable event triggered each time an input event is received from the rendering canvas
  36252. */
  36253. onPointerObservable: Observable<PointerInfo>;
  36254. /**
  36255. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36256. */
  36257. get unTranslatedPointer(): Vector2;
  36258. /**
  36259. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36260. */
  36261. static get DragMovementThreshold(): number;
  36262. static set DragMovementThreshold(value: number);
  36263. /**
  36264. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36265. */
  36266. static get LongPressDelay(): number;
  36267. static set LongPressDelay(value: number);
  36268. /**
  36269. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36270. */
  36271. static get DoubleClickDelay(): number;
  36272. static set DoubleClickDelay(value: number);
  36273. /** If you need to check double click without raising a single click at first click, enable this flag */
  36274. static get ExclusiveDoubleClickMode(): boolean;
  36275. static set ExclusiveDoubleClickMode(value: boolean);
  36276. /** @hidden */
  36277. _mirroredCameraPosition: Nullable<Vector3>;
  36278. /**
  36279. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36280. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36281. */
  36282. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36283. /**
  36284. * Observable event triggered each time an keyboard event is received from the hosting window
  36285. */
  36286. onKeyboardObservable: Observable<KeyboardInfo>;
  36287. private _useRightHandedSystem;
  36288. /**
  36289. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36290. */
  36291. set useRightHandedSystem(value: boolean);
  36292. get useRightHandedSystem(): boolean;
  36293. private _timeAccumulator;
  36294. private _currentStepId;
  36295. private _currentInternalStep;
  36296. /**
  36297. * Sets the step Id used by deterministic lock step
  36298. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36299. * @param newStepId defines the step Id
  36300. */
  36301. setStepId(newStepId: number): void;
  36302. /**
  36303. * Gets the step Id used by deterministic lock step
  36304. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36305. * @returns the step Id
  36306. */
  36307. getStepId(): number;
  36308. /**
  36309. * Gets the internal step used by deterministic lock step
  36310. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36311. * @returns the internal step
  36312. */
  36313. getInternalStep(): number;
  36314. private _fogEnabled;
  36315. /**
  36316. * Gets or sets a boolean indicating if fog is enabled on this scene
  36317. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36318. * (Default is true)
  36319. */
  36320. set fogEnabled(value: boolean);
  36321. get fogEnabled(): boolean;
  36322. private _fogMode;
  36323. /**
  36324. * Gets or sets the fog mode to use
  36325. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36326. * | mode | value |
  36327. * | --- | --- |
  36328. * | FOGMODE_NONE | 0 |
  36329. * | FOGMODE_EXP | 1 |
  36330. * | FOGMODE_EXP2 | 2 |
  36331. * | FOGMODE_LINEAR | 3 |
  36332. */
  36333. set fogMode(value: number);
  36334. get fogMode(): number;
  36335. /**
  36336. * Gets or sets the fog color to use
  36337. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36338. * (Default is Color3(0.2, 0.2, 0.3))
  36339. */
  36340. fogColor: Color3;
  36341. /**
  36342. * Gets or sets the fog density to use
  36343. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36344. * (Default is 0.1)
  36345. */
  36346. fogDensity: number;
  36347. /**
  36348. * Gets or sets the fog start distance to use
  36349. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36350. * (Default is 0)
  36351. */
  36352. fogStart: number;
  36353. /**
  36354. * Gets or sets the fog end distance to use
  36355. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36356. * (Default is 1000)
  36357. */
  36358. fogEnd: number;
  36359. private _shadowsEnabled;
  36360. /**
  36361. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36362. */
  36363. set shadowsEnabled(value: boolean);
  36364. get shadowsEnabled(): boolean;
  36365. private _lightsEnabled;
  36366. /**
  36367. * Gets or sets a boolean indicating if lights are enabled on this scene
  36368. */
  36369. set lightsEnabled(value: boolean);
  36370. get lightsEnabled(): boolean;
  36371. /** All of the active cameras added to this scene. */
  36372. activeCameras: Camera[];
  36373. /** @hidden */
  36374. _activeCamera: Nullable<Camera>;
  36375. /** Gets or sets the current active camera */
  36376. get activeCamera(): Nullable<Camera>;
  36377. set activeCamera(value: Nullable<Camera>);
  36378. private _defaultMaterial;
  36379. /** The default material used on meshes when no material is affected */
  36380. get defaultMaterial(): Material;
  36381. /** The default material used on meshes when no material is affected */
  36382. set defaultMaterial(value: Material);
  36383. private _texturesEnabled;
  36384. /**
  36385. * Gets or sets a boolean indicating if textures are enabled on this scene
  36386. */
  36387. set texturesEnabled(value: boolean);
  36388. get texturesEnabled(): boolean;
  36389. /**
  36390. * Gets or sets a boolean indicating if particles are enabled on this scene
  36391. */
  36392. particlesEnabled: boolean;
  36393. /**
  36394. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36395. */
  36396. spritesEnabled: boolean;
  36397. private _skeletonsEnabled;
  36398. /**
  36399. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36400. */
  36401. set skeletonsEnabled(value: boolean);
  36402. get skeletonsEnabled(): boolean;
  36403. /**
  36404. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36405. */
  36406. lensFlaresEnabled: boolean;
  36407. /**
  36408. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36410. */
  36411. collisionsEnabled: boolean;
  36412. private _collisionCoordinator;
  36413. /** @hidden */
  36414. get collisionCoordinator(): ICollisionCoordinator;
  36415. /**
  36416. * Defines the gravity applied to this scene (used only for collisions)
  36417. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36418. */
  36419. gravity: Vector3;
  36420. /**
  36421. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36422. */
  36423. postProcessesEnabled: boolean;
  36424. /**
  36425. * The list of postprocesses added to the scene
  36426. */
  36427. postProcesses: PostProcess[];
  36428. /**
  36429. * Gets the current postprocess manager
  36430. */
  36431. postProcessManager: PostProcessManager;
  36432. /**
  36433. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36434. */
  36435. renderTargetsEnabled: boolean;
  36436. /**
  36437. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36438. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36439. */
  36440. dumpNextRenderTargets: boolean;
  36441. /**
  36442. * The list of user defined render targets added to the scene
  36443. */
  36444. customRenderTargets: RenderTargetTexture[];
  36445. /**
  36446. * Defines if texture loading must be delayed
  36447. * If true, textures will only be loaded when they need to be rendered
  36448. */
  36449. useDelayedTextureLoading: boolean;
  36450. /**
  36451. * Gets the list of meshes imported to the scene through SceneLoader
  36452. */
  36453. importedMeshesFiles: String[];
  36454. /**
  36455. * Gets or sets a boolean indicating if probes are enabled on this scene
  36456. */
  36457. probesEnabled: boolean;
  36458. /**
  36459. * Gets or sets the current offline provider to use to store scene data
  36460. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36461. */
  36462. offlineProvider: IOfflineProvider;
  36463. /**
  36464. * Gets or sets the action manager associated with the scene
  36465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36466. */
  36467. actionManager: AbstractActionManager;
  36468. private _meshesForIntersections;
  36469. /**
  36470. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36471. */
  36472. proceduralTexturesEnabled: boolean;
  36473. private _engine;
  36474. private _totalVertices;
  36475. /** @hidden */
  36476. _activeIndices: PerfCounter;
  36477. /** @hidden */
  36478. _activeParticles: PerfCounter;
  36479. /** @hidden */
  36480. _activeBones: PerfCounter;
  36481. private _animationRatio;
  36482. /** @hidden */
  36483. _animationTimeLast: number;
  36484. /** @hidden */
  36485. _animationTime: number;
  36486. /**
  36487. * Gets or sets a general scale for animation speed
  36488. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36489. */
  36490. animationTimeScale: number;
  36491. /** @hidden */
  36492. _cachedMaterial: Nullable<Material>;
  36493. /** @hidden */
  36494. _cachedEffect: Nullable<Effect>;
  36495. /** @hidden */
  36496. _cachedVisibility: Nullable<number>;
  36497. private _renderId;
  36498. private _frameId;
  36499. private _executeWhenReadyTimeoutId;
  36500. private _intermediateRendering;
  36501. private _viewUpdateFlag;
  36502. private _projectionUpdateFlag;
  36503. /** @hidden */
  36504. _toBeDisposed: Nullable<IDisposable>[];
  36505. private _activeRequests;
  36506. /** @hidden */
  36507. _pendingData: any[];
  36508. private _isDisposed;
  36509. /**
  36510. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36511. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36512. */
  36513. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36514. private _activeMeshes;
  36515. private _processedMaterials;
  36516. private _renderTargets;
  36517. /** @hidden */
  36518. _activeParticleSystems: SmartArray<IParticleSystem>;
  36519. private _activeSkeletons;
  36520. private _softwareSkinnedMeshes;
  36521. private _renderingManager;
  36522. /** @hidden */
  36523. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36524. private _transformMatrix;
  36525. private _sceneUbo;
  36526. /** @hidden */
  36527. _viewMatrix: Matrix;
  36528. private _projectionMatrix;
  36529. /** @hidden */
  36530. _forcedViewPosition: Nullable<Vector3>;
  36531. /** @hidden */
  36532. _frustumPlanes: Plane[];
  36533. /**
  36534. * Gets the list of frustum planes (built from the active camera)
  36535. */
  36536. get frustumPlanes(): Plane[];
  36537. /**
  36538. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36539. * This is useful if there are more lights that the maximum simulteanous authorized
  36540. */
  36541. requireLightSorting: boolean;
  36542. /** @hidden */
  36543. readonly useMaterialMeshMap: boolean;
  36544. /** @hidden */
  36545. readonly useClonedMeshhMap: boolean;
  36546. private _externalData;
  36547. private _uid;
  36548. /**
  36549. * @hidden
  36550. * Backing store of defined scene components.
  36551. */
  36552. _components: ISceneComponent[];
  36553. /**
  36554. * @hidden
  36555. * Backing store of defined scene components.
  36556. */
  36557. _serializableComponents: ISceneSerializableComponent[];
  36558. /**
  36559. * List of components to register on the next registration step.
  36560. */
  36561. private _transientComponents;
  36562. /**
  36563. * Registers the transient components if needed.
  36564. */
  36565. private _registerTransientComponents;
  36566. /**
  36567. * @hidden
  36568. * Add a component to the scene.
  36569. * Note that the ccomponent could be registered on th next frame if this is called after
  36570. * the register component stage.
  36571. * @param component Defines the component to add to the scene
  36572. */
  36573. _addComponent(component: ISceneComponent): void;
  36574. /**
  36575. * @hidden
  36576. * Gets a component from the scene.
  36577. * @param name defines the name of the component to retrieve
  36578. * @returns the component or null if not present
  36579. */
  36580. _getComponent(name: string): Nullable<ISceneComponent>;
  36581. /**
  36582. * @hidden
  36583. * Defines the actions happening before camera updates.
  36584. */
  36585. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36586. /**
  36587. * @hidden
  36588. * Defines the actions happening before clear the canvas.
  36589. */
  36590. _beforeClearStage: Stage<SimpleStageAction>;
  36591. /**
  36592. * @hidden
  36593. * Defines the actions when collecting render targets for the frame.
  36594. */
  36595. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36596. /**
  36597. * @hidden
  36598. * Defines the actions happening for one camera in the frame.
  36599. */
  36600. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36601. /**
  36602. * @hidden
  36603. * Defines the actions happening during the per mesh ready checks.
  36604. */
  36605. _isReadyForMeshStage: Stage<MeshStageAction>;
  36606. /**
  36607. * @hidden
  36608. * Defines the actions happening before evaluate active mesh checks.
  36609. */
  36610. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36611. /**
  36612. * @hidden
  36613. * Defines the actions happening during the evaluate sub mesh checks.
  36614. */
  36615. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36616. /**
  36617. * @hidden
  36618. * Defines the actions happening during the active mesh stage.
  36619. */
  36620. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36621. /**
  36622. * @hidden
  36623. * Defines the actions happening during the per camera render target step.
  36624. */
  36625. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36626. /**
  36627. * @hidden
  36628. * Defines the actions happening just before the active camera is drawing.
  36629. */
  36630. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36631. /**
  36632. * @hidden
  36633. * Defines the actions happening just before a render target is drawing.
  36634. */
  36635. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36636. /**
  36637. * @hidden
  36638. * Defines the actions happening just before a rendering group is drawing.
  36639. */
  36640. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36641. /**
  36642. * @hidden
  36643. * Defines the actions happening just before a mesh is drawing.
  36644. */
  36645. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36646. /**
  36647. * @hidden
  36648. * Defines the actions happening just after a mesh has been drawn.
  36649. */
  36650. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36651. /**
  36652. * @hidden
  36653. * Defines the actions happening just after a rendering group has been drawn.
  36654. */
  36655. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36656. /**
  36657. * @hidden
  36658. * Defines the actions happening just after the active camera has been drawn.
  36659. */
  36660. _afterCameraDrawStage: Stage<CameraStageAction>;
  36661. /**
  36662. * @hidden
  36663. * Defines the actions happening just after a render target has been drawn.
  36664. */
  36665. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36666. /**
  36667. * @hidden
  36668. * Defines the actions happening just after rendering all cameras and computing intersections.
  36669. */
  36670. _afterRenderStage: Stage<SimpleStageAction>;
  36671. /**
  36672. * @hidden
  36673. * Defines the actions happening when a pointer move event happens.
  36674. */
  36675. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36676. /**
  36677. * @hidden
  36678. * Defines the actions happening when a pointer down event happens.
  36679. */
  36680. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36681. /**
  36682. * @hidden
  36683. * Defines the actions happening when a pointer up event happens.
  36684. */
  36685. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36686. /**
  36687. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36688. */
  36689. private geometriesByUniqueId;
  36690. /**
  36691. * Creates a new Scene
  36692. * @param engine defines the engine to use to render this scene
  36693. * @param options defines the scene options
  36694. */
  36695. constructor(engine: Engine, options?: SceneOptions);
  36696. /**
  36697. * Gets a string idenfifying the name of the class
  36698. * @returns "Scene" string
  36699. */
  36700. getClassName(): string;
  36701. private _defaultMeshCandidates;
  36702. /**
  36703. * @hidden
  36704. */
  36705. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36706. private _defaultSubMeshCandidates;
  36707. /**
  36708. * @hidden
  36709. */
  36710. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36711. /**
  36712. * Sets the default candidate providers for the scene.
  36713. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36714. * and getCollidingSubMeshCandidates to their default function
  36715. */
  36716. setDefaultCandidateProviders(): void;
  36717. /**
  36718. * Gets the mesh that is currently under the pointer
  36719. */
  36720. get meshUnderPointer(): Nullable<AbstractMesh>;
  36721. /**
  36722. * Gets or sets the current on-screen X position of the pointer
  36723. */
  36724. get pointerX(): number;
  36725. set pointerX(value: number);
  36726. /**
  36727. * Gets or sets the current on-screen Y position of the pointer
  36728. */
  36729. get pointerY(): number;
  36730. set pointerY(value: number);
  36731. /**
  36732. * Gets the cached material (ie. the latest rendered one)
  36733. * @returns the cached material
  36734. */
  36735. getCachedMaterial(): Nullable<Material>;
  36736. /**
  36737. * Gets the cached effect (ie. the latest rendered one)
  36738. * @returns the cached effect
  36739. */
  36740. getCachedEffect(): Nullable<Effect>;
  36741. /**
  36742. * Gets the cached visibility state (ie. the latest rendered one)
  36743. * @returns the cached visibility state
  36744. */
  36745. getCachedVisibility(): Nullable<number>;
  36746. /**
  36747. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36748. * @param material defines the current material
  36749. * @param effect defines the current effect
  36750. * @param visibility defines the current visibility state
  36751. * @returns true if one parameter is not cached
  36752. */
  36753. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36754. /**
  36755. * Gets the engine associated with the scene
  36756. * @returns an Engine
  36757. */
  36758. getEngine(): Engine;
  36759. /**
  36760. * Gets the total number of vertices rendered per frame
  36761. * @returns the total number of vertices rendered per frame
  36762. */
  36763. getTotalVertices(): number;
  36764. /**
  36765. * Gets the performance counter for total vertices
  36766. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36767. */
  36768. get totalVerticesPerfCounter(): PerfCounter;
  36769. /**
  36770. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36771. * @returns the total number of active indices rendered per frame
  36772. */
  36773. getActiveIndices(): number;
  36774. /**
  36775. * Gets the performance counter for active indices
  36776. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36777. */
  36778. get totalActiveIndicesPerfCounter(): PerfCounter;
  36779. /**
  36780. * Gets the total number of active particles rendered per frame
  36781. * @returns the total number of active particles rendered per frame
  36782. */
  36783. getActiveParticles(): number;
  36784. /**
  36785. * Gets the performance counter for active particles
  36786. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36787. */
  36788. get activeParticlesPerfCounter(): PerfCounter;
  36789. /**
  36790. * Gets the total number of active bones rendered per frame
  36791. * @returns the total number of active bones rendered per frame
  36792. */
  36793. getActiveBones(): number;
  36794. /**
  36795. * Gets the performance counter for active bones
  36796. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36797. */
  36798. get activeBonesPerfCounter(): PerfCounter;
  36799. /**
  36800. * Gets the array of active meshes
  36801. * @returns an array of AbstractMesh
  36802. */
  36803. getActiveMeshes(): SmartArray<AbstractMesh>;
  36804. /**
  36805. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36806. * @returns a number
  36807. */
  36808. getAnimationRatio(): number;
  36809. /**
  36810. * Gets an unique Id for the current render phase
  36811. * @returns a number
  36812. */
  36813. getRenderId(): number;
  36814. /**
  36815. * Gets an unique Id for the current frame
  36816. * @returns a number
  36817. */
  36818. getFrameId(): number;
  36819. /** Call this function if you want to manually increment the render Id*/
  36820. incrementRenderId(): void;
  36821. private _createUbo;
  36822. /**
  36823. * Use this method to simulate a pointer move on a mesh
  36824. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36825. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36826. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36827. * @returns the current scene
  36828. */
  36829. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36830. /**
  36831. * Use this method to simulate a pointer down on a mesh
  36832. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36833. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36834. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36835. * @returns the current scene
  36836. */
  36837. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36838. /**
  36839. * Use this method to simulate a pointer up on a mesh
  36840. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36841. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36842. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36843. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36844. * @returns the current scene
  36845. */
  36846. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36847. /**
  36848. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36849. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36850. * @returns true if the pointer was captured
  36851. */
  36852. isPointerCaptured(pointerId?: number): boolean;
  36853. /**
  36854. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36855. * @param attachUp defines if you want to attach events to pointerup
  36856. * @param attachDown defines if you want to attach events to pointerdown
  36857. * @param attachMove defines if you want to attach events to pointermove
  36858. */
  36859. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36860. /** Detaches all event handlers*/
  36861. detachControl(): void;
  36862. /**
  36863. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36864. * Delay loaded resources are not taking in account
  36865. * @return true if all required resources are ready
  36866. */
  36867. isReady(): boolean;
  36868. /** Resets all cached information relative to material (including effect and visibility) */
  36869. resetCachedMaterial(): void;
  36870. /**
  36871. * Registers a function to be called before every frame render
  36872. * @param func defines the function to register
  36873. */
  36874. registerBeforeRender(func: () => void): void;
  36875. /**
  36876. * Unregisters a function called before every frame render
  36877. * @param func defines the function to unregister
  36878. */
  36879. unregisterBeforeRender(func: () => void): void;
  36880. /**
  36881. * Registers a function to be called after every frame render
  36882. * @param func defines the function to register
  36883. */
  36884. registerAfterRender(func: () => void): void;
  36885. /**
  36886. * Unregisters a function called after every frame render
  36887. * @param func defines the function to unregister
  36888. */
  36889. unregisterAfterRender(func: () => void): void;
  36890. private _executeOnceBeforeRender;
  36891. /**
  36892. * The provided function will run before render once and will be disposed afterwards.
  36893. * A timeout delay can be provided so that the function will be executed in N ms.
  36894. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36895. * @param func The function to be executed.
  36896. * @param timeout optional delay in ms
  36897. */
  36898. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36899. /** @hidden */
  36900. _addPendingData(data: any): void;
  36901. /** @hidden */
  36902. _removePendingData(data: any): void;
  36903. /**
  36904. * Returns the number of items waiting to be loaded
  36905. * @returns the number of items waiting to be loaded
  36906. */
  36907. getWaitingItemsCount(): number;
  36908. /**
  36909. * Returns a boolean indicating if the scene is still loading data
  36910. */
  36911. get isLoading(): boolean;
  36912. /**
  36913. * Registers a function to be executed when the scene is ready
  36914. * @param {Function} func - the function to be executed
  36915. */
  36916. executeWhenReady(func: () => void): void;
  36917. /**
  36918. * Returns a promise that resolves when the scene is ready
  36919. * @returns A promise that resolves when the scene is ready
  36920. */
  36921. whenReadyAsync(): Promise<void>;
  36922. /** @hidden */
  36923. _checkIsReady(): void;
  36924. /**
  36925. * Gets all animatable attached to the scene
  36926. */
  36927. get animatables(): Animatable[];
  36928. /**
  36929. * Resets the last animation time frame.
  36930. * Useful to override when animations start running when loading a scene for the first time.
  36931. */
  36932. resetLastAnimationTimeFrame(): void;
  36933. /**
  36934. * Gets the current view matrix
  36935. * @returns a Matrix
  36936. */
  36937. getViewMatrix(): Matrix;
  36938. /**
  36939. * Gets the current projection matrix
  36940. * @returns a Matrix
  36941. */
  36942. getProjectionMatrix(): Matrix;
  36943. /**
  36944. * Gets the current transform matrix
  36945. * @returns a Matrix made of View * Projection
  36946. */
  36947. getTransformMatrix(): Matrix;
  36948. /**
  36949. * Sets the current transform matrix
  36950. * @param viewL defines the View matrix to use
  36951. * @param projectionL defines the Projection matrix to use
  36952. * @param viewR defines the right View matrix to use (if provided)
  36953. * @param projectionR defines the right Projection matrix to use (if provided)
  36954. */
  36955. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36956. /**
  36957. * Gets the uniform buffer used to store scene data
  36958. * @returns a UniformBuffer
  36959. */
  36960. getSceneUniformBuffer(): UniformBuffer;
  36961. /**
  36962. * Gets an unique (relatively to the current scene) Id
  36963. * @returns an unique number for the scene
  36964. */
  36965. getUniqueId(): number;
  36966. /**
  36967. * Add a mesh to the list of scene's meshes
  36968. * @param newMesh defines the mesh to add
  36969. * @param recursive if all child meshes should also be added to the scene
  36970. */
  36971. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36972. /**
  36973. * Remove a mesh for the list of scene's meshes
  36974. * @param toRemove defines the mesh to remove
  36975. * @param recursive if all child meshes should also be removed from the scene
  36976. * @returns the index where the mesh was in the mesh list
  36977. */
  36978. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36979. /**
  36980. * Add a transform node to the list of scene's transform nodes
  36981. * @param newTransformNode defines the transform node to add
  36982. */
  36983. addTransformNode(newTransformNode: TransformNode): void;
  36984. /**
  36985. * Remove a transform node for the list of scene's transform nodes
  36986. * @param toRemove defines the transform node to remove
  36987. * @returns the index where the transform node was in the transform node list
  36988. */
  36989. removeTransformNode(toRemove: TransformNode): number;
  36990. /**
  36991. * Remove a skeleton for the list of scene's skeletons
  36992. * @param toRemove defines the skeleton to remove
  36993. * @returns the index where the skeleton was in the skeleton list
  36994. */
  36995. removeSkeleton(toRemove: Skeleton): number;
  36996. /**
  36997. * Remove a morph target for the list of scene's morph targets
  36998. * @param toRemove defines the morph target to remove
  36999. * @returns the index where the morph target was in the morph target list
  37000. */
  37001. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37002. /**
  37003. * Remove a light for the list of scene's lights
  37004. * @param toRemove defines the light to remove
  37005. * @returns the index where the light was in the light list
  37006. */
  37007. removeLight(toRemove: Light): number;
  37008. /**
  37009. * Remove a camera for the list of scene's cameras
  37010. * @param toRemove defines the camera to remove
  37011. * @returns the index where the camera was in the camera list
  37012. */
  37013. removeCamera(toRemove: Camera): number;
  37014. /**
  37015. * Remove a particle system for the list of scene's particle systems
  37016. * @param toRemove defines the particle system to remove
  37017. * @returns the index where the particle system was in the particle system list
  37018. */
  37019. removeParticleSystem(toRemove: IParticleSystem): number;
  37020. /**
  37021. * Remove a animation for the list of scene's animations
  37022. * @param toRemove defines the animation to remove
  37023. * @returns the index where the animation was in the animation list
  37024. */
  37025. removeAnimation(toRemove: Animation): number;
  37026. /**
  37027. * Will stop the animation of the given target
  37028. * @param target - the target
  37029. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37030. * @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)
  37031. */
  37032. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37033. /**
  37034. * Removes the given animation group from this scene.
  37035. * @param toRemove The animation group to remove
  37036. * @returns The index of the removed animation group
  37037. */
  37038. removeAnimationGroup(toRemove: AnimationGroup): number;
  37039. /**
  37040. * Removes the given multi-material from this scene.
  37041. * @param toRemove The multi-material to remove
  37042. * @returns The index of the removed multi-material
  37043. */
  37044. removeMultiMaterial(toRemove: MultiMaterial): number;
  37045. /**
  37046. * Removes the given material from this scene.
  37047. * @param toRemove The material to remove
  37048. * @returns The index of the removed material
  37049. */
  37050. removeMaterial(toRemove: Material): number;
  37051. /**
  37052. * Removes the given action manager from this scene.
  37053. * @param toRemove The action manager to remove
  37054. * @returns The index of the removed action manager
  37055. */
  37056. removeActionManager(toRemove: AbstractActionManager): number;
  37057. /**
  37058. * Removes the given texture from this scene.
  37059. * @param toRemove The texture to remove
  37060. * @returns The index of the removed texture
  37061. */
  37062. removeTexture(toRemove: BaseTexture): number;
  37063. /**
  37064. * Adds the given light to this scene
  37065. * @param newLight The light to add
  37066. */
  37067. addLight(newLight: Light): void;
  37068. /**
  37069. * Sorts the list list based on light priorities
  37070. */
  37071. sortLightsByPriority(): void;
  37072. /**
  37073. * Adds the given camera to this scene
  37074. * @param newCamera The camera to add
  37075. */
  37076. addCamera(newCamera: Camera): void;
  37077. /**
  37078. * Adds the given skeleton to this scene
  37079. * @param newSkeleton The skeleton to add
  37080. */
  37081. addSkeleton(newSkeleton: Skeleton): void;
  37082. /**
  37083. * Adds the given particle system to this scene
  37084. * @param newParticleSystem The particle system to add
  37085. */
  37086. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37087. /**
  37088. * Adds the given animation to this scene
  37089. * @param newAnimation The animation to add
  37090. */
  37091. addAnimation(newAnimation: Animation): void;
  37092. /**
  37093. * Adds the given animation group to this scene.
  37094. * @param newAnimationGroup The animation group to add
  37095. */
  37096. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37097. /**
  37098. * Adds the given multi-material to this scene
  37099. * @param newMultiMaterial The multi-material to add
  37100. */
  37101. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37102. /**
  37103. * Adds the given material to this scene
  37104. * @param newMaterial The material to add
  37105. */
  37106. addMaterial(newMaterial: Material): void;
  37107. /**
  37108. * Adds the given morph target to this scene
  37109. * @param newMorphTargetManager The morph target to add
  37110. */
  37111. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37112. /**
  37113. * Adds the given geometry to this scene
  37114. * @param newGeometry The geometry to add
  37115. */
  37116. addGeometry(newGeometry: Geometry): void;
  37117. /**
  37118. * Adds the given action manager to this scene
  37119. * @param newActionManager The action manager to add
  37120. */
  37121. addActionManager(newActionManager: AbstractActionManager): void;
  37122. /**
  37123. * Adds the given texture to this scene.
  37124. * @param newTexture The texture to add
  37125. */
  37126. addTexture(newTexture: BaseTexture): void;
  37127. /**
  37128. * Switch active camera
  37129. * @param newCamera defines the new active camera
  37130. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37131. */
  37132. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37133. /**
  37134. * sets the active camera of the scene using its ID
  37135. * @param id defines the camera's ID
  37136. * @return the new active camera or null if none found.
  37137. */
  37138. setActiveCameraByID(id: string): Nullable<Camera>;
  37139. /**
  37140. * sets the active camera of the scene using its name
  37141. * @param name defines the camera's name
  37142. * @returns the new active camera or null if none found.
  37143. */
  37144. setActiveCameraByName(name: string): Nullable<Camera>;
  37145. /**
  37146. * get an animation group using its name
  37147. * @param name defines the material's name
  37148. * @return the animation group or null if none found.
  37149. */
  37150. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37151. /**
  37152. * Get a material using its unique id
  37153. * @param uniqueId defines the material's unique id
  37154. * @return the material or null if none found.
  37155. */
  37156. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37157. /**
  37158. * get a material using its id
  37159. * @param id defines the material's ID
  37160. * @return the material or null if none found.
  37161. */
  37162. getMaterialByID(id: string): Nullable<Material>;
  37163. /**
  37164. * Gets a the last added material using a given id
  37165. * @param id defines the material's ID
  37166. * @return the last material with the given id or null if none found.
  37167. */
  37168. getLastMaterialByID(id: string): Nullable<Material>;
  37169. /**
  37170. * Gets a material using its name
  37171. * @param name defines the material's name
  37172. * @return the material or null if none found.
  37173. */
  37174. getMaterialByName(name: string): Nullable<Material>;
  37175. /**
  37176. * Get a texture using its unique id
  37177. * @param uniqueId defines the texture's unique id
  37178. * @return the texture or null if none found.
  37179. */
  37180. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37181. /**
  37182. * Gets a camera using its id
  37183. * @param id defines the id to look for
  37184. * @returns the camera or null if not found
  37185. */
  37186. getCameraByID(id: string): Nullable<Camera>;
  37187. /**
  37188. * Gets a camera using its unique id
  37189. * @param uniqueId defines the unique id to look for
  37190. * @returns the camera or null if not found
  37191. */
  37192. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37193. /**
  37194. * Gets a camera using its name
  37195. * @param name defines the camera's name
  37196. * @return the camera or null if none found.
  37197. */
  37198. getCameraByName(name: string): Nullable<Camera>;
  37199. /**
  37200. * Gets a bone using its id
  37201. * @param id defines the bone's id
  37202. * @return the bone or null if not found
  37203. */
  37204. getBoneByID(id: string): Nullable<Bone>;
  37205. /**
  37206. * Gets a bone using its id
  37207. * @param name defines the bone's name
  37208. * @return the bone or null if not found
  37209. */
  37210. getBoneByName(name: string): Nullable<Bone>;
  37211. /**
  37212. * Gets a light node using its name
  37213. * @param name defines the the light's name
  37214. * @return the light or null if none found.
  37215. */
  37216. getLightByName(name: string): Nullable<Light>;
  37217. /**
  37218. * Gets a light node using its id
  37219. * @param id defines the light's id
  37220. * @return the light or null if none found.
  37221. */
  37222. getLightByID(id: string): Nullable<Light>;
  37223. /**
  37224. * Gets a light node using its scene-generated unique ID
  37225. * @param uniqueId defines the light's unique id
  37226. * @return the light or null if none found.
  37227. */
  37228. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37229. /**
  37230. * Gets a particle system by id
  37231. * @param id defines the particle system id
  37232. * @return the corresponding system or null if none found
  37233. */
  37234. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37235. /**
  37236. * Gets a geometry using its ID
  37237. * @param id defines the geometry's id
  37238. * @return the geometry or null if none found.
  37239. */
  37240. getGeometryByID(id: string): Nullable<Geometry>;
  37241. private _getGeometryByUniqueID;
  37242. /**
  37243. * Add a new geometry to this scene
  37244. * @param geometry defines the geometry to be added to the scene.
  37245. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37246. * @return a boolean defining if the geometry was added or not
  37247. */
  37248. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37249. /**
  37250. * Removes an existing geometry
  37251. * @param geometry defines the geometry to be removed from the scene
  37252. * @return a boolean defining if the geometry was removed or not
  37253. */
  37254. removeGeometry(geometry: Geometry): boolean;
  37255. /**
  37256. * Gets the list of geometries attached to the scene
  37257. * @returns an array of Geometry
  37258. */
  37259. getGeometries(): Geometry[];
  37260. /**
  37261. * Gets the first added mesh found of a given ID
  37262. * @param id defines the id to search for
  37263. * @return the mesh found or null if not found at all
  37264. */
  37265. getMeshByID(id: string): Nullable<AbstractMesh>;
  37266. /**
  37267. * Gets a list of meshes using their id
  37268. * @param id defines the id to search for
  37269. * @returns a list of meshes
  37270. */
  37271. getMeshesByID(id: string): Array<AbstractMesh>;
  37272. /**
  37273. * Gets the first added transform node found of a given ID
  37274. * @param id defines the id to search for
  37275. * @return the found transform node or null if not found at all.
  37276. */
  37277. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37278. /**
  37279. * Gets a transform node with its auto-generated unique id
  37280. * @param uniqueId efines the unique id to search for
  37281. * @return the found transform node or null if not found at all.
  37282. */
  37283. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37284. /**
  37285. * Gets a list of transform nodes using their id
  37286. * @param id defines the id to search for
  37287. * @returns a list of transform nodes
  37288. */
  37289. getTransformNodesByID(id: string): Array<TransformNode>;
  37290. /**
  37291. * Gets a mesh with its auto-generated unique id
  37292. * @param uniqueId defines the unique id to search for
  37293. * @return the found mesh or null if not found at all.
  37294. */
  37295. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37296. /**
  37297. * Gets a the last added mesh using a given id
  37298. * @param id defines the id to search for
  37299. * @return the found mesh or null if not found at all.
  37300. */
  37301. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37302. /**
  37303. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37304. * @param id defines the id to search for
  37305. * @return the found node or null if not found at all
  37306. */
  37307. getLastEntryByID(id: string): Nullable<Node>;
  37308. /**
  37309. * Gets a node (Mesh, Camera, Light) using a given id
  37310. * @param id defines the id to search for
  37311. * @return the found node or null if not found at all
  37312. */
  37313. getNodeByID(id: string): Nullable<Node>;
  37314. /**
  37315. * Gets a node (Mesh, Camera, Light) using a given name
  37316. * @param name defines the name to search for
  37317. * @return the found node or null if not found at all.
  37318. */
  37319. getNodeByName(name: string): Nullable<Node>;
  37320. /**
  37321. * Gets a mesh using a given name
  37322. * @param name defines the name to search for
  37323. * @return the found mesh or null if not found at all.
  37324. */
  37325. getMeshByName(name: string): Nullable<AbstractMesh>;
  37326. /**
  37327. * Gets a transform node using a given name
  37328. * @param name defines the name to search for
  37329. * @return the found transform node or null if not found at all.
  37330. */
  37331. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37332. /**
  37333. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37334. * @param id defines the id to search for
  37335. * @return the found skeleton or null if not found at all.
  37336. */
  37337. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37338. /**
  37339. * Gets a skeleton using a given auto generated unique id
  37340. * @param uniqueId defines the unique id to search for
  37341. * @return the found skeleton or null if not found at all.
  37342. */
  37343. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37344. /**
  37345. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37346. * @param id defines the id to search for
  37347. * @return the found skeleton or null if not found at all.
  37348. */
  37349. getSkeletonById(id: string): Nullable<Skeleton>;
  37350. /**
  37351. * Gets a skeleton using a given name
  37352. * @param name defines the name to search for
  37353. * @return the found skeleton or null if not found at all.
  37354. */
  37355. getSkeletonByName(name: string): Nullable<Skeleton>;
  37356. /**
  37357. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37358. * @param id defines the id to search for
  37359. * @return the found morph target manager or null if not found at all.
  37360. */
  37361. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37362. /**
  37363. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37364. * @param id defines the id to search for
  37365. * @return the found morph target or null if not found at all.
  37366. */
  37367. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37368. /**
  37369. * Gets a boolean indicating if the given mesh is active
  37370. * @param mesh defines the mesh to look for
  37371. * @returns true if the mesh is in the active list
  37372. */
  37373. isActiveMesh(mesh: AbstractMesh): boolean;
  37374. /**
  37375. * Return a unique id as a string which can serve as an identifier for the scene
  37376. */
  37377. get uid(): string;
  37378. /**
  37379. * Add an externaly attached data from its key.
  37380. * This method call will fail and return false, if such key already exists.
  37381. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37382. * @param key the unique key that identifies the data
  37383. * @param data the data object to associate to the key for this Engine instance
  37384. * @return true if no such key were already present and the data was added successfully, false otherwise
  37385. */
  37386. addExternalData<T>(key: string, data: T): boolean;
  37387. /**
  37388. * Get an externaly attached data from its key
  37389. * @param key the unique key that identifies the data
  37390. * @return the associated data, if present (can be null), or undefined if not present
  37391. */
  37392. getExternalData<T>(key: string): Nullable<T>;
  37393. /**
  37394. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37395. * @param key the unique key that identifies the data
  37396. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37397. * @return the associated data, can be null if the factory returned null.
  37398. */
  37399. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37400. /**
  37401. * Remove an externaly attached data from the Engine instance
  37402. * @param key the unique key that identifies the data
  37403. * @return true if the data was successfully removed, false if it doesn't exist
  37404. */
  37405. removeExternalData(key: string): boolean;
  37406. private _evaluateSubMesh;
  37407. /**
  37408. * Clear the processed materials smart array preventing retention point in material dispose.
  37409. */
  37410. freeProcessedMaterials(): void;
  37411. private _preventFreeActiveMeshesAndRenderingGroups;
  37412. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37413. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37414. * when disposing several meshes in a row or a hierarchy of meshes.
  37415. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37416. */
  37417. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37418. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37419. /**
  37420. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37421. */
  37422. freeActiveMeshes(): void;
  37423. /**
  37424. * Clear the info related to rendering groups preventing retention points during dispose.
  37425. */
  37426. freeRenderingGroups(): void;
  37427. /** @hidden */
  37428. _isInIntermediateRendering(): boolean;
  37429. /**
  37430. * Lambda returning the list of potentially active meshes.
  37431. */
  37432. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37433. /**
  37434. * Lambda returning the list of potentially active sub meshes.
  37435. */
  37436. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37437. /**
  37438. * Lambda returning the list of potentially intersecting sub meshes.
  37439. */
  37440. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37441. /**
  37442. * Lambda returning the list of potentially colliding sub meshes.
  37443. */
  37444. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37445. private _activeMeshesFrozen;
  37446. private _skipEvaluateActiveMeshesCompletely;
  37447. /**
  37448. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37449. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37450. * @returns the current scene
  37451. */
  37452. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37453. /**
  37454. * Use this function to restart evaluating active meshes on every frame
  37455. * @returns the current scene
  37456. */
  37457. unfreezeActiveMeshes(): Scene;
  37458. private _evaluateActiveMeshes;
  37459. private _activeMesh;
  37460. /**
  37461. * Update the transform matrix to update from the current active camera
  37462. * @param force defines a boolean used to force the update even if cache is up to date
  37463. */
  37464. updateTransformMatrix(force?: boolean): void;
  37465. private _bindFrameBuffer;
  37466. /** @hidden */
  37467. _allowPostProcessClearColor: boolean;
  37468. /** @hidden */
  37469. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37470. private _processSubCameras;
  37471. private _checkIntersections;
  37472. /** @hidden */
  37473. _advancePhysicsEngineStep(step: number): void;
  37474. /**
  37475. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37476. */
  37477. getDeterministicFrameTime: () => number;
  37478. /** @hidden */
  37479. _animate(): void;
  37480. /** Execute all animations (for a frame) */
  37481. animate(): void;
  37482. /**
  37483. * Render the scene
  37484. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37485. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37486. */
  37487. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37488. /**
  37489. * Freeze all materials
  37490. * A frozen material will not be updatable but should be faster to render
  37491. */
  37492. freezeMaterials(): void;
  37493. /**
  37494. * Unfreeze all materials
  37495. * A frozen material will not be updatable but should be faster to render
  37496. */
  37497. unfreezeMaterials(): void;
  37498. /**
  37499. * Releases all held ressources
  37500. */
  37501. dispose(): void;
  37502. /**
  37503. * Gets if the scene is already disposed
  37504. */
  37505. get isDisposed(): boolean;
  37506. /**
  37507. * Call this function to reduce memory footprint of the scene.
  37508. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37509. */
  37510. clearCachedVertexData(): void;
  37511. /**
  37512. * This function will remove the local cached buffer data from texture.
  37513. * It will save memory but will prevent the texture from being rebuilt
  37514. */
  37515. cleanCachedTextureBuffer(): void;
  37516. /**
  37517. * Get the world extend vectors with an optional filter
  37518. *
  37519. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37520. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37521. */
  37522. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37523. min: Vector3;
  37524. max: Vector3;
  37525. };
  37526. /**
  37527. * Creates a ray that can be used to pick in the scene
  37528. * @param x defines the x coordinate of the origin (on-screen)
  37529. * @param y defines the y coordinate of the origin (on-screen)
  37530. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37531. * @param camera defines the camera to use for the picking
  37532. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37533. * @returns a Ray
  37534. */
  37535. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37536. /**
  37537. * Creates a ray that can be used to pick in the scene
  37538. * @param x defines the x coordinate of the origin (on-screen)
  37539. * @param y defines the y coordinate of the origin (on-screen)
  37540. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37541. * @param result defines the ray where to store the picking ray
  37542. * @param camera defines the camera to use for the picking
  37543. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37544. * @returns the current scene
  37545. */
  37546. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37547. /**
  37548. * Creates a ray that can be used to pick in the scene
  37549. * @param x defines the x coordinate of the origin (on-screen)
  37550. * @param y defines the y coordinate of the origin (on-screen)
  37551. * @param camera defines the camera to use for the picking
  37552. * @returns a Ray
  37553. */
  37554. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37555. /**
  37556. * Creates a ray that can be used to pick in the scene
  37557. * @param x defines the x coordinate of the origin (on-screen)
  37558. * @param y defines the y coordinate of the origin (on-screen)
  37559. * @param result defines the ray where to store the picking ray
  37560. * @param camera defines the camera to use for the picking
  37561. * @returns the current scene
  37562. */
  37563. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37564. /** Launch a ray to try to pick a mesh in the scene
  37565. * @param x position on screen
  37566. * @param y position on screen
  37567. * @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
  37568. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37569. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37570. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37571. * @returns a PickingInfo
  37572. */
  37573. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37574. /** Use the given ray to pick a mesh in the scene
  37575. * @param ray The ray to use to pick meshes
  37576. * @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
  37577. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37578. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37579. * @returns a PickingInfo
  37580. */
  37581. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37582. /**
  37583. * Launch a ray to try to pick a mesh in the scene
  37584. * @param x X position on screen
  37585. * @param y Y position on screen
  37586. * @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
  37587. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37588. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37589. * @returns an array of PickingInfo
  37590. */
  37591. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37592. /**
  37593. * Launch a ray to try to pick a mesh in the scene
  37594. * @param ray Ray to use
  37595. * @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
  37596. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37597. * @returns an array of PickingInfo
  37598. */
  37599. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37600. /**
  37601. * Force the value of meshUnderPointer
  37602. * @param mesh defines the mesh to use
  37603. */
  37604. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37605. /**
  37606. * Gets the mesh under the pointer
  37607. * @returns a Mesh or null if no mesh is under the pointer
  37608. */
  37609. getPointerOverMesh(): Nullable<AbstractMesh>;
  37610. /** @hidden */
  37611. _rebuildGeometries(): void;
  37612. /** @hidden */
  37613. _rebuildTextures(): void;
  37614. private _getByTags;
  37615. /**
  37616. * Get a list of meshes by tags
  37617. * @param tagsQuery defines the tags query to use
  37618. * @param forEach defines a predicate used to filter results
  37619. * @returns an array of Mesh
  37620. */
  37621. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37622. /**
  37623. * Get a list of cameras by tags
  37624. * @param tagsQuery defines the tags query to use
  37625. * @param forEach defines a predicate used to filter results
  37626. * @returns an array of Camera
  37627. */
  37628. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37629. /**
  37630. * Get a list of lights by tags
  37631. * @param tagsQuery defines the tags query to use
  37632. * @param forEach defines a predicate used to filter results
  37633. * @returns an array of Light
  37634. */
  37635. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37636. /**
  37637. * Get a list of materials by tags
  37638. * @param tagsQuery defines the tags query to use
  37639. * @param forEach defines a predicate used to filter results
  37640. * @returns an array of Material
  37641. */
  37642. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37643. /**
  37644. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37645. * This allowed control for front to back rendering or reversly depending of the special needs.
  37646. *
  37647. * @param renderingGroupId The rendering group id corresponding to its index
  37648. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37649. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37650. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37651. */
  37652. 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;
  37653. /**
  37654. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37655. *
  37656. * @param renderingGroupId The rendering group id corresponding to its index
  37657. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37658. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37659. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37660. */
  37661. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37662. /**
  37663. * Gets the current auto clear configuration for one rendering group of the rendering
  37664. * manager.
  37665. * @param index the rendering group index to get the information for
  37666. * @returns The auto clear setup for the requested rendering group
  37667. */
  37668. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37669. private _blockMaterialDirtyMechanism;
  37670. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37671. get blockMaterialDirtyMechanism(): boolean;
  37672. set blockMaterialDirtyMechanism(value: boolean);
  37673. /**
  37674. * Will flag all materials as dirty to trigger new shader compilation
  37675. * @param flag defines the flag used to specify which material part must be marked as dirty
  37676. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37677. */
  37678. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37679. /** @hidden */
  37680. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  37681. /** @hidden */
  37682. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37683. /** @hidden */
  37684. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  37685. /** @hidden */
  37686. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37687. /** @hidden */
  37688. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37689. /** @hidden */
  37690. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37691. }
  37692. }
  37693. declare module "babylonjs/assetContainer" {
  37694. import { AbstractScene } from "babylonjs/abstractScene";
  37695. import { Scene } from "babylonjs/scene";
  37696. import { Mesh } from "babylonjs/Meshes/mesh";
  37697. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37698. import { Skeleton } from "babylonjs/Bones/skeleton";
  37699. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37700. import { Animatable } from "babylonjs/Animations/animatable";
  37701. import { Nullable } from "babylonjs/types";
  37702. import { Node } from "babylonjs/node";
  37703. /**
  37704. * Set of assets to keep when moving a scene into an asset container.
  37705. */
  37706. export class KeepAssets extends AbstractScene {
  37707. }
  37708. /**
  37709. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37710. */
  37711. export class InstantiatedEntries {
  37712. /**
  37713. * List of new root nodes (eg. nodes with no parent)
  37714. */
  37715. rootNodes: TransformNode[];
  37716. /**
  37717. * List of new skeletons
  37718. */
  37719. skeletons: Skeleton[];
  37720. /**
  37721. * List of new animation groups
  37722. */
  37723. animationGroups: AnimationGroup[];
  37724. }
  37725. /**
  37726. * Container with a set of assets that can be added or removed from a scene.
  37727. */
  37728. export class AssetContainer extends AbstractScene {
  37729. /**
  37730. * The scene the AssetContainer belongs to.
  37731. */
  37732. scene: Scene;
  37733. /**
  37734. * Instantiates an AssetContainer.
  37735. * @param scene The scene the AssetContainer belongs to.
  37736. */
  37737. constructor(scene: Scene);
  37738. /**
  37739. * Instantiate or clone all meshes and add the new ones to the scene.
  37740. * Skeletons and animation groups will all be cloned
  37741. * @param nameFunction defines an optional function used to get new names for clones
  37742. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37743. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37744. */
  37745. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37746. /**
  37747. * Adds all the assets from the container to the scene.
  37748. */
  37749. addAllToScene(): void;
  37750. /**
  37751. * Removes all the assets in the container from the scene
  37752. */
  37753. removeAllFromScene(): void;
  37754. /**
  37755. * Disposes all the assets in the container
  37756. */
  37757. dispose(): void;
  37758. private _moveAssets;
  37759. /**
  37760. * Removes all the assets contained in the scene and adds them to the container.
  37761. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37762. */
  37763. moveAllFromScene(keepAssets?: KeepAssets): void;
  37764. /**
  37765. * 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.
  37766. * @returns the root mesh
  37767. */
  37768. createRootMesh(): Mesh;
  37769. /**
  37770. * Merge animations from this asset container into a scene
  37771. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37772. * @param animatables set of animatables to retarget to a node from the scene
  37773. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37774. */
  37775. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37776. }
  37777. }
  37778. declare module "babylonjs/abstractScene" {
  37779. import { Scene } from "babylonjs/scene";
  37780. import { Nullable } from "babylonjs/types";
  37781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37782. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37783. import { Geometry } from "babylonjs/Meshes/geometry";
  37784. import { Skeleton } from "babylonjs/Bones/skeleton";
  37785. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37786. import { AssetContainer } from "babylonjs/assetContainer";
  37787. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37788. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37790. import { Material } from "babylonjs/Materials/material";
  37791. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37792. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37793. import { Camera } from "babylonjs/Cameras/camera";
  37794. import { Light } from "babylonjs/Lights/light";
  37795. import { Node } from "babylonjs/node";
  37796. import { Animation } from "babylonjs/Animations/animation";
  37797. /**
  37798. * Defines how the parser contract is defined.
  37799. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37800. */
  37801. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37802. /**
  37803. * Defines how the individual parser contract is defined.
  37804. * These parser can parse an individual asset
  37805. */
  37806. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37807. /**
  37808. * Base class of the scene acting as a container for the different elements composing a scene.
  37809. * This class is dynamically extended by the different components of the scene increasing
  37810. * flexibility and reducing coupling
  37811. */
  37812. export abstract class AbstractScene {
  37813. /**
  37814. * Stores the list of available parsers in the application.
  37815. */
  37816. private static _BabylonFileParsers;
  37817. /**
  37818. * Stores the list of available individual parsers in the application.
  37819. */
  37820. private static _IndividualBabylonFileParsers;
  37821. /**
  37822. * Adds a parser in the list of available ones
  37823. * @param name Defines the name of the parser
  37824. * @param parser Defines the parser to add
  37825. */
  37826. static AddParser(name: string, parser: BabylonFileParser): void;
  37827. /**
  37828. * Gets a general parser from the list of avaialble ones
  37829. * @param name Defines the name of the parser
  37830. * @returns the requested parser or null
  37831. */
  37832. static GetParser(name: string): Nullable<BabylonFileParser>;
  37833. /**
  37834. * Adds n individual parser in the list of available ones
  37835. * @param name Defines the name of the parser
  37836. * @param parser Defines the parser to add
  37837. */
  37838. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37839. /**
  37840. * Gets an individual parser from the list of avaialble ones
  37841. * @param name Defines the name of the parser
  37842. * @returns the requested parser or null
  37843. */
  37844. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37845. /**
  37846. * Parser json data and populate both a scene and its associated container object
  37847. * @param jsonData Defines the data to parse
  37848. * @param scene Defines the scene to parse the data for
  37849. * @param container Defines the container attached to the parsing sequence
  37850. * @param rootUrl Defines the root url of the data
  37851. */
  37852. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37853. /**
  37854. * Gets the list of root nodes (ie. nodes with no parent)
  37855. */
  37856. rootNodes: Node[];
  37857. /** All of the cameras added to this scene
  37858. * @see http://doc.babylonjs.com/babylon101/cameras
  37859. */
  37860. cameras: Camera[];
  37861. /**
  37862. * All of the lights added to this scene
  37863. * @see http://doc.babylonjs.com/babylon101/lights
  37864. */
  37865. lights: Light[];
  37866. /**
  37867. * All of the (abstract) meshes added to this scene
  37868. */
  37869. meshes: AbstractMesh[];
  37870. /**
  37871. * The list of skeletons added to the scene
  37872. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37873. */
  37874. skeletons: Skeleton[];
  37875. /**
  37876. * All of the particle systems added to this scene
  37877. * @see http://doc.babylonjs.com/babylon101/particles
  37878. */
  37879. particleSystems: IParticleSystem[];
  37880. /**
  37881. * Gets a list of Animations associated with the scene
  37882. */
  37883. animations: Animation[];
  37884. /**
  37885. * All of the animation groups added to this scene
  37886. * @see http://doc.babylonjs.com/how_to/group
  37887. */
  37888. animationGroups: AnimationGroup[];
  37889. /**
  37890. * All of the multi-materials added to this scene
  37891. * @see http://doc.babylonjs.com/how_to/multi_materials
  37892. */
  37893. multiMaterials: MultiMaterial[];
  37894. /**
  37895. * All of the materials added to this scene
  37896. * In the context of a Scene, it is not supposed to be modified manually.
  37897. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37898. * Note also that the order of the Material within the array is not significant and might change.
  37899. * @see http://doc.babylonjs.com/babylon101/materials
  37900. */
  37901. materials: Material[];
  37902. /**
  37903. * The list of morph target managers added to the scene
  37904. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37905. */
  37906. morphTargetManagers: MorphTargetManager[];
  37907. /**
  37908. * The list of geometries used in the scene.
  37909. */
  37910. geometries: Geometry[];
  37911. /**
  37912. * All of the tranform nodes added to this scene
  37913. * In the context of a Scene, it is not supposed to be modified manually.
  37914. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37915. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37916. * @see http://doc.babylonjs.com/how_to/transformnode
  37917. */
  37918. transformNodes: TransformNode[];
  37919. /**
  37920. * ActionManagers available on the scene.
  37921. */
  37922. actionManagers: AbstractActionManager[];
  37923. /**
  37924. * Textures to keep.
  37925. */
  37926. textures: BaseTexture[];
  37927. /**
  37928. * Environment texture for the scene
  37929. */
  37930. environmentTexture: Nullable<BaseTexture>;
  37931. /**
  37932. * @returns all meshes, lights, cameras, transformNodes and bones
  37933. */
  37934. getNodes(): Array<Node>;
  37935. }
  37936. }
  37937. declare module "babylonjs/Audio/sound" {
  37938. import { Observable } from "babylonjs/Misc/observable";
  37939. import { Vector3 } from "babylonjs/Maths/math.vector";
  37940. import { Nullable } from "babylonjs/types";
  37941. import { Scene } from "babylonjs/scene";
  37942. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37943. /**
  37944. * Interface used to define options for Sound class
  37945. */
  37946. export interface ISoundOptions {
  37947. /**
  37948. * Does the sound autoplay once loaded.
  37949. */
  37950. autoplay?: boolean;
  37951. /**
  37952. * Does the sound loop after it finishes playing once.
  37953. */
  37954. loop?: boolean;
  37955. /**
  37956. * Sound's volume
  37957. */
  37958. volume?: number;
  37959. /**
  37960. * Is it a spatial sound?
  37961. */
  37962. spatialSound?: boolean;
  37963. /**
  37964. * Maximum distance to hear that sound
  37965. */
  37966. maxDistance?: number;
  37967. /**
  37968. * Uses user defined attenuation function
  37969. */
  37970. useCustomAttenuation?: boolean;
  37971. /**
  37972. * Define the roll off factor of spatial sounds.
  37973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37974. */
  37975. rolloffFactor?: number;
  37976. /**
  37977. * Define the reference distance the sound should be heard perfectly.
  37978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37979. */
  37980. refDistance?: number;
  37981. /**
  37982. * Define the distance attenuation model the sound will follow.
  37983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37984. */
  37985. distanceModel?: string;
  37986. /**
  37987. * Defines the playback speed (1 by default)
  37988. */
  37989. playbackRate?: number;
  37990. /**
  37991. * Defines if the sound is from a streaming source
  37992. */
  37993. streaming?: boolean;
  37994. /**
  37995. * Defines an optional length (in seconds) inside the sound file
  37996. */
  37997. length?: number;
  37998. /**
  37999. * Defines an optional offset (in seconds) inside the sound file
  38000. */
  38001. offset?: number;
  38002. /**
  38003. * If true, URLs will not be required to state the audio file codec to use.
  38004. */
  38005. skipCodecCheck?: boolean;
  38006. }
  38007. /**
  38008. * Defines a sound that can be played in the application.
  38009. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38011. */
  38012. export class Sound {
  38013. /**
  38014. * The name of the sound in the scene.
  38015. */
  38016. name: string;
  38017. /**
  38018. * Does the sound autoplay once loaded.
  38019. */
  38020. autoplay: boolean;
  38021. /**
  38022. * Does the sound loop after it finishes playing once.
  38023. */
  38024. loop: boolean;
  38025. /**
  38026. * Does the sound use a custom attenuation curve to simulate the falloff
  38027. * happening when the source gets further away from the camera.
  38028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38029. */
  38030. useCustomAttenuation: boolean;
  38031. /**
  38032. * The sound track id this sound belongs to.
  38033. */
  38034. soundTrackId: number;
  38035. /**
  38036. * Is this sound currently played.
  38037. */
  38038. isPlaying: boolean;
  38039. /**
  38040. * Is this sound currently paused.
  38041. */
  38042. isPaused: boolean;
  38043. /**
  38044. * Does this sound enables spatial sound.
  38045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38046. */
  38047. spatialSound: boolean;
  38048. /**
  38049. * Define the reference distance the sound should be heard perfectly.
  38050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38051. */
  38052. refDistance: number;
  38053. /**
  38054. * Define the roll off factor of spatial sounds.
  38055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38056. */
  38057. rolloffFactor: number;
  38058. /**
  38059. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38061. */
  38062. maxDistance: number;
  38063. /**
  38064. * Define the distance attenuation model the sound will follow.
  38065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38066. */
  38067. distanceModel: string;
  38068. /**
  38069. * @hidden
  38070. * Back Compat
  38071. **/
  38072. onended: () => any;
  38073. /**
  38074. * Observable event when the current playing sound finishes.
  38075. */
  38076. onEndedObservable: Observable<Sound>;
  38077. private _panningModel;
  38078. private _playbackRate;
  38079. private _streaming;
  38080. private _startTime;
  38081. private _startOffset;
  38082. private _position;
  38083. /** @hidden */
  38084. _positionInEmitterSpace: boolean;
  38085. private _localDirection;
  38086. private _volume;
  38087. private _isReadyToPlay;
  38088. private _isDirectional;
  38089. private _readyToPlayCallback;
  38090. private _audioBuffer;
  38091. private _soundSource;
  38092. private _streamingSource;
  38093. private _soundPanner;
  38094. private _soundGain;
  38095. private _inputAudioNode;
  38096. private _outputAudioNode;
  38097. private _coneInnerAngle;
  38098. private _coneOuterAngle;
  38099. private _coneOuterGain;
  38100. private _scene;
  38101. private _connectedTransformNode;
  38102. private _customAttenuationFunction;
  38103. private _registerFunc;
  38104. private _isOutputConnected;
  38105. private _htmlAudioElement;
  38106. private _urlType;
  38107. private _length?;
  38108. private _offset?;
  38109. /** @hidden */
  38110. static _SceneComponentInitialization: (scene: Scene) => void;
  38111. /**
  38112. * Create a sound and attach it to a scene
  38113. * @param name Name of your sound
  38114. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38115. * @param scene defines the scene the sound belongs to
  38116. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38117. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38118. */
  38119. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38120. /**
  38121. * Release the sound and its associated resources
  38122. */
  38123. dispose(): void;
  38124. /**
  38125. * Gets if the sounds is ready to be played or not.
  38126. * @returns true if ready, otherwise false
  38127. */
  38128. isReady(): boolean;
  38129. private _soundLoaded;
  38130. /**
  38131. * Sets the data of the sound from an audiobuffer
  38132. * @param audioBuffer The audioBuffer containing the data
  38133. */
  38134. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38135. /**
  38136. * Updates the current sounds options such as maxdistance, loop...
  38137. * @param options A JSON object containing values named as the object properties
  38138. */
  38139. updateOptions(options: ISoundOptions): void;
  38140. private _createSpatialParameters;
  38141. private _updateSpatialParameters;
  38142. /**
  38143. * Switch the panning model to HRTF:
  38144. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38146. */
  38147. switchPanningModelToHRTF(): void;
  38148. /**
  38149. * Switch the panning model to Equal Power:
  38150. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38152. */
  38153. switchPanningModelToEqualPower(): void;
  38154. private _switchPanningModel;
  38155. /**
  38156. * Connect this sound to a sound track audio node like gain...
  38157. * @param soundTrackAudioNode the sound track audio node to connect to
  38158. */
  38159. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38160. /**
  38161. * Transform this sound into a directional source
  38162. * @param coneInnerAngle Size of the inner cone in degree
  38163. * @param coneOuterAngle Size of the outer cone in degree
  38164. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38165. */
  38166. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38167. /**
  38168. * Gets or sets the inner angle for the directional cone.
  38169. */
  38170. get directionalConeInnerAngle(): number;
  38171. /**
  38172. * Gets or sets the inner angle for the directional cone.
  38173. */
  38174. set directionalConeInnerAngle(value: number);
  38175. /**
  38176. * Gets or sets the outer angle for the directional cone.
  38177. */
  38178. get directionalConeOuterAngle(): number;
  38179. /**
  38180. * Gets or sets the outer angle for the directional cone.
  38181. */
  38182. set directionalConeOuterAngle(value: number);
  38183. /**
  38184. * Sets the position of the emitter if spatial sound is enabled
  38185. * @param newPosition Defines the new posisiton
  38186. */
  38187. setPosition(newPosition: Vector3): void;
  38188. /**
  38189. * Sets the local direction of the emitter if spatial sound is enabled
  38190. * @param newLocalDirection Defines the new local direction
  38191. */
  38192. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38193. private _updateDirection;
  38194. /** @hidden */
  38195. updateDistanceFromListener(): void;
  38196. /**
  38197. * Sets a new custom attenuation function for the sound.
  38198. * @param callback Defines the function used for the attenuation
  38199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38200. */
  38201. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38202. /**
  38203. * Play the sound
  38204. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38205. * @param offset (optional) Start the sound at a specific time in seconds
  38206. * @param length (optional) Sound duration (in seconds)
  38207. */
  38208. play(time?: number, offset?: number, length?: number): void;
  38209. private _onended;
  38210. /**
  38211. * Stop the sound
  38212. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38213. */
  38214. stop(time?: number): void;
  38215. /**
  38216. * Put the sound in pause
  38217. */
  38218. pause(): void;
  38219. /**
  38220. * Sets a dedicated volume for this sounds
  38221. * @param newVolume Define the new volume of the sound
  38222. * @param time Define time for gradual change to new volume
  38223. */
  38224. setVolume(newVolume: number, time?: number): void;
  38225. /**
  38226. * Set the sound play back rate
  38227. * @param newPlaybackRate Define the playback rate the sound should be played at
  38228. */
  38229. setPlaybackRate(newPlaybackRate: number): void;
  38230. /**
  38231. * Gets the volume of the sound.
  38232. * @returns the volume of the sound
  38233. */
  38234. getVolume(): number;
  38235. /**
  38236. * Attach the sound to a dedicated mesh
  38237. * @param transformNode The transform node to connect the sound with
  38238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38239. */
  38240. attachToMesh(transformNode: TransformNode): void;
  38241. /**
  38242. * Detach the sound from the previously attached mesh
  38243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38244. */
  38245. detachFromMesh(): void;
  38246. private _onRegisterAfterWorldMatrixUpdate;
  38247. /**
  38248. * Clone the current sound in the scene.
  38249. * @returns the new sound clone
  38250. */
  38251. clone(): Nullable<Sound>;
  38252. /**
  38253. * Gets the current underlying audio buffer containing the data
  38254. * @returns the audio buffer
  38255. */
  38256. getAudioBuffer(): Nullable<AudioBuffer>;
  38257. /**
  38258. * Serializes the Sound in a JSON representation
  38259. * @returns the JSON representation of the sound
  38260. */
  38261. serialize(): any;
  38262. /**
  38263. * Parse a JSON representation of a sound to innstantiate in a given scene
  38264. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38265. * @param scene Define the scene the new parsed sound should be created in
  38266. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38267. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38268. * @returns the newly parsed sound
  38269. */
  38270. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38271. }
  38272. }
  38273. declare module "babylonjs/Actions/directAudioActions" {
  38274. import { Action } from "babylonjs/Actions/action";
  38275. import { Condition } from "babylonjs/Actions/condition";
  38276. import { Sound } from "babylonjs/Audio/sound";
  38277. /**
  38278. * This defines an action helpful to play a defined sound on a triggered action.
  38279. */
  38280. export class PlaySoundAction extends Action {
  38281. private _sound;
  38282. /**
  38283. * Instantiate the action
  38284. * @param triggerOptions defines the trigger options
  38285. * @param sound defines the sound to play
  38286. * @param condition defines the trigger related conditions
  38287. */
  38288. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38289. /** @hidden */
  38290. _prepare(): void;
  38291. /**
  38292. * Execute the action and play the sound.
  38293. */
  38294. execute(): void;
  38295. /**
  38296. * Serializes the actions and its related information.
  38297. * @param parent defines the object to serialize in
  38298. * @returns the serialized object
  38299. */
  38300. serialize(parent: any): any;
  38301. }
  38302. /**
  38303. * This defines an action helpful to stop a defined sound on a triggered action.
  38304. */
  38305. export class StopSoundAction extends Action {
  38306. private _sound;
  38307. /**
  38308. * Instantiate the action
  38309. * @param triggerOptions defines the trigger options
  38310. * @param sound defines the sound to stop
  38311. * @param condition defines the trigger related conditions
  38312. */
  38313. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38314. /** @hidden */
  38315. _prepare(): void;
  38316. /**
  38317. * Execute the action and stop the sound.
  38318. */
  38319. execute(): void;
  38320. /**
  38321. * Serializes the actions and its related information.
  38322. * @param parent defines the object to serialize in
  38323. * @returns the serialized object
  38324. */
  38325. serialize(parent: any): any;
  38326. }
  38327. }
  38328. declare module "babylonjs/Actions/interpolateValueAction" {
  38329. import { Action } from "babylonjs/Actions/action";
  38330. import { Condition } from "babylonjs/Actions/condition";
  38331. import { Observable } from "babylonjs/Misc/observable";
  38332. /**
  38333. * This defines an action responsible to change the value of a property
  38334. * by interpolating between its current value and the newly set one once triggered.
  38335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38336. */
  38337. export class InterpolateValueAction extends Action {
  38338. /**
  38339. * Defines the path of the property where the value should be interpolated
  38340. */
  38341. propertyPath: string;
  38342. /**
  38343. * Defines the target value at the end of the interpolation.
  38344. */
  38345. value: any;
  38346. /**
  38347. * Defines the time it will take for the property to interpolate to the value.
  38348. */
  38349. duration: number;
  38350. /**
  38351. * Defines if the other scene animations should be stopped when the action has been triggered
  38352. */
  38353. stopOtherAnimations?: boolean;
  38354. /**
  38355. * Defines a callback raised once the interpolation animation has been done.
  38356. */
  38357. onInterpolationDone?: () => void;
  38358. /**
  38359. * Observable triggered once the interpolation animation has been done.
  38360. */
  38361. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38362. private _target;
  38363. private _effectiveTarget;
  38364. private _property;
  38365. /**
  38366. * Instantiate the action
  38367. * @param triggerOptions defines the trigger options
  38368. * @param target defines the object containing the value to interpolate
  38369. * @param propertyPath defines the path to the property in the target object
  38370. * @param value defines the target value at the end of the interpolation
  38371. * @param duration deines the time it will take for the property to interpolate to the value.
  38372. * @param condition defines the trigger related conditions
  38373. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38374. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38375. */
  38376. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38377. /** @hidden */
  38378. _prepare(): void;
  38379. /**
  38380. * Execute the action starts the value interpolation.
  38381. */
  38382. execute(): void;
  38383. /**
  38384. * Serializes the actions and its related information.
  38385. * @param parent defines the object to serialize in
  38386. * @returns the serialized object
  38387. */
  38388. serialize(parent: any): any;
  38389. }
  38390. }
  38391. declare module "babylonjs/Actions/index" {
  38392. export * from "babylonjs/Actions/abstractActionManager";
  38393. export * from "babylonjs/Actions/action";
  38394. export * from "babylonjs/Actions/actionEvent";
  38395. export * from "babylonjs/Actions/actionManager";
  38396. export * from "babylonjs/Actions/condition";
  38397. export * from "babylonjs/Actions/directActions";
  38398. export * from "babylonjs/Actions/directAudioActions";
  38399. export * from "babylonjs/Actions/interpolateValueAction";
  38400. }
  38401. declare module "babylonjs/Animations/index" {
  38402. export * from "babylonjs/Animations/animatable";
  38403. export * from "babylonjs/Animations/animation";
  38404. export * from "babylonjs/Animations/animationGroup";
  38405. export * from "babylonjs/Animations/animationPropertiesOverride";
  38406. export * from "babylonjs/Animations/easing";
  38407. export * from "babylonjs/Animations/runtimeAnimation";
  38408. export * from "babylonjs/Animations/animationEvent";
  38409. export * from "babylonjs/Animations/animationGroup";
  38410. export * from "babylonjs/Animations/animationKey";
  38411. export * from "babylonjs/Animations/animationRange";
  38412. export * from "babylonjs/Animations/animatable.interface";
  38413. }
  38414. declare module "babylonjs/Audio/soundTrack" {
  38415. import { Sound } from "babylonjs/Audio/sound";
  38416. import { Analyser } from "babylonjs/Audio/analyser";
  38417. import { Scene } from "babylonjs/scene";
  38418. /**
  38419. * Options allowed during the creation of a sound track.
  38420. */
  38421. export interface ISoundTrackOptions {
  38422. /**
  38423. * The volume the sound track should take during creation
  38424. */
  38425. volume?: number;
  38426. /**
  38427. * Define if the sound track is the main sound track of the scene
  38428. */
  38429. mainTrack?: boolean;
  38430. }
  38431. /**
  38432. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38433. * It will be also used in a future release to apply effects on a specific track.
  38434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38435. */
  38436. export class SoundTrack {
  38437. /**
  38438. * The unique identifier of the sound track in the scene.
  38439. */
  38440. id: number;
  38441. /**
  38442. * The list of sounds included in the sound track.
  38443. */
  38444. soundCollection: Array<Sound>;
  38445. private _outputAudioNode;
  38446. private _scene;
  38447. private _connectedAnalyser;
  38448. private _options;
  38449. private _isInitialized;
  38450. /**
  38451. * Creates a new sound track.
  38452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38453. * @param scene Define the scene the sound track belongs to
  38454. * @param options
  38455. */
  38456. constructor(scene: Scene, options?: ISoundTrackOptions);
  38457. private _initializeSoundTrackAudioGraph;
  38458. /**
  38459. * Release the sound track and its associated resources
  38460. */
  38461. dispose(): void;
  38462. /**
  38463. * Adds a sound to this sound track
  38464. * @param sound define the cound to add
  38465. * @ignoreNaming
  38466. */
  38467. AddSound(sound: Sound): void;
  38468. /**
  38469. * Removes a sound to this sound track
  38470. * @param sound define the cound to remove
  38471. * @ignoreNaming
  38472. */
  38473. RemoveSound(sound: Sound): void;
  38474. /**
  38475. * Set a global volume for the full sound track.
  38476. * @param newVolume Define the new volume of the sound track
  38477. */
  38478. setVolume(newVolume: number): void;
  38479. /**
  38480. * Switch the panning model to HRTF:
  38481. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38483. */
  38484. switchPanningModelToHRTF(): void;
  38485. /**
  38486. * Switch the panning model to Equal Power:
  38487. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38489. */
  38490. switchPanningModelToEqualPower(): void;
  38491. /**
  38492. * Connect the sound track to an audio analyser allowing some amazing
  38493. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38495. * @param analyser The analyser to connect to the engine
  38496. */
  38497. connectToAnalyser(analyser: Analyser): void;
  38498. }
  38499. }
  38500. declare module "babylonjs/Audio/audioSceneComponent" {
  38501. import { Sound } from "babylonjs/Audio/sound";
  38502. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38503. import { Nullable } from "babylonjs/types";
  38504. import { Vector3 } from "babylonjs/Maths/math.vector";
  38505. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38506. import { Scene } from "babylonjs/scene";
  38507. import { AbstractScene } from "babylonjs/abstractScene";
  38508. import "babylonjs/Audio/audioEngine";
  38509. module "babylonjs/abstractScene" {
  38510. interface AbstractScene {
  38511. /**
  38512. * The list of sounds used in the scene.
  38513. */
  38514. sounds: Nullable<Array<Sound>>;
  38515. }
  38516. }
  38517. module "babylonjs/scene" {
  38518. interface Scene {
  38519. /**
  38520. * @hidden
  38521. * Backing field
  38522. */
  38523. _mainSoundTrack: SoundTrack;
  38524. /**
  38525. * The main sound track played by the scene.
  38526. * It cotains your primary collection of sounds.
  38527. */
  38528. mainSoundTrack: SoundTrack;
  38529. /**
  38530. * The list of sound tracks added to the scene
  38531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38532. */
  38533. soundTracks: Nullable<Array<SoundTrack>>;
  38534. /**
  38535. * Gets a sound using a given name
  38536. * @param name defines the name to search for
  38537. * @return the found sound or null if not found at all.
  38538. */
  38539. getSoundByName(name: string): Nullable<Sound>;
  38540. /**
  38541. * Gets or sets if audio support is enabled
  38542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38543. */
  38544. audioEnabled: boolean;
  38545. /**
  38546. * Gets or sets if audio will be output to headphones
  38547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38548. */
  38549. headphone: boolean;
  38550. /**
  38551. * Gets or sets custom audio listener position provider
  38552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38553. */
  38554. audioListenerPositionProvider: Nullable<() => Vector3>;
  38555. /**
  38556. * Gets or sets a refresh rate when using 3D audio positioning
  38557. */
  38558. audioPositioningRefreshRate: number;
  38559. }
  38560. }
  38561. /**
  38562. * Defines the sound scene component responsible to manage any sounds
  38563. * in a given scene.
  38564. */
  38565. export class AudioSceneComponent implements ISceneSerializableComponent {
  38566. /**
  38567. * The component name helpfull to identify the component in the list of scene components.
  38568. */
  38569. readonly name: string;
  38570. /**
  38571. * The scene the component belongs to.
  38572. */
  38573. scene: Scene;
  38574. private _audioEnabled;
  38575. /**
  38576. * Gets whether audio is enabled or not.
  38577. * Please use related enable/disable method to switch state.
  38578. */
  38579. get audioEnabled(): boolean;
  38580. private _headphone;
  38581. /**
  38582. * Gets whether audio is outputing to headphone or not.
  38583. * Please use the according Switch methods to change output.
  38584. */
  38585. get headphone(): boolean;
  38586. /**
  38587. * Gets or sets a refresh rate when using 3D audio positioning
  38588. */
  38589. audioPositioningRefreshRate: number;
  38590. private _audioListenerPositionProvider;
  38591. /**
  38592. * Gets the current audio listener position provider
  38593. */
  38594. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38595. /**
  38596. * Sets a custom listener position for all sounds in the scene
  38597. * By default, this is the position of the first active camera
  38598. */
  38599. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38600. /**
  38601. * Creates a new instance of the component for the given scene
  38602. * @param scene Defines the scene to register the component in
  38603. */
  38604. constructor(scene: Scene);
  38605. /**
  38606. * Registers the component in a given scene
  38607. */
  38608. register(): void;
  38609. /**
  38610. * Rebuilds the elements related to this component in case of
  38611. * context lost for instance.
  38612. */
  38613. rebuild(): void;
  38614. /**
  38615. * Serializes the component data to the specified json object
  38616. * @param serializationObject The object to serialize to
  38617. */
  38618. serialize(serializationObject: any): void;
  38619. /**
  38620. * Adds all the elements from the container to the scene
  38621. * @param container the container holding the elements
  38622. */
  38623. addFromContainer(container: AbstractScene): void;
  38624. /**
  38625. * Removes all the elements in the container from the scene
  38626. * @param container contains the elements to remove
  38627. * @param dispose if the removed element should be disposed (default: false)
  38628. */
  38629. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38630. /**
  38631. * Disposes the component and the associated ressources.
  38632. */
  38633. dispose(): void;
  38634. /**
  38635. * Disables audio in the associated scene.
  38636. */
  38637. disableAudio(): void;
  38638. /**
  38639. * Enables audio in the associated scene.
  38640. */
  38641. enableAudio(): void;
  38642. /**
  38643. * Switch audio to headphone output.
  38644. */
  38645. switchAudioModeForHeadphones(): void;
  38646. /**
  38647. * Switch audio to normal speakers.
  38648. */
  38649. switchAudioModeForNormalSpeakers(): void;
  38650. private _cachedCameraDirection;
  38651. private _cachedCameraPosition;
  38652. private _lastCheck;
  38653. private _afterRender;
  38654. }
  38655. }
  38656. declare module "babylonjs/Audio/weightedsound" {
  38657. import { Sound } from "babylonjs/Audio/sound";
  38658. /**
  38659. * Wraps one or more Sound objects and selects one with random weight for playback.
  38660. */
  38661. export class WeightedSound {
  38662. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38663. loop: boolean;
  38664. private _coneInnerAngle;
  38665. private _coneOuterAngle;
  38666. private _volume;
  38667. /** A Sound is currently playing. */
  38668. isPlaying: boolean;
  38669. /** A Sound is currently paused. */
  38670. isPaused: boolean;
  38671. private _sounds;
  38672. private _weights;
  38673. private _currentIndex?;
  38674. /**
  38675. * Creates a new WeightedSound from the list of sounds given.
  38676. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38677. * @param sounds Array of Sounds that will be selected from.
  38678. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38679. */
  38680. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38681. /**
  38682. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38683. */
  38684. get directionalConeInnerAngle(): number;
  38685. /**
  38686. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38687. */
  38688. set directionalConeInnerAngle(value: number);
  38689. /**
  38690. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38691. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38692. */
  38693. get directionalConeOuterAngle(): number;
  38694. /**
  38695. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38696. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38697. */
  38698. set directionalConeOuterAngle(value: number);
  38699. /**
  38700. * Playback volume.
  38701. */
  38702. get volume(): number;
  38703. /**
  38704. * Playback volume.
  38705. */
  38706. set volume(value: number);
  38707. private _onended;
  38708. /**
  38709. * Suspend playback
  38710. */
  38711. pause(): void;
  38712. /**
  38713. * Stop playback
  38714. */
  38715. stop(): void;
  38716. /**
  38717. * Start playback.
  38718. * @param startOffset Position the clip head at a specific time in seconds.
  38719. */
  38720. play(startOffset?: number): void;
  38721. }
  38722. }
  38723. declare module "babylonjs/Audio/index" {
  38724. export * from "babylonjs/Audio/analyser";
  38725. export * from "babylonjs/Audio/audioEngine";
  38726. export * from "babylonjs/Audio/audioSceneComponent";
  38727. export * from "babylonjs/Audio/sound";
  38728. export * from "babylonjs/Audio/soundTrack";
  38729. export * from "babylonjs/Audio/weightedsound";
  38730. }
  38731. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38732. import { Behavior } from "babylonjs/Behaviors/behavior";
  38733. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38734. import { BackEase } from "babylonjs/Animations/easing";
  38735. /**
  38736. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38737. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38738. */
  38739. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38740. /**
  38741. * Gets the name of the behavior.
  38742. */
  38743. get name(): string;
  38744. /**
  38745. * The easing function used by animations
  38746. */
  38747. static EasingFunction: BackEase;
  38748. /**
  38749. * The easing mode used by animations
  38750. */
  38751. static EasingMode: number;
  38752. /**
  38753. * The duration of the animation, in milliseconds
  38754. */
  38755. transitionDuration: number;
  38756. /**
  38757. * Length of the distance animated by the transition when lower radius is reached
  38758. */
  38759. lowerRadiusTransitionRange: number;
  38760. /**
  38761. * Length of the distance animated by the transition when upper radius is reached
  38762. */
  38763. upperRadiusTransitionRange: number;
  38764. private _autoTransitionRange;
  38765. /**
  38766. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38767. */
  38768. get autoTransitionRange(): boolean;
  38769. /**
  38770. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38771. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38772. */
  38773. set autoTransitionRange(value: boolean);
  38774. private _attachedCamera;
  38775. private _onAfterCheckInputsObserver;
  38776. private _onMeshTargetChangedObserver;
  38777. /**
  38778. * Initializes the behavior.
  38779. */
  38780. init(): void;
  38781. /**
  38782. * Attaches the behavior to its arc rotate camera.
  38783. * @param camera Defines the camera to attach the behavior to
  38784. */
  38785. attach(camera: ArcRotateCamera): void;
  38786. /**
  38787. * Detaches the behavior from its current arc rotate camera.
  38788. */
  38789. detach(): void;
  38790. private _radiusIsAnimating;
  38791. private _radiusBounceTransition;
  38792. private _animatables;
  38793. private _cachedWheelPrecision;
  38794. /**
  38795. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38796. * @param radiusLimit The limit to check against.
  38797. * @return Bool to indicate if at limit.
  38798. */
  38799. private _isRadiusAtLimit;
  38800. /**
  38801. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38802. * @param radiusDelta The delta by which to animate to. Can be negative.
  38803. */
  38804. private _applyBoundRadiusAnimation;
  38805. /**
  38806. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38807. */
  38808. protected _clearAnimationLocks(): void;
  38809. /**
  38810. * Stops and removes all animations that have been applied to the camera
  38811. */
  38812. stopAllAnimations(): void;
  38813. }
  38814. }
  38815. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38816. import { Behavior } from "babylonjs/Behaviors/behavior";
  38817. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38818. import { ExponentialEase } from "babylonjs/Animations/easing";
  38819. import { Nullable } from "babylonjs/types";
  38820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38821. import { Vector3 } from "babylonjs/Maths/math.vector";
  38822. /**
  38823. * 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.
  38824. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38825. */
  38826. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38827. /**
  38828. * Gets the name of the behavior.
  38829. */
  38830. get name(): string;
  38831. private _mode;
  38832. private _radiusScale;
  38833. private _positionScale;
  38834. private _defaultElevation;
  38835. private _elevationReturnTime;
  38836. private _elevationReturnWaitTime;
  38837. private _zoomStopsAnimation;
  38838. private _framingTime;
  38839. /**
  38840. * The easing function used by animations
  38841. */
  38842. static EasingFunction: ExponentialEase;
  38843. /**
  38844. * The easing mode used by animations
  38845. */
  38846. static EasingMode: number;
  38847. /**
  38848. * Sets the current mode used by the behavior
  38849. */
  38850. set mode(mode: number);
  38851. /**
  38852. * Gets current mode used by the behavior.
  38853. */
  38854. get mode(): number;
  38855. /**
  38856. * Sets the scale applied to the radius (1 by default)
  38857. */
  38858. set radiusScale(radius: number);
  38859. /**
  38860. * Gets the scale applied to the radius
  38861. */
  38862. get radiusScale(): number;
  38863. /**
  38864. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38865. */
  38866. set positionScale(scale: number);
  38867. /**
  38868. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38869. */
  38870. get positionScale(): number;
  38871. /**
  38872. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38873. * behaviour is triggered, in radians.
  38874. */
  38875. set defaultElevation(elevation: number);
  38876. /**
  38877. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38878. * behaviour is triggered, in radians.
  38879. */
  38880. get defaultElevation(): number;
  38881. /**
  38882. * Sets the time (in milliseconds) taken to return to the default beta position.
  38883. * Negative value indicates camera should not return to default.
  38884. */
  38885. set elevationReturnTime(speed: number);
  38886. /**
  38887. * Gets the time (in milliseconds) taken to return to the default beta position.
  38888. * Negative value indicates camera should not return to default.
  38889. */
  38890. get elevationReturnTime(): number;
  38891. /**
  38892. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38893. */
  38894. set elevationReturnWaitTime(time: number);
  38895. /**
  38896. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38897. */
  38898. get elevationReturnWaitTime(): number;
  38899. /**
  38900. * Sets the flag that indicates if user zooming should stop animation.
  38901. */
  38902. set zoomStopsAnimation(flag: boolean);
  38903. /**
  38904. * Gets the flag that indicates if user zooming should stop animation.
  38905. */
  38906. get zoomStopsAnimation(): boolean;
  38907. /**
  38908. * Sets the transition time when framing the mesh, in milliseconds
  38909. */
  38910. set framingTime(time: number);
  38911. /**
  38912. * Gets the transition time when framing the mesh, in milliseconds
  38913. */
  38914. get framingTime(): number;
  38915. /**
  38916. * Define if the behavior should automatically change the configured
  38917. * camera limits and sensibilities.
  38918. */
  38919. autoCorrectCameraLimitsAndSensibility: boolean;
  38920. private _onPrePointerObservableObserver;
  38921. private _onAfterCheckInputsObserver;
  38922. private _onMeshTargetChangedObserver;
  38923. private _attachedCamera;
  38924. private _isPointerDown;
  38925. private _lastInteractionTime;
  38926. /**
  38927. * Initializes the behavior.
  38928. */
  38929. init(): void;
  38930. /**
  38931. * Attaches the behavior to its arc rotate camera.
  38932. * @param camera Defines the camera to attach the behavior to
  38933. */
  38934. attach(camera: ArcRotateCamera): void;
  38935. /**
  38936. * Detaches the behavior from its current arc rotate camera.
  38937. */
  38938. detach(): void;
  38939. private _animatables;
  38940. private _betaIsAnimating;
  38941. private _betaTransition;
  38942. private _radiusTransition;
  38943. private _vectorTransition;
  38944. /**
  38945. * Targets the given mesh and updates zoom level accordingly.
  38946. * @param mesh The mesh to target.
  38947. * @param radius Optional. If a cached radius position already exists, overrides default.
  38948. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38949. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38950. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38951. */
  38952. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38953. /**
  38954. * Targets the given mesh with its children and updates zoom level accordingly.
  38955. * @param mesh The mesh to target.
  38956. * @param radius Optional. If a cached radius position already exists, overrides default.
  38957. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38958. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38959. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38960. */
  38961. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38962. /**
  38963. * Targets the given meshes with their children and updates zoom level accordingly.
  38964. * @param meshes The mesh to target.
  38965. * @param radius Optional. If a cached radius position already exists, overrides default.
  38966. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38967. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38968. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38969. */
  38970. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38971. /**
  38972. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38973. * @param minimumWorld Determines the smaller position of the bounding box extend
  38974. * @param maximumWorld Determines the bigger position of the bounding box extend
  38975. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38976. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38977. */
  38978. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38979. /**
  38980. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38981. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38982. * frustum width.
  38983. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38984. * to fully enclose the mesh in the viewing frustum.
  38985. */
  38986. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38987. /**
  38988. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38989. * is automatically returned to its default position (expected to be above ground plane).
  38990. */
  38991. private _maintainCameraAboveGround;
  38992. /**
  38993. * Returns the frustum slope based on the canvas ratio and camera FOV
  38994. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38995. */
  38996. private _getFrustumSlope;
  38997. /**
  38998. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38999. */
  39000. private _clearAnimationLocks;
  39001. /**
  39002. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39003. */
  39004. private _applyUserInteraction;
  39005. /**
  39006. * Stops and removes all animations that have been applied to the camera
  39007. */
  39008. stopAllAnimations(): void;
  39009. /**
  39010. * Gets a value indicating if the user is moving the camera
  39011. */
  39012. get isUserIsMoving(): boolean;
  39013. /**
  39014. * The camera can move all the way towards the mesh.
  39015. */
  39016. static IgnoreBoundsSizeMode: number;
  39017. /**
  39018. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39019. */
  39020. static FitFrustumSidesMode: number;
  39021. }
  39022. }
  39023. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39024. import { Nullable } from "babylonjs/types";
  39025. import { Camera } from "babylonjs/Cameras/camera";
  39026. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39027. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39028. /**
  39029. * Base class for Camera Pointer Inputs.
  39030. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39031. * for example usage.
  39032. */
  39033. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39034. /**
  39035. * Defines the camera the input is attached to.
  39036. */
  39037. abstract camera: Camera;
  39038. /**
  39039. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39040. */
  39041. protected _altKey: boolean;
  39042. protected _ctrlKey: boolean;
  39043. protected _metaKey: boolean;
  39044. protected _shiftKey: boolean;
  39045. /**
  39046. * Which mouse buttons were pressed at time of last mouse event.
  39047. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39048. */
  39049. protected _buttonsPressed: number;
  39050. /**
  39051. * Defines the buttons associated with the input to handle camera move.
  39052. */
  39053. buttons: number[];
  39054. /**
  39055. * Attach the input controls to a specific dom element to get the input from.
  39056. * @param element Defines the element the controls should be listened from
  39057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39058. */
  39059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39060. /**
  39061. * Detach the current controls from the specified dom element.
  39062. * @param element Defines the element to stop listening the inputs from
  39063. */
  39064. detachControl(element: Nullable<HTMLElement>): void;
  39065. /**
  39066. * Gets the class name of the current input.
  39067. * @returns the class name
  39068. */
  39069. getClassName(): string;
  39070. /**
  39071. * Get the friendly name associated with the input class.
  39072. * @returns the input friendly name
  39073. */
  39074. getSimpleName(): string;
  39075. /**
  39076. * Called on pointer POINTERDOUBLETAP event.
  39077. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39078. */
  39079. protected onDoubleTap(type: string): void;
  39080. /**
  39081. * Called on pointer POINTERMOVE event if only a single touch is active.
  39082. * Override this method to provide functionality.
  39083. */
  39084. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39085. /**
  39086. * Called on pointer POINTERMOVE event if multiple touches are active.
  39087. * Override this method to provide functionality.
  39088. */
  39089. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39090. /**
  39091. * Called on JS contextmenu event.
  39092. * Override this method to provide functionality.
  39093. */
  39094. protected onContextMenu(evt: PointerEvent): void;
  39095. /**
  39096. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39097. * press.
  39098. * Override this method to provide functionality.
  39099. */
  39100. protected onButtonDown(evt: PointerEvent): void;
  39101. /**
  39102. * Called each time a new POINTERUP event occurs. Ie, for each button
  39103. * release.
  39104. * Override this method to provide functionality.
  39105. */
  39106. protected onButtonUp(evt: PointerEvent): void;
  39107. /**
  39108. * Called when window becomes inactive.
  39109. * Override this method to provide functionality.
  39110. */
  39111. protected onLostFocus(): void;
  39112. private _pointerInput;
  39113. private _observer;
  39114. private _onLostFocus;
  39115. private pointA;
  39116. private pointB;
  39117. }
  39118. }
  39119. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39120. import { Nullable } from "babylonjs/types";
  39121. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39122. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39123. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39124. /**
  39125. * Manage the pointers inputs to control an arc rotate camera.
  39126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39127. */
  39128. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39129. /**
  39130. * Defines the camera the input is attached to.
  39131. */
  39132. camera: ArcRotateCamera;
  39133. /**
  39134. * Gets the class name of the current input.
  39135. * @returns the class name
  39136. */
  39137. getClassName(): string;
  39138. /**
  39139. * Defines the buttons associated with the input to handle camera move.
  39140. */
  39141. buttons: number[];
  39142. /**
  39143. * Defines the pointer angular sensibility along the X axis or how fast is
  39144. * the camera rotating.
  39145. */
  39146. angularSensibilityX: number;
  39147. /**
  39148. * Defines the pointer angular sensibility along the Y axis or how fast is
  39149. * the camera rotating.
  39150. */
  39151. angularSensibilityY: number;
  39152. /**
  39153. * Defines the pointer pinch precision or how fast is the camera zooming.
  39154. */
  39155. pinchPrecision: number;
  39156. /**
  39157. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39158. * from 0.
  39159. * It defines the percentage of current camera.radius to use as delta when
  39160. * pinch zoom is used.
  39161. */
  39162. pinchDeltaPercentage: number;
  39163. /**
  39164. * Defines the pointer panning sensibility or how fast is the camera moving.
  39165. */
  39166. panningSensibility: number;
  39167. /**
  39168. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39169. */
  39170. multiTouchPanning: boolean;
  39171. /**
  39172. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39173. * zoom (pinch) through multitouch.
  39174. */
  39175. multiTouchPanAndZoom: boolean;
  39176. /**
  39177. * Revers pinch action direction.
  39178. */
  39179. pinchInwards: boolean;
  39180. private _isPanClick;
  39181. private _twoFingerActivityCount;
  39182. private _isPinching;
  39183. /**
  39184. * Called on pointer POINTERMOVE event if only a single touch is active.
  39185. */
  39186. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39187. /**
  39188. * Called on pointer POINTERDOUBLETAP event.
  39189. */
  39190. protected onDoubleTap(type: string): void;
  39191. /**
  39192. * Called on pointer POINTERMOVE event if multiple touches are active.
  39193. */
  39194. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39195. /**
  39196. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39197. * press.
  39198. */
  39199. protected onButtonDown(evt: PointerEvent): void;
  39200. /**
  39201. * Called each time a new POINTERUP event occurs. Ie, for each button
  39202. * release.
  39203. */
  39204. protected onButtonUp(evt: PointerEvent): void;
  39205. /**
  39206. * Called when window becomes inactive.
  39207. */
  39208. protected onLostFocus(): void;
  39209. }
  39210. }
  39211. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39212. import { Nullable } from "babylonjs/types";
  39213. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39214. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39215. /**
  39216. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39218. */
  39219. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39220. /**
  39221. * Defines the camera the input is attached to.
  39222. */
  39223. camera: ArcRotateCamera;
  39224. /**
  39225. * Defines the list of key codes associated with the up action (increase alpha)
  39226. */
  39227. keysUp: number[];
  39228. /**
  39229. * Defines the list of key codes associated with the down action (decrease alpha)
  39230. */
  39231. keysDown: number[];
  39232. /**
  39233. * Defines the list of key codes associated with the left action (increase beta)
  39234. */
  39235. keysLeft: number[];
  39236. /**
  39237. * Defines the list of key codes associated with the right action (decrease beta)
  39238. */
  39239. keysRight: number[];
  39240. /**
  39241. * Defines the list of key codes associated with the reset action.
  39242. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39243. */
  39244. keysReset: number[];
  39245. /**
  39246. * Defines the panning sensibility of the inputs.
  39247. * (How fast is the camera paning)
  39248. */
  39249. panningSensibility: number;
  39250. /**
  39251. * Defines the zooming sensibility of the inputs.
  39252. * (How fast is the camera zooming)
  39253. */
  39254. zoomingSensibility: number;
  39255. /**
  39256. * Defines wether maintaining the alt key down switch the movement mode from
  39257. * orientation to zoom.
  39258. */
  39259. useAltToZoom: boolean;
  39260. /**
  39261. * Rotation speed of the camera
  39262. */
  39263. angularSpeed: number;
  39264. private _keys;
  39265. private _ctrlPressed;
  39266. private _altPressed;
  39267. private _onCanvasBlurObserver;
  39268. private _onKeyboardObserver;
  39269. private _engine;
  39270. private _scene;
  39271. /**
  39272. * Attach the input controls to a specific dom element to get the input from.
  39273. * @param element Defines the element the controls should be listened from
  39274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39275. */
  39276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39277. /**
  39278. * Detach the current controls from the specified dom element.
  39279. * @param element Defines the element to stop listening the inputs from
  39280. */
  39281. detachControl(element: Nullable<HTMLElement>): void;
  39282. /**
  39283. * Update the current camera state depending on the inputs that have been used this frame.
  39284. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39285. */
  39286. checkInputs(): void;
  39287. /**
  39288. * Gets the class name of the current intput.
  39289. * @returns the class name
  39290. */
  39291. getClassName(): string;
  39292. /**
  39293. * Get the friendly name associated with the input class.
  39294. * @returns the input friendly name
  39295. */
  39296. getSimpleName(): string;
  39297. }
  39298. }
  39299. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39300. import { Nullable } from "babylonjs/types";
  39301. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39302. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39303. /**
  39304. * Manage the mouse wheel inputs to control an arc rotate camera.
  39305. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39306. */
  39307. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39308. /**
  39309. * Defines the camera the input is attached to.
  39310. */
  39311. camera: ArcRotateCamera;
  39312. /**
  39313. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39314. */
  39315. wheelPrecision: number;
  39316. /**
  39317. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39318. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39319. */
  39320. wheelDeltaPercentage: number;
  39321. private _wheel;
  39322. private _observer;
  39323. private computeDeltaFromMouseWheelLegacyEvent;
  39324. /**
  39325. * Attach the input controls to a specific dom element to get the input from.
  39326. * @param element Defines the element the controls should be listened from
  39327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39328. */
  39329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39330. /**
  39331. * Detach the current controls from the specified dom element.
  39332. * @param element Defines the element to stop listening the inputs from
  39333. */
  39334. detachControl(element: Nullable<HTMLElement>): void;
  39335. /**
  39336. * Gets the class name of the current intput.
  39337. * @returns the class name
  39338. */
  39339. getClassName(): string;
  39340. /**
  39341. * Get the friendly name associated with the input class.
  39342. * @returns the input friendly name
  39343. */
  39344. getSimpleName(): string;
  39345. }
  39346. }
  39347. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39348. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39349. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39350. /**
  39351. * Default Inputs manager for the ArcRotateCamera.
  39352. * It groups all the default supported inputs for ease of use.
  39353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39354. */
  39355. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39356. /**
  39357. * Instantiates a new ArcRotateCameraInputsManager.
  39358. * @param camera Defines the camera the inputs belong to
  39359. */
  39360. constructor(camera: ArcRotateCamera);
  39361. /**
  39362. * Add mouse wheel input support to the input manager.
  39363. * @returns the current input manager
  39364. */
  39365. addMouseWheel(): ArcRotateCameraInputsManager;
  39366. /**
  39367. * Add pointers input support to the input manager.
  39368. * @returns the current input manager
  39369. */
  39370. addPointers(): ArcRotateCameraInputsManager;
  39371. /**
  39372. * Add keyboard input support to the input manager.
  39373. * @returns the current input manager
  39374. */
  39375. addKeyboard(): ArcRotateCameraInputsManager;
  39376. }
  39377. }
  39378. declare module "babylonjs/Cameras/arcRotateCamera" {
  39379. import { Observable } from "babylonjs/Misc/observable";
  39380. import { Nullable } from "babylonjs/types";
  39381. import { Scene } from "babylonjs/scene";
  39382. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39384. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39385. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39386. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39387. import { Camera } from "babylonjs/Cameras/camera";
  39388. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39389. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39390. import { Collider } from "babylonjs/Collisions/collider";
  39391. /**
  39392. * This represents an orbital type of camera.
  39393. *
  39394. * 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.
  39395. * 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.
  39396. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39397. */
  39398. export class ArcRotateCamera extends TargetCamera {
  39399. /**
  39400. * Defines the rotation angle of the camera along the longitudinal axis.
  39401. */
  39402. alpha: number;
  39403. /**
  39404. * Defines the rotation angle of the camera along the latitudinal axis.
  39405. */
  39406. beta: number;
  39407. /**
  39408. * Defines the radius of the camera from it s target point.
  39409. */
  39410. radius: number;
  39411. protected _target: Vector3;
  39412. protected _targetHost: Nullable<AbstractMesh>;
  39413. /**
  39414. * Defines the target point of the camera.
  39415. * The camera looks towards it form the radius distance.
  39416. */
  39417. get target(): Vector3;
  39418. set target(value: Vector3);
  39419. /**
  39420. * Define the current local position of the camera in the scene
  39421. */
  39422. get position(): Vector3;
  39423. set position(newPosition: Vector3);
  39424. protected _upVector: Vector3;
  39425. protected _upToYMatrix: Matrix;
  39426. protected _YToUpMatrix: Matrix;
  39427. /**
  39428. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39429. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39430. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39431. */
  39432. set upVector(vec: Vector3);
  39433. get upVector(): Vector3;
  39434. /**
  39435. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39436. */
  39437. setMatUp(): void;
  39438. /**
  39439. * Current inertia value on the longitudinal axis.
  39440. * The bigger this number the longer it will take for the camera to stop.
  39441. */
  39442. inertialAlphaOffset: number;
  39443. /**
  39444. * Current inertia value on the latitudinal axis.
  39445. * The bigger this number the longer it will take for the camera to stop.
  39446. */
  39447. inertialBetaOffset: number;
  39448. /**
  39449. * Current inertia value on the radius axis.
  39450. * The bigger this number the longer it will take for the camera to stop.
  39451. */
  39452. inertialRadiusOffset: number;
  39453. /**
  39454. * Minimum allowed angle on the longitudinal axis.
  39455. * This can help limiting how the Camera is able to move in the scene.
  39456. */
  39457. lowerAlphaLimit: Nullable<number>;
  39458. /**
  39459. * Maximum allowed angle on the longitudinal axis.
  39460. * This can help limiting how the Camera is able to move in the scene.
  39461. */
  39462. upperAlphaLimit: Nullable<number>;
  39463. /**
  39464. * Minimum allowed angle on the latitudinal axis.
  39465. * This can help limiting how the Camera is able to move in the scene.
  39466. */
  39467. lowerBetaLimit: number;
  39468. /**
  39469. * Maximum allowed angle on the latitudinal axis.
  39470. * This can help limiting how the Camera is able to move in the scene.
  39471. */
  39472. upperBetaLimit: number;
  39473. /**
  39474. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39475. * This can help limiting how the Camera is able to move in the scene.
  39476. */
  39477. lowerRadiusLimit: Nullable<number>;
  39478. /**
  39479. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39480. * This can help limiting how the Camera is able to move in the scene.
  39481. */
  39482. upperRadiusLimit: Nullable<number>;
  39483. /**
  39484. * Defines the current inertia value used during panning of the camera along the X axis.
  39485. */
  39486. inertialPanningX: number;
  39487. /**
  39488. * Defines the current inertia value used during panning of the camera along the Y axis.
  39489. */
  39490. inertialPanningY: number;
  39491. /**
  39492. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39493. * Basically if your fingers moves away from more than this distance you will be considered
  39494. * in pinch mode.
  39495. */
  39496. pinchToPanMaxDistance: number;
  39497. /**
  39498. * Defines the maximum distance the camera can pan.
  39499. * This could help keeping the cammera always in your scene.
  39500. */
  39501. panningDistanceLimit: Nullable<number>;
  39502. /**
  39503. * Defines the target of the camera before paning.
  39504. */
  39505. panningOriginTarget: Vector3;
  39506. /**
  39507. * Defines the value of the inertia used during panning.
  39508. * 0 would mean stop inertia and one would mean no decelleration at all.
  39509. */
  39510. panningInertia: number;
  39511. /**
  39512. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39513. */
  39514. get angularSensibilityX(): number;
  39515. set angularSensibilityX(value: number);
  39516. /**
  39517. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39518. */
  39519. get angularSensibilityY(): number;
  39520. set angularSensibilityY(value: number);
  39521. /**
  39522. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39523. */
  39524. get pinchPrecision(): number;
  39525. set pinchPrecision(value: number);
  39526. /**
  39527. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39528. * It will be used instead of pinchDeltaPrecision if different from 0.
  39529. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39530. */
  39531. get pinchDeltaPercentage(): number;
  39532. set pinchDeltaPercentage(value: number);
  39533. /**
  39534. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39535. */
  39536. get panningSensibility(): number;
  39537. set panningSensibility(value: number);
  39538. /**
  39539. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39540. */
  39541. get keysUp(): number[];
  39542. set keysUp(value: number[]);
  39543. /**
  39544. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39545. */
  39546. get keysDown(): number[];
  39547. set keysDown(value: number[]);
  39548. /**
  39549. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39550. */
  39551. get keysLeft(): number[];
  39552. set keysLeft(value: number[]);
  39553. /**
  39554. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39555. */
  39556. get keysRight(): number[];
  39557. set keysRight(value: number[]);
  39558. /**
  39559. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39560. */
  39561. get wheelPrecision(): number;
  39562. set wheelPrecision(value: number);
  39563. /**
  39564. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39565. * It will be used instead of pinchDeltaPrecision if different from 0.
  39566. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39567. */
  39568. get wheelDeltaPercentage(): number;
  39569. set wheelDeltaPercentage(value: number);
  39570. /**
  39571. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39572. */
  39573. zoomOnFactor: number;
  39574. /**
  39575. * Defines a screen offset for the camera position.
  39576. */
  39577. targetScreenOffset: Vector2;
  39578. /**
  39579. * Allows the camera to be completely reversed.
  39580. * If false the camera can not arrive upside down.
  39581. */
  39582. allowUpsideDown: boolean;
  39583. /**
  39584. * Define if double tap/click is used to restore the previously saved state of the camera.
  39585. */
  39586. useInputToRestoreState: boolean;
  39587. /** @hidden */
  39588. _viewMatrix: Matrix;
  39589. /** @hidden */
  39590. _useCtrlForPanning: boolean;
  39591. /** @hidden */
  39592. _panningMouseButton: number;
  39593. /**
  39594. * Defines the input associated to the camera.
  39595. */
  39596. inputs: ArcRotateCameraInputsManager;
  39597. /** @hidden */
  39598. _reset: () => void;
  39599. /**
  39600. * Defines the allowed panning axis.
  39601. */
  39602. panningAxis: Vector3;
  39603. protected _localDirection: Vector3;
  39604. protected _transformedDirection: Vector3;
  39605. private _bouncingBehavior;
  39606. /**
  39607. * Gets the bouncing behavior of the camera if it has been enabled.
  39608. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39609. */
  39610. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39611. /**
  39612. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39613. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39614. */
  39615. get useBouncingBehavior(): boolean;
  39616. set useBouncingBehavior(value: boolean);
  39617. private _framingBehavior;
  39618. /**
  39619. * Gets the framing behavior of the camera if it has been enabled.
  39620. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39621. */
  39622. get framingBehavior(): Nullable<FramingBehavior>;
  39623. /**
  39624. * Defines if the framing behavior of the camera is enabled on the camera.
  39625. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39626. */
  39627. get useFramingBehavior(): boolean;
  39628. set useFramingBehavior(value: boolean);
  39629. private _autoRotationBehavior;
  39630. /**
  39631. * Gets the auto rotation behavior of the camera if it has been enabled.
  39632. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39633. */
  39634. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39635. /**
  39636. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39637. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39638. */
  39639. get useAutoRotationBehavior(): boolean;
  39640. set useAutoRotationBehavior(value: boolean);
  39641. /**
  39642. * Observable triggered when the mesh target has been changed on the camera.
  39643. */
  39644. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39645. /**
  39646. * Event raised when the camera is colliding with a mesh.
  39647. */
  39648. onCollide: (collidedMesh: AbstractMesh) => void;
  39649. /**
  39650. * Defines whether the camera should check collision with the objects oh the scene.
  39651. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39652. */
  39653. checkCollisions: boolean;
  39654. /**
  39655. * Defines the collision radius of the camera.
  39656. * This simulates a sphere around the camera.
  39657. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39658. */
  39659. collisionRadius: Vector3;
  39660. protected _collider: Collider;
  39661. protected _previousPosition: Vector3;
  39662. protected _collisionVelocity: Vector3;
  39663. protected _newPosition: Vector3;
  39664. protected _previousAlpha: number;
  39665. protected _previousBeta: number;
  39666. protected _previousRadius: number;
  39667. protected _collisionTriggered: boolean;
  39668. protected _targetBoundingCenter: Nullable<Vector3>;
  39669. private _computationVector;
  39670. /**
  39671. * Instantiates a new ArcRotateCamera in a given scene
  39672. * @param name Defines the name of the camera
  39673. * @param alpha Defines the camera rotation along the logitudinal axis
  39674. * @param beta Defines the camera rotation along the latitudinal axis
  39675. * @param radius Defines the camera distance from its target
  39676. * @param target Defines the camera target
  39677. * @param scene Defines the scene the camera belongs to
  39678. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39679. */
  39680. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39681. /** @hidden */
  39682. _initCache(): void;
  39683. /** @hidden */
  39684. _updateCache(ignoreParentClass?: boolean): void;
  39685. protected _getTargetPosition(): Vector3;
  39686. private _storedAlpha;
  39687. private _storedBeta;
  39688. private _storedRadius;
  39689. private _storedTarget;
  39690. private _storedTargetScreenOffset;
  39691. /**
  39692. * Stores the current state of the camera (alpha, beta, radius and target)
  39693. * @returns the camera itself
  39694. */
  39695. storeState(): Camera;
  39696. /**
  39697. * @hidden
  39698. * Restored camera state. You must call storeState() first
  39699. */
  39700. _restoreStateValues(): boolean;
  39701. /** @hidden */
  39702. _isSynchronizedViewMatrix(): boolean;
  39703. /**
  39704. * Attached controls to the current camera.
  39705. * @param element Defines the element the controls should be listened from
  39706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39707. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39708. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39709. */
  39710. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39711. /**
  39712. * Detach the current controls from the camera.
  39713. * The camera will stop reacting to inputs.
  39714. * @param element Defines the element to stop listening the inputs from
  39715. */
  39716. detachControl(element: HTMLElement): void;
  39717. /** @hidden */
  39718. _checkInputs(): void;
  39719. protected _checkLimits(): void;
  39720. /**
  39721. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39722. */
  39723. rebuildAnglesAndRadius(): void;
  39724. /**
  39725. * Use a position to define the current camera related information like alpha, beta and radius
  39726. * @param position Defines the position to set the camera at
  39727. */
  39728. setPosition(position: Vector3): void;
  39729. /**
  39730. * Defines the target the camera should look at.
  39731. * This will automatically adapt alpha beta and radius to fit within the new target.
  39732. * @param target Defines the new target as a Vector or a mesh
  39733. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39734. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39735. */
  39736. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39737. /** @hidden */
  39738. _getViewMatrix(): Matrix;
  39739. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39740. /**
  39741. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39742. * @param meshes Defines the mesh to zoom on
  39743. * @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)
  39744. */
  39745. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39746. /**
  39747. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39748. * The target will be changed but the radius
  39749. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39750. * @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)
  39751. */
  39752. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39753. min: Vector3;
  39754. max: Vector3;
  39755. distance: number;
  39756. }, doNotUpdateMaxZ?: boolean): void;
  39757. /**
  39758. * @override
  39759. * Override Camera.createRigCamera
  39760. */
  39761. createRigCamera(name: string, cameraIndex: number): Camera;
  39762. /**
  39763. * @hidden
  39764. * @override
  39765. * Override Camera._updateRigCameras
  39766. */
  39767. _updateRigCameras(): void;
  39768. /**
  39769. * Destroy the camera and release the current resources hold by it.
  39770. */
  39771. dispose(): void;
  39772. /**
  39773. * Gets the current object class name.
  39774. * @return the class name
  39775. */
  39776. getClassName(): string;
  39777. }
  39778. }
  39779. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39780. import { Behavior } from "babylonjs/Behaviors/behavior";
  39781. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39782. /**
  39783. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39784. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39785. */
  39786. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39787. /**
  39788. * Gets the name of the behavior.
  39789. */
  39790. get name(): string;
  39791. private _zoomStopsAnimation;
  39792. private _idleRotationSpeed;
  39793. private _idleRotationWaitTime;
  39794. private _idleRotationSpinupTime;
  39795. /**
  39796. * Sets the flag that indicates if user zooming should stop animation.
  39797. */
  39798. set zoomStopsAnimation(flag: boolean);
  39799. /**
  39800. * Gets the flag that indicates if user zooming should stop animation.
  39801. */
  39802. get zoomStopsAnimation(): boolean;
  39803. /**
  39804. * Sets the default speed at which the camera rotates around the model.
  39805. */
  39806. set idleRotationSpeed(speed: number);
  39807. /**
  39808. * Gets the default speed at which the camera rotates around the model.
  39809. */
  39810. get idleRotationSpeed(): number;
  39811. /**
  39812. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39813. */
  39814. set idleRotationWaitTime(time: number);
  39815. /**
  39816. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39817. */
  39818. get idleRotationWaitTime(): number;
  39819. /**
  39820. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39821. */
  39822. set idleRotationSpinupTime(time: number);
  39823. /**
  39824. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39825. */
  39826. get idleRotationSpinupTime(): number;
  39827. /**
  39828. * Gets a value indicating if the camera is currently rotating because of this behavior
  39829. */
  39830. get rotationInProgress(): boolean;
  39831. private _onPrePointerObservableObserver;
  39832. private _onAfterCheckInputsObserver;
  39833. private _attachedCamera;
  39834. private _isPointerDown;
  39835. private _lastFrameTime;
  39836. private _lastInteractionTime;
  39837. private _cameraRotationSpeed;
  39838. /**
  39839. * Initializes the behavior.
  39840. */
  39841. init(): void;
  39842. /**
  39843. * Attaches the behavior to its arc rotate camera.
  39844. * @param camera Defines the camera to attach the behavior to
  39845. */
  39846. attach(camera: ArcRotateCamera): void;
  39847. /**
  39848. * Detaches the behavior from its current arc rotate camera.
  39849. */
  39850. detach(): void;
  39851. /**
  39852. * Returns true if user is scrolling.
  39853. * @return true if user is scrolling.
  39854. */
  39855. private _userIsZooming;
  39856. private _lastFrameRadius;
  39857. private _shouldAnimationStopForInteraction;
  39858. /**
  39859. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39860. */
  39861. private _applyUserInteraction;
  39862. private _userIsMoving;
  39863. }
  39864. }
  39865. declare module "babylonjs/Behaviors/Cameras/index" {
  39866. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39867. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39868. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39869. }
  39870. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39871. import { Mesh } from "babylonjs/Meshes/mesh";
  39872. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39873. import { Behavior } from "babylonjs/Behaviors/behavior";
  39874. /**
  39875. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39876. */
  39877. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39878. private ui;
  39879. /**
  39880. * The name of the behavior
  39881. */
  39882. name: string;
  39883. /**
  39884. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39885. */
  39886. distanceAwayFromFace: number;
  39887. /**
  39888. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39889. */
  39890. distanceAwayFromBottomOfFace: number;
  39891. private _faceVectors;
  39892. private _target;
  39893. private _scene;
  39894. private _onRenderObserver;
  39895. private _tmpMatrix;
  39896. private _tmpVector;
  39897. /**
  39898. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39899. * @param ui The transform node that should be attched to the mesh
  39900. */
  39901. constructor(ui: TransformNode);
  39902. /**
  39903. * Initializes the behavior
  39904. */
  39905. init(): void;
  39906. private _closestFace;
  39907. private _zeroVector;
  39908. private _lookAtTmpMatrix;
  39909. private _lookAtToRef;
  39910. /**
  39911. * Attaches the AttachToBoxBehavior to the passed in mesh
  39912. * @param target The mesh that the specified node will be attached to
  39913. */
  39914. attach(target: Mesh): void;
  39915. /**
  39916. * Detaches the behavior from the mesh
  39917. */
  39918. detach(): void;
  39919. }
  39920. }
  39921. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39922. import { Behavior } from "babylonjs/Behaviors/behavior";
  39923. import { Mesh } from "babylonjs/Meshes/mesh";
  39924. /**
  39925. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39926. */
  39927. export class FadeInOutBehavior implements Behavior<Mesh> {
  39928. /**
  39929. * Time in milliseconds to delay before fading in (Default: 0)
  39930. */
  39931. delay: number;
  39932. /**
  39933. * Time in milliseconds for the mesh to fade in (Default: 300)
  39934. */
  39935. fadeInTime: number;
  39936. private _millisecondsPerFrame;
  39937. private _hovered;
  39938. private _hoverValue;
  39939. private _ownerNode;
  39940. /**
  39941. * Instatiates the FadeInOutBehavior
  39942. */
  39943. constructor();
  39944. /**
  39945. * The name of the behavior
  39946. */
  39947. get name(): string;
  39948. /**
  39949. * Initializes the behavior
  39950. */
  39951. init(): void;
  39952. /**
  39953. * Attaches the fade behavior on the passed in mesh
  39954. * @param ownerNode The mesh that will be faded in/out once attached
  39955. */
  39956. attach(ownerNode: Mesh): void;
  39957. /**
  39958. * Detaches the behavior from the mesh
  39959. */
  39960. detach(): void;
  39961. /**
  39962. * Triggers the mesh to begin fading in or out
  39963. * @param value if the object should fade in or out (true to fade in)
  39964. */
  39965. fadeIn(value: boolean): void;
  39966. private _update;
  39967. private _setAllVisibility;
  39968. }
  39969. }
  39970. declare module "babylonjs/Misc/pivotTools" {
  39971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39972. /**
  39973. * Class containing a set of static utilities functions for managing Pivots
  39974. * @hidden
  39975. */
  39976. export class PivotTools {
  39977. private static _PivotCached;
  39978. private static _OldPivotPoint;
  39979. private static _PivotTranslation;
  39980. private static _PivotTmpVector;
  39981. /** @hidden */
  39982. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39983. /** @hidden */
  39984. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39985. }
  39986. }
  39987. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39988. import { Scene } from "babylonjs/scene";
  39989. import { Vector4 } from "babylonjs/Maths/math.vector";
  39990. import { Mesh } from "babylonjs/Meshes/mesh";
  39991. import { Nullable } from "babylonjs/types";
  39992. import { Plane } from "babylonjs/Maths/math.plane";
  39993. /**
  39994. * Class containing static functions to help procedurally build meshes
  39995. */
  39996. export class PlaneBuilder {
  39997. /**
  39998. * Creates a plane mesh
  39999. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40000. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40001. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40005. * @param name defines the name of the mesh
  40006. * @param options defines the options used to create the mesh
  40007. * @param scene defines the hosting scene
  40008. * @returns the plane mesh
  40009. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40010. */
  40011. static CreatePlane(name: string, options: {
  40012. size?: number;
  40013. width?: number;
  40014. height?: number;
  40015. sideOrientation?: number;
  40016. frontUVs?: Vector4;
  40017. backUVs?: Vector4;
  40018. updatable?: boolean;
  40019. sourcePlane?: Plane;
  40020. }, scene?: Nullable<Scene>): Mesh;
  40021. }
  40022. }
  40023. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40024. import { Behavior } from "babylonjs/Behaviors/behavior";
  40025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40026. import { Observable } from "babylonjs/Misc/observable";
  40027. import { Vector3 } from "babylonjs/Maths/math.vector";
  40028. import { Ray } from "babylonjs/Culling/ray";
  40029. import "babylonjs/Meshes/Builders/planeBuilder";
  40030. /**
  40031. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40032. */
  40033. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40034. private static _AnyMouseID;
  40035. /**
  40036. * Abstract mesh the behavior is set on
  40037. */
  40038. attachedNode: AbstractMesh;
  40039. private _dragPlane;
  40040. private _scene;
  40041. private _pointerObserver;
  40042. private _beforeRenderObserver;
  40043. private static _planeScene;
  40044. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40045. /**
  40046. * 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)
  40047. */
  40048. maxDragAngle: number;
  40049. /**
  40050. * @hidden
  40051. */
  40052. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40053. /**
  40054. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40055. */
  40056. currentDraggingPointerID: number;
  40057. /**
  40058. * The last position where the pointer hit the drag plane in world space
  40059. */
  40060. lastDragPosition: Vector3;
  40061. /**
  40062. * If the behavior is currently in a dragging state
  40063. */
  40064. dragging: boolean;
  40065. /**
  40066. * 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)
  40067. */
  40068. dragDeltaRatio: number;
  40069. /**
  40070. * If the drag plane orientation should be updated during the dragging (Default: true)
  40071. */
  40072. updateDragPlane: boolean;
  40073. private _debugMode;
  40074. private _moving;
  40075. /**
  40076. * Fires each time the attached mesh is dragged with the pointer
  40077. * * delta between last drag position and current drag position in world space
  40078. * * dragDistance along the drag axis
  40079. * * dragPlaneNormal normal of the current drag plane used during the drag
  40080. * * dragPlanePoint in world space where the drag intersects the drag plane
  40081. */
  40082. onDragObservable: Observable<{
  40083. delta: Vector3;
  40084. dragPlanePoint: Vector3;
  40085. dragPlaneNormal: Vector3;
  40086. dragDistance: number;
  40087. pointerId: number;
  40088. }>;
  40089. /**
  40090. * Fires each time a drag begins (eg. mouse down on mesh)
  40091. */
  40092. onDragStartObservable: Observable<{
  40093. dragPlanePoint: Vector3;
  40094. pointerId: number;
  40095. }>;
  40096. /**
  40097. * Fires each time a drag ends (eg. mouse release after drag)
  40098. */
  40099. onDragEndObservable: Observable<{
  40100. dragPlanePoint: Vector3;
  40101. pointerId: number;
  40102. }>;
  40103. /**
  40104. * If the attached mesh should be moved when dragged
  40105. */
  40106. moveAttached: boolean;
  40107. /**
  40108. * If the drag behavior will react to drag events (Default: true)
  40109. */
  40110. enabled: boolean;
  40111. /**
  40112. * If pointer events should start and release the drag (Default: true)
  40113. */
  40114. startAndReleaseDragOnPointerEvents: boolean;
  40115. /**
  40116. * If camera controls should be detached during the drag
  40117. */
  40118. detachCameraControls: boolean;
  40119. /**
  40120. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40121. */
  40122. useObjectOrienationForDragging: boolean;
  40123. private _options;
  40124. /**
  40125. * Gets the options used by the behavior
  40126. */
  40127. get options(): {
  40128. dragAxis?: Vector3;
  40129. dragPlaneNormal?: Vector3;
  40130. };
  40131. /**
  40132. * Sets the options used by the behavior
  40133. */
  40134. set options(options: {
  40135. dragAxis?: Vector3;
  40136. dragPlaneNormal?: Vector3;
  40137. });
  40138. /**
  40139. * Creates a pointer drag behavior that can be attached to a mesh
  40140. * @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)
  40141. */
  40142. constructor(options?: {
  40143. dragAxis?: Vector3;
  40144. dragPlaneNormal?: Vector3;
  40145. });
  40146. /**
  40147. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40148. */
  40149. validateDrag: (targetPosition: Vector3) => boolean;
  40150. /**
  40151. * The name of the behavior
  40152. */
  40153. get name(): string;
  40154. /**
  40155. * Initializes the behavior
  40156. */
  40157. init(): void;
  40158. private _tmpVector;
  40159. private _alternatePickedPoint;
  40160. private _worldDragAxis;
  40161. private _targetPosition;
  40162. private _attachedElement;
  40163. /**
  40164. * Attaches the drag behavior the passed in mesh
  40165. * @param ownerNode The mesh that will be dragged around once attached
  40166. * @param predicate Predicate to use for pick filtering
  40167. */
  40168. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40169. /**
  40170. * Force relase the drag action by code.
  40171. */
  40172. releaseDrag(): void;
  40173. private _startDragRay;
  40174. private _lastPointerRay;
  40175. /**
  40176. * Simulates the start of a pointer drag event on the behavior
  40177. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40178. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40179. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40180. */
  40181. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40182. private _startDrag;
  40183. private _dragDelta;
  40184. private _moveDrag;
  40185. private _pickWithRayOnDragPlane;
  40186. private _pointA;
  40187. private _pointB;
  40188. private _pointC;
  40189. private _lineA;
  40190. private _lineB;
  40191. private _localAxis;
  40192. private _lookAt;
  40193. private _updateDragPlanePosition;
  40194. /**
  40195. * Detaches the behavior from the mesh
  40196. */
  40197. detach(): void;
  40198. }
  40199. }
  40200. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40201. import { Mesh } from "babylonjs/Meshes/mesh";
  40202. import { Behavior } from "babylonjs/Behaviors/behavior";
  40203. /**
  40204. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40205. */
  40206. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40207. private _dragBehaviorA;
  40208. private _dragBehaviorB;
  40209. private _startDistance;
  40210. private _initialScale;
  40211. private _targetScale;
  40212. private _ownerNode;
  40213. private _sceneRenderObserver;
  40214. /**
  40215. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40216. */
  40217. constructor();
  40218. /**
  40219. * The name of the behavior
  40220. */
  40221. get name(): string;
  40222. /**
  40223. * Initializes the behavior
  40224. */
  40225. init(): void;
  40226. private _getCurrentDistance;
  40227. /**
  40228. * Attaches the scale behavior the passed in mesh
  40229. * @param ownerNode The mesh that will be scaled around once attached
  40230. */
  40231. attach(ownerNode: Mesh): void;
  40232. /**
  40233. * Detaches the behavior from the mesh
  40234. */
  40235. detach(): void;
  40236. }
  40237. }
  40238. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40239. import { Behavior } from "babylonjs/Behaviors/behavior";
  40240. import { Mesh } from "babylonjs/Meshes/mesh";
  40241. import { Observable } from "babylonjs/Misc/observable";
  40242. /**
  40243. * 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
  40244. */
  40245. export class SixDofDragBehavior implements Behavior<Mesh> {
  40246. private static _virtualScene;
  40247. private _ownerNode;
  40248. private _sceneRenderObserver;
  40249. private _scene;
  40250. private _targetPosition;
  40251. private _virtualOriginMesh;
  40252. private _virtualDragMesh;
  40253. private _pointerObserver;
  40254. private _moving;
  40255. private _startingOrientation;
  40256. /**
  40257. * 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)
  40258. */
  40259. private zDragFactor;
  40260. /**
  40261. * If the object should rotate to face the drag origin
  40262. */
  40263. rotateDraggedObject: boolean;
  40264. /**
  40265. * If the behavior is currently in a dragging state
  40266. */
  40267. dragging: boolean;
  40268. /**
  40269. * 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)
  40270. */
  40271. dragDeltaRatio: number;
  40272. /**
  40273. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40274. */
  40275. currentDraggingPointerID: number;
  40276. /**
  40277. * If camera controls should be detached during the drag
  40278. */
  40279. detachCameraControls: boolean;
  40280. /**
  40281. * Fires each time a drag starts
  40282. */
  40283. onDragStartObservable: Observable<{}>;
  40284. /**
  40285. * Fires each time a drag ends (eg. mouse release after drag)
  40286. */
  40287. onDragEndObservable: Observable<{}>;
  40288. /**
  40289. * 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
  40290. */
  40291. constructor();
  40292. /**
  40293. * The name of the behavior
  40294. */
  40295. get name(): string;
  40296. /**
  40297. * Initializes the behavior
  40298. */
  40299. init(): void;
  40300. /**
  40301. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40302. */
  40303. private get _pointerCamera();
  40304. /**
  40305. * Attaches the scale behavior the passed in mesh
  40306. * @param ownerNode The mesh that will be scaled around once attached
  40307. */
  40308. attach(ownerNode: Mesh): void;
  40309. /**
  40310. * Detaches the behavior from the mesh
  40311. */
  40312. detach(): void;
  40313. }
  40314. }
  40315. declare module "babylonjs/Behaviors/Meshes/index" {
  40316. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40317. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40318. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40319. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40320. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40321. }
  40322. declare module "babylonjs/Behaviors/index" {
  40323. export * from "babylonjs/Behaviors/behavior";
  40324. export * from "babylonjs/Behaviors/Cameras/index";
  40325. export * from "babylonjs/Behaviors/Meshes/index";
  40326. }
  40327. declare module "babylonjs/Bones/boneIKController" {
  40328. import { Bone } from "babylonjs/Bones/bone";
  40329. import { Vector3 } from "babylonjs/Maths/math.vector";
  40330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40331. import { Nullable } from "babylonjs/types";
  40332. /**
  40333. * Class used to apply inverse kinematics to bones
  40334. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40335. */
  40336. export class BoneIKController {
  40337. private static _tmpVecs;
  40338. private static _tmpQuat;
  40339. private static _tmpMats;
  40340. /**
  40341. * Gets or sets the target mesh
  40342. */
  40343. targetMesh: AbstractMesh;
  40344. /** Gets or sets the mesh used as pole */
  40345. poleTargetMesh: AbstractMesh;
  40346. /**
  40347. * Gets or sets the bone used as pole
  40348. */
  40349. poleTargetBone: Nullable<Bone>;
  40350. /**
  40351. * Gets or sets the target position
  40352. */
  40353. targetPosition: Vector3;
  40354. /**
  40355. * Gets or sets the pole target position
  40356. */
  40357. poleTargetPosition: Vector3;
  40358. /**
  40359. * Gets or sets the pole target local offset
  40360. */
  40361. poleTargetLocalOffset: Vector3;
  40362. /**
  40363. * Gets or sets the pole angle
  40364. */
  40365. poleAngle: number;
  40366. /**
  40367. * Gets or sets the mesh associated with the controller
  40368. */
  40369. mesh: AbstractMesh;
  40370. /**
  40371. * 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)
  40372. */
  40373. slerpAmount: number;
  40374. private _bone1Quat;
  40375. private _bone1Mat;
  40376. private _bone2Ang;
  40377. private _bone1;
  40378. private _bone2;
  40379. private _bone1Length;
  40380. private _bone2Length;
  40381. private _maxAngle;
  40382. private _maxReach;
  40383. private _rightHandedSystem;
  40384. private _bendAxis;
  40385. private _slerping;
  40386. private _adjustRoll;
  40387. /**
  40388. * Gets or sets maximum allowed angle
  40389. */
  40390. get maxAngle(): number;
  40391. set maxAngle(value: number);
  40392. /**
  40393. * Creates a new BoneIKController
  40394. * @param mesh defines the mesh to control
  40395. * @param bone defines the bone to control
  40396. * @param options defines options to set up the controller
  40397. */
  40398. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40399. targetMesh?: AbstractMesh;
  40400. poleTargetMesh?: AbstractMesh;
  40401. poleTargetBone?: Bone;
  40402. poleTargetLocalOffset?: Vector3;
  40403. poleAngle?: number;
  40404. bendAxis?: Vector3;
  40405. maxAngle?: number;
  40406. slerpAmount?: number;
  40407. });
  40408. private _setMaxAngle;
  40409. /**
  40410. * Force the controller to update the bones
  40411. */
  40412. update(): void;
  40413. }
  40414. }
  40415. declare module "babylonjs/Bones/boneLookController" {
  40416. import { Vector3 } from "babylonjs/Maths/math.vector";
  40417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40418. import { Bone } from "babylonjs/Bones/bone";
  40419. import { Space } from "babylonjs/Maths/math.axis";
  40420. /**
  40421. * Class used to make a bone look toward a point in space
  40422. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40423. */
  40424. export class BoneLookController {
  40425. private static _tmpVecs;
  40426. private static _tmpQuat;
  40427. private static _tmpMats;
  40428. /**
  40429. * The target Vector3 that the bone will look at
  40430. */
  40431. target: Vector3;
  40432. /**
  40433. * The mesh that the bone is attached to
  40434. */
  40435. mesh: AbstractMesh;
  40436. /**
  40437. * The bone that will be looking to the target
  40438. */
  40439. bone: Bone;
  40440. /**
  40441. * The up axis of the coordinate system that is used when the bone is rotated
  40442. */
  40443. upAxis: Vector3;
  40444. /**
  40445. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40446. */
  40447. upAxisSpace: Space;
  40448. /**
  40449. * Used to make an adjustment to the yaw of the bone
  40450. */
  40451. adjustYaw: number;
  40452. /**
  40453. * Used to make an adjustment to the pitch of the bone
  40454. */
  40455. adjustPitch: number;
  40456. /**
  40457. * Used to make an adjustment to the roll of the bone
  40458. */
  40459. adjustRoll: number;
  40460. /**
  40461. * 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)
  40462. */
  40463. slerpAmount: number;
  40464. private _minYaw;
  40465. private _maxYaw;
  40466. private _minPitch;
  40467. private _maxPitch;
  40468. private _minYawSin;
  40469. private _minYawCos;
  40470. private _maxYawSin;
  40471. private _maxYawCos;
  40472. private _midYawConstraint;
  40473. private _minPitchTan;
  40474. private _maxPitchTan;
  40475. private _boneQuat;
  40476. private _slerping;
  40477. private _transformYawPitch;
  40478. private _transformYawPitchInv;
  40479. private _firstFrameSkipped;
  40480. private _yawRange;
  40481. private _fowardAxis;
  40482. /**
  40483. * Gets or sets the minimum yaw angle that the bone can look to
  40484. */
  40485. get minYaw(): number;
  40486. set minYaw(value: number);
  40487. /**
  40488. * Gets or sets the maximum yaw angle that the bone can look to
  40489. */
  40490. get maxYaw(): number;
  40491. set maxYaw(value: number);
  40492. /**
  40493. * Gets or sets the minimum pitch angle that the bone can look to
  40494. */
  40495. get minPitch(): number;
  40496. set minPitch(value: number);
  40497. /**
  40498. * Gets or sets the maximum pitch angle that the bone can look to
  40499. */
  40500. get maxPitch(): number;
  40501. set maxPitch(value: number);
  40502. /**
  40503. * Create a BoneLookController
  40504. * @param mesh the mesh that the bone belongs to
  40505. * @param bone the bone that will be looking to the target
  40506. * @param target the target Vector3 to look at
  40507. * @param options optional settings:
  40508. * * maxYaw: the maximum angle the bone will yaw to
  40509. * * minYaw: the minimum angle the bone will yaw to
  40510. * * maxPitch: the maximum angle the bone will pitch to
  40511. * * minPitch: the minimum angle the bone will yaw to
  40512. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40513. * * upAxis: the up axis of the coordinate system
  40514. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40515. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40516. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40517. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40518. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40519. * * adjustRoll: used to make an adjustment to the roll of the bone
  40520. **/
  40521. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40522. maxYaw?: number;
  40523. minYaw?: number;
  40524. maxPitch?: number;
  40525. minPitch?: number;
  40526. slerpAmount?: number;
  40527. upAxis?: Vector3;
  40528. upAxisSpace?: Space;
  40529. yawAxis?: Vector3;
  40530. pitchAxis?: Vector3;
  40531. adjustYaw?: number;
  40532. adjustPitch?: number;
  40533. adjustRoll?: number;
  40534. });
  40535. /**
  40536. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40537. */
  40538. update(): void;
  40539. private _getAngleDiff;
  40540. private _getAngleBetween;
  40541. private _isAngleBetween;
  40542. }
  40543. }
  40544. declare module "babylonjs/Bones/index" {
  40545. export * from "babylonjs/Bones/bone";
  40546. export * from "babylonjs/Bones/boneIKController";
  40547. export * from "babylonjs/Bones/boneLookController";
  40548. export * from "babylonjs/Bones/skeleton";
  40549. }
  40550. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40551. import { Nullable } from "babylonjs/types";
  40552. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40553. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40554. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40555. /**
  40556. * Manage the gamepad inputs to control an arc rotate camera.
  40557. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40558. */
  40559. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40560. /**
  40561. * Defines the camera the input is attached to.
  40562. */
  40563. camera: ArcRotateCamera;
  40564. /**
  40565. * Defines the gamepad the input is gathering event from.
  40566. */
  40567. gamepad: Nullable<Gamepad>;
  40568. /**
  40569. * Defines the gamepad rotation sensiblity.
  40570. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40571. */
  40572. gamepadRotationSensibility: number;
  40573. /**
  40574. * Defines the gamepad move sensiblity.
  40575. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40576. */
  40577. gamepadMoveSensibility: number;
  40578. private _yAxisScale;
  40579. /**
  40580. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40581. */
  40582. get invertYAxis(): boolean;
  40583. set invertYAxis(value: boolean);
  40584. private _onGamepadConnectedObserver;
  40585. private _onGamepadDisconnectedObserver;
  40586. /**
  40587. * Attach the input controls to a specific dom element to get the input from.
  40588. * @param element Defines the element the controls should be listened from
  40589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40590. */
  40591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40592. /**
  40593. * Detach the current controls from the specified dom element.
  40594. * @param element Defines the element to stop listening the inputs from
  40595. */
  40596. detachControl(element: Nullable<HTMLElement>): void;
  40597. /**
  40598. * Update the current camera state depending on the inputs that have been used this frame.
  40599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40600. */
  40601. checkInputs(): void;
  40602. /**
  40603. * Gets the class name of the current intput.
  40604. * @returns the class name
  40605. */
  40606. getClassName(): string;
  40607. /**
  40608. * Get the friendly name associated with the input class.
  40609. * @returns the input friendly name
  40610. */
  40611. getSimpleName(): string;
  40612. }
  40613. }
  40614. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40615. import { Nullable } from "babylonjs/types";
  40616. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40617. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40618. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40619. interface ArcRotateCameraInputsManager {
  40620. /**
  40621. * Add orientation input support to the input manager.
  40622. * @returns the current input manager
  40623. */
  40624. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40625. }
  40626. }
  40627. /**
  40628. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40630. */
  40631. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40632. /**
  40633. * Defines the camera the input is attached to.
  40634. */
  40635. camera: ArcRotateCamera;
  40636. /**
  40637. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40638. */
  40639. alphaCorrection: number;
  40640. /**
  40641. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40642. */
  40643. gammaCorrection: number;
  40644. private _alpha;
  40645. private _gamma;
  40646. private _dirty;
  40647. private _deviceOrientationHandler;
  40648. /**
  40649. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40650. */
  40651. constructor();
  40652. /**
  40653. * Attach the input controls to a specific dom element to get the input from.
  40654. * @param element Defines the element the controls should be listened from
  40655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40656. */
  40657. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40658. /** @hidden */
  40659. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40660. /**
  40661. * Update the current camera state depending on the inputs that have been used this frame.
  40662. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40663. */
  40664. checkInputs(): void;
  40665. /**
  40666. * Detach the current controls from the specified dom element.
  40667. * @param element Defines the element to stop listening the inputs from
  40668. */
  40669. detachControl(element: Nullable<HTMLElement>): void;
  40670. /**
  40671. * Gets the class name of the current intput.
  40672. * @returns the class name
  40673. */
  40674. getClassName(): string;
  40675. /**
  40676. * Get the friendly name associated with the input class.
  40677. * @returns the input friendly name
  40678. */
  40679. getSimpleName(): string;
  40680. }
  40681. }
  40682. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40683. import { Nullable } from "babylonjs/types";
  40684. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40685. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40686. /**
  40687. * Listen to mouse events to control the camera.
  40688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40689. */
  40690. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40691. /**
  40692. * Defines the camera the input is attached to.
  40693. */
  40694. camera: FlyCamera;
  40695. /**
  40696. * Defines if touch is enabled. (Default is true.)
  40697. */
  40698. touchEnabled: boolean;
  40699. /**
  40700. * Defines the buttons associated with the input to handle camera rotation.
  40701. */
  40702. buttons: number[];
  40703. /**
  40704. * Assign buttons for Yaw control.
  40705. */
  40706. buttonsYaw: number[];
  40707. /**
  40708. * Assign buttons for Pitch control.
  40709. */
  40710. buttonsPitch: number[];
  40711. /**
  40712. * Assign buttons for Roll control.
  40713. */
  40714. buttonsRoll: number[];
  40715. /**
  40716. * Detect if any button is being pressed while mouse is moved.
  40717. * -1 = Mouse locked.
  40718. * 0 = Left button.
  40719. * 1 = Middle Button.
  40720. * 2 = Right Button.
  40721. */
  40722. activeButton: number;
  40723. /**
  40724. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40725. * Higher values reduce its sensitivity.
  40726. */
  40727. angularSensibility: number;
  40728. private _mousemoveCallback;
  40729. private _observer;
  40730. private _rollObserver;
  40731. private previousPosition;
  40732. private noPreventDefault;
  40733. private element;
  40734. /**
  40735. * Listen to mouse events to control the camera.
  40736. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40738. */
  40739. constructor(touchEnabled?: boolean);
  40740. /**
  40741. * Attach the mouse control to the HTML DOM element.
  40742. * @param element Defines the element that listens to the input events.
  40743. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40744. */
  40745. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40746. /**
  40747. * Detach the current controls from the specified dom element.
  40748. * @param element Defines the element to stop listening the inputs from
  40749. */
  40750. detachControl(element: Nullable<HTMLElement>): void;
  40751. /**
  40752. * Gets the class name of the current input.
  40753. * @returns the class name.
  40754. */
  40755. getClassName(): string;
  40756. /**
  40757. * Get the friendly name associated with the input class.
  40758. * @returns the input's friendly name.
  40759. */
  40760. getSimpleName(): string;
  40761. private _pointerInput;
  40762. private _onMouseMove;
  40763. /**
  40764. * Rotate camera by mouse offset.
  40765. */
  40766. private rotateCamera;
  40767. }
  40768. }
  40769. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40770. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40771. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40772. /**
  40773. * Default Inputs manager for the FlyCamera.
  40774. * It groups all the default supported inputs for ease of use.
  40775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40776. */
  40777. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40778. /**
  40779. * Instantiates a new FlyCameraInputsManager.
  40780. * @param camera Defines the camera the inputs belong to.
  40781. */
  40782. constructor(camera: FlyCamera);
  40783. /**
  40784. * Add keyboard input support to the input manager.
  40785. * @returns the new FlyCameraKeyboardMoveInput().
  40786. */
  40787. addKeyboard(): FlyCameraInputsManager;
  40788. /**
  40789. * Add mouse input support to the input manager.
  40790. * @param touchEnabled Enable touch screen support.
  40791. * @returns the new FlyCameraMouseInput().
  40792. */
  40793. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40794. }
  40795. }
  40796. declare module "babylonjs/Cameras/flyCamera" {
  40797. import { Scene } from "babylonjs/scene";
  40798. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40800. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40801. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40802. /**
  40803. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40804. * such as in a 3D Space Shooter or a Flight Simulator.
  40805. */
  40806. export class FlyCamera extends TargetCamera {
  40807. /**
  40808. * Define the collision ellipsoid of the camera.
  40809. * This is helpful for simulating a camera body, like a player's body.
  40810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40811. */
  40812. ellipsoid: Vector3;
  40813. /**
  40814. * Define an offset for the position of the ellipsoid around the camera.
  40815. * This can be helpful if the camera is attached away from the player's body center,
  40816. * such as at its head.
  40817. */
  40818. ellipsoidOffset: Vector3;
  40819. /**
  40820. * Enable or disable collisions of the camera with the rest of the scene objects.
  40821. */
  40822. checkCollisions: boolean;
  40823. /**
  40824. * Enable or disable gravity on the camera.
  40825. */
  40826. applyGravity: boolean;
  40827. /**
  40828. * Define the current direction the camera is moving to.
  40829. */
  40830. cameraDirection: Vector3;
  40831. /**
  40832. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40833. * This overrides and empties cameraRotation.
  40834. */
  40835. rotationQuaternion: Quaternion;
  40836. /**
  40837. * Track Roll to maintain the wanted Rolling when looking around.
  40838. */
  40839. _trackRoll: number;
  40840. /**
  40841. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40842. */
  40843. rollCorrect: number;
  40844. /**
  40845. * Mimic a banked turn, Rolling the camera when Yawing.
  40846. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40847. */
  40848. bankedTurn: boolean;
  40849. /**
  40850. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40851. */
  40852. bankedTurnLimit: number;
  40853. /**
  40854. * Value of 0 disables the banked Roll.
  40855. * Value of 1 is equal to the Yaw angle in radians.
  40856. */
  40857. bankedTurnMultiplier: number;
  40858. /**
  40859. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40860. */
  40861. inputs: FlyCameraInputsManager;
  40862. /**
  40863. * Gets the input sensibility for mouse input.
  40864. * Higher values reduce sensitivity.
  40865. */
  40866. get angularSensibility(): number;
  40867. /**
  40868. * Sets the input sensibility for a mouse input.
  40869. * Higher values reduce sensitivity.
  40870. */
  40871. set angularSensibility(value: number);
  40872. /**
  40873. * Get the keys for camera movement forward.
  40874. */
  40875. get keysForward(): number[];
  40876. /**
  40877. * Set the keys for camera movement forward.
  40878. */
  40879. set keysForward(value: number[]);
  40880. /**
  40881. * Get the keys for camera movement backward.
  40882. */
  40883. get keysBackward(): number[];
  40884. set keysBackward(value: number[]);
  40885. /**
  40886. * Get the keys for camera movement up.
  40887. */
  40888. get keysUp(): number[];
  40889. /**
  40890. * Set the keys for camera movement up.
  40891. */
  40892. set keysUp(value: number[]);
  40893. /**
  40894. * Get the keys for camera movement down.
  40895. */
  40896. get keysDown(): number[];
  40897. /**
  40898. * Set the keys for camera movement down.
  40899. */
  40900. set keysDown(value: number[]);
  40901. /**
  40902. * Get the keys for camera movement left.
  40903. */
  40904. get keysLeft(): number[];
  40905. /**
  40906. * Set the keys for camera movement left.
  40907. */
  40908. set keysLeft(value: number[]);
  40909. /**
  40910. * Set the keys for camera movement right.
  40911. */
  40912. get keysRight(): number[];
  40913. /**
  40914. * Set the keys for camera movement right.
  40915. */
  40916. set keysRight(value: number[]);
  40917. /**
  40918. * Event raised when the camera collides with a mesh in the scene.
  40919. */
  40920. onCollide: (collidedMesh: AbstractMesh) => void;
  40921. private _collider;
  40922. private _needMoveForGravity;
  40923. private _oldPosition;
  40924. private _diffPosition;
  40925. private _newPosition;
  40926. /** @hidden */
  40927. _localDirection: Vector3;
  40928. /** @hidden */
  40929. _transformedDirection: Vector3;
  40930. /**
  40931. * Instantiates a FlyCamera.
  40932. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40933. * such as in a 3D Space Shooter or a Flight Simulator.
  40934. * @param name Define the name of the camera in the scene.
  40935. * @param position Define the starting position of the camera in the scene.
  40936. * @param scene Define the scene the camera belongs to.
  40937. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40938. */
  40939. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40940. /**
  40941. * Attach a control to the HTML DOM element.
  40942. * @param element Defines the element that listens to the input events.
  40943. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40944. */
  40945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40946. /**
  40947. * Detach a control from the HTML DOM element.
  40948. * The camera will stop reacting to that input.
  40949. * @param element Defines the element that listens to the input events.
  40950. */
  40951. detachControl(element: HTMLElement): void;
  40952. private _collisionMask;
  40953. /**
  40954. * Get the mask that the camera ignores in collision events.
  40955. */
  40956. get collisionMask(): number;
  40957. /**
  40958. * Set the mask that the camera ignores in collision events.
  40959. */
  40960. set collisionMask(mask: number);
  40961. /** @hidden */
  40962. _collideWithWorld(displacement: Vector3): void;
  40963. /** @hidden */
  40964. private _onCollisionPositionChange;
  40965. /** @hidden */
  40966. _checkInputs(): void;
  40967. /** @hidden */
  40968. _decideIfNeedsToMove(): boolean;
  40969. /** @hidden */
  40970. _updatePosition(): void;
  40971. /**
  40972. * Restore the Roll to its target value at the rate specified.
  40973. * @param rate - Higher means slower restoring.
  40974. * @hidden
  40975. */
  40976. restoreRoll(rate: number): void;
  40977. /**
  40978. * Destroy the camera and release the current resources held by it.
  40979. */
  40980. dispose(): void;
  40981. /**
  40982. * Get the current object class name.
  40983. * @returns the class name.
  40984. */
  40985. getClassName(): string;
  40986. }
  40987. }
  40988. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40989. import { Nullable } from "babylonjs/types";
  40990. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40991. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40992. /**
  40993. * Listen to keyboard events to control the camera.
  40994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40995. */
  40996. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40997. /**
  40998. * Defines the camera the input is attached to.
  40999. */
  41000. camera: FlyCamera;
  41001. /**
  41002. * The list of keyboard keys used to control the forward move of the camera.
  41003. */
  41004. keysForward: number[];
  41005. /**
  41006. * The list of keyboard keys used to control the backward move of the camera.
  41007. */
  41008. keysBackward: number[];
  41009. /**
  41010. * The list of keyboard keys used to control the forward move of the camera.
  41011. */
  41012. keysUp: number[];
  41013. /**
  41014. * The list of keyboard keys used to control the backward move of the camera.
  41015. */
  41016. keysDown: number[];
  41017. /**
  41018. * The list of keyboard keys used to control the right strafe move of the camera.
  41019. */
  41020. keysRight: number[];
  41021. /**
  41022. * The list of keyboard keys used to control the left strafe move of the camera.
  41023. */
  41024. keysLeft: number[];
  41025. private _keys;
  41026. private _onCanvasBlurObserver;
  41027. private _onKeyboardObserver;
  41028. private _engine;
  41029. private _scene;
  41030. /**
  41031. * Attach the input controls to a specific dom element to get the input from.
  41032. * @param element Defines the element the controls should be listened from
  41033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41034. */
  41035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41036. /**
  41037. * Detach the current controls from the specified dom element.
  41038. * @param element Defines the element to stop listening the inputs from
  41039. */
  41040. detachControl(element: Nullable<HTMLElement>): void;
  41041. /**
  41042. * Gets the class name of the current intput.
  41043. * @returns the class name
  41044. */
  41045. getClassName(): string;
  41046. /** @hidden */
  41047. _onLostFocus(e: FocusEvent): void;
  41048. /**
  41049. * Get the friendly name associated with the input class.
  41050. * @returns the input friendly name
  41051. */
  41052. getSimpleName(): string;
  41053. /**
  41054. * Update the current camera state depending on the inputs that have been used this frame.
  41055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41056. */
  41057. checkInputs(): void;
  41058. }
  41059. }
  41060. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41061. import { Nullable } from "babylonjs/types";
  41062. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41063. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41064. /**
  41065. * Manage the mouse wheel inputs to control a follow camera.
  41066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41067. */
  41068. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41069. /**
  41070. * Defines the camera the input is attached to.
  41071. */
  41072. camera: FollowCamera;
  41073. /**
  41074. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41075. */
  41076. axisControlRadius: boolean;
  41077. /**
  41078. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41079. */
  41080. axisControlHeight: boolean;
  41081. /**
  41082. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41083. */
  41084. axisControlRotation: boolean;
  41085. /**
  41086. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41087. * relation to mouseWheel events.
  41088. */
  41089. wheelPrecision: number;
  41090. /**
  41091. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41092. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41093. */
  41094. wheelDeltaPercentage: number;
  41095. private _wheel;
  41096. private _observer;
  41097. /**
  41098. * Attach the input controls to a specific dom element to get the input from.
  41099. * @param element Defines the element the controls should be listened from
  41100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41101. */
  41102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41103. /**
  41104. * Detach the current controls from the specified dom element.
  41105. * @param element Defines the element to stop listening the inputs from
  41106. */
  41107. detachControl(element: Nullable<HTMLElement>): void;
  41108. /**
  41109. * Gets the class name of the current intput.
  41110. * @returns the class name
  41111. */
  41112. getClassName(): string;
  41113. /**
  41114. * Get the friendly name associated with the input class.
  41115. * @returns the input friendly name
  41116. */
  41117. getSimpleName(): string;
  41118. }
  41119. }
  41120. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41121. import { Nullable } from "babylonjs/types";
  41122. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41123. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41124. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41125. /**
  41126. * Manage the pointers inputs to control an follow camera.
  41127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41128. */
  41129. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41130. /**
  41131. * Defines the camera the input is attached to.
  41132. */
  41133. camera: FollowCamera;
  41134. /**
  41135. * Gets the class name of the current input.
  41136. * @returns the class name
  41137. */
  41138. getClassName(): string;
  41139. /**
  41140. * Defines the pointer angular sensibility along the X axis or how fast is
  41141. * the camera rotating.
  41142. * A negative number will reverse the axis direction.
  41143. */
  41144. angularSensibilityX: number;
  41145. /**
  41146. * Defines the pointer angular sensibility along the Y axis or how fast is
  41147. * the camera rotating.
  41148. * A negative number will reverse the axis direction.
  41149. */
  41150. angularSensibilityY: number;
  41151. /**
  41152. * Defines the pointer pinch precision or how fast is the camera zooming.
  41153. * A negative number will reverse the axis direction.
  41154. */
  41155. pinchPrecision: number;
  41156. /**
  41157. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41158. * from 0.
  41159. * It defines the percentage of current camera.radius to use as delta when
  41160. * pinch zoom is used.
  41161. */
  41162. pinchDeltaPercentage: number;
  41163. /**
  41164. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41165. */
  41166. axisXControlRadius: boolean;
  41167. /**
  41168. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41169. */
  41170. axisXControlHeight: boolean;
  41171. /**
  41172. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41173. */
  41174. axisXControlRotation: boolean;
  41175. /**
  41176. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41177. */
  41178. axisYControlRadius: boolean;
  41179. /**
  41180. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41181. */
  41182. axisYControlHeight: boolean;
  41183. /**
  41184. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41185. */
  41186. axisYControlRotation: boolean;
  41187. /**
  41188. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41189. */
  41190. axisPinchControlRadius: boolean;
  41191. /**
  41192. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41193. */
  41194. axisPinchControlHeight: boolean;
  41195. /**
  41196. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41197. */
  41198. axisPinchControlRotation: boolean;
  41199. /**
  41200. * Log error messages if basic misconfiguration has occurred.
  41201. */
  41202. warningEnable: boolean;
  41203. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41204. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41205. private _warningCounter;
  41206. private _warning;
  41207. }
  41208. }
  41209. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41210. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41211. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41212. /**
  41213. * Default Inputs manager for the FollowCamera.
  41214. * It groups all the default supported inputs for ease of use.
  41215. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41216. */
  41217. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41218. /**
  41219. * Instantiates a new FollowCameraInputsManager.
  41220. * @param camera Defines the camera the inputs belong to
  41221. */
  41222. constructor(camera: FollowCamera);
  41223. /**
  41224. * Add keyboard input support to the input manager.
  41225. * @returns the current input manager
  41226. */
  41227. addKeyboard(): FollowCameraInputsManager;
  41228. /**
  41229. * Add mouse wheel input support to the input manager.
  41230. * @returns the current input manager
  41231. */
  41232. addMouseWheel(): FollowCameraInputsManager;
  41233. /**
  41234. * Add pointers input support to the input manager.
  41235. * @returns the current input manager
  41236. */
  41237. addPointers(): FollowCameraInputsManager;
  41238. /**
  41239. * Add orientation input support to the input manager.
  41240. * @returns the current input manager
  41241. */
  41242. addVRDeviceOrientation(): FollowCameraInputsManager;
  41243. }
  41244. }
  41245. declare module "babylonjs/Cameras/followCamera" {
  41246. import { Nullable } from "babylonjs/types";
  41247. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41248. import { Scene } from "babylonjs/scene";
  41249. import { Vector3 } from "babylonjs/Maths/math.vector";
  41250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41251. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41252. /**
  41253. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41254. * an arc rotate version arcFollowCamera are available.
  41255. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41256. */
  41257. export class FollowCamera extends TargetCamera {
  41258. /**
  41259. * Distance the follow camera should follow an object at
  41260. */
  41261. radius: number;
  41262. /**
  41263. * Minimum allowed distance of the camera to the axis of rotation
  41264. * (The camera can not get closer).
  41265. * This can help limiting how the Camera is able to move in the scene.
  41266. */
  41267. lowerRadiusLimit: Nullable<number>;
  41268. /**
  41269. * Maximum allowed distance of the camera to the axis of rotation
  41270. * (The camera can not get further).
  41271. * This can help limiting how the Camera is able to move in the scene.
  41272. */
  41273. upperRadiusLimit: Nullable<number>;
  41274. /**
  41275. * Define a rotation offset between the camera and the object it follows
  41276. */
  41277. rotationOffset: number;
  41278. /**
  41279. * Minimum allowed angle to camera position relative to target object.
  41280. * This can help limiting how the Camera is able to move in the scene.
  41281. */
  41282. lowerRotationOffsetLimit: Nullable<number>;
  41283. /**
  41284. * Maximum allowed angle to camera position relative to target object.
  41285. * This can help limiting how the Camera is able to move in the scene.
  41286. */
  41287. upperRotationOffsetLimit: Nullable<number>;
  41288. /**
  41289. * Define a height offset between the camera and the object it follows.
  41290. * It can help following an object from the top (like a car chaing a plane)
  41291. */
  41292. heightOffset: number;
  41293. /**
  41294. * Minimum allowed height of camera position relative to target object.
  41295. * This can help limiting how the Camera is able to move in the scene.
  41296. */
  41297. lowerHeightOffsetLimit: Nullable<number>;
  41298. /**
  41299. * Maximum allowed height of camera position relative to target object.
  41300. * This can help limiting how the Camera is able to move in the scene.
  41301. */
  41302. upperHeightOffsetLimit: Nullable<number>;
  41303. /**
  41304. * Define how fast the camera can accelerate to follow it s target.
  41305. */
  41306. cameraAcceleration: number;
  41307. /**
  41308. * Define the speed limit of the camera following an object.
  41309. */
  41310. maxCameraSpeed: number;
  41311. /**
  41312. * Define the target of the camera.
  41313. */
  41314. lockedTarget: Nullable<AbstractMesh>;
  41315. /**
  41316. * Defines the input associated with the camera.
  41317. */
  41318. inputs: FollowCameraInputsManager;
  41319. /**
  41320. * Instantiates the follow camera.
  41321. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41322. * @param name Define the name of the camera in the scene
  41323. * @param position Define the position of the camera
  41324. * @param scene Define the scene the camera belong to
  41325. * @param lockedTarget Define the target of the camera
  41326. */
  41327. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41328. private _follow;
  41329. /**
  41330. * Attached controls to the current camera.
  41331. * @param element Defines the element the controls should be listened from
  41332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41333. */
  41334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41335. /**
  41336. * Detach the current controls from the camera.
  41337. * The camera will stop reacting to inputs.
  41338. * @param element Defines the element to stop listening the inputs from
  41339. */
  41340. detachControl(element: HTMLElement): void;
  41341. /** @hidden */
  41342. _checkInputs(): void;
  41343. private _checkLimits;
  41344. /**
  41345. * Gets the camera class name.
  41346. * @returns the class name
  41347. */
  41348. getClassName(): string;
  41349. }
  41350. /**
  41351. * Arc Rotate version of the follow camera.
  41352. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41353. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41354. */
  41355. export class ArcFollowCamera extends TargetCamera {
  41356. /** The longitudinal angle of the camera */
  41357. alpha: number;
  41358. /** The latitudinal angle of the camera */
  41359. beta: number;
  41360. /** The radius of the camera from its target */
  41361. radius: number;
  41362. /** Define the camera target (the messh it should follow) */
  41363. target: Nullable<AbstractMesh>;
  41364. private _cartesianCoordinates;
  41365. /**
  41366. * Instantiates a new ArcFollowCamera
  41367. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41368. * @param name Define the name of the camera
  41369. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41370. * @param beta Define the rotation angle of the camera around the elevation axis
  41371. * @param radius Define the radius of the camera from its target point
  41372. * @param target Define the target of the camera
  41373. * @param scene Define the scene the camera belongs to
  41374. */
  41375. constructor(name: string,
  41376. /** The longitudinal angle of the camera */
  41377. alpha: number,
  41378. /** The latitudinal angle of the camera */
  41379. beta: number,
  41380. /** The radius of the camera from its target */
  41381. radius: number,
  41382. /** Define the camera target (the messh it should follow) */
  41383. target: Nullable<AbstractMesh>, scene: Scene);
  41384. private _follow;
  41385. /** @hidden */
  41386. _checkInputs(): void;
  41387. /**
  41388. * Returns the class name of the object.
  41389. * It is mostly used internally for serialization purposes.
  41390. */
  41391. getClassName(): string;
  41392. }
  41393. }
  41394. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41395. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41396. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41397. import { Nullable } from "babylonjs/types";
  41398. /**
  41399. * Manage the keyboard inputs to control the movement of a follow camera.
  41400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41401. */
  41402. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41403. /**
  41404. * Defines the camera the input is attached to.
  41405. */
  41406. camera: FollowCamera;
  41407. /**
  41408. * Defines the list of key codes associated with the up action (increase heightOffset)
  41409. */
  41410. keysHeightOffsetIncr: number[];
  41411. /**
  41412. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41413. */
  41414. keysHeightOffsetDecr: number[];
  41415. /**
  41416. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41417. */
  41418. keysHeightOffsetModifierAlt: boolean;
  41419. /**
  41420. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41421. */
  41422. keysHeightOffsetModifierCtrl: boolean;
  41423. /**
  41424. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41425. */
  41426. keysHeightOffsetModifierShift: boolean;
  41427. /**
  41428. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41429. */
  41430. keysRotationOffsetIncr: number[];
  41431. /**
  41432. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41433. */
  41434. keysRotationOffsetDecr: number[];
  41435. /**
  41436. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41437. */
  41438. keysRotationOffsetModifierAlt: boolean;
  41439. /**
  41440. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41441. */
  41442. keysRotationOffsetModifierCtrl: boolean;
  41443. /**
  41444. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41445. */
  41446. keysRotationOffsetModifierShift: boolean;
  41447. /**
  41448. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41449. */
  41450. keysRadiusIncr: number[];
  41451. /**
  41452. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41453. */
  41454. keysRadiusDecr: number[];
  41455. /**
  41456. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41457. */
  41458. keysRadiusModifierAlt: boolean;
  41459. /**
  41460. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41461. */
  41462. keysRadiusModifierCtrl: boolean;
  41463. /**
  41464. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41465. */
  41466. keysRadiusModifierShift: boolean;
  41467. /**
  41468. * Defines the rate of change of heightOffset.
  41469. */
  41470. heightSensibility: number;
  41471. /**
  41472. * Defines the rate of change of rotationOffset.
  41473. */
  41474. rotationSensibility: number;
  41475. /**
  41476. * Defines the rate of change of radius.
  41477. */
  41478. radiusSensibility: number;
  41479. private _keys;
  41480. private _ctrlPressed;
  41481. private _altPressed;
  41482. private _shiftPressed;
  41483. private _onCanvasBlurObserver;
  41484. private _onKeyboardObserver;
  41485. private _engine;
  41486. private _scene;
  41487. /**
  41488. * Attach the input controls to a specific dom element to get the input from.
  41489. * @param element Defines the element the controls should be listened from
  41490. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41491. */
  41492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41493. /**
  41494. * Detach the current controls from the specified dom element.
  41495. * @param element Defines the element to stop listening the inputs from
  41496. */
  41497. detachControl(element: Nullable<HTMLElement>): void;
  41498. /**
  41499. * Update the current camera state depending on the inputs that have been used this frame.
  41500. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41501. */
  41502. checkInputs(): void;
  41503. /**
  41504. * Gets the class name of the current input.
  41505. * @returns the class name
  41506. */
  41507. getClassName(): string;
  41508. /**
  41509. * Get the friendly name associated with the input class.
  41510. * @returns the input friendly name
  41511. */
  41512. getSimpleName(): string;
  41513. /**
  41514. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41515. * allow modification of the heightOffset value.
  41516. */
  41517. private _modifierHeightOffset;
  41518. /**
  41519. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41520. * allow modification of the rotationOffset value.
  41521. */
  41522. private _modifierRotationOffset;
  41523. /**
  41524. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41525. * allow modification of the radius value.
  41526. */
  41527. private _modifierRadius;
  41528. }
  41529. }
  41530. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41531. import { Nullable } from "babylonjs/types";
  41532. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41533. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41534. import { Observable } from "babylonjs/Misc/observable";
  41535. module "babylonjs/Cameras/freeCameraInputsManager" {
  41536. interface FreeCameraInputsManager {
  41537. /**
  41538. * @hidden
  41539. */
  41540. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41541. /**
  41542. * Add orientation input support to the input manager.
  41543. * @returns the current input manager
  41544. */
  41545. addDeviceOrientation(): FreeCameraInputsManager;
  41546. }
  41547. }
  41548. /**
  41549. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41550. * Screen rotation is taken into account.
  41551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41552. */
  41553. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41554. private _camera;
  41555. private _screenOrientationAngle;
  41556. private _constantTranform;
  41557. private _screenQuaternion;
  41558. private _alpha;
  41559. private _beta;
  41560. private _gamma;
  41561. /**
  41562. * Can be used to detect if a device orientation sensor is available on a device
  41563. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41564. * @returns a promise that will resolve on orientation change
  41565. */
  41566. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41567. /**
  41568. * @hidden
  41569. */
  41570. _onDeviceOrientationChangedObservable: Observable<void>;
  41571. /**
  41572. * Instantiates a new input
  41573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41574. */
  41575. constructor();
  41576. /**
  41577. * Define the camera controlled by the input.
  41578. */
  41579. get camera(): FreeCamera;
  41580. set camera(camera: FreeCamera);
  41581. /**
  41582. * Attach the input controls to a specific dom element to get the input from.
  41583. * @param element Defines the element the controls should be listened from
  41584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41585. */
  41586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41587. private _orientationChanged;
  41588. private _deviceOrientation;
  41589. /**
  41590. * Detach the current controls from the specified dom element.
  41591. * @param element Defines the element to stop listening the inputs from
  41592. */
  41593. detachControl(element: Nullable<HTMLElement>): void;
  41594. /**
  41595. * Update the current camera state depending on the inputs that have been used this frame.
  41596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41597. */
  41598. checkInputs(): void;
  41599. /**
  41600. * Gets the class name of the current intput.
  41601. * @returns the class name
  41602. */
  41603. getClassName(): string;
  41604. /**
  41605. * Get the friendly name associated with the input class.
  41606. * @returns the input friendly name
  41607. */
  41608. getSimpleName(): string;
  41609. }
  41610. }
  41611. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41612. import { Nullable } from "babylonjs/types";
  41613. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41614. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41615. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41616. /**
  41617. * Manage the gamepad inputs to control a free camera.
  41618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41619. */
  41620. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41621. /**
  41622. * Define the camera the input is attached to.
  41623. */
  41624. camera: FreeCamera;
  41625. /**
  41626. * Define the Gamepad controlling the input
  41627. */
  41628. gamepad: Nullable<Gamepad>;
  41629. /**
  41630. * Defines the gamepad rotation sensiblity.
  41631. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41632. */
  41633. gamepadAngularSensibility: number;
  41634. /**
  41635. * Defines the gamepad move sensiblity.
  41636. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41637. */
  41638. gamepadMoveSensibility: number;
  41639. private _yAxisScale;
  41640. /**
  41641. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41642. */
  41643. get invertYAxis(): boolean;
  41644. set invertYAxis(value: boolean);
  41645. private _onGamepadConnectedObserver;
  41646. private _onGamepadDisconnectedObserver;
  41647. private _cameraTransform;
  41648. private _deltaTransform;
  41649. private _vector3;
  41650. private _vector2;
  41651. /**
  41652. * Attach the input controls to a specific dom element to get the input from.
  41653. * @param element Defines the element the controls should be listened from
  41654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41655. */
  41656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41657. /**
  41658. * Detach the current controls from the specified dom element.
  41659. * @param element Defines the element to stop listening the inputs from
  41660. */
  41661. detachControl(element: Nullable<HTMLElement>): void;
  41662. /**
  41663. * Update the current camera state depending on the inputs that have been used this frame.
  41664. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41665. */
  41666. checkInputs(): void;
  41667. /**
  41668. * Gets the class name of the current intput.
  41669. * @returns the class name
  41670. */
  41671. getClassName(): string;
  41672. /**
  41673. * Get the friendly name associated with the input class.
  41674. * @returns the input friendly name
  41675. */
  41676. getSimpleName(): string;
  41677. }
  41678. }
  41679. declare module "babylonjs/Misc/virtualJoystick" {
  41680. import { Nullable } from "babylonjs/types";
  41681. import { Vector3 } from "babylonjs/Maths/math.vector";
  41682. /**
  41683. * Defines the potential axis of a Joystick
  41684. */
  41685. export enum JoystickAxis {
  41686. /** X axis */
  41687. X = 0,
  41688. /** Y axis */
  41689. Y = 1,
  41690. /** Z axis */
  41691. Z = 2
  41692. }
  41693. /**
  41694. * Class used to define virtual joystick (used in touch mode)
  41695. */
  41696. export class VirtualJoystick {
  41697. /**
  41698. * Gets or sets a boolean indicating that left and right values must be inverted
  41699. */
  41700. reverseLeftRight: boolean;
  41701. /**
  41702. * Gets or sets a boolean indicating that up and down values must be inverted
  41703. */
  41704. reverseUpDown: boolean;
  41705. /**
  41706. * Gets the offset value for the position (ie. the change of the position value)
  41707. */
  41708. deltaPosition: Vector3;
  41709. /**
  41710. * Gets a boolean indicating if the virtual joystick was pressed
  41711. */
  41712. pressed: boolean;
  41713. /**
  41714. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41715. */
  41716. static Canvas: Nullable<HTMLCanvasElement>;
  41717. private static _globalJoystickIndex;
  41718. private static vjCanvasContext;
  41719. private static vjCanvasWidth;
  41720. private static vjCanvasHeight;
  41721. private static halfWidth;
  41722. private _action;
  41723. private _axisTargetedByLeftAndRight;
  41724. private _axisTargetedByUpAndDown;
  41725. private _joystickSensibility;
  41726. private _inversedSensibility;
  41727. private _joystickPointerID;
  41728. private _joystickColor;
  41729. private _joystickPointerPos;
  41730. private _joystickPreviousPointerPos;
  41731. private _joystickPointerStartPos;
  41732. private _deltaJoystickVector;
  41733. private _leftJoystick;
  41734. private _touches;
  41735. private _onPointerDownHandlerRef;
  41736. private _onPointerMoveHandlerRef;
  41737. private _onPointerUpHandlerRef;
  41738. private _onResize;
  41739. /**
  41740. * Creates a new virtual joystick
  41741. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41742. */
  41743. constructor(leftJoystick?: boolean);
  41744. /**
  41745. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41746. * @param newJoystickSensibility defines the new sensibility
  41747. */
  41748. setJoystickSensibility(newJoystickSensibility: number): void;
  41749. private _onPointerDown;
  41750. private _onPointerMove;
  41751. private _onPointerUp;
  41752. /**
  41753. * Change the color of the virtual joystick
  41754. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41755. */
  41756. setJoystickColor(newColor: string): void;
  41757. /**
  41758. * Defines a callback to call when the joystick is touched
  41759. * @param action defines the callback
  41760. */
  41761. setActionOnTouch(action: () => any): void;
  41762. /**
  41763. * Defines which axis you'd like to control for left & right
  41764. * @param axis defines the axis to use
  41765. */
  41766. setAxisForLeftRight(axis: JoystickAxis): void;
  41767. /**
  41768. * Defines which axis you'd like to control for up & down
  41769. * @param axis defines the axis to use
  41770. */
  41771. setAxisForUpDown(axis: JoystickAxis): void;
  41772. private _drawVirtualJoystick;
  41773. /**
  41774. * Release internal HTML canvas
  41775. */
  41776. releaseCanvas(): void;
  41777. }
  41778. }
  41779. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41780. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41781. import { Nullable } from "babylonjs/types";
  41782. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41783. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41784. module "babylonjs/Cameras/freeCameraInputsManager" {
  41785. interface FreeCameraInputsManager {
  41786. /**
  41787. * Add virtual joystick input support to the input manager.
  41788. * @returns the current input manager
  41789. */
  41790. addVirtualJoystick(): FreeCameraInputsManager;
  41791. }
  41792. }
  41793. /**
  41794. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41796. */
  41797. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41798. /**
  41799. * Defines the camera the input is attached to.
  41800. */
  41801. camera: FreeCamera;
  41802. private _leftjoystick;
  41803. private _rightjoystick;
  41804. /**
  41805. * Gets the left stick of the virtual joystick.
  41806. * @returns The virtual Joystick
  41807. */
  41808. getLeftJoystick(): VirtualJoystick;
  41809. /**
  41810. * Gets the right stick of the virtual joystick.
  41811. * @returns The virtual Joystick
  41812. */
  41813. getRightJoystick(): VirtualJoystick;
  41814. /**
  41815. * Update the current camera state depending on the inputs that have been used this frame.
  41816. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41817. */
  41818. checkInputs(): void;
  41819. /**
  41820. * Attach the input controls to a specific dom element to get the input from.
  41821. * @param element Defines the element the controls should be listened from
  41822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41823. */
  41824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41825. /**
  41826. * Detach the current controls from the specified dom element.
  41827. * @param element Defines the element to stop listening the inputs from
  41828. */
  41829. detachControl(element: Nullable<HTMLElement>): void;
  41830. /**
  41831. * Gets the class name of the current intput.
  41832. * @returns the class name
  41833. */
  41834. getClassName(): string;
  41835. /**
  41836. * Get the friendly name associated with the input class.
  41837. * @returns the input friendly name
  41838. */
  41839. getSimpleName(): string;
  41840. }
  41841. }
  41842. declare module "babylonjs/Cameras/Inputs/index" {
  41843. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41844. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41845. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41846. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41847. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41848. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41849. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41850. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41851. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41852. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41853. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41854. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41855. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41856. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41857. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41858. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41859. }
  41860. declare module "babylonjs/Cameras/touchCamera" {
  41861. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41862. import { Scene } from "babylonjs/scene";
  41863. import { Vector3 } from "babylonjs/Maths/math.vector";
  41864. /**
  41865. * This represents a FPS type of camera controlled by touch.
  41866. * This is like a universal camera minus the Gamepad controls.
  41867. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41868. */
  41869. export class TouchCamera extends FreeCamera {
  41870. /**
  41871. * Defines the touch sensibility for rotation.
  41872. * The higher the faster.
  41873. */
  41874. get touchAngularSensibility(): number;
  41875. set touchAngularSensibility(value: number);
  41876. /**
  41877. * Defines the touch sensibility for move.
  41878. * The higher the faster.
  41879. */
  41880. get touchMoveSensibility(): number;
  41881. set touchMoveSensibility(value: number);
  41882. /**
  41883. * Instantiates a new touch camera.
  41884. * This represents a FPS type of camera controlled by touch.
  41885. * This is like a universal camera minus the Gamepad controls.
  41886. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41887. * @param name Define the name of the camera in the scene
  41888. * @param position Define the start position of the camera in the scene
  41889. * @param scene Define the scene the camera belongs to
  41890. */
  41891. constructor(name: string, position: Vector3, scene: Scene);
  41892. /**
  41893. * Gets the current object class name.
  41894. * @return the class name
  41895. */
  41896. getClassName(): string;
  41897. /** @hidden */
  41898. _setupInputs(): void;
  41899. }
  41900. }
  41901. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41902. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41903. import { Scene } from "babylonjs/scene";
  41904. import { Vector3 } from "babylonjs/Maths/math.vector";
  41905. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41906. import { Axis } from "babylonjs/Maths/math.axis";
  41907. /**
  41908. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41909. * being tilted forward or back and left or right.
  41910. */
  41911. export class DeviceOrientationCamera extends FreeCamera {
  41912. private _initialQuaternion;
  41913. private _quaternionCache;
  41914. private _tmpDragQuaternion;
  41915. private _disablePointerInputWhenUsingDeviceOrientation;
  41916. /**
  41917. * Creates a new device orientation camera
  41918. * @param name The name of the camera
  41919. * @param position The start position camera
  41920. * @param scene The scene the camera belongs to
  41921. */
  41922. constructor(name: string, position: Vector3, scene: Scene);
  41923. /**
  41924. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41925. */
  41926. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41927. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41928. private _dragFactor;
  41929. /**
  41930. * Enabled turning on the y axis when the orientation sensor is active
  41931. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41932. */
  41933. enableHorizontalDragging(dragFactor?: number): void;
  41934. /**
  41935. * Gets the current instance class name ("DeviceOrientationCamera").
  41936. * This helps avoiding instanceof at run time.
  41937. * @returns the class name
  41938. */
  41939. getClassName(): string;
  41940. /**
  41941. * @hidden
  41942. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41943. */
  41944. _checkInputs(): void;
  41945. /**
  41946. * Reset the camera to its default orientation on the specified axis only.
  41947. * @param axis The axis to reset
  41948. */
  41949. resetToCurrentRotation(axis?: Axis): void;
  41950. }
  41951. }
  41952. declare module "babylonjs/Gamepads/xboxGamepad" {
  41953. import { Observable } from "babylonjs/Misc/observable";
  41954. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41955. /**
  41956. * Defines supported buttons for XBox360 compatible gamepads
  41957. */
  41958. export enum Xbox360Button {
  41959. /** A */
  41960. A = 0,
  41961. /** B */
  41962. B = 1,
  41963. /** X */
  41964. X = 2,
  41965. /** Y */
  41966. Y = 3,
  41967. /** Start */
  41968. Start = 4,
  41969. /** Back */
  41970. Back = 5,
  41971. /** Left button */
  41972. LB = 6,
  41973. /** Right button */
  41974. RB = 7,
  41975. /** Left stick */
  41976. LeftStick = 8,
  41977. /** Right stick */
  41978. RightStick = 9
  41979. }
  41980. /** Defines values for XBox360 DPad */
  41981. export enum Xbox360Dpad {
  41982. /** Up */
  41983. Up = 0,
  41984. /** Down */
  41985. Down = 1,
  41986. /** Left */
  41987. Left = 2,
  41988. /** Right */
  41989. Right = 3
  41990. }
  41991. /**
  41992. * Defines a XBox360 gamepad
  41993. */
  41994. export class Xbox360Pad extends Gamepad {
  41995. private _leftTrigger;
  41996. private _rightTrigger;
  41997. private _onlefttriggerchanged;
  41998. private _onrighttriggerchanged;
  41999. private _onbuttondown;
  42000. private _onbuttonup;
  42001. private _ondpaddown;
  42002. private _ondpadup;
  42003. /** Observable raised when a button is pressed */
  42004. onButtonDownObservable: Observable<Xbox360Button>;
  42005. /** Observable raised when a button is released */
  42006. onButtonUpObservable: Observable<Xbox360Button>;
  42007. /** Observable raised when a pad is pressed */
  42008. onPadDownObservable: Observable<Xbox360Dpad>;
  42009. /** Observable raised when a pad is released */
  42010. onPadUpObservable: Observable<Xbox360Dpad>;
  42011. private _buttonA;
  42012. private _buttonB;
  42013. private _buttonX;
  42014. private _buttonY;
  42015. private _buttonBack;
  42016. private _buttonStart;
  42017. private _buttonLB;
  42018. private _buttonRB;
  42019. private _buttonLeftStick;
  42020. private _buttonRightStick;
  42021. private _dPadUp;
  42022. private _dPadDown;
  42023. private _dPadLeft;
  42024. private _dPadRight;
  42025. private _isXboxOnePad;
  42026. /**
  42027. * Creates a new XBox360 gamepad object
  42028. * @param id defines the id of this gamepad
  42029. * @param index defines its index
  42030. * @param gamepad defines the internal HTML gamepad object
  42031. * @param xboxOne defines if it is a XBox One gamepad
  42032. */
  42033. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42034. /**
  42035. * Defines the callback to call when left trigger is pressed
  42036. * @param callback defines the callback to use
  42037. */
  42038. onlefttriggerchanged(callback: (value: number) => void): void;
  42039. /**
  42040. * Defines the callback to call when right trigger is pressed
  42041. * @param callback defines the callback to use
  42042. */
  42043. onrighttriggerchanged(callback: (value: number) => void): void;
  42044. /**
  42045. * Gets the left trigger value
  42046. */
  42047. get leftTrigger(): number;
  42048. /**
  42049. * Sets the left trigger value
  42050. */
  42051. set leftTrigger(newValue: number);
  42052. /**
  42053. * Gets the right trigger value
  42054. */
  42055. get rightTrigger(): number;
  42056. /**
  42057. * Sets the right trigger value
  42058. */
  42059. set rightTrigger(newValue: number);
  42060. /**
  42061. * Defines the callback to call when a button is pressed
  42062. * @param callback defines the callback to use
  42063. */
  42064. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42065. /**
  42066. * Defines the callback to call when a button is released
  42067. * @param callback defines the callback to use
  42068. */
  42069. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42070. /**
  42071. * Defines the callback to call when a pad is pressed
  42072. * @param callback defines the callback to use
  42073. */
  42074. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42075. /**
  42076. * Defines the callback to call when a pad is released
  42077. * @param callback defines the callback to use
  42078. */
  42079. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42080. private _setButtonValue;
  42081. private _setDPadValue;
  42082. /**
  42083. * Gets the value of the `A` button
  42084. */
  42085. get buttonA(): number;
  42086. /**
  42087. * Sets the value of the `A` button
  42088. */
  42089. set buttonA(value: number);
  42090. /**
  42091. * Gets the value of the `B` button
  42092. */
  42093. get buttonB(): number;
  42094. /**
  42095. * Sets the value of the `B` button
  42096. */
  42097. set buttonB(value: number);
  42098. /**
  42099. * Gets the value of the `X` button
  42100. */
  42101. get buttonX(): number;
  42102. /**
  42103. * Sets the value of the `X` button
  42104. */
  42105. set buttonX(value: number);
  42106. /**
  42107. * Gets the value of the `Y` button
  42108. */
  42109. get buttonY(): number;
  42110. /**
  42111. * Sets the value of the `Y` button
  42112. */
  42113. set buttonY(value: number);
  42114. /**
  42115. * Gets the value of the `Start` button
  42116. */
  42117. get buttonStart(): number;
  42118. /**
  42119. * Sets the value of the `Start` button
  42120. */
  42121. set buttonStart(value: number);
  42122. /**
  42123. * Gets the value of the `Back` button
  42124. */
  42125. get buttonBack(): number;
  42126. /**
  42127. * Sets the value of the `Back` button
  42128. */
  42129. set buttonBack(value: number);
  42130. /**
  42131. * Gets the value of the `Left` button
  42132. */
  42133. get buttonLB(): number;
  42134. /**
  42135. * Sets the value of the `Left` button
  42136. */
  42137. set buttonLB(value: number);
  42138. /**
  42139. * Gets the value of the `Right` button
  42140. */
  42141. get buttonRB(): number;
  42142. /**
  42143. * Sets the value of the `Right` button
  42144. */
  42145. set buttonRB(value: number);
  42146. /**
  42147. * Gets the value of the Left joystick
  42148. */
  42149. get buttonLeftStick(): number;
  42150. /**
  42151. * Sets the value of the Left joystick
  42152. */
  42153. set buttonLeftStick(value: number);
  42154. /**
  42155. * Gets the value of the Right joystick
  42156. */
  42157. get buttonRightStick(): number;
  42158. /**
  42159. * Sets the value of the Right joystick
  42160. */
  42161. set buttonRightStick(value: number);
  42162. /**
  42163. * Gets the value of D-pad up
  42164. */
  42165. get dPadUp(): number;
  42166. /**
  42167. * Sets the value of D-pad up
  42168. */
  42169. set dPadUp(value: number);
  42170. /**
  42171. * Gets the value of D-pad down
  42172. */
  42173. get dPadDown(): number;
  42174. /**
  42175. * Sets the value of D-pad down
  42176. */
  42177. set dPadDown(value: number);
  42178. /**
  42179. * Gets the value of D-pad left
  42180. */
  42181. get dPadLeft(): number;
  42182. /**
  42183. * Sets the value of D-pad left
  42184. */
  42185. set dPadLeft(value: number);
  42186. /**
  42187. * Gets the value of D-pad right
  42188. */
  42189. get dPadRight(): number;
  42190. /**
  42191. * Sets the value of D-pad right
  42192. */
  42193. set dPadRight(value: number);
  42194. /**
  42195. * Force the gamepad to synchronize with device values
  42196. */
  42197. update(): void;
  42198. /**
  42199. * Disposes the gamepad
  42200. */
  42201. dispose(): void;
  42202. }
  42203. }
  42204. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42205. import { Observable } from "babylonjs/Misc/observable";
  42206. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42207. /**
  42208. * Defines supported buttons for DualShock compatible gamepads
  42209. */
  42210. export enum DualShockButton {
  42211. /** Cross */
  42212. Cross = 0,
  42213. /** Circle */
  42214. Circle = 1,
  42215. /** Square */
  42216. Square = 2,
  42217. /** Triangle */
  42218. Triangle = 3,
  42219. /** Options */
  42220. Options = 4,
  42221. /** Share */
  42222. Share = 5,
  42223. /** L1 */
  42224. L1 = 6,
  42225. /** R1 */
  42226. R1 = 7,
  42227. /** Left stick */
  42228. LeftStick = 8,
  42229. /** Right stick */
  42230. RightStick = 9
  42231. }
  42232. /** Defines values for DualShock DPad */
  42233. export enum DualShockDpad {
  42234. /** Up */
  42235. Up = 0,
  42236. /** Down */
  42237. Down = 1,
  42238. /** Left */
  42239. Left = 2,
  42240. /** Right */
  42241. Right = 3
  42242. }
  42243. /**
  42244. * Defines a DualShock gamepad
  42245. */
  42246. export class DualShockPad extends Gamepad {
  42247. private _leftTrigger;
  42248. private _rightTrigger;
  42249. private _onlefttriggerchanged;
  42250. private _onrighttriggerchanged;
  42251. private _onbuttondown;
  42252. private _onbuttonup;
  42253. private _ondpaddown;
  42254. private _ondpadup;
  42255. /** Observable raised when a button is pressed */
  42256. onButtonDownObservable: Observable<DualShockButton>;
  42257. /** Observable raised when a button is released */
  42258. onButtonUpObservable: Observable<DualShockButton>;
  42259. /** Observable raised when a pad is pressed */
  42260. onPadDownObservable: Observable<DualShockDpad>;
  42261. /** Observable raised when a pad is released */
  42262. onPadUpObservable: Observable<DualShockDpad>;
  42263. private _buttonCross;
  42264. private _buttonCircle;
  42265. private _buttonSquare;
  42266. private _buttonTriangle;
  42267. private _buttonShare;
  42268. private _buttonOptions;
  42269. private _buttonL1;
  42270. private _buttonR1;
  42271. private _buttonLeftStick;
  42272. private _buttonRightStick;
  42273. private _dPadUp;
  42274. private _dPadDown;
  42275. private _dPadLeft;
  42276. private _dPadRight;
  42277. /**
  42278. * Creates a new DualShock gamepad object
  42279. * @param id defines the id of this gamepad
  42280. * @param index defines its index
  42281. * @param gamepad defines the internal HTML gamepad object
  42282. */
  42283. constructor(id: string, index: number, gamepad: any);
  42284. /**
  42285. * Defines the callback to call when left trigger is pressed
  42286. * @param callback defines the callback to use
  42287. */
  42288. onlefttriggerchanged(callback: (value: number) => void): void;
  42289. /**
  42290. * Defines the callback to call when right trigger is pressed
  42291. * @param callback defines the callback to use
  42292. */
  42293. onrighttriggerchanged(callback: (value: number) => void): void;
  42294. /**
  42295. * Gets the left trigger value
  42296. */
  42297. get leftTrigger(): number;
  42298. /**
  42299. * Sets the left trigger value
  42300. */
  42301. set leftTrigger(newValue: number);
  42302. /**
  42303. * Gets the right trigger value
  42304. */
  42305. get rightTrigger(): number;
  42306. /**
  42307. * Sets the right trigger value
  42308. */
  42309. set rightTrigger(newValue: number);
  42310. /**
  42311. * Defines the callback to call when a button is pressed
  42312. * @param callback defines the callback to use
  42313. */
  42314. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42315. /**
  42316. * Defines the callback to call when a button is released
  42317. * @param callback defines the callback to use
  42318. */
  42319. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42320. /**
  42321. * Defines the callback to call when a pad is pressed
  42322. * @param callback defines the callback to use
  42323. */
  42324. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42325. /**
  42326. * Defines the callback to call when a pad is released
  42327. * @param callback defines the callback to use
  42328. */
  42329. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42330. private _setButtonValue;
  42331. private _setDPadValue;
  42332. /**
  42333. * Gets the value of the `Cross` button
  42334. */
  42335. get buttonCross(): number;
  42336. /**
  42337. * Sets the value of the `Cross` button
  42338. */
  42339. set buttonCross(value: number);
  42340. /**
  42341. * Gets the value of the `Circle` button
  42342. */
  42343. get buttonCircle(): number;
  42344. /**
  42345. * Sets the value of the `Circle` button
  42346. */
  42347. set buttonCircle(value: number);
  42348. /**
  42349. * Gets the value of the `Square` button
  42350. */
  42351. get buttonSquare(): number;
  42352. /**
  42353. * Sets the value of the `Square` button
  42354. */
  42355. set buttonSquare(value: number);
  42356. /**
  42357. * Gets the value of the `Triangle` button
  42358. */
  42359. get buttonTriangle(): number;
  42360. /**
  42361. * Sets the value of the `Triangle` button
  42362. */
  42363. set buttonTriangle(value: number);
  42364. /**
  42365. * Gets the value of the `Options` button
  42366. */
  42367. get buttonOptions(): number;
  42368. /**
  42369. * Sets the value of the `Options` button
  42370. */
  42371. set buttonOptions(value: number);
  42372. /**
  42373. * Gets the value of the `Share` button
  42374. */
  42375. get buttonShare(): number;
  42376. /**
  42377. * Sets the value of the `Share` button
  42378. */
  42379. set buttonShare(value: number);
  42380. /**
  42381. * Gets the value of the `L1` button
  42382. */
  42383. get buttonL1(): number;
  42384. /**
  42385. * Sets the value of the `L1` button
  42386. */
  42387. set buttonL1(value: number);
  42388. /**
  42389. * Gets the value of the `R1` button
  42390. */
  42391. get buttonR1(): number;
  42392. /**
  42393. * Sets the value of the `R1` button
  42394. */
  42395. set buttonR1(value: number);
  42396. /**
  42397. * Gets the value of the Left joystick
  42398. */
  42399. get buttonLeftStick(): number;
  42400. /**
  42401. * Sets the value of the Left joystick
  42402. */
  42403. set buttonLeftStick(value: number);
  42404. /**
  42405. * Gets the value of the Right joystick
  42406. */
  42407. get buttonRightStick(): number;
  42408. /**
  42409. * Sets the value of the Right joystick
  42410. */
  42411. set buttonRightStick(value: number);
  42412. /**
  42413. * Gets the value of D-pad up
  42414. */
  42415. get dPadUp(): number;
  42416. /**
  42417. * Sets the value of D-pad up
  42418. */
  42419. set dPadUp(value: number);
  42420. /**
  42421. * Gets the value of D-pad down
  42422. */
  42423. get dPadDown(): number;
  42424. /**
  42425. * Sets the value of D-pad down
  42426. */
  42427. set dPadDown(value: number);
  42428. /**
  42429. * Gets the value of D-pad left
  42430. */
  42431. get dPadLeft(): number;
  42432. /**
  42433. * Sets the value of D-pad left
  42434. */
  42435. set dPadLeft(value: number);
  42436. /**
  42437. * Gets the value of D-pad right
  42438. */
  42439. get dPadRight(): number;
  42440. /**
  42441. * Sets the value of D-pad right
  42442. */
  42443. set dPadRight(value: number);
  42444. /**
  42445. * Force the gamepad to synchronize with device values
  42446. */
  42447. update(): void;
  42448. /**
  42449. * Disposes the gamepad
  42450. */
  42451. dispose(): void;
  42452. }
  42453. }
  42454. declare module "babylonjs/Gamepads/gamepadManager" {
  42455. import { Observable } from "babylonjs/Misc/observable";
  42456. import { Nullable } from "babylonjs/types";
  42457. import { Scene } from "babylonjs/scene";
  42458. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42459. /**
  42460. * Manager for handling gamepads
  42461. */
  42462. export class GamepadManager {
  42463. private _scene?;
  42464. private _babylonGamepads;
  42465. private _oneGamepadConnected;
  42466. /** @hidden */
  42467. _isMonitoring: boolean;
  42468. private _gamepadEventSupported;
  42469. private _gamepadSupport?;
  42470. /**
  42471. * observable to be triggered when the gamepad controller has been connected
  42472. */
  42473. onGamepadConnectedObservable: Observable<Gamepad>;
  42474. /**
  42475. * observable to be triggered when the gamepad controller has been disconnected
  42476. */
  42477. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42478. private _onGamepadConnectedEvent;
  42479. private _onGamepadDisconnectedEvent;
  42480. /**
  42481. * Initializes the gamepad manager
  42482. * @param _scene BabylonJS scene
  42483. */
  42484. constructor(_scene?: Scene | undefined);
  42485. /**
  42486. * The gamepads in the game pad manager
  42487. */
  42488. get gamepads(): Gamepad[];
  42489. /**
  42490. * Get the gamepad controllers based on type
  42491. * @param type The type of gamepad controller
  42492. * @returns Nullable gamepad
  42493. */
  42494. getGamepadByType(type?: number): Nullable<Gamepad>;
  42495. /**
  42496. * Disposes the gamepad manager
  42497. */
  42498. dispose(): void;
  42499. private _addNewGamepad;
  42500. private _startMonitoringGamepads;
  42501. private _stopMonitoringGamepads;
  42502. /** @hidden */
  42503. _checkGamepadsStatus(): void;
  42504. private _updateGamepadObjects;
  42505. }
  42506. }
  42507. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42508. import { Nullable } from "babylonjs/types";
  42509. import { Scene } from "babylonjs/scene";
  42510. import { ISceneComponent } from "babylonjs/sceneComponent";
  42511. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42512. module "babylonjs/scene" {
  42513. interface Scene {
  42514. /** @hidden */
  42515. _gamepadManager: Nullable<GamepadManager>;
  42516. /**
  42517. * Gets the gamepad manager associated with the scene
  42518. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42519. */
  42520. gamepadManager: GamepadManager;
  42521. }
  42522. }
  42523. module "babylonjs/Cameras/freeCameraInputsManager" {
  42524. /**
  42525. * Interface representing a free camera inputs manager
  42526. */
  42527. interface FreeCameraInputsManager {
  42528. /**
  42529. * Adds gamepad input support to the FreeCameraInputsManager.
  42530. * @returns the FreeCameraInputsManager
  42531. */
  42532. addGamepad(): FreeCameraInputsManager;
  42533. }
  42534. }
  42535. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42536. /**
  42537. * Interface representing an arc rotate camera inputs manager
  42538. */
  42539. interface ArcRotateCameraInputsManager {
  42540. /**
  42541. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42542. * @returns the camera inputs manager
  42543. */
  42544. addGamepad(): ArcRotateCameraInputsManager;
  42545. }
  42546. }
  42547. /**
  42548. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42549. */
  42550. export class GamepadSystemSceneComponent implements ISceneComponent {
  42551. /**
  42552. * The component name helpfull to identify the component in the list of scene components.
  42553. */
  42554. readonly name: string;
  42555. /**
  42556. * The scene the component belongs to.
  42557. */
  42558. scene: Scene;
  42559. /**
  42560. * Creates a new instance of the component for the given scene
  42561. * @param scene Defines the scene to register the component in
  42562. */
  42563. constructor(scene: Scene);
  42564. /**
  42565. * Registers the component in a given scene
  42566. */
  42567. register(): void;
  42568. /**
  42569. * Rebuilds the elements related to this component in case of
  42570. * context lost for instance.
  42571. */
  42572. rebuild(): void;
  42573. /**
  42574. * Disposes the component and the associated ressources
  42575. */
  42576. dispose(): void;
  42577. private _beforeCameraUpdate;
  42578. }
  42579. }
  42580. declare module "babylonjs/Cameras/universalCamera" {
  42581. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42582. import { Scene } from "babylonjs/scene";
  42583. import { Vector3 } from "babylonjs/Maths/math.vector";
  42584. import "babylonjs/Gamepads/gamepadSceneComponent";
  42585. /**
  42586. * 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,
  42587. * which still works and will still be found in many Playgrounds.
  42588. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42589. */
  42590. export class UniversalCamera extends TouchCamera {
  42591. /**
  42592. * Defines the gamepad rotation sensiblity.
  42593. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42594. */
  42595. get gamepadAngularSensibility(): number;
  42596. set gamepadAngularSensibility(value: number);
  42597. /**
  42598. * Defines the gamepad move sensiblity.
  42599. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42600. */
  42601. get gamepadMoveSensibility(): number;
  42602. set gamepadMoveSensibility(value: number);
  42603. /**
  42604. * 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,
  42605. * which still works and will still be found in many Playgrounds.
  42606. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42607. * @param name Define the name of the camera in the scene
  42608. * @param position Define the start position of the camera in the scene
  42609. * @param scene Define the scene the camera belongs to
  42610. */
  42611. constructor(name: string, position: Vector3, scene: Scene);
  42612. /**
  42613. * Gets the current object class name.
  42614. * @return the class name
  42615. */
  42616. getClassName(): string;
  42617. }
  42618. }
  42619. declare module "babylonjs/Cameras/gamepadCamera" {
  42620. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42621. import { Scene } from "babylonjs/scene";
  42622. import { Vector3 } from "babylonjs/Maths/math.vector";
  42623. /**
  42624. * This represents a FPS type of camera. This is only here for back compat purpose.
  42625. * Please use the UniversalCamera instead as both are identical.
  42626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42627. */
  42628. export class GamepadCamera extends UniversalCamera {
  42629. /**
  42630. * Instantiates a new Gamepad Camera
  42631. * This represents a FPS type of camera. This is only here for back compat purpose.
  42632. * Please use the UniversalCamera instead as both are identical.
  42633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42634. * @param name Define the name of the camera in the scene
  42635. * @param position Define the start position of the camera in the scene
  42636. * @param scene Define the scene the camera belongs to
  42637. */
  42638. constructor(name: string, position: Vector3, scene: Scene);
  42639. /**
  42640. * Gets the current object class name.
  42641. * @return the class name
  42642. */
  42643. getClassName(): string;
  42644. }
  42645. }
  42646. declare module "babylonjs/Shaders/pass.fragment" {
  42647. /** @hidden */
  42648. export var passPixelShader: {
  42649. name: string;
  42650. shader: string;
  42651. };
  42652. }
  42653. declare module "babylonjs/Shaders/passCube.fragment" {
  42654. /** @hidden */
  42655. export var passCubePixelShader: {
  42656. name: string;
  42657. shader: string;
  42658. };
  42659. }
  42660. declare module "babylonjs/PostProcesses/passPostProcess" {
  42661. import { Nullable } from "babylonjs/types";
  42662. import { Camera } from "babylonjs/Cameras/camera";
  42663. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42664. import { Engine } from "babylonjs/Engines/engine";
  42665. import "babylonjs/Shaders/pass.fragment";
  42666. import "babylonjs/Shaders/passCube.fragment";
  42667. /**
  42668. * PassPostProcess which produces an output the same as it's input
  42669. */
  42670. export class PassPostProcess extends PostProcess {
  42671. /**
  42672. * Creates the PassPostProcess
  42673. * @param name The name of the effect.
  42674. * @param options The required width/height ratio to downsize to before computing the render pass.
  42675. * @param camera The camera to apply the render pass to.
  42676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42677. * @param engine The engine which the post process will be applied. (default: current engine)
  42678. * @param reusable If the post process can be reused on the same frame. (default: false)
  42679. * @param textureType The type of texture to be used when performing the post processing.
  42680. * @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)
  42681. */
  42682. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42683. }
  42684. /**
  42685. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42686. */
  42687. export class PassCubePostProcess extends PostProcess {
  42688. private _face;
  42689. /**
  42690. * Gets or sets the cube face to display.
  42691. * * 0 is +X
  42692. * * 1 is -X
  42693. * * 2 is +Y
  42694. * * 3 is -Y
  42695. * * 4 is +Z
  42696. * * 5 is -Z
  42697. */
  42698. get face(): number;
  42699. set face(value: number);
  42700. /**
  42701. * Creates the PassCubePostProcess
  42702. * @param name The name of the effect.
  42703. * @param options The required width/height ratio to downsize to before computing the render pass.
  42704. * @param camera The camera to apply the render pass to.
  42705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42706. * @param engine The engine which the post process will be applied. (default: current engine)
  42707. * @param reusable If the post process can be reused on the same frame. (default: false)
  42708. * @param textureType The type of texture to be used when performing the post processing.
  42709. * @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)
  42710. */
  42711. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42712. }
  42713. }
  42714. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42715. /** @hidden */
  42716. export var anaglyphPixelShader: {
  42717. name: string;
  42718. shader: string;
  42719. };
  42720. }
  42721. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42722. import { Engine } from "babylonjs/Engines/engine";
  42723. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42724. import { Camera } from "babylonjs/Cameras/camera";
  42725. import "babylonjs/Shaders/anaglyph.fragment";
  42726. /**
  42727. * Postprocess used to generate anaglyphic rendering
  42728. */
  42729. export class AnaglyphPostProcess extends PostProcess {
  42730. private _passedProcess;
  42731. /**
  42732. * Creates a new AnaglyphPostProcess
  42733. * @param name defines postprocess name
  42734. * @param options defines creation options or target ratio scale
  42735. * @param rigCameras defines cameras using this postprocess
  42736. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42737. * @param engine defines hosting engine
  42738. * @param reusable defines if the postprocess will be reused multiple times per frame
  42739. */
  42740. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42741. }
  42742. }
  42743. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42744. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42745. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42746. import { Scene } from "babylonjs/scene";
  42747. import { Vector3 } from "babylonjs/Maths/math.vector";
  42748. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42749. /**
  42750. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42751. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42752. */
  42753. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42754. /**
  42755. * Creates a new AnaglyphArcRotateCamera
  42756. * @param name defines camera name
  42757. * @param alpha defines alpha angle (in radians)
  42758. * @param beta defines beta angle (in radians)
  42759. * @param radius defines radius
  42760. * @param target defines camera target
  42761. * @param interaxialDistance defines distance between each color axis
  42762. * @param scene defines the hosting scene
  42763. */
  42764. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42765. /**
  42766. * Gets camera class name
  42767. * @returns AnaglyphArcRotateCamera
  42768. */
  42769. getClassName(): string;
  42770. }
  42771. }
  42772. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42773. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42774. import { Scene } from "babylonjs/scene";
  42775. import { Vector3 } from "babylonjs/Maths/math.vector";
  42776. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42777. /**
  42778. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42779. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42780. */
  42781. export class AnaglyphFreeCamera extends FreeCamera {
  42782. /**
  42783. * Creates a new AnaglyphFreeCamera
  42784. * @param name defines camera name
  42785. * @param position defines initial position
  42786. * @param interaxialDistance defines distance between each color axis
  42787. * @param scene defines the hosting scene
  42788. */
  42789. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42790. /**
  42791. * Gets camera class name
  42792. * @returns AnaglyphFreeCamera
  42793. */
  42794. getClassName(): string;
  42795. }
  42796. }
  42797. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42798. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42799. import { Scene } from "babylonjs/scene";
  42800. import { Vector3 } from "babylonjs/Maths/math.vector";
  42801. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42802. /**
  42803. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42804. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42805. */
  42806. export class AnaglyphGamepadCamera extends GamepadCamera {
  42807. /**
  42808. * Creates a new AnaglyphGamepadCamera
  42809. * @param name defines camera name
  42810. * @param position defines initial position
  42811. * @param interaxialDistance defines distance between each color axis
  42812. * @param scene defines the hosting scene
  42813. */
  42814. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42815. /**
  42816. * Gets camera class name
  42817. * @returns AnaglyphGamepadCamera
  42818. */
  42819. getClassName(): string;
  42820. }
  42821. }
  42822. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42823. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42824. import { Scene } from "babylonjs/scene";
  42825. import { Vector3 } from "babylonjs/Maths/math.vector";
  42826. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42827. /**
  42828. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42829. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42830. */
  42831. export class AnaglyphUniversalCamera extends UniversalCamera {
  42832. /**
  42833. * Creates a new AnaglyphUniversalCamera
  42834. * @param name defines camera name
  42835. * @param position defines initial position
  42836. * @param interaxialDistance defines distance between each color axis
  42837. * @param scene defines the hosting scene
  42838. */
  42839. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42840. /**
  42841. * Gets camera class name
  42842. * @returns AnaglyphUniversalCamera
  42843. */
  42844. getClassName(): string;
  42845. }
  42846. }
  42847. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42848. /** @hidden */
  42849. export var stereoscopicInterlacePixelShader: {
  42850. name: string;
  42851. shader: string;
  42852. };
  42853. }
  42854. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42855. import { Camera } from "babylonjs/Cameras/camera";
  42856. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42857. import { Engine } from "babylonjs/Engines/engine";
  42858. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42859. /**
  42860. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42861. */
  42862. export class StereoscopicInterlacePostProcess extends PostProcess {
  42863. private _stepSize;
  42864. private _passedProcess;
  42865. /**
  42866. * Initializes a StereoscopicInterlacePostProcess
  42867. * @param name The name of the effect.
  42868. * @param rigCameras The rig cameras to be appled to the post process
  42869. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42871. * @param engine The engine which the post process will be applied. (default: current engine)
  42872. * @param reusable If the post process can be reused on the same frame. (default: false)
  42873. */
  42874. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42875. }
  42876. }
  42877. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42878. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42879. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42880. import { Scene } from "babylonjs/scene";
  42881. import { Vector3 } from "babylonjs/Maths/math.vector";
  42882. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42883. /**
  42884. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42885. * @see http://doc.babylonjs.com/features/cameras
  42886. */
  42887. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42888. /**
  42889. * Creates a new StereoscopicArcRotateCamera
  42890. * @param name defines camera name
  42891. * @param alpha defines alpha angle (in radians)
  42892. * @param beta defines beta angle (in radians)
  42893. * @param radius defines radius
  42894. * @param target defines camera target
  42895. * @param interaxialDistance defines distance between each color axis
  42896. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42897. * @param scene defines the hosting scene
  42898. */
  42899. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42900. /**
  42901. * Gets camera class name
  42902. * @returns StereoscopicArcRotateCamera
  42903. */
  42904. getClassName(): string;
  42905. }
  42906. }
  42907. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42908. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42909. import { Scene } from "babylonjs/scene";
  42910. import { Vector3 } from "babylonjs/Maths/math.vector";
  42911. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42912. /**
  42913. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42914. * @see http://doc.babylonjs.com/features/cameras
  42915. */
  42916. export class StereoscopicFreeCamera extends FreeCamera {
  42917. /**
  42918. * Creates a new StereoscopicFreeCamera
  42919. * @param name defines camera name
  42920. * @param position defines initial position
  42921. * @param interaxialDistance defines distance between each color axis
  42922. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42923. * @param scene defines the hosting scene
  42924. */
  42925. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42926. /**
  42927. * Gets camera class name
  42928. * @returns StereoscopicFreeCamera
  42929. */
  42930. getClassName(): string;
  42931. }
  42932. }
  42933. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42934. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42935. import { Scene } from "babylonjs/scene";
  42936. import { Vector3 } from "babylonjs/Maths/math.vector";
  42937. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42938. /**
  42939. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42940. * @see http://doc.babylonjs.com/features/cameras
  42941. */
  42942. export class StereoscopicGamepadCamera extends GamepadCamera {
  42943. /**
  42944. * Creates a new StereoscopicGamepadCamera
  42945. * @param name defines camera name
  42946. * @param position defines initial position
  42947. * @param interaxialDistance defines distance between each color axis
  42948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42949. * @param scene defines the hosting scene
  42950. */
  42951. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42952. /**
  42953. * Gets camera class name
  42954. * @returns StereoscopicGamepadCamera
  42955. */
  42956. getClassName(): string;
  42957. }
  42958. }
  42959. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42960. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42961. import { Scene } from "babylonjs/scene";
  42962. import { Vector3 } from "babylonjs/Maths/math.vector";
  42963. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42964. /**
  42965. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42966. * @see http://doc.babylonjs.com/features/cameras
  42967. */
  42968. export class StereoscopicUniversalCamera extends UniversalCamera {
  42969. /**
  42970. * Creates a new StereoscopicUniversalCamera
  42971. * @param name defines camera name
  42972. * @param position defines initial position
  42973. * @param interaxialDistance defines distance between each color axis
  42974. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42975. * @param scene defines the hosting scene
  42976. */
  42977. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42978. /**
  42979. * Gets camera class name
  42980. * @returns StereoscopicUniversalCamera
  42981. */
  42982. getClassName(): string;
  42983. }
  42984. }
  42985. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42986. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42987. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42988. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42989. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42990. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42991. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42992. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42993. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42994. }
  42995. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42996. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42997. import { Scene } from "babylonjs/scene";
  42998. import { Vector3 } from "babylonjs/Maths/math.vector";
  42999. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43000. /**
  43001. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43002. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43003. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43004. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43005. */
  43006. export class VirtualJoysticksCamera extends FreeCamera {
  43007. /**
  43008. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43009. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43010. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43011. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43012. * @param name Define the name of the camera in the scene
  43013. * @param position Define the start position of the camera in the scene
  43014. * @param scene Define the scene the camera belongs to
  43015. */
  43016. constructor(name: string, position: Vector3, scene: Scene);
  43017. /**
  43018. * Gets the current object class name.
  43019. * @return the class name
  43020. */
  43021. getClassName(): string;
  43022. }
  43023. }
  43024. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43025. import { Matrix } from "babylonjs/Maths/math.vector";
  43026. /**
  43027. * This represents all the required metrics to create a VR camera.
  43028. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43029. */
  43030. export class VRCameraMetrics {
  43031. /**
  43032. * Define the horizontal resolution off the screen.
  43033. */
  43034. hResolution: number;
  43035. /**
  43036. * Define the vertical resolution off the screen.
  43037. */
  43038. vResolution: number;
  43039. /**
  43040. * Define the horizontal screen size.
  43041. */
  43042. hScreenSize: number;
  43043. /**
  43044. * Define the vertical screen size.
  43045. */
  43046. vScreenSize: number;
  43047. /**
  43048. * Define the vertical screen center position.
  43049. */
  43050. vScreenCenter: number;
  43051. /**
  43052. * Define the distance of the eyes to the screen.
  43053. */
  43054. eyeToScreenDistance: number;
  43055. /**
  43056. * Define the distance between both lenses
  43057. */
  43058. lensSeparationDistance: number;
  43059. /**
  43060. * Define the distance between both viewer's eyes.
  43061. */
  43062. interpupillaryDistance: number;
  43063. /**
  43064. * Define the distortion factor of the VR postprocess.
  43065. * Please, touch with care.
  43066. */
  43067. distortionK: number[];
  43068. /**
  43069. * Define the chromatic aberration correction factors for the VR post process.
  43070. */
  43071. chromaAbCorrection: number[];
  43072. /**
  43073. * Define the scale factor of the post process.
  43074. * The smaller the better but the slower.
  43075. */
  43076. postProcessScaleFactor: number;
  43077. /**
  43078. * Define an offset for the lens center.
  43079. */
  43080. lensCenterOffset: number;
  43081. /**
  43082. * Define if the current vr camera should compensate the distortion of the lense or not.
  43083. */
  43084. compensateDistortion: boolean;
  43085. /**
  43086. * Defines if multiview should be enabled when rendering (Default: false)
  43087. */
  43088. multiviewEnabled: boolean;
  43089. /**
  43090. * Gets the rendering aspect ratio based on the provided resolutions.
  43091. */
  43092. get aspectRatio(): number;
  43093. /**
  43094. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43095. */
  43096. get aspectRatioFov(): number;
  43097. /**
  43098. * @hidden
  43099. */
  43100. get leftHMatrix(): Matrix;
  43101. /**
  43102. * @hidden
  43103. */
  43104. get rightHMatrix(): Matrix;
  43105. /**
  43106. * @hidden
  43107. */
  43108. get leftPreViewMatrix(): Matrix;
  43109. /**
  43110. * @hidden
  43111. */
  43112. get rightPreViewMatrix(): Matrix;
  43113. /**
  43114. * Get the default VRMetrics based on the most generic setup.
  43115. * @returns the default vr metrics
  43116. */
  43117. static GetDefault(): VRCameraMetrics;
  43118. }
  43119. }
  43120. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43121. /** @hidden */
  43122. export var vrDistortionCorrectionPixelShader: {
  43123. name: string;
  43124. shader: string;
  43125. };
  43126. }
  43127. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43128. import { Camera } from "babylonjs/Cameras/camera";
  43129. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43130. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43131. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43132. /**
  43133. * VRDistortionCorrectionPostProcess used for mobile VR
  43134. */
  43135. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43136. private _isRightEye;
  43137. private _distortionFactors;
  43138. private _postProcessScaleFactor;
  43139. private _lensCenterOffset;
  43140. private _scaleIn;
  43141. private _scaleFactor;
  43142. private _lensCenter;
  43143. /**
  43144. * Initializes the VRDistortionCorrectionPostProcess
  43145. * @param name The name of the effect.
  43146. * @param camera The camera to apply the render pass to.
  43147. * @param isRightEye If this is for the right eye distortion
  43148. * @param vrMetrics All the required metrics for the VR camera
  43149. */
  43150. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43151. }
  43152. }
  43153. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43154. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43155. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43156. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43157. import { Scene } from "babylonjs/scene";
  43158. import { Vector3 } from "babylonjs/Maths/math.vector";
  43159. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43160. import "babylonjs/Cameras/RigModes/vrRigMode";
  43161. /**
  43162. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43163. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43164. */
  43165. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43166. /**
  43167. * Creates a new VRDeviceOrientationArcRotateCamera
  43168. * @param name defines camera name
  43169. * @param alpha defines the camera rotation along the logitudinal axis
  43170. * @param beta defines the camera rotation along the latitudinal axis
  43171. * @param radius defines the camera distance from its target
  43172. * @param target defines the camera target
  43173. * @param scene defines the scene the camera belongs to
  43174. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43175. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43176. */
  43177. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43178. /**
  43179. * Gets camera class name
  43180. * @returns VRDeviceOrientationArcRotateCamera
  43181. */
  43182. getClassName(): string;
  43183. }
  43184. }
  43185. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43186. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43187. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43188. import { Scene } from "babylonjs/scene";
  43189. import { Vector3 } from "babylonjs/Maths/math.vector";
  43190. import "babylonjs/Cameras/RigModes/vrRigMode";
  43191. /**
  43192. * Camera used to simulate VR rendering (based on FreeCamera)
  43193. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43194. */
  43195. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43196. /**
  43197. * Creates a new VRDeviceOrientationFreeCamera
  43198. * @param name defines camera name
  43199. * @param position defines the start position of the camera
  43200. * @param scene defines the scene the camera belongs to
  43201. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43202. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43203. */
  43204. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43205. /**
  43206. * Gets camera class name
  43207. * @returns VRDeviceOrientationFreeCamera
  43208. */
  43209. getClassName(): string;
  43210. }
  43211. }
  43212. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43213. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43214. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43215. import { Scene } from "babylonjs/scene";
  43216. import { Vector3 } from "babylonjs/Maths/math.vector";
  43217. import "babylonjs/Gamepads/gamepadSceneComponent";
  43218. /**
  43219. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43220. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43221. */
  43222. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43223. /**
  43224. * Creates a new VRDeviceOrientationGamepadCamera
  43225. * @param name defines camera name
  43226. * @param position defines the start position of the camera
  43227. * @param scene defines the scene the camera belongs to
  43228. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43229. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43230. */
  43231. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43232. /**
  43233. * Gets camera class name
  43234. * @returns VRDeviceOrientationGamepadCamera
  43235. */
  43236. getClassName(): string;
  43237. }
  43238. }
  43239. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43240. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43241. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43242. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43243. /** @hidden */
  43244. export var imageProcessingPixelShader: {
  43245. name: string;
  43246. shader: string;
  43247. };
  43248. }
  43249. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43250. import { Nullable } from "babylonjs/types";
  43251. import { Color4 } from "babylonjs/Maths/math.color";
  43252. import { Camera } from "babylonjs/Cameras/camera";
  43253. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43254. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43255. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43256. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43257. import { Engine } from "babylonjs/Engines/engine";
  43258. import "babylonjs/Shaders/imageProcessing.fragment";
  43259. import "babylonjs/Shaders/postprocess.vertex";
  43260. /**
  43261. * ImageProcessingPostProcess
  43262. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43263. */
  43264. export class ImageProcessingPostProcess extends PostProcess {
  43265. /**
  43266. * Default configuration related to image processing available in the PBR Material.
  43267. */
  43268. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43269. /**
  43270. * Gets the image processing configuration used either in this material.
  43271. */
  43272. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43273. /**
  43274. * Sets the Default image processing configuration used either in the this material.
  43275. *
  43276. * If sets to null, the scene one is in use.
  43277. */
  43278. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43279. /**
  43280. * Keep track of the image processing observer to allow dispose and replace.
  43281. */
  43282. private _imageProcessingObserver;
  43283. /**
  43284. * Attaches a new image processing configuration to the PBR Material.
  43285. * @param configuration
  43286. */
  43287. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43288. /**
  43289. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43290. */
  43291. get colorCurves(): Nullable<ColorCurves>;
  43292. /**
  43293. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43294. */
  43295. set colorCurves(value: Nullable<ColorCurves>);
  43296. /**
  43297. * Gets wether the color curves effect is enabled.
  43298. */
  43299. get colorCurvesEnabled(): boolean;
  43300. /**
  43301. * Sets wether the color curves effect is enabled.
  43302. */
  43303. set colorCurvesEnabled(value: boolean);
  43304. /**
  43305. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43306. */
  43307. get colorGradingTexture(): Nullable<BaseTexture>;
  43308. /**
  43309. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43310. */
  43311. set colorGradingTexture(value: Nullable<BaseTexture>);
  43312. /**
  43313. * Gets wether the color grading effect is enabled.
  43314. */
  43315. get colorGradingEnabled(): boolean;
  43316. /**
  43317. * Gets wether the color grading effect is enabled.
  43318. */
  43319. set colorGradingEnabled(value: boolean);
  43320. /**
  43321. * Gets exposure used in the effect.
  43322. */
  43323. get exposure(): number;
  43324. /**
  43325. * Sets exposure used in the effect.
  43326. */
  43327. set exposure(value: number);
  43328. /**
  43329. * Gets wether tonemapping is enabled or not.
  43330. */
  43331. get toneMappingEnabled(): boolean;
  43332. /**
  43333. * Sets wether tonemapping is enabled or not
  43334. */
  43335. set toneMappingEnabled(value: boolean);
  43336. /**
  43337. * Gets the type of tone mapping effect.
  43338. */
  43339. get toneMappingType(): number;
  43340. /**
  43341. * Sets the type of tone mapping effect.
  43342. */
  43343. set toneMappingType(value: number);
  43344. /**
  43345. * Gets contrast used in the effect.
  43346. */
  43347. get contrast(): number;
  43348. /**
  43349. * Sets contrast used in the effect.
  43350. */
  43351. set contrast(value: number);
  43352. /**
  43353. * Gets Vignette stretch size.
  43354. */
  43355. get vignetteStretch(): number;
  43356. /**
  43357. * Sets Vignette stretch size.
  43358. */
  43359. set vignetteStretch(value: number);
  43360. /**
  43361. * Gets Vignette centre X Offset.
  43362. */
  43363. get vignetteCentreX(): number;
  43364. /**
  43365. * Sets Vignette centre X Offset.
  43366. */
  43367. set vignetteCentreX(value: number);
  43368. /**
  43369. * Gets Vignette centre Y Offset.
  43370. */
  43371. get vignetteCentreY(): number;
  43372. /**
  43373. * Sets Vignette centre Y Offset.
  43374. */
  43375. set vignetteCentreY(value: number);
  43376. /**
  43377. * Gets Vignette weight or intensity of the vignette effect.
  43378. */
  43379. get vignetteWeight(): number;
  43380. /**
  43381. * Sets Vignette weight or intensity of the vignette effect.
  43382. */
  43383. set vignetteWeight(value: number);
  43384. /**
  43385. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43386. * if vignetteEnabled is set to true.
  43387. */
  43388. get vignetteColor(): Color4;
  43389. /**
  43390. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43391. * if vignetteEnabled is set to true.
  43392. */
  43393. set vignetteColor(value: Color4);
  43394. /**
  43395. * Gets Camera field of view used by the Vignette effect.
  43396. */
  43397. get vignetteCameraFov(): number;
  43398. /**
  43399. * Sets Camera field of view used by the Vignette effect.
  43400. */
  43401. set vignetteCameraFov(value: number);
  43402. /**
  43403. * Gets the vignette blend mode allowing different kind of effect.
  43404. */
  43405. get vignetteBlendMode(): number;
  43406. /**
  43407. * Sets the vignette blend mode allowing different kind of effect.
  43408. */
  43409. set vignetteBlendMode(value: number);
  43410. /**
  43411. * Gets wether the vignette effect is enabled.
  43412. */
  43413. get vignetteEnabled(): boolean;
  43414. /**
  43415. * Sets wether the vignette effect is enabled.
  43416. */
  43417. set vignetteEnabled(value: boolean);
  43418. private _fromLinearSpace;
  43419. /**
  43420. * Gets wether the input of the processing is in Gamma or Linear Space.
  43421. */
  43422. get fromLinearSpace(): boolean;
  43423. /**
  43424. * Sets wether the input of the processing is in Gamma or Linear Space.
  43425. */
  43426. set fromLinearSpace(value: boolean);
  43427. /**
  43428. * Defines cache preventing GC.
  43429. */
  43430. private _defines;
  43431. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43432. /**
  43433. * "ImageProcessingPostProcess"
  43434. * @returns "ImageProcessingPostProcess"
  43435. */
  43436. getClassName(): string;
  43437. protected _updateParameters(): void;
  43438. dispose(camera?: Camera): void;
  43439. }
  43440. }
  43441. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43442. import { Scene } from "babylonjs/scene";
  43443. import { Color3 } from "babylonjs/Maths/math.color";
  43444. import { Mesh } from "babylonjs/Meshes/mesh";
  43445. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43446. import { Nullable } from "babylonjs/types";
  43447. /**
  43448. * Class containing static functions to help procedurally build meshes
  43449. */
  43450. export class GroundBuilder {
  43451. /**
  43452. * Creates a ground mesh
  43453. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43454. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43456. * @param name defines the name of the mesh
  43457. * @param options defines the options used to create the mesh
  43458. * @param scene defines the hosting scene
  43459. * @returns the ground mesh
  43460. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43461. */
  43462. static CreateGround(name: string, options: {
  43463. width?: number;
  43464. height?: number;
  43465. subdivisions?: number;
  43466. subdivisionsX?: number;
  43467. subdivisionsY?: number;
  43468. updatable?: boolean;
  43469. }, scene: any): Mesh;
  43470. /**
  43471. * Creates a tiled ground mesh
  43472. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43473. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43474. * * 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
  43475. * * 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
  43476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43477. * @param name defines the name of the mesh
  43478. * @param options defines the options used to create the mesh
  43479. * @param scene defines the hosting scene
  43480. * @returns the tiled ground mesh
  43481. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43482. */
  43483. static CreateTiledGround(name: string, options: {
  43484. xmin: number;
  43485. zmin: number;
  43486. xmax: number;
  43487. zmax: number;
  43488. subdivisions?: {
  43489. w: number;
  43490. h: number;
  43491. };
  43492. precision?: {
  43493. w: number;
  43494. h: number;
  43495. };
  43496. updatable?: boolean;
  43497. }, scene?: Nullable<Scene>): Mesh;
  43498. /**
  43499. * Creates a ground mesh from a height map
  43500. * * The parameter `url` sets the URL of the height map image resource.
  43501. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43502. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43503. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43504. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43505. * * 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.
  43506. * * 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).
  43507. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43509. * @param name defines the name of the mesh
  43510. * @param url defines the url to the height map
  43511. * @param options defines the options used to create the mesh
  43512. * @param scene defines the hosting scene
  43513. * @returns the ground mesh
  43514. * @see https://doc.babylonjs.com/babylon101/height_map
  43515. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43516. */
  43517. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43518. width?: number;
  43519. height?: number;
  43520. subdivisions?: number;
  43521. minHeight?: number;
  43522. maxHeight?: number;
  43523. colorFilter?: Color3;
  43524. alphaFilter?: number;
  43525. updatable?: boolean;
  43526. onReady?: (mesh: GroundMesh) => void;
  43527. }, scene?: Nullable<Scene>): GroundMesh;
  43528. }
  43529. }
  43530. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43531. import { Vector4 } from "babylonjs/Maths/math.vector";
  43532. import { Mesh } from "babylonjs/Meshes/mesh";
  43533. /**
  43534. * Class containing static functions to help procedurally build meshes
  43535. */
  43536. export class TorusBuilder {
  43537. /**
  43538. * Creates a torus mesh
  43539. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43540. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43541. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43545. * @param name defines the name of the mesh
  43546. * @param options defines the options used to create the mesh
  43547. * @param scene defines the hosting scene
  43548. * @returns the torus mesh
  43549. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43550. */
  43551. static CreateTorus(name: string, options: {
  43552. diameter?: number;
  43553. thickness?: number;
  43554. tessellation?: number;
  43555. updatable?: boolean;
  43556. sideOrientation?: number;
  43557. frontUVs?: Vector4;
  43558. backUVs?: Vector4;
  43559. }, scene: any): Mesh;
  43560. }
  43561. }
  43562. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43563. import { Vector4 } from "babylonjs/Maths/math.vector";
  43564. import { Color4 } from "babylonjs/Maths/math.color";
  43565. import { Mesh } from "babylonjs/Meshes/mesh";
  43566. /**
  43567. * Class containing static functions to help procedurally build meshes
  43568. */
  43569. export class CylinderBuilder {
  43570. /**
  43571. * Creates a cylinder or a cone mesh
  43572. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43573. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43574. * * 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.
  43575. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43576. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43577. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43578. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43579. * * 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).
  43580. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43581. * * 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).
  43582. * * 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
  43583. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43584. * * 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
  43585. * * 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.
  43586. * * If `enclose` is false, a ring surface is one element.
  43587. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43588. * * 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
  43589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43592. * @param name defines the name of the mesh
  43593. * @param options defines the options used to create the mesh
  43594. * @param scene defines the hosting scene
  43595. * @returns the cylinder mesh
  43596. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43597. */
  43598. static CreateCylinder(name: string, options: {
  43599. height?: number;
  43600. diameterTop?: number;
  43601. diameterBottom?: number;
  43602. diameter?: number;
  43603. tessellation?: number;
  43604. subdivisions?: number;
  43605. arc?: number;
  43606. faceColors?: Color4[];
  43607. faceUV?: Vector4[];
  43608. updatable?: boolean;
  43609. hasRings?: boolean;
  43610. enclose?: boolean;
  43611. cap?: number;
  43612. sideOrientation?: number;
  43613. frontUVs?: Vector4;
  43614. backUVs?: Vector4;
  43615. }, scene: any): Mesh;
  43616. }
  43617. }
  43618. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43619. import { Nullable } from "babylonjs/types";
  43620. import { IDisposable } from "babylonjs/scene";
  43621. /**
  43622. * States of the webXR experience
  43623. */
  43624. export enum WebXRState {
  43625. /**
  43626. * Transitioning to being in XR mode
  43627. */
  43628. ENTERING_XR = 0,
  43629. /**
  43630. * Transitioning to non XR mode
  43631. */
  43632. EXITING_XR = 1,
  43633. /**
  43634. * In XR mode and presenting
  43635. */
  43636. IN_XR = 2,
  43637. /**
  43638. * Not entered XR mode
  43639. */
  43640. NOT_IN_XR = 3
  43641. }
  43642. /**
  43643. * Abstraction of the XR render target
  43644. */
  43645. export interface WebXRRenderTarget extends IDisposable {
  43646. /**
  43647. * xrpresent context of the canvas which can be used to display/mirror xr content
  43648. */
  43649. canvasContext: WebGLRenderingContext;
  43650. /**
  43651. * xr layer for the canvas
  43652. */
  43653. xrLayer: Nullable<XRWebGLLayer>;
  43654. /**
  43655. * Initializes the xr layer for the session
  43656. * @param xrSession xr session
  43657. * @returns a promise that will resolve once the XR Layer has been created
  43658. */
  43659. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43660. }
  43661. }
  43662. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43663. import { Nullable } from "babylonjs/types";
  43664. import { Observable } from "babylonjs/Misc/observable";
  43665. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43666. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43667. /**
  43668. * COnfiguration object for WebXR output canvas
  43669. */
  43670. export class WebXRManagedOutputCanvasOptions {
  43671. /**
  43672. * Options for this XR Layer output
  43673. */
  43674. canvasOptions: XRWebGLLayerOptions;
  43675. /**
  43676. * CSS styling for a newly created canvas (if not provided)
  43677. */
  43678. newCanvasCssStyle?: string;
  43679. /**
  43680. * Get the default values of the configuration object
  43681. * @returns default values of this configuration object
  43682. */
  43683. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43684. }
  43685. /**
  43686. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43687. */
  43688. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43689. private configuration;
  43690. private _engine;
  43691. private _canvas;
  43692. /**
  43693. * xrpresent context of the canvas which can be used to display/mirror xr content
  43694. */
  43695. canvasContext: WebGLRenderingContext;
  43696. /**
  43697. * xr layer for the canvas
  43698. */
  43699. xrLayer: Nullable<XRWebGLLayer>;
  43700. /**
  43701. * Initializes the xr layer for the session
  43702. * @param xrSession xr session
  43703. * @returns a promise that will resolve once the XR Layer has been created
  43704. */
  43705. initializeXRLayerAsync(xrSession: any): any;
  43706. /**
  43707. * Initializes the canvas to be added/removed upon entering/exiting xr
  43708. * @param engine the Babylon engine
  43709. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43710. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43711. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43712. */
  43713. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43714. /**
  43715. * Disposes of the object
  43716. */
  43717. dispose(): void;
  43718. private _setManagedOutputCanvas;
  43719. private _addCanvas;
  43720. private _removeCanvas;
  43721. }
  43722. }
  43723. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43724. import { Observable } from "babylonjs/Misc/observable";
  43725. import { Nullable } from "babylonjs/types";
  43726. import { IDisposable, Scene } from "babylonjs/scene";
  43727. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43728. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43729. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43730. /**
  43731. * Manages an XRSession to work with Babylon's engine
  43732. * @see https://doc.babylonjs.com/how_to/webxr
  43733. */
  43734. export class WebXRSessionManager implements IDisposable {
  43735. /** The scene which the session should be created for */
  43736. scene: Scene;
  43737. /**
  43738. * Fires every time a new xrFrame arrives which can be used to update the camera
  43739. */
  43740. onXRFrameObservable: Observable<XRFrame>;
  43741. /**
  43742. * Fires when the xr session is ended either by the device or manually done
  43743. */
  43744. onXRSessionEnded: Observable<any>;
  43745. /**
  43746. * Fires when the xr session is ended either by the device or manually done
  43747. */
  43748. onXRSessionInit: Observable<XRSession>;
  43749. /**
  43750. * Underlying xr session
  43751. */
  43752. session: XRSession;
  43753. /**
  43754. * Type of reference space used when creating the session
  43755. */
  43756. referenceSpace: XRReferenceSpace;
  43757. /**
  43758. * Current XR frame
  43759. */
  43760. currentFrame: Nullable<XRFrame>;
  43761. /** WebXR timestamp updated every frame */
  43762. currentTimestamp: number;
  43763. private _xrNavigator;
  43764. private baseLayer;
  43765. private _rttProvider;
  43766. private _sessionEnded;
  43767. /**
  43768. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43769. * @param scene The scene which the session should be created for
  43770. */
  43771. constructor(
  43772. /** The scene which the session should be created for */
  43773. scene: Scene);
  43774. /**
  43775. * Initializes the manager
  43776. * After initialization enterXR can be called to start an XR session
  43777. * @returns Promise which resolves after it is initialized
  43778. */
  43779. initializeAsync(): Promise<void>;
  43780. /**
  43781. * Initializes an xr session
  43782. * @param xrSessionMode mode to initialize
  43783. * @param optionalFeatures defines optional values to pass to the session builder
  43784. * @returns a promise which will resolve once the session has been initialized
  43785. */
  43786. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43787. /**
  43788. * Sets the reference space on the xr session
  43789. * @param referenceSpace space to set
  43790. * @returns a promise that will resolve once the reference space has been set
  43791. */
  43792. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43793. /**
  43794. * Updates the render state of the session
  43795. * @param state state to set
  43796. * @returns a promise that resolves once the render state has been updated
  43797. */
  43798. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43799. /**
  43800. * Starts rendering to the xr layer
  43801. * @returns a promise that will resolve once rendering has started
  43802. */
  43803. startRenderingToXRAsync(): Promise<void>;
  43804. /**
  43805. * Gets the correct render target texture to be rendered this frame for this eye
  43806. * @param eye the eye for which to get the render target
  43807. * @returns the render target for the specified eye
  43808. */
  43809. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43810. /**
  43811. * Stops the xrSession and restores the renderloop
  43812. * @returns Promise which resolves after it exits XR
  43813. */
  43814. exitXRAsync(): Promise<void>;
  43815. /**
  43816. * Checks if a session would be supported for the creation options specified
  43817. * @param sessionMode session mode to check if supported eg. immersive-vr
  43818. * @returns true if supported
  43819. */
  43820. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43821. /**
  43822. * Creates a WebXRRenderTarget object for the XR session
  43823. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43824. * @param options optional options to provide when creating a new render target
  43825. * @returns a WebXR render target to which the session can render
  43826. */
  43827. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43828. /**
  43829. * @hidden
  43830. * Converts the render layer of xrSession to a render target
  43831. * @param session session to create render target for
  43832. * @param scene scene the new render target should be created for
  43833. * @param baseLayer the webgl layer to create the render target for
  43834. */
  43835. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43836. /**
  43837. * Disposes of the session manager
  43838. */
  43839. dispose(): void;
  43840. /**
  43841. * Gets a promise returning true when fullfiled if the given session mode is supported
  43842. * @param sessionMode defines the session to test
  43843. * @returns a promise
  43844. */
  43845. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43846. }
  43847. }
  43848. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43849. import { Scene } from "babylonjs/scene";
  43850. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43851. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43852. /**
  43853. * WebXR Camera which holds the views for the xrSession
  43854. * @see https://doc.babylonjs.com/how_to/webxr
  43855. */
  43856. export class WebXRCamera extends FreeCamera {
  43857. /**
  43858. * Is the camera in debug mode. Used when using an emulator
  43859. */
  43860. debugMode: boolean;
  43861. /**
  43862. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43863. * @param name the name of the camera
  43864. * @param scene the scene to add the camera to
  43865. */
  43866. constructor(name: string, scene: Scene);
  43867. private _updateNumberOfRigCameras;
  43868. /** @hidden */
  43869. _updateForDualEyeDebugging(): void;
  43870. /**
  43871. * Updates the cameras position from the current pose information of the XR session
  43872. * @param xrSessionManager the session containing pose information
  43873. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43874. */
  43875. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43876. }
  43877. }
  43878. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43879. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43880. import { IDisposable } from "babylonjs/scene";
  43881. /**
  43882. * Defining the interface required for a (webxr) feature
  43883. */
  43884. export interface IWebXRFeature extends IDisposable {
  43885. /**
  43886. * Attach the feature to the session
  43887. * Will usually be called by the features manager
  43888. *
  43889. * @returns true if successful.
  43890. */
  43891. attach(): boolean;
  43892. /**
  43893. * Detach the feature from the session
  43894. * Will usually be called by the features manager
  43895. *
  43896. * @returns true if successful.
  43897. */
  43898. detach(): boolean;
  43899. }
  43900. /**
  43901. * Defining the constructor of a feature. Used to register the modules.
  43902. */
  43903. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43904. /**
  43905. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43906. * It is mainly used in AR sessions.
  43907. *
  43908. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43909. */
  43910. export class WebXRFeaturesManager implements IDisposable {
  43911. private _xrSessionManager;
  43912. private static readonly _AvailableFeatures;
  43913. /**
  43914. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43915. * Mainly used internally.
  43916. *
  43917. * @param featureName the name of the feature to register
  43918. * @param constructorFunction the function used to construct the module
  43919. * @param version the (babylon) version of the module
  43920. * @param stable is that a stable version of this module
  43921. */
  43922. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43923. /**
  43924. * Returns a constructor of a specific feature.
  43925. *
  43926. * @param featureName the name of the feature to construct
  43927. * @param version the version of the feature to load
  43928. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43929. * @param options optional options provided to the module.
  43930. * @returns a function that, when called, will return a new instance of this feature
  43931. */
  43932. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43933. /**
  43934. * Return the latest unstable version of this feature
  43935. * @param featureName the name of the feature to search
  43936. * @returns the version number. if not found will return -1
  43937. */
  43938. static GetLatestVersionOfFeature(featureName: string): number;
  43939. /**
  43940. * Return the latest stable version of this feature
  43941. * @param featureName the name of the feature to search
  43942. * @returns the version number. if not found will return -1
  43943. */
  43944. static GetStableVersionOfFeature(featureName: string): number;
  43945. /**
  43946. * Can be used to return the list of features currently registered
  43947. *
  43948. * @returns an Array of available features
  43949. */
  43950. static GetAvailableFeatures(): string[];
  43951. /**
  43952. * Gets the versions available for a specific feature
  43953. * @param featureName the name of the feature
  43954. * @returns an array with the available versions
  43955. */
  43956. static GetAvailableVersions(featureName: string): string[];
  43957. private _features;
  43958. /**
  43959. * constructs a new features manages.
  43960. *
  43961. * @param _xrSessionManager an instance of WebXRSessionManager
  43962. */
  43963. constructor(_xrSessionManager: WebXRSessionManager);
  43964. /**
  43965. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  43966. *
  43967. * @param featureName the name of the feature to load or the class of the feature
  43968. * @param version optional version to load. if not provided the latest version will be enabled
  43969. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43970. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43971. * @returns a new constructed feature or throws an error if feature not found.
  43972. */
  43973. enableFeature(featureName: string | {
  43974. Name: string;
  43975. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43976. /**
  43977. * Used to disable an already-enabled feature
  43978. * @param featureName the feature to disable
  43979. * @returns true if disable was successful
  43980. */
  43981. disableFeature(featureName: string | {
  43982. Name: string;
  43983. }): boolean;
  43984. /**
  43985. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43986. * Can be used during a session to start a feature
  43987. * @param featureName the name of feature to attach
  43988. */
  43989. attachFeature(featureName: string): void;
  43990. /**
  43991. * Can be used inside a session or when the session ends to detach a specific feature
  43992. * @param featureName the name of the feature to detach
  43993. */
  43994. detachFeature(featureName: string): void;
  43995. /**
  43996. * Get the list of enabled features
  43997. * @returns an array of enabled features
  43998. */
  43999. getEnabledFeatures(): string[];
  44000. /**
  44001. * get the implementation of an enabled feature.
  44002. * @param featureName the name of the feature to load
  44003. * @returns the feature class, if found
  44004. */
  44005. getEnabledFeature(featureName: string): IWebXRFeature;
  44006. /**
  44007. * dispose this features manager
  44008. */
  44009. dispose(): void;
  44010. }
  44011. }
  44012. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44013. import { Observable } from "babylonjs/Misc/observable";
  44014. import { IDisposable, Scene } from "babylonjs/scene";
  44015. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  44016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44017. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44018. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44019. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44020. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44021. /**
  44022. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44023. * @see https://doc.babylonjs.com/how_to/webxr
  44024. */
  44025. export class WebXRExperienceHelper implements IDisposable {
  44026. private scene;
  44027. /**
  44028. * 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
  44029. */
  44030. container: AbstractMesh;
  44031. /**
  44032. * Camera used to render xr content
  44033. */
  44034. camera: WebXRCamera;
  44035. /**
  44036. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44037. */
  44038. state: WebXRState;
  44039. private _setState;
  44040. private static _TmpVector;
  44041. /**
  44042. * Fires when the state of the experience helper has changed
  44043. */
  44044. onStateChangedObservable: Observable<WebXRState>;
  44045. /** Session manager used to keep track of xr session */
  44046. sessionManager: WebXRSessionManager;
  44047. /** A features manager for this xr session */
  44048. featuresManager: WebXRFeaturesManager;
  44049. private _nonVRCamera;
  44050. private _originalSceneAutoClear;
  44051. private _supported;
  44052. /**
  44053. * Creates the experience helper
  44054. * @param scene the scene to attach the experience helper to
  44055. * @returns a promise for the experience helper
  44056. */
  44057. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44058. /**
  44059. * Creates a WebXRExperienceHelper
  44060. * @param scene The scene the helper should be created in
  44061. */
  44062. private constructor();
  44063. /**
  44064. * Exits XR mode and returns the scene to its original state
  44065. * @returns promise that resolves after xr mode has exited
  44066. */
  44067. exitXRAsync(): Promise<void>;
  44068. /**
  44069. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44070. * @param sessionMode options for the XR session
  44071. * @param referenceSpaceType frame of reference of the XR session
  44072. * @param renderTarget the output canvas that will be used to enter XR mode
  44073. * @returns promise that resolves after xr mode has entered
  44074. */
  44075. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44076. /**
  44077. * Updates the global position of the camera by moving the camera's container
  44078. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  44079. * @param position The desired global position of the camera
  44080. */
  44081. setPositionOfCameraUsingContainer(position: Vector3): void;
  44082. /**
  44083. * Rotates the xr camera by rotating the camera's container around the camera's position
  44084. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  44085. * @param rotation the desired quaternion rotation to apply to the camera
  44086. */
  44087. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  44088. /**
  44089. * Disposes of the experience helper
  44090. */
  44091. dispose(): void;
  44092. }
  44093. }
  44094. declare module "babylonjs/Cameras/XR/webXRController" {
  44095. import { Nullable } from "babylonjs/types";
  44096. import { Observable } from "babylonjs/Misc/observable";
  44097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44098. import { Ray } from "babylonjs/Culling/ray";
  44099. import { Scene } from "babylonjs/scene";
  44100. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44101. /**
  44102. * Represents an XR input
  44103. */
  44104. export class WebXRController {
  44105. private scene;
  44106. /** The underlying input source for the controller */
  44107. inputSource: XRInputSource;
  44108. private parentContainer;
  44109. /**
  44110. * 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
  44111. */
  44112. grip?: AbstractMesh;
  44113. /**
  44114. * Pointer which can be used to select objects or attach a visible laser to
  44115. */
  44116. pointer: AbstractMesh;
  44117. private _gamepadMode;
  44118. /**
  44119. * If available, this is the gamepad object related to this controller.
  44120. * Using this object it is possible to get click events and trackpad changes of the
  44121. * webxr controller that is currently being used.
  44122. */
  44123. gamepadController?: WebVRController;
  44124. /**
  44125. * Event that fires when the controller is removed/disposed
  44126. */
  44127. onDisposeObservable: Observable<{}>;
  44128. private _tmpQuaternion;
  44129. private _tmpVector;
  44130. /**
  44131. * Creates the controller
  44132. * @see https://doc.babylonjs.com/how_to/webxr
  44133. * @param scene the scene which the controller should be associated to
  44134. * @param inputSource the underlying input source for the controller
  44135. * @param parentContainer parent that the controller meshes should be children of
  44136. */
  44137. constructor(scene: Scene,
  44138. /** The underlying input source for the controller */
  44139. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  44140. /**
  44141. * Updates the controller pose based on the given XRFrame
  44142. * @param xrFrame xr frame to update the pose with
  44143. * @param referenceSpace reference space to use
  44144. */
  44145. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44146. /**
  44147. * Gets a world space ray coming from the controller
  44148. * @param result the resulting ray
  44149. */
  44150. getWorldPointerRayToRef(result: Ray): void;
  44151. /**
  44152. * Get the scene associated with this controller
  44153. * @returns the scene object
  44154. */
  44155. getScene(): Scene;
  44156. /**
  44157. * Disposes of the object
  44158. */
  44159. dispose(): void;
  44160. }
  44161. }
  44162. declare module "babylonjs/Cameras/XR/webXRInput" {
  44163. import { Observable } from "babylonjs/Misc/observable";
  44164. import { IDisposable } from "babylonjs/scene";
  44165. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44166. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44167. /**
  44168. * XR input used to track XR inputs such as controllers/rays
  44169. */
  44170. export class WebXRInput implements IDisposable {
  44171. /**
  44172. * Base experience the input listens to
  44173. */
  44174. baseExperience: WebXRExperienceHelper;
  44175. /**
  44176. * XR controllers being tracked
  44177. */
  44178. controllers: Array<WebXRController>;
  44179. private _frameObserver;
  44180. private _stateObserver;
  44181. /**
  44182. * Event when a controller has been connected/added
  44183. */
  44184. onControllerAddedObservable: Observable<WebXRController>;
  44185. /**
  44186. * Event when a controller has been removed/disconnected
  44187. */
  44188. onControllerRemovedObservable: Observable<WebXRController>;
  44189. /**
  44190. * Initializes the WebXRInput
  44191. * @param baseExperience experience helper which the input should be created for
  44192. */
  44193. constructor(
  44194. /**
  44195. * Base experience the input listens to
  44196. */
  44197. baseExperience: WebXRExperienceHelper);
  44198. private _onInputSourcesChange;
  44199. private _addAndRemoveControllers;
  44200. /**
  44201. * Disposes of the object
  44202. */
  44203. dispose(): void;
  44204. }
  44205. }
  44206. declare module "babylonjs/Loading/sceneLoader" {
  44207. import { Observable } from "babylonjs/Misc/observable";
  44208. import { Nullable } from "babylonjs/types";
  44209. import { Scene } from "babylonjs/scene";
  44210. import { Engine } from "babylonjs/Engines/engine";
  44211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44212. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44213. import { AssetContainer } from "babylonjs/assetContainer";
  44214. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44215. import { Skeleton } from "babylonjs/Bones/skeleton";
  44216. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44217. import { WebRequest } from "babylonjs/Misc/webRequest";
  44218. /**
  44219. * Class used to represent data loading progression
  44220. */
  44221. export class SceneLoaderProgressEvent {
  44222. /** defines if data length to load can be evaluated */
  44223. readonly lengthComputable: boolean;
  44224. /** defines the loaded data length */
  44225. readonly loaded: number;
  44226. /** defines the data length to load */
  44227. readonly total: number;
  44228. /**
  44229. * Create a new progress event
  44230. * @param lengthComputable defines if data length to load can be evaluated
  44231. * @param loaded defines the loaded data length
  44232. * @param total defines the data length to load
  44233. */
  44234. constructor(
  44235. /** defines if data length to load can be evaluated */
  44236. lengthComputable: boolean,
  44237. /** defines the loaded data length */
  44238. loaded: number,
  44239. /** defines the data length to load */
  44240. total: number);
  44241. /**
  44242. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44243. * @param event defines the source event
  44244. * @returns a new SceneLoaderProgressEvent
  44245. */
  44246. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44247. }
  44248. /**
  44249. * Interface used by SceneLoader plugins to define supported file extensions
  44250. */
  44251. export interface ISceneLoaderPluginExtensions {
  44252. /**
  44253. * Defines the list of supported extensions
  44254. */
  44255. [extension: string]: {
  44256. isBinary: boolean;
  44257. };
  44258. }
  44259. /**
  44260. * Interface used by SceneLoader plugin factory
  44261. */
  44262. export interface ISceneLoaderPluginFactory {
  44263. /**
  44264. * Defines the name of the factory
  44265. */
  44266. name: string;
  44267. /**
  44268. * Function called to create a new plugin
  44269. * @return the new plugin
  44270. */
  44271. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44272. /**
  44273. * The callback that returns true if the data can be directly loaded.
  44274. * @param data string containing the file data
  44275. * @returns if the data can be loaded directly
  44276. */
  44277. canDirectLoad?(data: string): boolean;
  44278. }
  44279. /**
  44280. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44281. */
  44282. export interface ISceneLoaderPluginBase {
  44283. /**
  44284. * The friendly name of this plugin.
  44285. */
  44286. name: string;
  44287. /**
  44288. * The file extensions supported by this plugin.
  44289. */
  44290. extensions: string | ISceneLoaderPluginExtensions;
  44291. /**
  44292. * The callback called when loading from a url.
  44293. * @param scene scene loading this url
  44294. * @param url url to load
  44295. * @param onSuccess callback called when the file successfully loads
  44296. * @param onProgress callback called while file is loading (if the server supports this mode)
  44297. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44298. * @param onError callback called when the file fails to load
  44299. * @returns a file request object
  44300. */
  44301. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44302. /**
  44303. * The callback called when loading from a file object.
  44304. * @param scene scene loading this file
  44305. * @param file defines the file to load
  44306. * @param onSuccess defines the callback to call when data is loaded
  44307. * @param onProgress defines the callback to call during loading process
  44308. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44309. * @param onError defines the callback to call when an error occurs
  44310. * @returns a file request object
  44311. */
  44312. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44313. /**
  44314. * The callback that returns true if the data can be directly loaded.
  44315. * @param data string containing the file data
  44316. * @returns if the data can be loaded directly
  44317. */
  44318. canDirectLoad?(data: string): boolean;
  44319. /**
  44320. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44321. * @param scene scene loading this data
  44322. * @param data string containing the data
  44323. * @returns data to pass to the plugin
  44324. */
  44325. directLoad?(scene: Scene, data: string): any;
  44326. /**
  44327. * The callback that allows custom handling of the root url based on the response url.
  44328. * @param rootUrl the original root url
  44329. * @param responseURL the response url if available
  44330. * @returns the new root url
  44331. */
  44332. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44333. }
  44334. /**
  44335. * Interface used to define a SceneLoader plugin
  44336. */
  44337. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44338. /**
  44339. * Import meshes into a scene.
  44340. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44341. * @param scene The scene to import into
  44342. * @param data The data to import
  44343. * @param rootUrl The root url for scene and resources
  44344. * @param meshes The meshes array to import into
  44345. * @param particleSystems The particle systems array to import into
  44346. * @param skeletons The skeletons array to import into
  44347. * @param onError The callback when import fails
  44348. * @returns True if successful or false otherwise
  44349. */
  44350. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44351. /**
  44352. * Load into a scene.
  44353. * @param scene The scene to load into
  44354. * @param data The data to import
  44355. * @param rootUrl The root url for scene and resources
  44356. * @param onError The callback when import fails
  44357. * @returns True if successful or false otherwise
  44358. */
  44359. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44360. /**
  44361. * Load into an asset container.
  44362. * @param scene The scene to load into
  44363. * @param data The data to import
  44364. * @param rootUrl The root url for scene and resources
  44365. * @param onError The callback when import fails
  44366. * @returns The loaded asset container
  44367. */
  44368. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44369. }
  44370. /**
  44371. * Interface used to define an async SceneLoader plugin
  44372. */
  44373. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44374. /**
  44375. * Import meshes into a scene.
  44376. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44377. * @param scene The scene to import into
  44378. * @param data The data to import
  44379. * @param rootUrl The root url for scene and resources
  44380. * @param onProgress The callback when the load progresses
  44381. * @param fileName Defines the name of the file to load
  44382. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44383. */
  44384. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44385. meshes: AbstractMesh[];
  44386. particleSystems: IParticleSystem[];
  44387. skeletons: Skeleton[];
  44388. animationGroups: AnimationGroup[];
  44389. }>;
  44390. /**
  44391. * Load into a scene.
  44392. * @param scene The scene to load into
  44393. * @param data The data to import
  44394. * @param rootUrl The root url for scene and resources
  44395. * @param onProgress The callback when the load progresses
  44396. * @param fileName Defines the name of the file to load
  44397. * @returns Nothing
  44398. */
  44399. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44400. /**
  44401. * Load into an asset container.
  44402. * @param scene The scene to load into
  44403. * @param data The data to import
  44404. * @param rootUrl The root url for scene and resources
  44405. * @param onProgress The callback when the load progresses
  44406. * @param fileName Defines the name of the file to load
  44407. * @returns The loaded asset container
  44408. */
  44409. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44410. }
  44411. /**
  44412. * Mode that determines how to handle old animation groups before loading new ones.
  44413. */
  44414. export enum SceneLoaderAnimationGroupLoadingMode {
  44415. /**
  44416. * Reset all old animations to initial state then dispose them.
  44417. */
  44418. Clean = 0,
  44419. /**
  44420. * Stop all old animations.
  44421. */
  44422. Stop = 1,
  44423. /**
  44424. * Restart old animations from first frame.
  44425. */
  44426. Sync = 2,
  44427. /**
  44428. * Old animations remains untouched.
  44429. */
  44430. NoSync = 3
  44431. }
  44432. /**
  44433. * Class used to load scene from various file formats using registered plugins
  44434. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44435. */
  44436. export class SceneLoader {
  44437. /**
  44438. * No logging while loading
  44439. */
  44440. static readonly NO_LOGGING: number;
  44441. /**
  44442. * Minimal logging while loading
  44443. */
  44444. static readonly MINIMAL_LOGGING: number;
  44445. /**
  44446. * Summary logging while loading
  44447. */
  44448. static readonly SUMMARY_LOGGING: number;
  44449. /**
  44450. * Detailled logging while loading
  44451. */
  44452. static readonly DETAILED_LOGGING: number;
  44453. /**
  44454. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44455. */
  44456. static get ForceFullSceneLoadingForIncremental(): boolean;
  44457. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44458. /**
  44459. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44460. */
  44461. static get ShowLoadingScreen(): boolean;
  44462. static set ShowLoadingScreen(value: boolean);
  44463. /**
  44464. * Defines the current logging level (while loading the scene)
  44465. * @ignorenaming
  44466. */
  44467. static get loggingLevel(): number;
  44468. static set loggingLevel(value: number);
  44469. /**
  44470. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44471. */
  44472. static get CleanBoneMatrixWeights(): boolean;
  44473. static set CleanBoneMatrixWeights(value: boolean);
  44474. /**
  44475. * Event raised when a plugin is used to load a scene
  44476. */
  44477. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44478. private static _registeredPlugins;
  44479. private static _getDefaultPlugin;
  44480. private static _getPluginForExtension;
  44481. private static _getPluginForDirectLoad;
  44482. private static _getPluginForFilename;
  44483. private static _getDirectLoad;
  44484. private static _loadData;
  44485. private static _getFileInfo;
  44486. /**
  44487. * Gets a plugin that can load the given extension
  44488. * @param extension defines the extension to load
  44489. * @returns a plugin or null if none works
  44490. */
  44491. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44492. /**
  44493. * Gets a boolean indicating that the given extension can be loaded
  44494. * @param extension defines the extension to load
  44495. * @returns true if the extension is supported
  44496. */
  44497. static IsPluginForExtensionAvailable(extension: string): boolean;
  44498. /**
  44499. * Adds a new plugin to the list of registered plugins
  44500. * @param plugin defines the plugin to add
  44501. */
  44502. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44503. /**
  44504. * Import meshes into a scene
  44505. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44506. * @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)
  44507. * @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)
  44508. * @param scene the instance of BABYLON.Scene to append to
  44509. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44510. * @param onProgress a callback with a progress event for each file being loaded
  44511. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44512. * @param pluginExtension the extension used to determine the plugin
  44513. * @returns The loaded plugin
  44514. */
  44515. 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>;
  44516. /**
  44517. * Import meshes into a scene
  44518. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44519. * @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)
  44520. * @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)
  44521. * @param scene the instance of BABYLON.Scene to append to
  44522. * @param onProgress a callback with a progress event for each file being loaded
  44523. * @param pluginExtension the extension used to determine the plugin
  44524. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44525. */
  44526. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44527. meshes: AbstractMesh[];
  44528. particleSystems: IParticleSystem[];
  44529. skeletons: Skeleton[];
  44530. animationGroups: AnimationGroup[];
  44531. }>;
  44532. /**
  44533. * Load a scene
  44534. * @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)
  44535. * @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)
  44536. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44537. * @param onSuccess a callback with the scene when import succeeds
  44538. * @param onProgress a callback with a progress event for each file being loaded
  44539. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44540. * @param pluginExtension the extension used to determine the plugin
  44541. * @returns The loaded plugin
  44542. */
  44543. 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>;
  44544. /**
  44545. * Load a scene
  44546. * @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)
  44547. * @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)
  44548. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44549. * @param onProgress a callback with a progress event for each file being loaded
  44550. * @param pluginExtension the extension used to determine the plugin
  44551. * @returns The loaded scene
  44552. */
  44553. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44554. /**
  44555. * Append a scene
  44556. * @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)
  44557. * @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)
  44558. * @param scene is the instance of BABYLON.Scene to append to
  44559. * @param onSuccess a callback with the scene when import succeeds
  44560. * @param onProgress a callback with a progress event for each file being loaded
  44561. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44562. * @param pluginExtension the extension used to determine the plugin
  44563. * @returns The loaded plugin
  44564. */
  44565. 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>;
  44566. /**
  44567. * Append a scene
  44568. * @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)
  44569. * @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)
  44570. * @param scene is the instance of BABYLON.Scene to append to
  44571. * @param onProgress a callback with a progress event for each file being loaded
  44572. * @param pluginExtension the extension used to determine the plugin
  44573. * @returns The given scene
  44574. */
  44575. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44576. /**
  44577. * Load a scene into an asset container
  44578. * @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)
  44579. * @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)
  44580. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44581. * @param onSuccess a callback with the scene when import succeeds
  44582. * @param onProgress a callback with a progress event for each file being loaded
  44583. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44584. * @param pluginExtension the extension used to determine the plugin
  44585. * @returns The loaded plugin
  44586. */
  44587. 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>;
  44588. /**
  44589. * Load a scene into an asset container
  44590. * @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)
  44591. * @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)
  44592. * @param scene is the instance of Scene to append to
  44593. * @param onProgress a callback with a progress event for each file being loaded
  44594. * @param pluginExtension the extension used to determine the plugin
  44595. * @returns The loaded asset container
  44596. */
  44597. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44598. /**
  44599. * Import animations from a file into a scene
  44600. * @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)
  44601. * @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)
  44602. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44603. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44604. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44605. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44606. * @param onSuccess a callback with the scene when import succeeds
  44607. * @param onProgress a callback with a progress event for each file being loaded
  44608. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44609. */
  44610. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  44611. /**
  44612. * Import animations from a file into a scene
  44613. * @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)
  44614. * @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)
  44615. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44616. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44617. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44618. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44619. * @param onSuccess a callback with the scene when import succeeds
  44620. * @param onProgress a callback with a progress event for each file being loaded
  44621. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44622. * @returns the updated scene with imported animations
  44623. */
  44624. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  44625. }
  44626. }
  44627. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44628. import { Scene } from "babylonjs/scene";
  44629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44630. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44631. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44632. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44633. /**
  44634. * Generic Controller
  44635. */
  44636. export class GenericController extends WebVRController {
  44637. /**
  44638. * Base Url for the controller model.
  44639. */
  44640. static readonly MODEL_BASE_URL: string;
  44641. /**
  44642. * File name for the controller model.
  44643. */
  44644. static readonly MODEL_FILENAME: string;
  44645. /**
  44646. * Creates a new GenericController from a gamepad
  44647. * @param vrGamepad the gamepad that the controller should be created from
  44648. */
  44649. constructor(vrGamepad: any);
  44650. /**
  44651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44652. * @param scene scene in which to add meshes
  44653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44654. */
  44655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44656. /**
  44657. * Called once for each button that changed state since the last frame
  44658. * @param buttonIdx Which button index changed
  44659. * @param state New state of the button
  44660. * @param changes Which properties on the state changed since last frame
  44661. */
  44662. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44663. }
  44664. }
  44665. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44666. import { Observable } from "babylonjs/Misc/observable";
  44667. import { Scene } from "babylonjs/scene";
  44668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44669. import { Ray } from "babylonjs/Culling/ray";
  44670. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44671. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44672. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44673. /**
  44674. * Defines the WindowsMotionController object that the state of the windows motion controller
  44675. */
  44676. export class WindowsMotionController extends WebVRController {
  44677. /**
  44678. * The base url used to load the left and right controller models
  44679. */
  44680. static MODEL_BASE_URL: string;
  44681. /**
  44682. * The name of the left controller model file
  44683. */
  44684. static MODEL_LEFT_FILENAME: string;
  44685. /**
  44686. * The name of the right controller model file
  44687. */
  44688. static MODEL_RIGHT_FILENAME: string;
  44689. /**
  44690. * The controller name prefix for this controller type
  44691. */
  44692. static readonly GAMEPAD_ID_PREFIX: string;
  44693. /**
  44694. * The controller id pattern for this controller type
  44695. */
  44696. private static readonly GAMEPAD_ID_PATTERN;
  44697. private _loadedMeshInfo;
  44698. protected readonly _mapping: {
  44699. buttons: string[];
  44700. buttonMeshNames: {
  44701. 'trigger': string;
  44702. 'menu': string;
  44703. 'grip': string;
  44704. 'thumbstick': string;
  44705. 'trackpad': string;
  44706. };
  44707. buttonObservableNames: {
  44708. 'trigger': string;
  44709. 'menu': string;
  44710. 'grip': string;
  44711. 'thumbstick': string;
  44712. 'trackpad': string;
  44713. };
  44714. axisMeshNames: string[];
  44715. pointingPoseMeshName: string;
  44716. };
  44717. /**
  44718. * Fired when the trackpad on this controller is clicked
  44719. */
  44720. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44721. /**
  44722. * Fired when the trackpad on this controller is modified
  44723. */
  44724. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44725. /**
  44726. * The current x and y values of this controller's trackpad
  44727. */
  44728. trackpad: StickValues;
  44729. /**
  44730. * Creates a new WindowsMotionController from a gamepad
  44731. * @param vrGamepad the gamepad that the controller should be created from
  44732. */
  44733. constructor(vrGamepad: any);
  44734. /**
  44735. * Fired when the trigger on this controller is modified
  44736. */
  44737. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44738. /**
  44739. * Fired when the menu button on this controller is modified
  44740. */
  44741. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44742. /**
  44743. * Fired when the grip button on this controller is modified
  44744. */
  44745. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44746. /**
  44747. * Fired when the thumbstick button on this controller is modified
  44748. */
  44749. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44750. /**
  44751. * Fired when the touchpad button on this controller is modified
  44752. */
  44753. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44754. /**
  44755. * Fired when the touchpad values on this controller are modified
  44756. */
  44757. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  44758. protected _updateTrackpad(): void;
  44759. /**
  44760. * Called once per frame by the engine.
  44761. */
  44762. update(): void;
  44763. /**
  44764. * Called once for each button that changed state since the last frame
  44765. * @param buttonIdx Which button index changed
  44766. * @param state New state of the button
  44767. * @param changes Which properties on the state changed since last frame
  44768. */
  44769. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44770. /**
  44771. * Moves the buttons on the controller mesh based on their current state
  44772. * @param buttonName the name of the button to move
  44773. * @param buttonValue the value of the button which determines the buttons new position
  44774. */
  44775. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44776. /**
  44777. * Moves the axis on the controller mesh based on its current state
  44778. * @param axis the index of the axis
  44779. * @param axisValue the value of the axis which determines the meshes new position
  44780. * @hidden
  44781. */
  44782. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44783. /**
  44784. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44785. * @param scene scene in which to add meshes
  44786. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44787. */
  44788. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44789. /**
  44790. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44791. * can be transformed by button presses and axes values, based on this._mapping.
  44792. *
  44793. * @param scene scene in which the meshes exist
  44794. * @param meshes list of meshes that make up the controller model to process
  44795. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44796. */
  44797. private processModel;
  44798. private createMeshInfo;
  44799. /**
  44800. * Gets the ray of the controller in the direction the controller is pointing
  44801. * @param length the length the resulting ray should be
  44802. * @returns a ray in the direction the controller is pointing
  44803. */
  44804. getForwardRay(length?: number): Ray;
  44805. /**
  44806. * Disposes of the controller
  44807. */
  44808. dispose(): void;
  44809. }
  44810. /**
  44811. * This class represents a new windows motion controller in XR.
  44812. */
  44813. export class XRWindowsMotionController extends WindowsMotionController {
  44814. /**
  44815. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44816. */
  44817. protected readonly _mapping: {
  44818. buttons: string[];
  44819. buttonMeshNames: {
  44820. 'trigger': string;
  44821. 'menu': string;
  44822. 'grip': string;
  44823. 'thumbstick': string;
  44824. 'trackpad': string;
  44825. };
  44826. buttonObservableNames: {
  44827. 'trigger': string;
  44828. 'menu': string;
  44829. 'grip': string;
  44830. 'thumbstick': string;
  44831. 'trackpad': string;
  44832. };
  44833. axisMeshNames: string[];
  44834. pointingPoseMeshName: string;
  44835. };
  44836. /**
  44837. * Construct a new XR-Based windows motion controller
  44838. *
  44839. * @param gamepadInfo the gamepad object from the browser
  44840. */
  44841. constructor(gamepadInfo: any);
  44842. /**
  44843. * holds the thumbstick values (X,Y)
  44844. */
  44845. thumbstickValues: StickValues;
  44846. /**
  44847. * Fired when the thumbstick on this controller is clicked
  44848. */
  44849. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44850. /**
  44851. * Fired when the thumbstick on this controller is modified
  44852. */
  44853. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44854. /**
  44855. * Fired when the touchpad button on this controller is modified
  44856. */
  44857. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44858. /**
  44859. * Fired when the touchpad values on this controller are modified
  44860. */
  44861. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44862. /**
  44863. * Fired when the thumbstick button on this controller is modified
  44864. * here to prevent breaking changes
  44865. */
  44866. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44867. /**
  44868. * updating the thumbstick(!) and not the trackpad.
  44869. * This is named this way due to the difference between WebVR and XR and to avoid
  44870. * changing the parent class.
  44871. */
  44872. protected _updateTrackpad(): void;
  44873. /**
  44874. * Disposes the class with joy
  44875. */
  44876. dispose(): void;
  44877. }
  44878. }
  44879. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44880. import { Observable } from "babylonjs/Misc/observable";
  44881. import { Scene } from "babylonjs/scene";
  44882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44883. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44884. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44885. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44886. /**
  44887. * Oculus Touch Controller
  44888. */
  44889. export class OculusTouchController extends WebVRController {
  44890. /**
  44891. * Base Url for the controller model.
  44892. */
  44893. static MODEL_BASE_URL: string;
  44894. /**
  44895. * File name for the left controller model.
  44896. */
  44897. static MODEL_LEFT_FILENAME: string;
  44898. /**
  44899. * File name for the right controller model.
  44900. */
  44901. static MODEL_RIGHT_FILENAME: string;
  44902. /**
  44903. * Base Url for the Quest controller model.
  44904. */
  44905. static QUEST_MODEL_BASE_URL: string;
  44906. /**
  44907. * @hidden
  44908. * If the controllers are running on a device that needs the updated Quest controller models
  44909. */
  44910. static _IsQuest: boolean;
  44911. /**
  44912. * Fired when the secondary trigger on this controller is modified
  44913. */
  44914. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44915. /**
  44916. * Fired when the thumb rest on this controller is modified
  44917. */
  44918. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44919. /**
  44920. * Creates a new OculusTouchController from a gamepad
  44921. * @param vrGamepad the gamepad that the controller should be created from
  44922. */
  44923. constructor(vrGamepad: any);
  44924. /**
  44925. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44926. * @param scene scene in which to add meshes
  44927. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44928. */
  44929. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44930. /**
  44931. * Fired when the A button on this controller is modified
  44932. */
  44933. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44934. /**
  44935. * Fired when the B button on this controller is modified
  44936. */
  44937. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44938. /**
  44939. * Fired when the X button on this controller is modified
  44940. */
  44941. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44942. /**
  44943. * Fired when the Y button on this controller is modified
  44944. */
  44945. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44946. /**
  44947. * Called once for each button that changed state since the last frame
  44948. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44949. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44950. * 2) secondary trigger (same)
  44951. * 3) A (right) X (left), touch, pressed = value
  44952. * 4) B / Y
  44953. * 5) thumb rest
  44954. * @param buttonIdx Which button index changed
  44955. * @param state New state of the button
  44956. * @param changes Which properties on the state changed since last frame
  44957. */
  44958. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44959. }
  44960. }
  44961. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44962. import { Scene } from "babylonjs/scene";
  44963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44964. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44965. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44966. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44967. import { Observable } from "babylonjs/Misc/observable";
  44968. /**
  44969. * Vive Controller
  44970. */
  44971. export class ViveController extends WebVRController {
  44972. /**
  44973. * Base Url for the controller model.
  44974. */
  44975. static MODEL_BASE_URL: string;
  44976. /**
  44977. * File name for the controller model.
  44978. */
  44979. static MODEL_FILENAME: string;
  44980. /**
  44981. * Creates a new ViveController from a gamepad
  44982. * @param vrGamepad the gamepad that the controller should be created from
  44983. */
  44984. constructor(vrGamepad: any);
  44985. /**
  44986. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44987. * @param scene scene in which to add meshes
  44988. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44989. */
  44990. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44991. /**
  44992. * Fired when the left button on this controller is modified
  44993. */
  44994. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44995. /**
  44996. * Fired when the right button on this controller is modified
  44997. */
  44998. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44999. /**
  45000. * Fired when the menu button on this controller is modified
  45001. */
  45002. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45003. /**
  45004. * Called once for each button that changed state since the last frame
  45005. * Vive mapping:
  45006. * 0: touchpad
  45007. * 1: trigger
  45008. * 2: left AND right buttons
  45009. * 3: menu button
  45010. * @param buttonIdx Which button index changed
  45011. * @param state New state of the button
  45012. * @param changes Which properties on the state changed since last frame
  45013. */
  45014. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45015. }
  45016. }
  45017. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  45018. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45019. import { Observable } from "babylonjs/Misc/observable";
  45020. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45021. /**
  45022. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  45023. */
  45024. export class WebXRControllerModelLoader {
  45025. /**
  45026. * an observable that triggers when a new model (the mesh itself) was initialized.
  45027. * To know when the mesh was loaded use the controller's own modelLoaded() method
  45028. */
  45029. onControllerModelLoaded: Observable<WebXRController>;
  45030. /**
  45031. * Creates the WebXRControllerModelLoader
  45032. * @param input xr input that creates the controllers
  45033. */
  45034. constructor(input: WebXRInput);
  45035. }
  45036. }
  45037. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45038. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45039. /**
  45040. * Handles pointer input automatically for the pointer of XR controllers
  45041. */
  45042. export class WebXRControllerPointerSelection {
  45043. private static _idCounter;
  45044. private _tmpRay;
  45045. /**
  45046. * Creates a WebXRControllerPointerSelection
  45047. * @param input input manager to setup pointer selection
  45048. */
  45049. constructor(input: WebXRInput);
  45050. private _convertNormalToDirectionOfRay;
  45051. private _updatePointerDistance;
  45052. }
  45053. }
  45054. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45056. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45057. /**
  45058. * Enables teleportation
  45059. */
  45060. export class WebXRControllerTeleportation {
  45061. private _teleportationFillColor;
  45062. private _teleportationBorderColor;
  45063. private _tmpRay;
  45064. private _tmpVector;
  45065. /**
  45066. * when set to true (default) teleportation will wait for thumbstick changes.
  45067. * When set to false teleportation will be disabled.
  45068. *
  45069. * If set to false while teleporting results can be unexpected.
  45070. */
  45071. enabled: boolean;
  45072. /**
  45073. * Creates a WebXRControllerTeleportation
  45074. * @param input input manager to add teleportation to
  45075. * @param floorMeshes floormeshes which can be teleported to
  45076. */
  45077. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45078. }
  45079. }
  45080. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45081. import { Nullable } from "babylonjs/types";
  45082. import { Observable } from "babylonjs/Misc/observable";
  45083. import { IDisposable, Scene } from "babylonjs/scene";
  45084. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45085. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45086. /**
  45087. * Button which can be used to enter a different mode of XR
  45088. */
  45089. export class WebXREnterExitUIButton {
  45090. /** button element */
  45091. element: HTMLElement;
  45092. /** XR initialization options for the button */
  45093. sessionMode: XRSessionMode;
  45094. /** Reference space type */
  45095. referenceSpaceType: XRReferenceSpaceType;
  45096. /**
  45097. * Creates a WebXREnterExitUIButton
  45098. * @param element button element
  45099. * @param sessionMode XR initialization session mode
  45100. * @param referenceSpaceType the type of reference space to be used
  45101. */
  45102. constructor(
  45103. /** button element */
  45104. element: HTMLElement,
  45105. /** XR initialization options for the button */
  45106. sessionMode: XRSessionMode,
  45107. /** Reference space type */
  45108. referenceSpaceType: XRReferenceSpaceType);
  45109. /**
  45110. * Overwritable function which can be used to update the button's visuals when the state changes
  45111. * @param activeButton the current active button in the UI
  45112. */
  45113. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45114. }
  45115. /**
  45116. * Options to create the webXR UI
  45117. */
  45118. export class WebXREnterExitUIOptions {
  45119. /**
  45120. * Context to enter xr with
  45121. */
  45122. renderTarget?: Nullable<WebXRRenderTarget>;
  45123. /**
  45124. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45125. */
  45126. customButtons?: Array<WebXREnterExitUIButton>;
  45127. /**
  45128. * A session mode to use when creating the default button.
  45129. * Default is immersive-vr
  45130. */
  45131. sessionMode?: XRSessionMode;
  45132. /**
  45133. * A reference space type to use when creating the default button.
  45134. * Default is local-floor
  45135. */
  45136. referenceSpaceType?: XRReferenceSpaceType;
  45137. }
  45138. /**
  45139. * UI to allow the user to enter/exit XR mode
  45140. */
  45141. export class WebXREnterExitUI implements IDisposable {
  45142. private scene;
  45143. /** version of the options passed to this UI */
  45144. options: WebXREnterExitUIOptions;
  45145. private _overlay;
  45146. private _buttons;
  45147. private _activeButton;
  45148. /**
  45149. * Fired every time the active button is changed.
  45150. *
  45151. * When xr is entered via a button that launches xr that button will be the callback parameter
  45152. *
  45153. * When exiting xr the callback parameter will be null)
  45154. */
  45155. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45156. /**
  45157. * Creates UI to allow the user to enter/exit XR mode
  45158. * @param scene the scene to add the ui to
  45159. * @param helper the xr experience helper to enter/exit xr with
  45160. * @param options options to configure the UI
  45161. * @returns the created ui
  45162. */
  45163. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45164. /**
  45165. *
  45166. * @param scene babylon scene object to use
  45167. * @param options (read-only) version of the options passed to this UI
  45168. */
  45169. private constructor();
  45170. private _updateButtons;
  45171. /**
  45172. * Disposes of the object
  45173. */
  45174. dispose(): void;
  45175. }
  45176. }
  45177. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45178. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45179. import { Scene } from "babylonjs/scene";
  45180. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45181. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45182. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45183. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45184. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45185. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45187. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45188. /**
  45189. * Options for the default xr helper
  45190. */
  45191. export class WebXRDefaultExperienceOptions {
  45192. /**
  45193. * Floor meshes that should be used for teleporting
  45194. */
  45195. floorMeshes: Array<AbstractMesh>;
  45196. /**
  45197. * Enable or disable default UI to enter XR
  45198. */
  45199. disableDefaultUI?: boolean;
  45200. /**
  45201. * optional configuration for the output canvas
  45202. */
  45203. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45204. /**
  45205. * optional UI options. This can be used among other to change session mode and reference space type
  45206. */
  45207. uiOptions?: WebXREnterExitUIOptions;
  45208. }
  45209. /**
  45210. * Default experience which provides a similar setup to the previous webVRExperience
  45211. */
  45212. export class WebXRDefaultExperience {
  45213. /**
  45214. * Base experience
  45215. */
  45216. baseExperience: WebXRExperienceHelper;
  45217. /**
  45218. * Input experience extension
  45219. */
  45220. input: WebXRInput;
  45221. /**
  45222. * Loads the controller models
  45223. */
  45224. controllerModelLoader: WebXRControllerModelLoader;
  45225. /**
  45226. * Enables laser pointer and selection
  45227. */
  45228. pointerSelection: WebXRControllerPointerSelection;
  45229. /**
  45230. * Enables teleportation
  45231. */
  45232. teleportation: WebXRControllerTeleportation;
  45233. /**
  45234. * Enables ui for entering/exiting xr
  45235. */
  45236. enterExitUI: WebXREnterExitUI;
  45237. /**
  45238. * Default target xr should render to
  45239. */
  45240. renderTarget: WebXRRenderTarget;
  45241. /**
  45242. * Creates the default xr experience
  45243. * @param scene scene
  45244. * @param options options for basic configuration
  45245. * @returns resulting WebXRDefaultExperience
  45246. */
  45247. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45248. private constructor();
  45249. /**
  45250. * DIsposes of the experience helper
  45251. */
  45252. dispose(): void;
  45253. }
  45254. }
  45255. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45256. import { Observable } from "babylonjs/Misc/observable";
  45257. import { Nullable } from "babylonjs/types";
  45258. import { Camera } from "babylonjs/Cameras/camera";
  45259. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45260. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45261. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45262. import { Scene } from "babylonjs/scene";
  45263. import { Vector3 } from "babylonjs/Maths/math.vector";
  45264. import { Color3 } from "babylonjs/Maths/math.color";
  45265. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45267. import { Mesh } from "babylonjs/Meshes/mesh";
  45268. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45269. import { EasingFunction } from "babylonjs/Animations/easing";
  45270. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45271. import "babylonjs/Meshes/Builders/groundBuilder";
  45272. import "babylonjs/Meshes/Builders/torusBuilder";
  45273. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45274. import "babylonjs/Gamepads/gamepadSceneComponent";
  45275. import "babylonjs/Animations/animatable";
  45276. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45277. /**
  45278. * Options to modify the vr teleportation behavior.
  45279. */
  45280. export interface VRTeleportationOptions {
  45281. /**
  45282. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45283. */
  45284. floorMeshName?: string;
  45285. /**
  45286. * A list of meshes to be used as the teleportation floor. (default: empty)
  45287. */
  45288. floorMeshes?: Mesh[];
  45289. /**
  45290. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45291. */
  45292. teleportationMode?: number;
  45293. /**
  45294. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45295. */
  45296. teleportationTime?: number;
  45297. /**
  45298. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45299. */
  45300. teleportationSpeed?: number;
  45301. /**
  45302. * The easing function used in the animation or null for Linear. (default CircleEase)
  45303. */
  45304. easingFunction?: EasingFunction;
  45305. }
  45306. /**
  45307. * Options to modify the vr experience helper's behavior.
  45308. */
  45309. export interface VRExperienceHelperOptions extends WebVROptions {
  45310. /**
  45311. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45312. */
  45313. createDeviceOrientationCamera?: boolean;
  45314. /**
  45315. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45316. */
  45317. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45318. /**
  45319. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45320. */
  45321. laserToggle?: boolean;
  45322. /**
  45323. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45324. */
  45325. floorMeshes?: Mesh[];
  45326. /**
  45327. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45328. */
  45329. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45330. /**
  45331. * Defines if WebXR should be used instead of WebVR (if available)
  45332. */
  45333. useXR?: boolean;
  45334. }
  45335. /**
  45336. * Event containing information after VR has been entered
  45337. */
  45338. export class OnAfterEnteringVRObservableEvent {
  45339. /**
  45340. * If entering vr was successful
  45341. */
  45342. success: boolean;
  45343. }
  45344. /**
  45345. * Helps to quickly add VR support to an existing scene.
  45346. * See http://doc.babylonjs.com/how_to/webvr_helper
  45347. */
  45348. export class VRExperienceHelper {
  45349. /** Options to modify the vr experience helper's behavior. */
  45350. webVROptions: VRExperienceHelperOptions;
  45351. private _scene;
  45352. private _position;
  45353. private _btnVR;
  45354. private _btnVRDisplayed;
  45355. private _webVRsupported;
  45356. private _webVRready;
  45357. private _webVRrequesting;
  45358. private _webVRpresenting;
  45359. private _hasEnteredVR;
  45360. private _fullscreenVRpresenting;
  45361. private _inputElement;
  45362. private _webVRCamera;
  45363. private _vrDeviceOrientationCamera;
  45364. private _deviceOrientationCamera;
  45365. private _existingCamera;
  45366. private _onKeyDown;
  45367. private _onVrDisplayPresentChange;
  45368. private _onVRDisplayChanged;
  45369. private _onVRRequestPresentStart;
  45370. private _onVRRequestPresentComplete;
  45371. /**
  45372. * 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)
  45373. */
  45374. enableGazeEvenWhenNoPointerLock: boolean;
  45375. /**
  45376. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45377. */
  45378. exitVROnDoubleTap: boolean;
  45379. /**
  45380. * Observable raised right before entering VR.
  45381. */
  45382. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45383. /**
  45384. * Observable raised when entering VR has completed.
  45385. */
  45386. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45387. /**
  45388. * Observable raised when exiting VR.
  45389. */
  45390. onExitingVRObservable: Observable<VRExperienceHelper>;
  45391. /**
  45392. * Observable raised when controller mesh is loaded.
  45393. */
  45394. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45395. /** Return this.onEnteringVRObservable
  45396. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45397. */
  45398. get onEnteringVR(): Observable<VRExperienceHelper>;
  45399. /** Return this.onExitingVRObservable
  45400. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45401. */
  45402. get onExitingVR(): Observable<VRExperienceHelper>;
  45403. /** Return this.onControllerMeshLoadedObservable
  45404. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45405. */
  45406. get onControllerMeshLoaded(): Observable<WebVRController>;
  45407. private _rayLength;
  45408. private _useCustomVRButton;
  45409. private _teleportationRequested;
  45410. private _teleportActive;
  45411. private _floorMeshName;
  45412. private _floorMeshesCollection;
  45413. private _teleportationMode;
  45414. private _teleportationTime;
  45415. private _teleportationSpeed;
  45416. private _teleportationEasing;
  45417. private _rotationAllowed;
  45418. private _teleportBackwardsVector;
  45419. private _teleportationTarget;
  45420. private _isDefaultTeleportationTarget;
  45421. private _postProcessMove;
  45422. private _teleportationFillColor;
  45423. private _teleportationBorderColor;
  45424. private _rotationAngle;
  45425. private _haloCenter;
  45426. private _cameraGazer;
  45427. private _padSensibilityUp;
  45428. private _padSensibilityDown;
  45429. private _leftController;
  45430. private _rightController;
  45431. /**
  45432. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45433. */
  45434. onNewMeshSelected: Observable<AbstractMesh>;
  45435. /**
  45436. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45437. * This observable will provide the mesh and the controller used to select the mesh
  45438. */
  45439. onMeshSelectedWithController: Observable<{
  45440. mesh: AbstractMesh;
  45441. controller: WebVRController;
  45442. }>;
  45443. /**
  45444. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45445. */
  45446. onNewMeshPicked: Observable<PickingInfo>;
  45447. private _circleEase;
  45448. /**
  45449. * Observable raised before camera teleportation
  45450. */
  45451. onBeforeCameraTeleport: Observable<Vector3>;
  45452. /**
  45453. * Observable raised after camera teleportation
  45454. */
  45455. onAfterCameraTeleport: Observable<Vector3>;
  45456. /**
  45457. * Observable raised when current selected mesh gets unselected
  45458. */
  45459. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45460. private _raySelectionPredicate;
  45461. /**
  45462. * To be optionaly changed by user to define custom ray selection
  45463. */
  45464. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45465. /**
  45466. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45467. */
  45468. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45469. /**
  45470. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45471. */
  45472. teleportationEnabled: boolean;
  45473. private _defaultHeight;
  45474. private _teleportationInitialized;
  45475. private _interactionsEnabled;
  45476. private _interactionsRequested;
  45477. private _displayGaze;
  45478. private _displayLaserPointer;
  45479. /**
  45480. * The mesh used to display where the user is going to teleport.
  45481. */
  45482. get teleportationTarget(): Mesh;
  45483. /**
  45484. * Sets the mesh to be used to display where the user is going to teleport.
  45485. */
  45486. set teleportationTarget(value: Mesh);
  45487. /**
  45488. * 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
  45489. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45490. * See http://doc.babylonjs.com/resources/baking_transformations
  45491. */
  45492. get gazeTrackerMesh(): Mesh;
  45493. set gazeTrackerMesh(value: Mesh);
  45494. /**
  45495. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45496. */
  45497. updateGazeTrackerScale: boolean;
  45498. /**
  45499. * If the gaze trackers color should be updated when selecting meshes
  45500. */
  45501. updateGazeTrackerColor: boolean;
  45502. /**
  45503. * If the controller laser color should be updated when selecting meshes
  45504. */
  45505. updateControllerLaserColor: boolean;
  45506. /**
  45507. * The gaze tracking mesh corresponding to the left controller
  45508. */
  45509. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45510. /**
  45511. * The gaze tracking mesh corresponding to the right controller
  45512. */
  45513. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45514. /**
  45515. * If the ray of the gaze should be displayed.
  45516. */
  45517. get displayGaze(): boolean;
  45518. /**
  45519. * Sets if the ray of the gaze should be displayed.
  45520. */
  45521. set displayGaze(value: boolean);
  45522. /**
  45523. * If the ray of the LaserPointer should be displayed.
  45524. */
  45525. get displayLaserPointer(): boolean;
  45526. /**
  45527. * Sets if the ray of the LaserPointer should be displayed.
  45528. */
  45529. set displayLaserPointer(value: boolean);
  45530. /**
  45531. * The deviceOrientationCamera used as the camera when not in VR.
  45532. */
  45533. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45534. /**
  45535. * Based on the current WebVR support, returns the current VR camera used.
  45536. */
  45537. get currentVRCamera(): Nullable<Camera>;
  45538. /**
  45539. * The webVRCamera which is used when in VR.
  45540. */
  45541. get webVRCamera(): WebVRFreeCamera;
  45542. /**
  45543. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45544. */
  45545. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45546. /**
  45547. * The html button that is used to trigger entering into VR.
  45548. */
  45549. get vrButton(): Nullable<HTMLButtonElement>;
  45550. private get _teleportationRequestInitiated();
  45551. /**
  45552. * Defines wether or not Pointer lock should be requested when switching to
  45553. * full screen.
  45554. */
  45555. requestPointerLockOnFullScreen: boolean;
  45556. /**
  45557. * If asking to force XR, this will be populated with the default xr experience
  45558. */
  45559. xr: WebXRDefaultExperience;
  45560. /**
  45561. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45562. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45563. */
  45564. xrTestDone: boolean;
  45565. /**
  45566. * Instantiates a VRExperienceHelper.
  45567. * Helps to quickly add VR support to an existing scene.
  45568. * @param scene The scene the VRExperienceHelper belongs to.
  45569. * @param webVROptions Options to modify the vr experience helper's behavior.
  45570. */
  45571. constructor(scene: Scene,
  45572. /** Options to modify the vr experience helper's behavior. */
  45573. webVROptions?: VRExperienceHelperOptions);
  45574. private completeVRInit;
  45575. private _onDefaultMeshLoaded;
  45576. private _onResize;
  45577. private _onFullscreenChange;
  45578. /**
  45579. * Gets a value indicating if we are currently in VR mode.
  45580. */
  45581. get isInVRMode(): boolean;
  45582. private onVrDisplayPresentChange;
  45583. private onVRDisplayChanged;
  45584. private moveButtonToBottomRight;
  45585. private displayVRButton;
  45586. private updateButtonVisibility;
  45587. private _cachedAngularSensibility;
  45588. /**
  45589. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45590. * Otherwise, will use the fullscreen API.
  45591. */
  45592. enterVR(): void;
  45593. /**
  45594. * Attempt to exit VR, or fullscreen.
  45595. */
  45596. exitVR(): void;
  45597. /**
  45598. * The position of the vr experience helper.
  45599. */
  45600. get position(): Vector3;
  45601. /**
  45602. * Sets the position of the vr experience helper.
  45603. */
  45604. set position(value: Vector3);
  45605. /**
  45606. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45607. */
  45608. enableInteractions(): void;
  45609. private get _noControllerIsActive();
  45610. private beforeRender;
  45611. private _isTeleportationFloor;
  45612. /**
  45613. * Adds a floor mesh to be used for teleportation.
  45614. * @param floorMesh the mesh to be used for teleportation.
  45615. */
  45616. addFloorMesh(floorMesh: Mesh): void;
  45617. /**
  45618. * Removes a floor mesh from being used for teleportation.
  45619. * @param floorMesh the mesh to be removed.
  45620. */
  45621. removeFloorMesh(floorMesh: Mesh): void;
  45622. /**
  45623. * Enables interactions and teleportation using the VR controllers and gaze.
  45624. * @param vrTeleportationOptions options to modify teleportation behavior.
  45625. */
  45626. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45627. private _onNewGamepadConnected;
  45628. private _tryEnableInteractionOnController;
  45629. private _onNewGamepadDisconnected;
  45630. private _enableInteractionOnController;
  45631. private _checkTeleportWithRay;
  45632. private _checkRotate;
  45633. private _checkTeleportBackwards;
  45634. private _enableTeleportationOnController;
  45635. private _createTeleportationCircles;
  45636. private _displayTeleportationTarget;
  45637. private _hideTeleportationTarget;
  45638. private _rotateCamera;
  45639. private _moveTeleportationSelectorTo;
  45640. private _workingVector;
  45641. private _workingQuaternion;
  45642. private _workingMatrix;
  45643. /**
  45644. * Time Constant Teleportation Mode
  45645. */
  45646. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45647. /**
  45648. * Speed Constant Teleportation Mode
  45649. */
  45650. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45651. /**
  45652. * Teleports the users feet to the desired location
  45653. * @param location The location where the user's feet should be placed
  45654. */
  45655. teleportCamera(location: Vector3): void;
  45656. private _convertNormalToDirectionOfRay;
  45657. private _castRayAndSelectObject;
  45658. private _notifySelectedMeshUnselected;
  45659. /**
  45660. * Sets the color of the laser ray from the vr controllers.
  45661. * @param color new color for the ray.
  45662. */
  45663. changeLaserColor(color: Color3): void;
  45664. /**
  45665. * Sets the color of the ray from the vr headsets gaze.
  45666. * @param color new color for the ray.
  45667. */
  45668. changeGazeColor(color: Color3): void;
  45669. /**
  45670. * Exits VR and disposes of the vr experience helper
  45671. */
  45672. dispose(): void;
  45673. /**
  45674. * Gets the name of the VRExperienceHelper class
  45675. * @returns "VRExperienceHelper"
  45676. */
  45677. getClassName(): string;
  45678. }
  45679. }
  45680. declare module "babylonjs/Cameras/VR/index" {
  45681. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45682. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45683. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45684. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45685. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45686. export * from "babylonjs/Cameras/VR/webVRCamera";
  45687. }
  45688. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45689. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45690. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45691. import { Observable } from "babylonjs/Misc/observable";
  45692. import { Matrix } from "babylonjs/Maths/math.vector";
  45693. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45694. /**
  45695. * Options used for hit testing
  45696. */
  45697. export interface IWebXRHitTestOptions {
  45698. /**
  45699. * Only test when user interacted with the scene. Default - hit test every frame
  45700. */
  45701. testOnPointerDownOnly?: boolean;
  45702. /**
  45703. * The node to use to transform the local results to world coordinates
  45704. */
  45705. worldParentNode?: TransformNode;
  45706. }
  45707. /**
  45708. * Interface defining the babylon result of raycasting/hit-test
  45709. */
  45710. export interface IWebXRHitResult {
  45711. /**
  45712. * The native hit test result
  45713. */
  45714. xrHitResult: XRHitResult;
  45715. /**
  45716. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45717. */
  45718. transformationMatrix: Matrix;
  45719. }
  45720. /**
  45721. * The currently-working hit-test module.
  45722. * Hit test (or raycasting) is used to interact with the real world.
  45723. * For further information read here - https://github.com/immersive-web/hit-test
  45724. */
  45725. export class WebXRHitTestLegacy implements IWebXRFeature {
  45726. private _xrSessionManager;
  45727. /**
  45728. * options to use when constructing this feature
  45729. */
  45730. readonly options: IWebXRHitTestOptions;
  45731. /**
  45732. * The module's name
  45733. */
  45734. static readonly Name: string;
  45735. /**
  45736. * The (Babylon) version of this module.
  45737. * This is an integer representing the implementation version.
  45738. * This number does not correspond to the webxr specs version
  45739. */
  45740. static readonly Version: number;
  45741. /**
  45742. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45743. * @param event the (select) event to use to select with
  45744. * @param referenceSpace the reference space to use for this hit test
  45745. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45746. */
  45747. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45748. /**
  45749. * execute a hit test with an XR Ray
  45750. *
  45751. * @param xrSession a native xrSession that will execute this hit test
  45752. * @param xrRay the ray (position and direction) to use for raycasting
  45753. * @param referenceSpace native XR reference space to use for the hit-test
  45754. * @param filter filter function that will filter the results
  45755. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45756. */
  45757. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45758. /**
  45759. * Triggered when new babylon (transformed) hit test results are available
  45760. */
  45761. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45762. /**
  45763. * Creates a new instance of the (legacy version) hit test feature
  45764. * @param _xrSessionManager an instance of WebXRSessionManager
  45765. * @param options options to use when constructing this feature
  45766. */
  45767. constructor(_xrSessionManager: WebXRSessionManager,
  45768. /**
  45769. * options to use when constructing this feature
  45770. */
  45771. options?: IWebXRHitTestOptions);
  45772. private _onSelectEnabled;
  45773. private _xrFrameObserver;
  45774. private _attached;
  45775. /**
  45776. * Populated with the last native XR Hit Results
  45777. */
  45778. lastNativeXRHitResults: XRHitResult[];
  45779. /**
  45780. * attach this feature
  45781. * Will usually be called by the features manager
  45782. *
  45783. * @returns true if successful.
  45784. */
  45785. attach(): boolean;
  45786. /**
  45787. * detach this feature.
  45788. * Will usually be called by the features manager
  45789. *
  45790. * @returns true if successful.
  45791. */
  45792. detach(): boolean;
  45793. private _onHitTestResults;
  45794. private _onSelect;
  45795. /**
  45796. * Dispose this feature and all of the resources attached
  45797. */
  45798. dispose(): void;
  45799. }
  45800. }
  45801. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  45802. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45803. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45804. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45805. import { Observable } from "babylonjs/Misc/observable";
  45806. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  45807. /**
  45808. * Options used in the plane detector module
  45809. */
  45810. export interface IWebXRPlaneDetectorOptions {
  45811. /**
  45812. * The node to use to transform the local results to world coordinates
  45813. */
  45814. worldParentNode?: TransformNode;
  45815. }
  45816. /**
  45817. * A babylon interface for a webxr plane.
  45818. * A Plane is actually a polygon, built from N points in space
  45819. */
  45820. export interface IWebXRPlane {
  45821. /**
  45822. * a babylon-assigned ID for this polygon
  45823. */
  45824. id: number;
  45825. /**
  45826. * the native xr-plane object
  45827. */
  45828. xrPlane: XRPlane;
  45829. /**
  45830. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45831. */
  45832. polygonDefinition: Array<Vector3>;
  45833. /**
  45834. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45835. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45836. */
  45837. transformationMatrix: Matrix;
  45838. }
  45839. /**
  45840. * The plane detector is used to detect planes in the real world when in AR
  45841. * For more information see https://github.com/immersive-web/real-world-geometry/
  45842. */
  45843. export class WebXRPlaneDetector implements IWebXRFeature {
  45844. private _xrSessionManager;
  45845. private _options;
  45846. /**
  45847. * The module's name
  45848. */
  45849. static readonly Name: string;
  45850. /**
  45851. * The (Babylon) version of this module.
  45852. * This is an integer representing the implementation version.
  45853. * This number does not correspond to the webxr specs version
  45854. */
  45855. static readonly Version: number;
  45856. /**
  45857. * Observers registered here will be executed when a new plane was added to the session
  45858. */
  45859. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45860. /**
  45861. * Observers registered here will be executed when a plane is no longer detected in the session
  45862. */
  45863. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45864. /**
  45865. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45866. * This can execute N times every frame
  45867. */
  45868. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45869. private _enabled;
  45870. private _attached;
  45871. private _detectedPlanes;
  45872. private _lastFrameDetected;
  45873. private _observerTracked;
  45874. /**
  45875. * construct a new Plane Detector
  45876. * @param _xrSessionManager an instance of xr Session manager
  45877. * @param _options configuration to use when constructing this feature
  45878. */
  45879. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45880. /**
  45881. * attach this feature
  45882. * Will usually be called by the features manager
  45883. *
  45884. * @returns true if successful.
  45885. */
  45886. attach(): boolean;
  45887. /**
  45888. * detach this feature.
  45889. * Will usually be called by the features manager
  45890. *
  45891. * @returns true if successful.
  45892. */
  45893. detach(): boolean;
  45894. /**
  45895. * Dispose this feature and all of the resources attached
  45896. */
  45897. dispose(): void;
  45898. private _updatePlaneWithXRPlane;
  45899. /**
  45900. * avoiding using Array.find for global support.
  45901. * @param xrPlane the plane to find in the array
  45902. */
  45903. private findIndexInPlaneArray;
  45904. }
  45905. }
  45906. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  45907. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45908. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45909. import { Observable } from "babylonjs/Misc/observable";
  45910. import { Matrix } from "babylonjs/Maths/math.vector";
  45911. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45912. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  45913. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  45914. /**
  45915. * Configuration options of the anchor system
  45916. */
  45917. export interface IWebXRAnchorSystemOptions {
  45918. /**
  45919. * a node that will be used to convert local to world coordinates
  45920. */
  45921. worldParentNode?: TransformNode;
  45922. /**
  45923. * should the anchor system use plane detection.
  45924. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45925. */
  45926. usePlaneDetection?: boolean;
  45927. /**
  45928. * Should a new anchor be added every time a select event is triggered
  45929. */
  45930. addAnchorOnSelect?: boolean;
  45931. }
  45932. /**
  45933. * A babylon container for an XR Anchor
  45934. */
  45935. export interface IWebXRAnchor {
  45936. /**
  45937. * A babylon-assigned ID for this anchor
  45938. */
  45939. id: number;
  45940. /**
  45941. * The native anchor object
  45942. */
  45943. xrAnchor: XRAnchor;
  45944. /**
  45945. * Transformation matrix to apply to an object attached to this anchor
  45946. */
  45947. transformationMatrix: Matrix;
  45948. }
  45949. /**
  45950. * An implementation of the anchor system of WebXR.
  45951. * Note that the current documented implementation is not available in any browser. Future implementations
  45952. * will use the frame to create an anchor and not the session or a detected plane
  45953. * For further information see https://github.com/immersive-web/anchors/
  45954. */
  45955. export class WebXRAnchorSystem implements IWebXRFeature {
  45956. private _xrSessionManager;
  45957. private _options;
  45958. /**
  45959. * The module's name
  45960. */
  45961. static readonly Name: string;
  45962. /**
  45963. * The (Babylon) version of this module.
  45964. * This is an integer representing the implementation version.
  45965. * This number does not correspond to the webxr specs version
  45966. */
  45967. static readonly Version: number;
  45968. /**
  45969. * Observers registered here will be executed when a new anchor was added to the session
  45970. */
  45971. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  45972. /**
  45973. * Observers registered here will be executed when an existing anchor updates
  45974. * This can execute N times every frame
  45975. */
  45976. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  45977. /**
  45978. * Observers registered here will be executed when an anchor was removed from the session
  45979. */
  45980. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  45981. private _planeDetector;
  45982. private _hitTestModule;
  45983. private _enabled;
  45984. private _attached;
  45985. private _trackedAnchors;
  45986. private _lastFrameDetected;
  45987. private _observerTracked;
  45988. /**
  45989. * constructs a new anchor system
  45990. * @param _xrSessionManager an instance of WebXRSessionManager
  45991. * @param _options configuration object for this feature
  45992. */
  45993. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  45994. /**
  45995. * set the plane detector to use in order to create anchors from frames
  45996. * @param planeDetector the plane-detector module to use
  45997. * @param enable enable plane-anchors. default is true
  45998. */
  45999. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46000. /**
  46001. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46002. * @param hitTestModule the hit-test module to use.
  46003. */
  46004. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46005. /**
  46006. * attach this feature
  46007. * Will usually be called by the features manager
  46008. *
  46009. * @returns true if successful.
  46010. */
  46011. attach(): boolean;
  46012. /**
  46013. * detach this feature.
  46014. * Will usually be called by the features manager
  46015. *
  46016. * @returns true if successful.
  46017. */
  46018. detach(): boolean;
  46019. /**
  46020. * Dispose this feature and all of the resources attached
  46021. */
  46022. dispose(): void;
  46023. private _onSelect;
  46024. /**
  46025. * Add anchor at a specific XR point.
  46026. *
  46027. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46028. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46029. * @returns a promise the fulfills when the anchor was created
  46030. */
  46031. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46032. private _updateAnchorWithXRFrame;
  46033. /**
  46034. * avoiding using Array.find for global support.
  46035. * @param xrAnchor the plane to find in the array
  46036. */
  46037. private _findIndexInAnchorArray;
  46038. }
  46039. }
  46040. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46041. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46042. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46044. import { Observable } from "babylonjs/Misc/observable";
  46045. /**
  46046. * Options interface for the background remover plugin
  46047. */
  46048. export interface IWebXRBackgroundRemoverOptions {
  46049. /**
  46050. * don't disable the environment helper
  46051. */
  46052. ignoreEnvironmentHelper?: boolean;
  46053. /**
  46054. * flags to configure the removal of the environment helper.
  46055. * If not set, the entire background will be removed. If set, flags should be set as well.
  46056. */
  46057. environmentHelperRemovalFlags?: {
  46058. /**
  46059. * Should the skybox be removed (default false)
  46060. */
  46061. skyBox?: boolean;
  46062. /**
  46063. * Should the ground be removed (default false)
  46064. */
  46065. ground?: boolean;
  46066. };
  46067. /**
  46068. * Further background meshes to disable when entering AR
  46069. */
  46070. backgroundMeshes?: AbstractMesh[];
  46071. }
  46072. /**
  46073. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46074. */
  46075. export class WebXRBackgroundRemover implements IWebXRFeature {
  46076. private _xrSessionManager;
  46077. /**
  46078. * read-only options to be used in this module
  46079. */
  46080. readonly options: IWebXRBackgroundRemoverOptions;
  46081. /**
  46082. * The module's name
  46083. */
  46084. static readonly Name: string;
  46085. /**
  46086. * The (Babylon) version of this module.
  46087. * This is an integer representing the implementation version.
  46088. * This number does not correspond to the webxr specs version
  46089. */
  46090. static readonly Version: number;
  46091. /**
  46092. * registered observers will be triggered when the background state changes
  46093. */
  46094. onBackgroundStateChangedObservable: Observable<boolean>;
  46095. /**
  46096. * constructs a new background remover module
  46097. * @param _xrSessionManager the session manager for this module
  46098. * @param options read-only options to be used in this module
  46099. */
  46100. constructor(_xrSessionManager: WebXRSessionManager,
  46101. /**
  46102. * read-only options to be used in this module
  46103. */
  46104. options?: IWebXRBackgroundRemoverOptions);
  46105. /**
  46106. * attach this feature
  46107. * Will usually be called by the features manager
  46108. *
  46109. * @returns true if successful.
  46110. */
  46111. attach(): boolean;
  46112. /**
  46113. * detach this feature.
  46114. * Will usually be called by the features manager
  46115. *
  46116. * @returns true if successful.
  46117. */
  46118. detach(): boolean;
  46119. private _setBackgroundState;
  46120. /**
  46121. * Dispose this feature and all of the resources attached
  46122. */
  46123. dispose(): void;
  46124. }
  46125. }
  46126. declare module "babylonjs/Cameras/XR/features/index" {
  46127. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46128. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46129. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46130. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46131. }
  46132. declare module "babylonjs/Cameras/XR/index" {
  46133. export * from "babylonjs/Cameras/XR/webXRCamera";
  46134. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46135. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46136. export * from "babylonjs/Cameras/XR/webXRInput";
  46137. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46138. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46139. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  46140. export * from "babylonjs/Cameras/XR/webXRController";
  46141. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46142. export * from "babylonjs/Cameras/XR/webXRTypes";
  46143. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46144. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46145. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46146. export * from "babylonjs/Cameras/XR/features/index";
  46147. }
  46148. declare module "babylonjs/Cameras/RigModes/index" {
  46149. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46150. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46151. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46152. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46153. }
  46154. declare module "babylonjs/Cameras/index" {
  46155. export * from "babylonjs/Cameras/Inputs/index";
  46156. export * from "babylonjs/Cameras/cameraInputsManager";
  46157. export * from "babylonjs/Cameras/camera";
  46158. export * from "babylonjs/Cameras/targetCamera";
  46159. export * from "babylonjs/Cameras/freeCamera";
  46160. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46161. export * from "babylonjs/Cameras/touchCamera";
  46162. export * from "babylonjs/Cameras/arcRotateCamera";
  46163. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46164. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46165. export * from "babylonjs/Cameras/flyCamera";
  46166. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46167. export * from "babylonjs/Cameras/followCamera";
  46168. export * from "babylonjs/Cameras/followCameraInputsManager";
  46169. export * from "babylonjs/Cameras/gamepadCamera";
  46170. export * from "babylonjs/Cameras/Stereoscopic/index";
  46171. export * from "babylonjs/Cameras/universalCamera";
  46172. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46173. export * from "babylonjs/Cameras/VR/index";
  46174. export * from "babylonjs/Cameras/XR/index";
  46175. export * from "babylonjs/Cameras/RigModes/index";
  46176. }
  46177. declare module "babylonjs/Collisions/index" {
  46178. export * from "babylonjs/Collisions/collider";
  46179. export * from "babylonjs/Collisions/collisionCoordinator";
  46180. export * from "babylonjs/Collisions/pickingInfo";
  46181. export * from "babylonjs/Collisions/intersectionInfo";
  46182. export * from "babylonjs/Collisions/meshCollisionData";
  46183. }
  46184. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46185. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46186. import { Vector3 } from "babylonjs/Maths/math.vector";
  46187. import { Ray } from "babylonjs/Culling/ray";
  46188. import { Plane } from "babylonjs/Maths/math.plane";
  46189. /**
  46190. * Contains an array of blocks representing the octree
  46191. */
  46192. export interface IOctreeContainer<T> {
  46193. /**
  46194. * Blocks within the octree
  46195. */
  46196. blocks: Array<OctreeBlock<T>>;
  46197. }
  46198. /**
  46199. * Class used to store a cell in an octree
  46200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46201. */
  46202. export class OctreeBlock<T> {
  46203. /**
  46204. * Gets the content of the current block
  46205. */
  46206. entries: T[];
  46207. /**
  46208. * Gets the list of block children
  46209. */
  46210. blocks: Array<OctreeBlock<T>>;
  46211. private _depth;
  46212. private _maxDepth;
  46213. private _capacity;
  46214. private _minPoint;
  46215. private _maxPoint;
  46216. private _boundingVectors;
  46217. private _creationFunc;
  46218. /**
  46219. * Creates a new block
  46220. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46221. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46222. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46223. * @param depth defines the current depth of this block in the octree
  46224. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46225. * @param creationFunc defines a callback to call when an element is added to the block
  46226. */
  46227. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46228. /**
  46229. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46230. */
  46231. get capacity(): number;
  46232. /**
  46233. * Gets the minimum vector (in world space) of the block's bounding box
  46234. */
  46235. get minPoint(): Vector3;
  46236. /**
  46237. * Gets the maximum vector (in world space) of the block's bounding box
  46238. */
  46239. get maxPoint(): Vector3;
  46240. /**
  46241. * Add a new element to this block
  46242. * @param entry defines the element to add
  46243. */
  46244. addEntry(entry: T): void;
  46245. /**
  46246. * Remove an element from this block
  46247. * @param entry defines the element to remove
  46248. */
  46249. removeEntry(entry: T): void;
  46250. /**
  46251. * Add an array of elements to this block
  46252. * @param entries defines the array of elements to add
  46253. */
  46254. addEntries(entries: T[]): void;
  46255. /**
  46256. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46257. * @param frustumPlanes defines the frustum planes to test
  46258. * @param selection defines the array to store current content if selection is positive
  46259. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46260. */
  46261. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46262. /**
  46263. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46264. * @param sphereCenter defines the bounding sphere center
  46265. * @param sphereRadius defines the bounding sphere radius
  46266. * @param selection defines the array to store current content if selection is positive
  46267. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46268. */
  46269. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46270. /**
  46271. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46272. * @param ray defines the ray to test with
  46273. * @param selection defines the array to store current content if selection is positive
  46274. */
  46275. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46276. /**
  46277. * Subdivide the content into child blocks (this block will then be empty)
  46278. */
  46279. createInnerBlocks(): void;
  46280. /**
  46281. * @hidden
  46282. */
  46283. 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;
  46284. }
  46285. }
  46286. declare module "babylonjs/Culling/Octrees/octree" {
  46287. import { SmartArray } from "babylonjs/Misc/smartArray";
  46288. import { Vector3 } from "babylonjs/Maths/math.vector";
  46289. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46291. import { Ray } from "babylonjs/Culling/ray";
  46292. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46293. import { Plane } from "babylonjs/Maths/math.plane";
  46294. /**
  46295. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46296. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46297. */
  46298. export class Octree<T> {
  46299. /** 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.) */
  46300. maxDepth: number;
  46301. /**
  46302. * Blocks within the octree containing objects
  46303. */
  46304. blocks: Array<OctreeBlock<T>>;
  46305. /**
  46306. * Content stored in the octree
  46307. */
  46308. dynamicContent: T[];
  46309. private _maxBlockCapacity;
  46310. private _selectionContent;
  46311. private _creationFunc;
  46312. /**
  46313. * Creates a octree
  46314. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46315. * @param creationFunc function to be used to instatiate the octree
  46316. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46317. * @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.)
  46318. */
  46319. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46320. /** 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.) */
  46321. maxDepth?: number);
  46322. /**
  46323. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46324. * @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);
  46325. * @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);
  46326. * @param entries meshes to be added to the octree blocks
  46327. */
  46328. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46329. /**
  46330. * Adds a mesh to the octree
  46331. * @param entry Mesh to add to the octree
  46332. */
  46333. addMesh(entry: T): void;
  46334. /**
  46335. * Remove an element from the octree
  46336. * @param entry defines the element to remove
  46337. */
  46338. removeMesh(entry: T): void;
  46339. /**
  46340. * Selects an array of meshes within the frustum
  46341. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46342. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46343. * @returns array of meshes within the frustum
  46344. */
  46345. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46346. /**
  46347. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46348. * @param sphereCenter defines the bounding sphere center
  46349. * @param sphereRadius defines the bounding sphere radius
  46350. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46351. * @returns an array of objects that intersect the sphere
  46352. */
  46353. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46354. /**
  46355. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46356. * @param ray defines the ray to test with
  46357. * @returns array of intersected objects
  46358. */
  46359. intersectsRay(ray: Ray): SmartArray<T>;
  46360. /**
  46361. * Adds a mesh into the octree block if it intersects the block
  46362. */
  46363. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46364. /**
  46365. * Adds a submesh into the octree block if it intersects the block
  46366. */
  46367. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46368. }
  46369. }
  46370. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46371. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46372. import { Scene } from "babylonjs/scene";
  46373. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46375. import { Ray } from "babylonjs/Culling/ray";
  46376. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46377. import { Collider } from "babylonjs/Collisions/collider";
  46378. module "babylonjs/scene" {
  46379. interface Scene {
  46380. /**
  46381. * @hidden
  46382. * Backing Filed
  46383. */
  46384. _selectionOctree: Octree<AbstractMesh>;
  46385. /**
  46386. * Gets the octree used to boost mesh selection (picking)
  46387. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46388. */
  46389. selectionOctree: Octree<AbstractMesh>;
  46390. /**
  46391. * Creates or updates the octree used to boost selection (picking)
  46392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46393. * @param maxCapacity defines the maximum capacity per leaf
  46394. * @param maxDepth defines the maximum depth of the octree
  46395. * @returns an octree of AbstractMesh
  46396. */
  46397. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46398. }
  46399. }
  46400. module "babylonjs/Meshes/abstractMesh" {
  46401. interface AbstractMesh {
  46402. /**
  46403. * @hidden
  46404. * Backing Field
  46405. */
  46406. _submeshesOctree: Octree<SubMesh>;
  46407. /**
  46408. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46409. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46410. * @param maxCapacity defines the maximum size of each block (64 by default)
  46411. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46412. * @returns the new octree
  46413. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46415. */
  46416. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46417. }
  46418. }
  46419. /**
  46420. * Defines the octree scene component responsible to manage any octrees
  46421. * in a given scene.
  46422. */
  46423. export class OctreeSceneComponent {
  46424. /**
  46425. * The component name help to identify the component in the list of scene components.
  46426. */
  46427. readonly name: string;
  46428. /**
  46429. * The scene the component belongs to.
  46430. */
  46431. scene: Scene;
  46432. /**
  46433. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46434. */
  46435. readonly checksIsEnabled: boolean;
  46436. /**
  46437. * Creates a new instance of the component for the given scene
  46438. * @param scene Defines the scene to register the component in
  46439. */
  46440. constructor(scene: Scene);
  46441. /**
  46442. * Registers the component in a given scene
  46443. */
  46444. register(): void;
  46445. /**
  46446. * Return the list of active meshes
  46447. * @returns the list of active meshes
  46448. */
  46449. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46450. /**
  46451. * Return the list of active sub meshes
  46452. * @param mesh The mesh to get the candidates sub meshes from
  46453. * @returns the list of active sub meshes
  46454. */
  46455. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46456. private _tempRay;
  46457. /**
  46458. * Return the list of sub meshes intersecting with a given local ray
  46459. * @param mesh defines the mesh to find the submesh for
  46460. * @param localRay defines the ray in local space
  46461. * @returns the list of intersecting sub meshes
  46462. */
  46463. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46464. /**
  46465. * Return the list of sub meshes colliding with a collider
  46466. * @param mesh defines the mesh to find the submesh for
  46467. * @param collider defines the collider to evaluate the collision against
  46468. * @returns the list of colliding sub meshes
  46469. */
  46470. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46471. /**
  46472. * Rebuilds the elements related to this component in case of
  46473. * context lost for instance.
  46474. */
  46475. rebuild(): void;
  46476. /**
  46477. * Disposes the component and the associated ressources.
  46478. */
  46479. dispose(): void;
  46480. }
  46481. }
  46482. declare module "babylonjs/Culling/Octrees/index" {
  46483. export * from "babylonjs/Culling/Octrees/octree";
  46484. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46485. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46486. }
  46487. declare module "babylonjs/Culling/index" {
  46488. export * from "babylonjs/Culling/boundingBox";
  46489. export * from "babylonjs/Culling/boundingInfo";
  46490. export * from "babylonjs/Culling/boundingSphere";
  46491. export * from "babylonjs/Culling/Octrees/index";
  46492. export * from "babylonjs/Culling/ray";
  46493. }
  46494. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46495. import { IDisposable, Scene } from "babylonjs/scene";
  46496. import { Nullable } from "babylonjs/types";
  46497. import { Observable } from "babylonjs/Misc/observable";
  46498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46499. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46500. import { Camera } from "babylonjs/Cameras/camera";
  46501. /**
  46502. * Renders a layer on top of an existing scene
  46503. */
  46504. export class UtilityLayerRenderer implements IDisposable {
  46505. /** the original scene that will be rendered on top of */
  46506. originalScene: Scene;
  46507. private _pointerCaptures;
  46508. private _lastPointerEvents;
  46509. private static _DefaultUtilityLayer;
  46510. private static _DefaultKeepDepthUtilityLayer;
  46511. private _sharedGizmoLight;
  46512. private _renderCamera;
  46513. /**
  46514. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46515. * @returns the camera that is used when rendering the utility layer
  46516. */
  46517. getRenderCamera(): Nullable<Camera>;
  46518. /**
  46519. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46520. * @param cam the camera that should be used when rendering the utility layer
  46521. */
  46522. setRenderCamera(cam: Nullable<Camera>): void;
  46523. /**
  46524. * @hidden
  46525. * Light which used by gizmos to get light shading
  46526. */
  46527. _getSharedGizmoLight(): HemisphericLight;
  46528. /**
  46529. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46530. */
  46531. pickUtilitySceneFirst: boolean;
  46532. /**
  46533. * 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)
  46534. */
  46535. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46536. /**
  46537. * 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)
  46538. */
  46539. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46540. /**
  46541. * The scene that is rendered on top of the original scene
  46542. */
  46543. utilityLayerScene: Scene;
  46544. /**
  46545. * If the utility layer should automatically be rendered on top of existing scene
  46546. */
  46547. shouldRender: boolean;
  46548. /**
  46549. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46550. */
  46551. onlyCheckPointerDownEvents: boolean;
  46552. /**
  46553. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46554. */
  46555. processAllEvents: boolean;
  46556. /**
  46557. * Observable raised when the pointer move from the utility layer scene to the main scene
  46558. */
  46559. onPointerOutObservable: Observable<number>;
  46560. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46561. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46562. private _afterRenderObserver;
  46563. private _sceneDisposeObserver;
  46564. private _originalPointerObserver;
  46565. /**
  46566. * Instantiates a UtilityLayerRenderer
  46567. * @param originalScene the original scene that will be rendered on top of
  46568. * @param handleEvents boolean indicating if the utility layer should handle events
  46569. */
  46570. constructor(
  46571. /** the original scene that will be rendered on top of */
  46572. originalScene: Scene, handleEvents?: boolean);
  46573. private _notifyObservers;
  46574. /**
  46575. * Renders the utility layers scene on top of the original scene
  46576. */
  46577. render(): void;
  46578. /**
  46579. * Disposes of the renderer
  46580. */
  46581. dispose(): void;
  46582. private _updateCamera;
  46583. }
  46584. }
  46585. declare module "babylonjs/Gizmos/gizmo" {
  46586. import { Nullable } from "babylonjs/types";
  46587. import { IDisposable } from "babylonjs/scene";
  46588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46589. import { Mesh } from "babylonjs/Meshes/mesh";
  46590. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46591. /**
  46592. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46593. */
  46594. export class Gizmo implements IDisposable {
  46595. /** The utility layer the gizmo will be added to */
  46596. gizmoLayer: UtilityLayerRenderer;
  46597. /**
  46598. * The root mesh of the gizmo
  46599. */
  46600. _rootMesh: Mesh;
  46601. private _attachedMesh;
  46602. /**
  46603. * Ratio for the scale of the gizmo (Default: 1)
  46604. */
  46605. scaleRatio: number;
  46606. /**
  46607. * If a custom mesh has been set (Default: false)
  46608. */
  46609. protected _customMeshSet: boolean;
  46610. /**
  46611. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46612. * * When set, interactions will be enabled
  46613. */
  46614. get attachedMesh(): Nullable<AbstractMesh>;
  46615. set attachedMesh(value: Nullable<AbstractMesh>);
  46616. /**
  46617. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46618. * @param mesh The mesh to replace the default mesh of the gizmo
  46619. */
  46620. setCustomMesh(mesh: Mesh): void;
  46621. /**
  46622. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46623. */
  46624. updateGizmoRotationToMatchAttachedMesh: boolean;
  46625. /**
  46626. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46627. */
  46628. updateGizmoPositionToMatchAttachedMesh: boolean;
  46629. /**
  46630. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46631. */
  46632. updateScale: boolean;
  46633. protected _interactionsEnabled: boolean;
  46634. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46635. private _beforeRenderObserver;
  46636. private _tempVector;
  46637. /**
  46638. * Creates a gizmo
  46639. * @param gizmoLayer The utility layer the gizmo will be added to
  46640. */
  46641. constructor(
  46642. /** The utility layer the gizmo will be added to */
  46643. gizmoLayer?: UtilityLayerRenderer);
  46644. /**
  46645. * Updates the gizmo to match the attached mesh's position/rotation
  46646. */
  46647. protected _update(): void;
  46648. /**
  46649. * Disposes of the gizmo
  46650. */
  46651. dispose(): void;
  46652. }
  46653. }
  46654. declare module "babylonjs/Gizmos/planeDragGizmo" {
  46655. import { Observable } from "babylonjs/Misc/observable";
  46656. import { Nullable } from "babylonjs/types";
  46657. import { Vector3 } from "babylonjs/Maths/math.vector";
  46658. import { Color3 } from "babylonjs/Maths/math.color";
  46659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46661. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46662. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46663. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46664. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46665. import { Scene } from "babylonjs/scene";
  46666. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46667. /**
  46668. * Single plane drag gizmo
  46669. */
  46670. export class PlaneDragGizmo extends Gizmo {
  46671. /**
  46672. * Drag behavior responsible for the gizmos dragging interactions
  46673. */
  46674. dragBehavior: PointerDragBehavior;
  46675. private _pointerObserver;
  46676. /**
  46677. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46678. */
  46679. snapDistance: number;
  46680. /**
  46681. * Event that fires each time the gizmo snaps to a new location.
  46682. * * snapDistance is the the change in distance
  46683. */
  46684. onSnapObservable: Observable<{
  46685. snapDistance: number;
  46686. }>;
  46687. private _plane;
  46688. private _coloredMaterial;
  46689. private _hoverMaterial;
  46690. private _isEnabled;
  46691. private _parent;
  46692. /** @hidden */
  46693. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46694. /** @hidden */
  46695. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46696. /**
  46697. * Creates a PlaneDragGizmo
  46698. * @param gizmoLayer The utility layer the gizmo will be added to
  46699. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46700. * @param color The color of the gizmo
  46701. */
  46702. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46703. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46704. /**
  46705. * If the gizmo is enabled
  46706. */
  46707. set isEnabled(value: boolean);
  46708. get isEnabled(): boolean;
  46709. /**
  46710. * Disposes of the gizmo
  46711. */
  46712. dispose(): void;
  46713. }
  46714. }
  46715. declare module "babylonjs/Gizmos/positionGizmo" {
  46716. import { Observable } from "babylonjs/Misc/observable";
  46717. import { Nullable } from "babylonjs/types";
  46718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46719. import { Mesh } from "babylonjs/Meshes/mesh";
  46720. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46721. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  46722. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  46723. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46724. /**
  46725. * Gizmo that enables dragging a mesh along 3 axis
  46726. */
  46727. export class PositionGizmo extends Gizmo {
  46728. /**
  46729. * Internal gizmo used for interactions on the x axis
  46730. */
  46731. xGizmo: AxisDragGizmo;
  46732. /**
  46733. * Internal gizmo used for interactions on the y axis
  46734. */
  46735. yGizmo: AxisDragGizmo;
  46736. /**
  46737. * Internal gizmo used for interactions on the z axis
  46738. */
  46739. zGizmo: AxisDragGizmo;
  46740. /**
  46741. * Internal gizmo used for interactions on the yz plane
  46742. */
  46743. xPlaneGizmo: PlaneDragGizmo;
  46744. /**
  46745. * Internal gizmo used for interactions on the xz plane
  46746. */
  46747. yPlaneGizmo: PlaneDragGizmo;
  46748. /**
  46749. * Internal gizmo used for interactions on the xy plane
  46750. */
  46751. zPlaneGizmo: PlaneDragGizmo;
  46752. /**
  46753. * private variables
  46754. */
  46755. private _meshAttached;
  46756. private _updateGizmoRotationToMatchAttachedMesh;
  46757. private _snapDistance;
  46758. private _scaleRatio;
  46759. /** Fires an event when any of it's sub gizmos are dragged */
  46760. onDragStartObservable: Observable<unknown>;
  46761. /** Fires an event when any of it's sub gizmos are released from dragging */
  46762. onDragEndObservable: Observable<unknown>;
  46763. /**
  46764. * If set to true, planar drag is enabled
  46765. */
  46766. private _planarGizmoEnabled;
  46767. get attachedMesh(): Nullable<AbstractMesh>;
  46768. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46769. /**
  46770. * Creates a PositionGizmo
  46771. * @param gizmoLayer The utility layer the gizmo will be added to
  46772. */
  46773. constructor(gizmoLayer?: UtilityLayerRenderer);
  46774. /**
  46775. * If the planar drag gizmo is enabled
  46776. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46777. */
  46778. set planarGizmoEnabled(value: boolean);
  46779. get planarGizmoEnabled(): boolean;
  46780. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46781. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46782. /**
  46783. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46784. */
  46785. set snapDistance(value: number);
  46786. get snapDistance(): number;
  46787. /**
  46788. * Ratio for the scale of the gizmo (Default: 1)
  46789. */
  46790. set scaleRatio(value: number);
  46791. get scaleRatio(): number;
  46792. /**
  46793. * Disposes of the gizmo
  46794. */
  46795. dispose(): void;
  46796. /**
  46797. * CustomMeshes are not supported by this gizmo
  46798. * @param mesh The mesh to replace the default mesh of the gizmo
  46799. */
  46800. setCustomMesh(mesh: Mesh): void;
  46801. }
  46802. }
  46803. declare module "babylonjs/Gizmos/axisDragGizmo" {
  46804. import { Observable } from "babylonjs/Misc/observable";
  46805. import { Nullable } from "babylonjs/types";
  46806. import { Vector3 } from "babylonjs/Maths/math.vector";
  46807. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46809. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46810. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46811. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46812. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46813. import { Scene } from "babylonjs/scene";
  46814. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46815. import { Color3 } from "babylonjs/Maths/math.color";
  46816. /**
  46817. * Single axis drag gizmo
  46818. */
  46819. export class AxisDragGizmo extends Gizmo {
  46820. /**
  46821. * Drag behavior responsible for the gizmos dragging interactions
  46822. */
  46823. dragBehavior: PointerDragBehavior;
  46824. private _pointerObserver;
  46825. /**
  46826. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46827. */
  46828. snapDistance: number;
  46829. /**
  46830. * Event that fires each time the gizmo snaps to a new location.
  46831. * * snapDistance is the the change in distance
  46832. */
  46833. onSnapObservable: Observable<{
  46834. snapDistance: number;
  46835. }>;
  46836. private _isEnabled;
  46837. private _parent;
  46838. private _arrow;
  46839. private _coloredMaterial;
  46840. private _hoverMaterial;
  46841. /** @hidden */
  46842. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46843. /** @hidden */
  46844. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46845. /**
  46846. * Creates an AxisDragGizmo
  46847. * @param gizmoLayer The utility layer the gizmo will be added to
  46848. * @param dragAxis The axis which the gizmo will be able to drag on
  46849. * @param color The color of the gizmo
  46850. */
  46851. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46852. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46853. /**
  46854. * If the gizmo is enabled
  46855. */
  46856. set isEnabled(value: boolean);
  46857. get isEnabled(): boolean;
  46858. /**
  46859. * Disposes of the gizmo
  46860. */
  46861. dispose(): void;
  46862. }
  46863. }
  46864. declare module "babylonjs/Debug/axesViewer" {
  46865. import { Vector3 } from "babylonjs/Maths/math.vector";
  46866. import { Nullable } from "babylonjs/types";
  46867. import { Scene } from "babylonjs/scene";
  46868. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46869. /**
  46870. * The Axes viewer will show 3 axes in a specific point in space
  46871. */
  46872. export class AxesViewer {
  46873. private _xAxis;
  46874. private _yAxis;
  46875. private _zAxis;
  46876. private _scaleLinesFactor;
  46877. private _instanced;
  46878. /**
  46879. * Gets the hosting scene
  46880. */
  46881. scene: Scene;
  46882. /**
  46883. * Gets or sets a number used to scale line length
  46884. */
  46885. scaleLines: number;
  46886. /** Gets the node hierarchy used to render x-axis */
  46887. get xAxis(): TransformNode;
  46888. /** Gets the node hierarchy used to render y-axis */
  46889. get yAxis(): TransformNode;
  46890. /** Gets the node hierarchy used to render z-axis */
  46891. get zAxis(): TransformNode;
  46892. /**
  46893. * Creates a new AxesViewer
  46894. * @param scene defines the hosting scene
  46895. * @param scaleLines defines a number used to scale line length (1 by default)
  46896. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46897. * @param xAxis defines the node hierarchy used to render the x-axis
  46898. * @param yAxis defines the node hierarchy used to render the y-axis
  46899. * @param zAxis defines the node hierarchy used to render the z-axis
  46900. */
  46901. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46902. /**
  46903. * Force the viewer to update
  46904. * @param position defines the position of the viewer
  46905. * @param xaxis defines the x axis of the viewer
  46906. * @param yaxis defines the y axis of the viewer
  46907. * @param zaxis defines the z axis of the viewer
  46908. */
  46909. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46910. /**
  46911. * Creates an instance of this axes viewer.
  46912. * @returns a new axes viewer with instanced meshes
  46913. */
  46914. createInstance(): AxesViewer;
  46915. /** Releases resources */
  46916. dispose(): void;
  46917. private static _SetRenderingGroupId;
  46918. }
  46919. }
  46920. declare module "babylonjs/Debug/boneAxesViewer" {
  46921. import { Nullable } from "babylonjs/types";
  46922. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  46923. import { Vector3 } from "babylonjs/Maths/math.vector";
  46924. import { Mesh } from "babylonjs/Meshes/mesh";
  46925. import { Bone } from "babylonjs/Bones/bone";
  46926. import { Scene } from "babylonjs/scene";
  46927. /**
  46928. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46929. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46930. */
  46931. export class BoneAxesViewer extends AxesViewer {
  46932. /**
  46933. * Gets or sets the target mesh where to display the axes viewer
  46934. */
  46935. mesh: Nullable<Mesh>;
  46936. /**
  46937. * Gets or sets the target bone where to display the axes viewer
  46938. */
  46939. bone: Nullable<Bone>;
  46940. /** Gets current position */
  46941. pos: Vector3;
  46942. /** Gets direction of X axis */
  46943. xaxis: Vector3;
  46944. /** Gets direction of Y axis */
  46945. yaxis: Vector3;
  46946. /** Gets direction of Z axis */
  46947. zaxis: Vector3;
  46948. /**
  46949. * Creates a new BoneAxesViewer
  46950. * @param scene defines the hosting scene
  46951. * @param bone defines the target bone
  46952. * @param mesh defines the target mesh
  46953. * @param scaleLines defines a scaling factor for line length (1 by default)
  46954. */
  46955. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46956. /**
  46957. * Force the viewer to update
  46958. */
  46959. update(): void;
  46960. /** Releases resources */
  46961. dispose(): void;
  46962. }
  46963. }
  46964. declare module "babylonjs/Debug/debugLayer" {
  46965. import { Scene } from "babylonjs/scene";
  46966. /**
  46967. * Interface used to define scene explorer extensibility option
  46968. */
  46969. export interface IExplorerExtensibilityOption {
  46970. /**
  46971. * Define the option label
  46972. */
  46973. label: string;
  46974. /**
  46975. * Defines the action to execute on click
  46976. */
  46977. action: (entity: any) => void;
  46978. }
  46979. /**
  46980. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46981. */
  46982. export interface IExplorerExtensibilityGroup {
  46983. /**
  46984. * Defines a predicate to test if a given type mut be extended
  46985. */
  46986. predicate: (entity: any) => boolean;
  46987. /**
  46988. * Gets the list of options added to a type
  46989. */
  46990. entries: IExplorerExtensibilityOption[];
  46991. }
  46992. /**
  46993. * Interface used to define the options to use to create the Inspector
  46994. */
  46995. export interface IInspectorOptions {
  46996. /**
  46997. * Display in overlay mode (default: false)
  46998. */
  46999. overlay?: boolean;
  47000. /**
  47001. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47002. */
  47003. globalRoot?: HTMLElement;
  47004. /**
  47005. * Display the Scene explorer
  47006. */
  47007. showExplorer?: boolean;
  47008. /**
  47009. * Display the property inspector
  47010. */
  47011. showInspector?: boolean;
  47012. /**
  47013. * Display in embed mode (both panes on the right)
  47014. */
  47015. embedMode?: boolean;
  47016. /**
  47017. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47018. */
  47019. handleResize?: boolean;
  47020. /**
  47021. * Allow the panes to popup (default: true)
  47022. */
  47023. enablePopup?: boolean;
  47024. /**
  47025. * Allow the panes to be closed by users (default: true)
  47026. */
  47027. enableClose?: boolean;
  47028. /**
  47029. * Optional list of extensibility entries
  47030. */
  47031. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47032. /**
  47033. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47034. */
  47035. inspectorURL?: string;
  47036. /**
  47037. * Optional initial tab (default to DebugLayerTab.Properties)
  47038. */
  47039. initialTab?: DebugLayerTab;
  47040. }
  47041. module "babylonjs/scene" {
  47042. interface Scene {
  47043. /**
  47044. * @hidden
  47045. * Backing field
  47046. */
  47047. _debugLayer: DebugLayer;
  47048. /**
  47049. * Gets the debug layer (aka Inspector) associated with the scene
  47050. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47051. */
  47052. debugLayer: DebugLayer;
  47053. }
  47054. }
  47055. /**
  47056. * Enum of inspector action tab
  47057. */
  47058. export enum DebugLayerTab {
  47059. /**
  47060. * Properties tag (default)
  47061. */
  47062. Properties = 0,
  47063. /**
  47064. * Debug tab
  47065. */
  47066. Debug = 1,
  47067. /**
  47068. * Statistics tab
  47069. */
  47070. Statistics = 2,
  47071. /**
  47072. * Tools tab
  47073. */
  47074. Tools = 3,
  47075. /**
  47076. * Settings tab
  47077. */
  47078. Settings = 4
  47079. }
  47080. /**
  47081. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47082. * what is happening in your scene
  47083. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47084. */
  47085. export class DebugLayer {
  47086. /**
  47087. * Define the url to get the inspector script from.
  47088. * By default it uses the babylonjs CDN.
  47089. * @ignoreNaming
  47090. */
  47091. static InspectorURL: string;
  47092. private _scene;
  47093. private BJSINSPECTOR;
  47094. private _onPropertyChangedObservable?;
  47095. /**
  47096. * Observable triggered when a property is changed through the inspector.
  47097. */
  47098. get onPropertyChangedObservable(): any;
  47099. /**
  47100. * Instantiates a new debug layer.
  47101. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47102. * what is happening in your scene
  47103. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47104. * @param scene Defines the scene to inspect
  47105. */
  47106. constructor(scene: Scene);
  47107. /** Creates the inspector window. */
  47108. private _createInspector;
  47109. /**
  47110. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47111. * @param entity defines the entity to select
  47112. * @param lineContainerTitle defines the specific block to highlight
  47113. */
  47114. select(entity: any, lineContainerTitle?: string): void;
  47115. /** Get the inspector from bundle or global */
  47116. private _getGlobalInspector;
  47117. /**
  47118. * Get if the inspector is visible or not.
  47119. * @returns true if visible otherwise, false
  47120. */
  47121. isVisible(): boolean;
  47122. /**
  47123. * Hide the inspector and close its window.
  47124. */
  47125. hide(): void;
  47126. /**
  47127. * Launch the debugLayer.
  47128. * @param config Define the configuration of the inspector
  47129. * @return a promise fulfilled when the debug layer is visible
  47130. */
  47131. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47132. }
  47133. }
  47134. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47135. import { Nullable } from "babylonjs/types";
  47136. import { Scene } from "babylonjs/scene";
  47137. import { Vector4 } from "babylonjs/Maths/math.vector";
  47138. import { Color4 } from "babylonjs/Maths/math.color";
  47139. import { Mesh } from "babylonjs/Meshes/mesh";
  47140. /**
  47141. * Class containing static functions to help procedurally build meshes
  47142. */
  47143. export class BoxBuilder {
  47144. /**
  47145. * Creates a box mesh
  47146. * * The parameter `size` sets the size (float) of each box side (default 1)
  47147. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47148. * * 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)
  47149. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47153. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47154. * @param name defines the name of the mesh
  47155. * @param options defines the options used to create the mesh
  47156. * @param scene defines the hosting scene
  47157. * @returns the box mesh
  47158. */
  47159. static CreateBox(name: string, options: {
  47160. size?: number;
  47161. width?: number;
  47162. height?: number;
  47163. depth?: number;
  47164. faceUV?: Vector4[];
  47165. faceColors?: Color4[];
  47166. sideOrientation?: number;
  47167. frontUVs?: Vector4;
  47168. backUVs?: Vector4;
  47169. wrap?: boolean;
  47170. topBaseAt?: number;
  47171. bottomBaseAt?: number;
  47172. updatable?: boolean;
  47173. }, scene?: Nullable<Scene>): Mesh;
  47174. }
  47175. }
  47176. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47177. import { Vector4 } from "babylonjs/Maths/math.vector";
  47178. import { Mesh } from "babylonjs/Meshes/mesh";
  47179. import { Scene } from "babylonjs/scene";
  47180. import { Nullable } from "babylonjs/types";
  47181. /**
  47182. * Class containing static functions to help procedurally build meshes
  47183. */
  47184. export class SphereBuilder {
  47185. /**
  47186. * Creates a sphere mesh
  47187. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47188. * * 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`)
  47189. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47190. * * 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
  47191. * * 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)
  47192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47195. * @param name defines the name of the mesh
  47196. * @param options defines the options used to create the mesh
  47197. * @param scene defines the hosting scene
  47198. * @returns the sphere mesh
  47199. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47200. */
  47201. static CreateSphere(name: string, options: {
  47202. segments?: number;
  47203. diameter?: number;
  47204. diameterX?: number;
  47205. diameterY?: number;
  47206. diameterZ?: number;
  47207. arc?: number;
  47208. slice?: number;
  47209. sideOrientation?: number;
  47210. frontUVs?: Vector4;
  47211. backUVs?: Vector4;
  47212. updatable?: boolean;
  47213. }, scene?: Nullable<Scene>): Mesh;
  47214. }
  47215. }
  47216. declare module "babylonjs/Debug/physicsViewer" {
  47217. import { Nullable } from "babylonjs/types";
  47218. import { Scene } from "babylonjs/scene";
  47219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47220. import { Mesh } from "babylonjs/Meshes/mesh";
  47221. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47222. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47223. /**
  47224. * Used to show the physics impostor around the specific mesh
  47225. */
  47226. export class PhysicsViewer {
  47227. /** @hidden */
  47228. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47229. /** @hidden */
  47230. protected _meshes: Array<Nullable<AbstractMesh>>;
  47231. /** @hidden */
  47232. protected _scene: Nullable<Scene>;
  47233. /** @hidden */
  47234. protected _numMeshes: number;
  47235. /** @hidden */
  47236. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47237. private _renderFunction;
  47238. private _utilityLayer;
  47239. private _debugBoxMesh;
  47240. private _debugSphereMesh;
  47241. private _debugCylinderMesh;
  47242. private _debugMaterial;
  47243. private _debugMeshMeshes;
  47244. /**
  47245. * Creates a new PhysicsViewer
  47246. * @param scene defines the hosting scene
  47247. */
  47248. constructor(scene: Scene);
  47249. /** @hidden */
  47250. protected _updateDebugMeshes(): void;
  47251. /**
  47252. * Renders a specified physic impostor
  47253. * @param impostor defines the impostor to render
  47254. * @param targetMesh defines the mesh represented by the impostor
  47255. * @returns the new debug mesh used to render the impostor
  47256. */
  47257. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47258. /**
  47259. * Hides a specified physic impostor
  47260. * @param impostor defines the impostor to hide
  47261. */
  47262. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47263. private _getDebugMaterial;
  47264. private _getDebugBoxMesh;
  47265. private _getDebugSphereMesh;
  47266. private _getDebugCylinderMesh;
  47267. private _getDebugMeshMesh;
  47268. private _getDebugMesh;
  47269. /** Releases all resources */
  47270. dispose(): void;
  47271. }
  47272. }
  47273. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47274. import { Vector3 } from "babylonjs/Maths/math.vector";
  47275. import { Color4 } from "babylonjs/Maths/math.color";
  47276. import { Nullable } from "babylonjs/types";
  47277. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47278. import { Scene } from "babylonjs/scene";
  47279. /**
  47280. * Class containing static functions to help procedurally build meshes
  47281. */
  47282. export class LinesBuilder {
  47283. /**
  47284. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47285. * * 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
  47286. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47287. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47288. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47289. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47290. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47291. * * 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
  47292. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47295. * @param name defines the name of the new line system
  47296. * @param options defines the options used to create the line system
  47297. * @param scene defines the hosting scene
  47298. * @returns a new line system mesh
  47299. */
  47300. static CreateLineSystem(name: string, options: {
  47301. lines: Vector3[][];
  47302. updatable?: boolean;
  47303. instance?: Nullable<LinesMesh>;
  47304. colors?: Nullable<Color4[][]>;
  47305. useVertexAlpha?: boolean;
  47306. }, scene: Nullable<Scene>): LinesMesh;
  47307. /**
  47308. * Creates a line mesh
  47309. * 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
  47310. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47311. * * The parameter `points` is an array successive Vector3
  47312. * * 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
  47313. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47314. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47315. * * When updating an instance, remember that only point positions can change, not the number of points
  47316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47318. * @param name defines the name of the new line system
  47319. * @param options defines the options used to create the line system
  47320. * @param scene defines the hosting scene
  47321. * @returns a new line mesh
  47322. */
  47323. static CreateLines(name: string, options: {
  47324. points: Vector3[];
  47325. updatable?: boolean;
  47326. instance?: Nullable<LinesMesh>;
  47327. colors?: Color4[];
  47328. useVertexAlpha?: boolean;
  47329. }, scene?: Nullable<Scene>): LinesMesh;
  47330. /**
  47331. * Creates a dashed line mesh
  47332. * * 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
  47333. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47334. * * The parameter `points` is an array successive Vector3
  47335. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47336. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47337. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47338. * * 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
  47339. * * When updating an instance, remember that only point positions can change, not the number of points
  47340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47341. * @param name defines the name of the mesh
  47342. * @param options defines the options used to create the mesh
  47343. * @param scene defines the hosting scene
  47344. * @returns the dashed line mesh
  47345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47346. */
  47347. static CreateDashedLines(name: string, options: {
  47348. points: Vector3[];
  47349. dashSize?: number;
  47350. gapSize?: number;
  47351. dashNb?: number;
  47352. updatable?: boolean;
  47353. instance?: LinesMesh;
  47354. }, scene?: Nullable<Scene>): LinesMesh;
  47355. }
  47356. }
  47357. declare module "babylonjs/Debug/rayHelper" {
  47358. import { Nullable } from "babylonjs/types";
  47359. import { Ray } from "babylonjs/Culling/ray";
  47360. import { Vector3 } from "babylonjs/Maths/math.vector";
  47361. import { Color3 } from "babylonjs/Maths/math.color";
  47362. import { Scene } from "babylonjs/scene";
  47363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47364. import "babylonjs/Meshes/Builders/linesBuilder";
  47365. /**
  47366. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47367. * in order to better appreciate the issue one might have.
  47368. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47369. */
  47370. export class RayHelper {
  47371. /**
  47372. * Defines the ray we are currently tryin to visualize.
  47373. */
  47374. ray: Nullable<Ray>;
  47375. private _renderPoints;
  47376. private _renderLine;
  47377. private _renderFunction;
  47378. private _scene;
  47379. private _updateToMeshFunction;
  47380. private _attachedToMesh;
  47381. private _meshSpaceDirection;
  47382. private _meshSpaceOrigin;
  47383. /**
  47384. * Helper function to create a colored helper in a scene in one line.
  47385. * @param ray Defines the ray we are currently tryin to visualize
  47386. * @param scene Defines the scene the ray is used in
  47387. * @param color Defines the color we want to see the ray in
  47388. * @returns The newly created ray helper.
  47389. */
  47390. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47391. /**
  47392. * Instantiate a new ray helper.
  47393. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47394. * in order to better appreciate the issue one might have.
  47395. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47396. * @param ray Defines the ray we are currently tryin to visualize
  47397. */
  47398. constructor(ray: Ray);
  47399. /**
  47400. * Shows the ray we are willing to debug.
  47401. * @param scene Defines the scene the ray needs to be rendered in
  47402. * @param color Defines the color the ray needs to be rendered in
  47403. */
  47404. show(scene: Scene, color?: Color3): void;
  47405. /**
  47406. * Hides the ray we are debugging.
  47407. */
  47408. hide(): void;
  47409. private _render;
  47410. /**
  47411. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47412. * @param mesh Defines the mesh we want the helper attached to
  47413. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47414. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47415. * @param length Defines the length of the ray
  47416. */
  47417. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47418. /**
  47419. * Detach the ray helper from the mesh it has previously been attached to.
  47420. */
  47421. detachFromMesh(): void;
  47422. private _updateToMesh;
  47423. /**
  47424. * Dispose the helper and release its associated resources.
  47425. */
  47426. dispose(): void;
  47427. }
  47428. }
  47429. declare module "babylonjs/Debug/skeletonViewer" {
  47430. import { Color3 } from "babylonjs/Maths/math.color";
  47431. import { Scene } from "babylonjs/scene";
  47432. import { Nullable } from "babylonjs/types";
  47433. import { Skeleton } from "babylonjs/Bones/skeleton";
  47434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47435. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47436. /**
  47437. * Class used to render a debug view of a given skeleton
  47438. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47439. */
  47440. export class SkeletonViewer {
  47441. /** defines the skeleton to render */
  47442. skeleton: Skeleton;
  47443. /** defines the mesh attached to the skeleton */
  47444. mesh: AbstractMesh;
  47445. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47446. autoUpdateBonesMatrices: boolean;
  47447. /** defines the rendering group id to use with the viewer */
  47448. renderingGroupId: number;
  47449. /** Gets or sets the color used to render the skeleton */
  47450. color: Color3;
  47451. private _scene;
  47452. private _debugLines;
  47453. private _debugMesh;
  47454. private _isEnabled;
  47455. private _renderFunction;
  47456. private _utilityLayer;
  47457. /**
  47458. * Returns the mesh used to render the bones
  47459. */
  47460. get debugMesh(): Nullable<LinesMesh>;
  47461. /**
  47462. * Creates a new SkeletonViewer
  47463. * @param skeleton defines the skeleton to render
  47464. * @param mesh defines the mesh attached to the skeleton
  47465. * @param scene defines the hosting scene
  47466. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47467. * @param renderingGroupId defines the rendering group id to use with the viewer
  47468. */
  47469. constructor(
  47470. /** defines the skeleton to render */
  47471. skeleton: Skeleton,
  47472. /** defines the mesh attached to the skeleton */
  47473. mesh: AbstractMesh, scene: Scene,
  47474. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47475. autoUpdateBonesMatrices?: boolean,
  47476. /** defines the rendering group id to use with the viewer */
  47477. renderingGroupId?: number);
  47478. /** Gets or sets a boolean indicating if the viewer is enabled */
  47479. set isEnabled(value: boolean);
  47480. get isEnabled(): boolean;
  47481. private _getBonePosition;
  47482. private _getLinesForBonesWithLength;
  47483. private _getLinesForBonesNoLength;
  47484. /** Update the viewer to sync with current skeleton state */
  47485. update(): void;
  47486. /** Release associated resources */
  47487. dispose(): void;
  47488. }
  47489. }
  47490. declare module "babylonjs/Debug/index" {
  47491. export * from "babylonjs/Debug/axesViewer";
  47492. export * from "babylonjs/Debug/boneAxesViewer";
  47493. export * from "babylonjs/Debug/debugLayer";
  47494. export * from "babylonjs/Debug/physicsViewer";
  47495. export * from "babylonjs/Debug/rayHelper";
  47496. export * from "babylonjs/Debug/skeletonViewer";
  47497. }
  47498. declare module "babylonjs/Engines/nullEngine" {
  47499. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47500. import { Scene } from "babylonjs/scene";
  47501. import { Engine } from "babylonjs/Engines/engine";
  47502. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47503. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47504. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47505. import { Effect } from "babylonjs/Materials/effect";
  47506. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47507. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47508. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47509. /**
  47510. * Options to create the null engine
  47511. */
  47512. export class NullEngineOptions {
  47513. /**
  47514. * Render width (Default: 512)
  47515. */
  47516. renderWidth: number;
  47517. /**
  47518. * Render height (Default: 256)
  47519. */
  47520. renderHeight: number;
  47521. /**
  47522. * Texture size (Default: 512)
  47523. */
  47524. textureSize: number;
  47525. /**
  47526. * If delta time between frames should be constant
  47527. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47528. */
  47529. deterministicLockstep: boolean;
  47530. /**
  47531. * Maximum about of steps between frames (Default: 4)
  47532. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47533. */
  47534. lockstepMaxSteps: number;
  47535. }
  47536. /**
  47537. * The null engine class provides support for headless version of babylon.js.
  47538. * This can be used in server side scenario or for testing purposes
  47539. */
  47540. export class NullEngine extends Engine {
  47541. private _options;
  47542. /**
  47543. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47544. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47545. * @returns true if engine is in deterministic lock step mode
  47546. */
  47547. isDeterministicLockStep(): boolean;
  47548. /**
  47549. * Gets the max steps when engine is running in deterministic lock step
  47550. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47551. * @returns the max steps
  47552. */
  47553. getLockstepMaxSteps(): number;
  47554. /**
  47555. * Gets the current hardware scaling level.
  47556. * By default the hardware scaling level is computed from the window device ratio.
  47557. * 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.
  47558. * @returns a number indicating the current hardware scaling level
  47559. */
  47560. getHardwareScalingLevel(): number;
  47561. constructor(options?: NullEngineOptions);
  47562. /**
  47563. * Creates a vertex buffer
  47564. * @param vertices the data for the vertex buffer
  47565. * @returns the new WebGL static buffer
  47566. */
  47567. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47568. /**
  47569. * Creates a new index buffer
  47570. * @param indices defines the content of the index buffer
  47571. * @param updatable defines if the index buffer must be updatable
  47572. * @returns a new webGL buffer
  47573. */
  47574. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47575. /**
  47576. * Clear the current render buffer or the current render target (if any is set up)
  47577. * @param color defines the color to use
  47578. * @param backBuffer defines if the back buffer must be cleared
  47579. * @param depth defines if the depth buffer must be cleared
  47580. * @param stencil defines if the stencil buffer must be cleared
  47581. */
  47582. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47583. /**
  47584. * Gets the current render width
  47585. * @param useScreen defines if screen size must be used (or the current render target if any)
  47586. * @returns a number defining the current render width
  47587. */
  47588. getRenderWidth(useScreen?: boolean): number;
  47589. /**
  47590. * Gets the current render height
  47591. * @param useScreen defines if screen size must be used (or the current render target if any)
  47592. * @returns a number defining the current render height
  47593. */
  47594. getRenderHeight(useScreen?: boolean): number;
  47595. /**
  47596. * Set the WebGL's viewport
  47597. * @param viewport defines the viewport element to be used
  47598. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47599. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47600. */
  47601. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47602. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47603. /**
  47604. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47605. * @param pipelineContext defines the pipeline context to use
  47606. * @param uniformsNames defines the list of uniform names
  47607. * @returns an array of webGL uniform locations
  47608. */
  47609. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47610. /**
  47611. * Gets the lsit of active attributes for a given webGL program
  47612. * @param pipelineContext defines the pipeline context to use
  47613. * @param attributesNames defines the list of attribute names to get
  47614. * @returns an array of indices indicating the offset of each attribute
  47615. */
  47616. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47617. /**
  47618. * Binds an effect to the webGL context
  47619. * @param effect defines the effect to bind
  47620. */
  47621. bindSamplers(effect: Effect): void;
  47622. /**
  47623. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47624. * @param effect defines the effect to activate
  47625. */
  47626. enableEffect(effect: Effect): void;
  47627. /**
  47628. * Set various states to the webGL context
  47629. * @param culling defines backface culling state
  47630. * @param zOffset defines the value to apply to zOffset (0 by default)
  47631. * @param force defines if states must be applied even if cache is up to date
  47632. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47633. */
  47634. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47635. /**
  47636. * Set the value of an uniform to an array of int32
  47637. * @param uniform defines the webGL uniform location where to store the value
  47638. * @param array defines the array of int32 to store
  47639. */
  47640. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47641. /**
  47642. * Set the value of an uniform to an array of int32 (stored as vec2)
  47643. * @param uniform defines the webGL uniform location where to store the value
  47644. * @param array defines the array of int32 to store
  47645. */
  47646. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47647. /**
  47648. * Set the value of an uniform to an array of int32 (stored as vec3)
  47649. * @param uniform defines the webGL uniform location where to store the value
  47650. * @param array defines the array of int32 to store
  47651. */
  47652. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47653. /**
  47654. * Set the value of an uniform to an array of int32 (stored as vec4)
  47655. * @param uniform defines the webGL uniform location where to store the value
  47656. * @param array defines the array of int32 to store
  47657. */
  47658. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47659. /**
  47660. * Set the value of an uniform to an array of float32
  47661. * @param uniform defines the webGL uniform location where to store the value
  47662. * @param array defines the array of float32 to store
  47663. */
  47664. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47665. /**
  47666. * Set the value of an uniform to an array of float32 (stored as vec2)
  47667. * @param uniform defines the webGL uniform location where to store the value
  47668. * @param array defines the array of float32 to store
  47669. */
  47670. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47671. /**
  47672. * Set the value of an uniform to an array of float32 (stored as vec3)
  47673. * @param uniform defines the webGL uniform location where to store the value
  47674. * @param array defines the array of float32 to store
  47675. */
  47676. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47677. /**
  47678. * Set the value of an uniform to an array of float32 (stored as vec4)
  47679. * @param uniform defines the webGL uniform location where to store the value
  47680. * @param array defines the array of float32 to store
  47681. */
  47682. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47683. /**
  47684. * Set the value of an uniform to an array of number
  47685. * @param uniform defines the webGL uniform location where to store the value
  47686. * @param array defines the array of number to store
  47687. */
  47688. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47689. /**
  47690. * Set the value of an uniform to an array of number (stored as vec2)
  47691. * @param uniform defines the webGL uniform location where to store the value
  47692. * @param array defines the array of number to store
  47693. */
  47694. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47695. /**
  47696. * Set the value of an uniform to an array of number (stored as vec3)
  47697. * @param uniform defines the webGL uniform location where to store the value
  47698. * @param array defines the array of number to store
  47699. */
  47700. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47701. /**
  47702. * Set the value of an uniform to an array of number (stored as vec4)
  47703. * @param uniform defines the webGL uniform location where to store the value
  47704. * @param array defines the array of number to store
  47705. */
  47706. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47707. /**
  47708. * Set the value of an uniform to an array of float32 (stored as matrices)
  47709. * @param uniform defines the webGL uniform location where to store the value
  47710. * @param matrices defines the array of float32 to store
  47711. */
  47712. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47713. /**
  47714. * Set the value of an uniform to a matrix (3x3)
  47715. * @param uniform defines the webGL uniform location where to store the value
  47716. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47717. */
  47718. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47719. /**
  47720. * Set the value of an uniform to a matrix (2x2)
  47721. * @param uniform defines the webGL uniform location where to store the value
  47722. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47723. */
  47724. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47725. /**
  47726. * Set the value of an uniform to a number (float)
  47727. * @param uniform defines the webGL uniform location where to store the value
  47728. * @param value defines the float number to store
  47729. */
  47730. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47731. /**
  47732. * Set the value of an uniform to a vec2
  47733. * @param uniform defines the webGL uniform location where to store the value
  47734. * @param x defines the 1st component of the value
  47735. * @param y defines the 2nd component of the value
  47736. */
  47737. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47738. /**
  47739. * Set the value of an uniform to a vec3
  47740. * @param uniform defines the webGL uniform location where to store the value
  47741. * @param x defines the 1st component of the value
  47742. * @param y defines the 2nd component of the value
  47743. * @param z defines the 3rd component of the value
  47744. */
  47745. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47746. /**
  47747. * Set the value of an uniform to a boolean
  47748. * @param uniform defines the webGL uniform location where to store the value
  47749. * @param bool defines the boolean to store
  47750. */
  47751. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47752. /**
  47753. * Set the value of an uniform to a vec4
  47754. * @param uniform defines the webGL uniform location where to store the value
  47755. * @param x defines the 1st component of the value
  47756. * @param y defines the 2nd component of the value
  47757. * @param z defines the 3rd component of the value
  47758. * @param w defines the 4th component of the value
  47759. */
  47760. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47761. /**
  47762. * Sets the current alpha mode
  47763. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47764. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47765. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47766. */
  47767. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47768. /**
  47769. * Bind webGl buffers directly to the webGL context
  47770. * @param vertexBuffers defines the vertex buffer to bind
  47771. * @param indexBuffer defines the index buffer to bind
  47772. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47773. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47774. * @param effect defines the effect associated with the vertex buffer
  47775. */
  47776. bindBuffers(vertexBuffers: {
  47777. [key: string]: VertexBuffer;
  47778. }, indexBuffer: DataBuffer, effect: Effect): void;
  47779. /**
  47780. * Force the entire cache to be cleared
  47781. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47782. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47783. */
  47784. wipeCaches(bruteForce?: boolean): void;
  47785. /**
  47786. * Send a draw order
  47787. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47788. * @param indexStart defines the starting index
  47789. * @param indexCount defines the number of index to draw
  47790. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47791. */
  47792. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47793. /**
  47794. * Draw a list of indexed primitives
  47795. * @param fillMode defines the primitive to use
  47796. * @param indexStart defines the starting index
  47797. * @param indexCount defines the number of index to draw
  47798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47799. */
  47800. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47801. /**
  47802. * Draw a list of unindexed primitives
  47803. * @param fillMode defines the primitive to use
  47804. * @param verticesStart defines the index of first vertex to draw
  47805. * @param verticesCount defines the count of vertices to draw
  47806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47807. */
  47808. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47809. /** @hidden */
  47810. _createTexture(): WebGLTexture;
  47811. /** @hidden */
  47812. _releaseTexture(texture: InternalTexture): void;
  47813. /**
  47814. * Usually called from Texture.ts.
  47815. * Passed information to create a WebGLTexture
  47816. * @param urlArg defines a value which contains one of the following:
  47817. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47818. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47819. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47820. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47821. * @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)
  47822. * @param scene needed for loading to the correct scene
  47823. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47824. * @param onLoad optional callback to be called upon successful completion
  47825. * @param onError optional callback to be called upon failure
  47826. * @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
  47827. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47828. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47829. * @param forcedExtension defines the extension to use to pick the right loader
  47830. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47831. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47832. */
  47833. 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;
  47834. /**
  47835. * Creates a new render target texture
  47836. * @param size defines the size of the texture
  47837. * @param options defines the options used to create the texture
  47838. * @returns a new render target texture stored in an InternalTexture
  47839. */
  47840. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47841. /**
  47842. * Update the sampling mode of a given texture
  47843. * @param samplingMode defines the required sampling mode
  47844. * @param texture defines the texture to update
  47845. */
  47846. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47847. /**
  47848. * Binds the frame buffer to the specified texture.
  47849. * @param texture The texture to render to or null for the default canvas
  47850. * @param faceIndex The face of the texture to render to in case of cube texture
  47851. * @param requiredWidth The width of the target to render to
  47852. * @param requiredHeight The height of the target to render to
  47853. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47854. * @param depthStencilTexture The depth stencil texture to use to render
  47855. * @param lodLevel defines le lod level to bind to the frame buffer
  47856. */
  47857. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47858. /**
  47859. * Unbind the current render target texture from the webGL context
  47860. * @param texture defines the render target texture to unbind
  47861. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47862. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47863. */
  47864. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47865. /**
  47866. * Creates a dynamic vertex buffer
  47867. * @param vertices the data for the dynamic vertex buffer
  47868. * @returns the new WebGL dynamic buffer
  47869. */
  47870. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47871. /**
  47872. * Update the content of a dynamic texture
  47873. * @param texture defines the texture to update
  47874. * @param canvas defines the canvas containing the source
  47875. * @param invertY defines if data must be stored with Y axis inverted
  47876. * @param premulAlpha defines if alpha is stored as premultiplied
  47877. * @param format defines the format of the data
  47878. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47879. */
  47880. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47881. /**
  47882. * Gets a boolean indicating if all created effects are ready
  47883. * @returns true if all effects are ready
  47884. */
  47885. areAllEffectsReady(): boolean;
  47886. /**
  47887. * @hidden
  47888. * Get the current error code of the webGL context
  47889. * @returns the error code
  47890. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47891. */
  47892. getError(): number;
  47893. /** @hidden */
  47894. _getUnpackAlignement(): number;
  47895. /** @hidden */
  47896. _unpackFlipY(value: boolean): void;
  47897. /**
  47898. * Update a dynamic index buffer
  47899. * @param indexBuffer defines the target index buffer
  47900. * @param indices defines the data to update
  47901. * @param offset defines the offset in the target index buffer where update should start
  47902. */
  47903. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47904. /**
  47905. * Updates a dynamic vertex buffer.
  47906. * @param vertexBuffer the vertex buffer to update
  47907. * @param vertices the data used to update the vertex buffer
  47908. * @param byteOffset the byte offset of the data (optional)
  47909. * @param byteLength the byte length of the data (optional)
  47910. */
  47911. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47912. /** @hidden */
  47913. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47914. /** @hidden */
  47915. _bindTexture(channel: number, texture: InternalTexture): void;
  47916. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47917. /**
  47918. * 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
  47919. */
  47920. releaseEffects(): void;
  47921. displayLoadingUI(): void;
  47922. hideLoadingUI(): void;
  47923. /** @hidden */
  47924. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47925. /** @hidden */
  47926. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47927. /** @hidden */
  47928. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47929. /** @hidden */
  47930. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47931. }
  47932. }
  47933. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  47934. import { Nullable, int } from "babylonjs/types";
  47935. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  47936. /** @hidden */
  47937. export class _OcclusionDataStorage {
  47938. /** @hidden */
  47939. occlusionInternalRetryCounter: number;
  47940. /** @hidden */
  47941. isOcclusionQueryInProgress: boolean;
  47942. /** @hidden */
  47943. isOccluded: boolean;
  47944. /** @hidden */
  47945. occlusionRetryCount: number;
  47946. /** @hidden */
  47947. occlusionType: number;
  47948. /** @hidden */
  47949. occlusionQueryAlgorithmType: number;
  47950. }
  47951. module "babylonjs/Engines/engine" {
  47952. interface Engine {
  47953. /**
  47954. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47955. * @return the new query
  47956. */
  47957. createQuery(): WebGLQuery;
  47958. /**
  47959. * Delete and release a webGL query
  47960. * @param query defines the query to delete
  47961. * @return the current engine
  47962. */
  47963. deleteQuery(query: WebGLQuery): Engine;
  47964. /**
  47965. * Check if a given query has resolved and got its value
  47966. * @param query defines the query to check
  47967. * @returns true if the query got its value
  47968. */
  47969. isQueryResultAvailable(query: WebGLQuery): boolean;
  47970. /**
  47971. * Gets the value of a given query
  47972. * @param query defines the query to check
  47973. * @returns the value of the query
  47974. */
  47975. getQueryResult(query: WebGLQuery): number;
  47976. /**
  47977. * Initiates an occlusion query
  47978. * @param algorithmType defines the algorithm to use
  47979. * @param query defines the query to use
  47980. * @returns the current engine
  47981. * @see http://doc.babylonjs.com/features/occlusionquery
  47982. */
  47983. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47984. /**
  47985. * Ends an occlusion query
  47986. * @see http://doc.babylonjs.com/features/occlusionquery
  47987. * @param algorithmType defines the algorithm to use
  47988. * @returns the current engine
  47989. */
  47990. endOcclusionQuery(algorithmType: number): Engine;
  47991. /**
  47992. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47993. * Please note that only one query can be issued at a time
  47994. * @returns a time token used to track the time span
  47995. */
  47996. startTimeQuery(): Nullable<_TimeToken>;
  47997. /**
  47998. * Ends a time query
  47999. * @param token defines the token used to measure the time span
  48000. * @returns the time spent (in ns)
  48001. */
  48002. endTimeQuery(token: _TimeToken): int;
  48003. /** @hidden */
  48004. _currentNonTimestampToken: Nullable<_TimeToken>;
  48005. /** @hidden */
  48006. _createTimeQuery(): WebGLQuery;
  48007. /** @hidden */
  48008. _deleteTimeQuery(query: WebGLQuery): void;
  48009. /** @hidden */
  48010. _getGlAlgorithmType(algorithmType: number): number;
  48011. /** @hidden */
  48012. _getTimeQueryResult(query: WebGLQuery): any;
  48013. /** @hidden */
  48014. _getTimeQueryAvailability(query: WebGLQuery): any;
  48015. }
  48016. }
  48017. module "babylonjs/Meshes/abstractMesh" {
  48018. interface AbstractMesh {
  48019. /**
  48020. * Backing filed
  48021. * @hidden
  48022. */
  48023. __occlusionDataStorage: _OcclusionDataStorage;
  48024. /**
  48025. * Access property
  48026. * @hidden
  48027. */
  48028. _occlusionDataStorage: _OcclusionDataStorage;
  48029. /**
  48030. * 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.
  48031. * The default value is -1 which means don't break the query and wait till the result
  48032. * @see http://doc.babylonjs.com/features/occlusionquery
  48033. */
  48034. occlusionRetryCount: number;
  48035. /**
  48036. * 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:
  48037. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48038. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48039. * * 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.
  48040. * @see http://doc.babylonjs.com/features/occlusionquery
  48041. */
  48042. occlusionType: number;
  48043. /**
  48044. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48045. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48046. * * 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.
  48047. * @see http://doc.babylonjs.com/features/occlusionquery
  48048. */
  48049. occlusionQueryAlgorithmType: number;
  48050. /**
  48051. * 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
  48052. * @see http://doc.babylonjs.com/features/occlusionquery
  48053. */
  48054. isOccluded: boolean;
  48055. /**
  48056. * Flag to check the progress status of the query
  48057. * @see http://doc.babylonjs.com/features/occlusionquery
  48058. */
  48059. isOcclusionQueryInProgress: boolean;
  48060. }
  48061. }
  48062. }
  48063. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48064. import { Nullable } from "babylonjs/types";
  48065. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48066. /** @hidden */
  48067. export var _forceTransformFeedbackToBundle: boolean;
  48068. module "babylonjs/Engines/engine" {
  48069. interface Engine {
  48070. /**
  48071. * Creates a webGL transform feedback object
  48072. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48073. * @returns the webGL transform feedback object
  48074. */
  48075. createTransformFeedback(): WebGLTransformFeedback;
  48076. /**
  48077. * Delete a webGL transform feedback object
  48078. * @param value defines the webGL transform feedback object to delete
  48079. */
  48080. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48081. /**
  48082. * Bind a webGL transform feedback object to the webgl context
  48083. * @param value defines the webGL transform feedback object to bind
  48084. */
  48085. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48086. /**
  48087. * Begins a transform feedback operation
  48088. * @param usePoints defines if points or triangles must be used
  48089. */
  48090. beginTransformFeedback(usePoints: boolean): void;
  48091. /**
  48092. * Ends a transform feedback operation
  48093. */
  48094. endTransformFeedback(): void;
  48095. /**
  48096. * Specify the varyings to use with transform feedback
  48097. * @param program defines the associated webGL program
  48098. * @param value defines the list of strings representing the varying names
  48099. */
  48100. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48101. /**
  48102. * Bind a webGL buffer for a transform feedback operation
  48103. * @param value defines the webGL buffer to bind
  48104. */
  48105. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48106. }
  48107. }
  48108. }
  48109. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48110. import { Scene } from "babylonjs/scene";
  48111. import { Engine } from "babylonjs/Engines/engine";
  48112. import { Texture } from "babylonjs/Materials/Textures/texture";
  48113. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48114. import "babylonjs/Engines/Extensions/engine.multiRender";
  48115. /**
  48116. * Creation options of the multi render target texture.
  48117. */
  48118. export interface IMultiRenderTargetOptions {
  48119. /**
  48120. * Define if the texture needs to create mip maps after render.
  48121. */
  48122. generateMipMaps?: boolean;
  48123. /**
  48124. * Define the types of all the draw buffers we want to create
  48125. */
  48126. types?: number[];
  48127. /**
  48128. * Define the sampling modes of all the draw buffers we want to create
  48129. */
  48130. samplingModes?: number[];
  48131. /**
  48132. * Define if a depth buffer is required
  48133. */
  48134. generateDepthBuffer?: boolean;
  48135. /**
  48136. * Define if a stencil buffer is required
  48137. */
  48138. generateStencilBuffer?: boolean;
  48139. /**
  48140. * Define if a depth texture is required instead of a depth buffer
  48141. */
  48142. generateDepthTexture?: boolean;
  48143. /**
  48144. * Define the number of desired draw buffers
  48145. */
  48146. textureCount?: number;
  48147. /**
  48148. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48149. */
  48150. doNotChangeAspectRatio?: boolean;
  48151. /**
  48152. * Define the default type of the buffers we are creating
  48153. */
  48154. defaultType?: number;
  48155. }
  48156. /**
  48157. * A multi render target, like a render target provides the ability to render to a texture.
  48158. * Unlike the render target, it can render to several draw buffers in one draw.
  48159. * This is specially interesting in deferred rendering or for any effects requiring more than
  48160. * just one color from a single pass.
  48161. */
  48162. export class MultiRenderTarget extends RenderTargetTexture {
  48163. private _internalTextures;
  48164. private _textures;
  48165. private _multiRenderTargetOptions;
  48166. /**
  48167. * Get if draw buffers are currently supported by the used hardware and browser.
  48168. */
  48169. get isSupported(): boolean;
  48170. /**
  48171. * Get the list of textures generated by the multi render target.
  48172. */
  48173. get textures(): Texture[];
  48174. /**
  48175. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48176. */
  48177. get depthTexture(): Texture;
  48178. /**
  48179. * Set the wrapping mode on U of all the textures we are rendering to.
  48180. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48181. */
  48182. set wrapU(wrap: number);
  48183. /**
  48184. * Set the wrapping mode on V of all the textures we are rendering to.
  48185. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48186. */
  48187. set wrapV(wrap: number);
  48188. /**
  48189. * Instantiate a new multi render target texture.
  48190. * A multi render target, like a render target provides the ability to render to a texture.
  48191. * Unlike the render target, it can render to several draw buffers in one draw.
  48192. * This is specially interesting in deferred rendering or for any effects requiring more than
  48193. * just one color from a single pass.
  48194. * @param name Define the name of the texture
  48195. * @param size Define the size of the buffers to render to
  48196. * @param count Define the number of target we are rendering into
  48197. * @param scene Define the scene the texture belongs to
  48198. * @param options Define the options used to create the multi render target
  48199. */
  48200. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48201. /** @hidden */
  48202. _rebuild(): void;
  48203. private _createInternalTextures;
  48204. private _createTextures;
  48205. /**
  48206. * Define the number of samples used if MSAA is enabled.
  48207. */
  48208. get samples(): number;
  48209. set samples(value: number);
  48210. /**
  48211. * Resize all the textures in the multi render target.
  48212. * Be carrefull as it will recreate all the data in the new texture.
  48213. * @param size Define the new size
  48214. */
  48215. resize(size: any): void;
  48216. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48217. /**
  48218. * Dispose the render targets and their associated resources
  48219. */
  48220. dispose(): void;
  48221. /**
  48222. * Release all the underlying texture used as draw buffers.
  48223. */
  48224. releaseInternalTextures(): void;
  48225. }
  48226. }
  48227. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48229. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48230. import { Nullable } from "babylonjs/types";
  48231. module "babylonjs/Engines/thinEngine" {
  48232. interface ThinEngine {
  48233. /**
  48234. * Unbind a list of render target textures from the webGL context
  48235. * This is used only when drawBuffer extension or webGL2 are active
  48236. * @param textures defines the render target textures to unbind
  48237. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48238. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48239. */
  48240. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48241. /**
  48242. * Create a multi render target texture
  48243. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48244. * @param size defines the size of the texture
  48245. * @param options defines the creation options
  48246. * @returns the cube texture as an InternalTexture
  48247. */
  48248. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48249. /**
  48250. * Update the sample count for a given multiple render target texture
  48251. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48252. * @param textures defines the textures to update
  48253. * @param samples defines the sample count to set
  48254. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48255. */
  48256. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48257. }
  48258. }
  48259. }
  48260. declare module "babylonjs/Engines/Extensions/engine.views" {
  48261. import { Camera } from "babylonjs/Cameras/camera";
  48262. import { Nullable } from "babylonjs/types";
  48263. /**
  48264. * Class used to define an additional view for the engine
  48265. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48266. */
  48267. export class EngineView {
  48268. /** Defines the canvas where to render the view */
  48269. target: HTMLCanvasElement;
  48270. /** Defines an optional camera used to render the view (will use active camera else) */
  48271. camera?: Camera;
  48272. }
  48273. module "babylonjs/Engines/engine" {
  48274. interface Engine {
  48275. /**
  48276. * Gets or sets the HTML element to use for attaching events
  48277. */
  48278. inputElement: Nullable<HTMLElement>;
  48279. /**
  48280. * Gets the current engine view
  48281. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48282. */
  48283. activeView: Nullable<EngineView>;
  48284. /** Gets or sets the list of views */
  48285. views: EngineView[];
  48286. /**
  48287. * Register a new child canvas
  48288. * @param canvas defines the canvas to register
  48289. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48290. * @returns the associated view
  48291. */
  48292. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48293. /**
  48294. * Remove a registered child canvas
  48295. * @param canvas defines the canvas to remove
  48296. * @returns the current engine
  48297. */
  48298. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48299. }
  48300. }
  48301. }
  48302. declare module "babylonjs/Engines/Extensions/index" {
  48303. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48304. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48305. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48306. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48307. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48308. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48309. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48310. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48311. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48312. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48313. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48314. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48315. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48316. export * from "babylonjs/Engines/Extensions/engine.views";
  48317. }
  48318. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48319. import { Nullable } from "babylonjs/types";
  48320. /**
  48321. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48322. */
  48323. export interface CubeMapInfo {
  48324. /**
  48325. * The pixel array for the front face.
  48326. * This is stored in format, left to right, up to down format.
  48327. */
  48328. front: Nullable<ArrayBufferView>;
  48329. /**
  48330. * The pixel array for the back face.
  48331. * This is stored in format, left to right, up to down format.
  48332. */
  48333. back: Nullable<ArrayBufferView>;
  48334. /**
  48335. * The pixel array for the left face.
  48336. * This is stored in format, left to right, up to down format.
  48337. */
  48338. left: Nullable<ArrayBufferView>;
  48339. /**
  48340. * The pixel array for the right face.
  48341. * This is stored in format, left to right, up to down format.
  48342. */
  48343. right: Nullable<ArrayBufferView>;
  48344. /**
  48345. * The pixel array for the up face.
  48346. * This is stored in format, left to right, up to down format.
  48347. */
  48348. up: Nullable<ArrayBufferView>;
  48349. /**
  48350. * The pixel array for the down face.
  48351. * This is stored in format, left to right, up to down format.
  48352. */
  48353. down: Nullable<ArrayBufferView>;
  48354. /**
  48355. * The size of the cubemap stored.
  48356. *
  48357. * Each faces will be size * size pixels.
  48358. */
  48359. size: number;
  48360. /**
  48361. * The format of the texture.
  48362. *
  48363. * RGBA, RGB.
  48364. */
  48365. format: number;
  48366. /**
  48367. * The type of the texture data.
  48368. *
  48369. * UNSIGNED_INT, FLOAT.
  48370. */
  48371. type: number;
  48372. /**
  48373. * Specifies whether the texture is in gamma space.
  48374. */
  48375. gammaSpace: boolean;
  48376. }
  48377. /**
  48378. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48379. */
  48380. export class PanoramaToCubeMapTools {
  48381. private static FACE_FRONT;
  48382. private static FACE_BACK;
  48383. private static FACE_RIGHT;
  48384. private static FACE_LEFT;
  48385. private static FACE_DOWN;
  48386. private static FACE_UP;
  48387. /**
  48388. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48389. *
  48390. * @param float32Array The source data.
  48391. * @param inputWidth The width of the input panorama.
  48392. * @param inputHeight The height of the input panorama.
  48393. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48394. * @return The cubemap data
  48395. */
  48396. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48397. private static CreateCubemapTexture;
  48398. private static CalcProjectionSpherical;
  48399. }
  48400. }
  48401. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48402. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48404. import { Nullable } from "babylonjs/types";
  48405. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48406. /**
  48407. * Helper class dealing with the extraction of spherical polynomial dataArray
  48408. * from a cube map.
  48409. */
  48410. export class CubeMapToSphericalPolynomialTools {
  48411. private static FileFaces;
  48412. /**
  48413. * Converts a texture to the according Spherical Polynomial data.
  48414. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48415. *
  48416. * @param texture The texture to extract the information from.
  48417. * @return The Spherical Polynomial data.
  48418. */
  48419. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48420. /**
  48421. * Converts a cubemap to the according Spherical Polynomial data.
  48422. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48423. *
  48424. * @param cubeInfo The Cube map to extract the information from.
  48425. * @return The Spherical Polynomial data.
  48426. */
  48427. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48428. }
  48429. }
  48430. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48431. import { Nullable } from "babylonjs/types";
  48432. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48433. module "babylonjs/Materials/Textures/baseTexture" {
  48434. interface BaseTexture {
  48435. /**
  48436. * Get the polynomial representation of the texture data.
  48437. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48438. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48439. */
  48440. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48441. }
  48442. }
  48443. }
  48444. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48445. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48446. /** @hidden */
  48447. export var rgbdEncodePixelShader: {
  48448. name: string;
  48449. shader: string;
  48450. };
  48451. }
  48452. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48453. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48454. /** @hidden */
  48455. export var rgbdDecodePixelShader: {
  48456. name: string;
  48457. shader: string;
  48458. };
  48459. }
  48460. declare module "babylonjs/Misc/environmentTextureTools" {
  48461. import { Nullable } from "babylonjs/types";
  48462. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48464. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48465. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48466. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48467. import "babylonjs/Shaders/rgbdEncode.fragment";
  48468. import "babylonjs/Shaders/rgbdDecode.fragment";
  48469. /**
  48470. * Raw texture data and descriptor sufficient for WebGL texture upload
  48471. */
  48472. export interface EnvironmentTextureInfo {
  48473. /**
  48474. * Version of the environment map
  48475. */
  48476. version: number;
  48477. /**
  48478. * Width of image
  48479. */
  48480. width: number;
  48481. /**
  48482. * Irradiance information stored in the file.
  48483. */
  48484. irradiance: any;
  48485. /**
  48486. * Specular information stored in the file.
  48487. */
  48488. specular: any;
  48489. }
  48490. /**
  48491. * Defines One Image in the file. It requires only the position in the file
  48492. * as well as the length.
  48493. */
  48494. interface BufferImageData {
  48495. /**
  48496. * Length of the image data.
  48497. */
  48498. length: number;
  48499. /**
  48500. * Position of the data from the null terminator delimiting the end of the JSON.
  48501. */
  48502. position: number;
  48503. }
  48504. /**
  48505. * Defines the specular data enclosed in the file.
  48506. * This corresponds to the version 1 of the data.
  48507. */
  48508. export interface EnvironmentTextureSpecularInfoV1 {
  48509. /**
  48510. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48511. */
  48512. specularDataPosition?: number;
  48513. /**
  48514. * This contains all the images data needed to reconstruct the cubemap.
  48515. */
  48516. mipmaps: Array<BufferImageData>;
  48517. /**
  48518. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48519. */
  48520. lodGenerationScale: number;
  48521. }
  48522. /**
  48523. * Sets of helpers addressing the serialization and deserialization of environment texture
  48524. * stored in a BabylonJS env file.
  48525. * Those files are usually stored as .env files.
  48526. */
  48527. export class EnvironmentTextureTools {
  48528. /**
  48529. * Magic number identifying the env file.
  48530. */
  48531. private static _MagicBytes;
  48532. /**
  48533. * Gets the environment info from an env file.
  48534. * @param data The array buffer containing the .env bytes.
  48535. * @returns the environment file info (the json header) if successfully parsed.
  48536. */
  48537. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48538. /**
  48539. * Creates an environment texture from a loaded cube texture.
  48540. * @param texture defines the cube texture to convert in env file
  48541. * @return a promise containing the environment data if succesfull.
  48542. */
  48543. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48544. /**
  48545. * Creates a JSON representation of the spherical data.
  48546. * @param texture defines the texture containing the polynomials
  48547. * @return the JSON representation of the spherical info
  48548. */
  48549. private static _CreateEnvTextureIrradiance;
  48550. /**
  48551. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48552. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48553. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48554. * @return the views described by info providing access to the underlying buffer
  48555. */
  48556. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48557. /**
  48558. * Uploads the texture info contained in the env file to the GPU.
  48559. * @param texture defines the internal texture to upload to
  48560. * @param arrayBuffer defines the buffer cotaining the data to load
  48561. * @param info defines the texture info retrieved through the GetEnvInfo method
  48562. * @returns a promise
  48563. */
  48564. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48565. private static _OnImageReadyAsync;
  48566. /**
  48567. * Uploads the levels of image data to the GPU.
  48568. * @param texture defines the internal texture to upload to
  48569. * @param imageData defines the array buffer views of image data [mipmap][face]
  48570. * @returns a promise
  48571. */
  48572. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48573. /**
  48574. * Uploads spherical polynomials information to the texture.
  48575. * @param texture defines the texture we are trying to upload the information to
  48576. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48577. */
  48578. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48579. /** @hidden */
  48580. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48581. }
  48582. }
  48583. declare module "babylonjs/Maths/math.vertexFormat" {
  48584. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48585. /**
  48586. * Contains position and normal vectors for a vertex
  48587. */
  48588. export class PositionNormalVertex {
  48589. /** the position of the vertex (defaut: 0,0,0) */
  48590. position: Vector3;
  48591. /** the normal of the vertex (defaut: 0,1,0) */
  48592. normal: Vector3;
  48593. /**
  48594. * Creates a PositionNormalVertex
  48595. * @param position the position of the vertex (defaut: 0,0,0)
  48596. * @param normal the normal of the vertex (defaut: 0,1,0)
  48597. */
  48598. constructor(
  48599. /** the position of the vertex (defaut: 0,0,0) */
  48600. position?: Vector3,
  48601. /** the normal of the vertex (defaut: 0,1,0) */
  48602. normal?: Vector3);
  48603. /**
  48604. * Clones the PositionNormalVertex
  48605. * @returns the cloned PositionNormalVertex
  48606. */
  48607. clone(): PositionNormalVertex;
  48608. }
  48609. /**
  48610. * Contains position, normal and uv vectors for a vertex
  48611. */
  48612. export class PositionNormalTextureVertex {
  48613. /** the position of the vertex (defaut: 0,0,0) */
  48614. position: Vector3;
  48615. /** the normal of the vertex (defaut: 0,1,0) */
  48616. normal: Vector3;
  48617. /** the uv of the vertex (default: 0,0) */
  48618. uv: Vector2;
  48619. /**
  48620. * Creates a PositionNormalTextureVertex
  48621. * @param position the position of the vertex (defaut: 0,0,0)
  48622. * @param normal the normal of the vertex (defaut: 0,1,0)
  48623. * @param uv the uv of the vertex (default: 0,0)
  48624. */
  48625. constructor(
  48626. /** the position of the vertex (defaut: 0,0,0) */
  48627. position?: Vector3,
  48628. /** the normal of the vertex (defaut: 0,1,0) */
  48629. normal?: Vector3,
  48630. /** the uv of the vertex (default: 0,0) */
  48631. uv?: Vector2);
  48632. /**
  48633. * Clones the PositionNormalTextureVertex
  48634. * @returns the cloned PositionNormalTextureVertex
  48635. */
  48636. clone(): PositionNormalTextureVertex;
  48637. }
  48638. }
  48639. declare module "babylonjs/Maths/math" {
  48640. export * from "babylonjs/Maths/math.axis";
  48641. export * from "babylonjs/Maths/math.color";
  48642. export * from "babylonjs/Maths/math.constants";
  48643. export * from "babylonjs/Maths/math.frustum";
  48644. export * from "babylonjs/Maths/math.path";
  48645. export * from "babylonjs/Maths/math.plane";
  48646. export * from "babylonjs/Maths/math.size";
  48647. export * from "babylonjs/Maths/math.vector";
  48648. export * from "babylonjs/Maths/math.vertexFormat";
  48649. export * from "babylonjs/Maths/math.viewport";
  48650. }
  48651. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  48652. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48653. /** @hidden */
  48654. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48655. private _genericAttributeLocation;
  48656. private _varyingLocationCount;
  48657. private _varyingLocationMap;
  48658. private _replacements;
  48659. private _textureCount;
  48660. private _uniforms;
  48661. lineProcessor(line: string): string;
  48662. attributeProcessor(attribute: string): string;
  48663. varyingProcessor(varying: string, isFragment: boolean): string;
  48664. uniformProcessor(uniform: string): string;
  48665. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48666. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48667. }
  48668. }
  48669. declare module "babylonjs/Engines/nativeEngine" {
  48670. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  48671. import { Engine } from "babylonjs/Engines/engine";
  48672. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48673. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48675. import { Effect } from "babylonjs/Materials/effect";
  48676. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48677. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  48678. import { IColor4Like } from "babylonjs/Maths/math.like";
  48679. import { Scene } from "babylonjs/scene";
  48680. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48681. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48682. /**
  48683. * Container for accessors for natively-stored mesh data buffers.
  48684. */
  48685. class NativeDataBuffer extends DataBuffer {
  48686. /**
  48687. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48688. */
  48689. nativeIndexBuffer?: any;
  48690. /**
  48691. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48692. */
  48693. nativeVertexBuffer?: any;
  48694. }
  48695. /** @hidden */
  48696. class NativeTexture extends InternalTexture {
  48697. getInternalTexture(): InternalTexture;
  48698. getViewCount(): number;
  48699. }
  48700. /** @hidden */
  48701. export class NativeEngine extends Engine {
  48702. private readonly _native;
  48703. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48704. private readonly INVALID_HANDLE;
  48705. getHardwareScalingLevel(): number;
  48706. constructor();
  48707. /**
  48708. * Can be used to override the current requestAnimationFrame requester.
  48709. * @hidden
  48710. */
  48711. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48712. /**
  48713. * Override default engine behavior.
  48714. * @param color
  48715. * @param backBuffer
  48716. * @param depth
  48717. * @param stencil
  48718. */
  48719. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48720. /**
  48721. * Gets host document
  48722. * @returns the host document object
  48723. */
  48724. getHostDocument(): Nullable<Document>;
  48725. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48726. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48727. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48728. recordVertexArrayObject(vertexBuffers: {
  48729. [key: string]: VertexBuffer;
  48730. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48731. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48732. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48733. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48734. /**
  48735. * Draw a list of indexed primitives
  48736. * @param fillMode defines the primitive to use
  48737. * @param indexStart defines the starting index
  48738. * @param indexCount defines the number of index to draw
  48739. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48740. */
  48741. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48742. /**
  48743. * Draw a list of unindexed primitives
  48744. * @param fillMode defines the primitive to use
  48745. * @param verticesStart defines the index of first vertex to draw
  48746. * @param verticesCount defines the count of vertices to draw
  48747. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48748. */
  48749. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48750. createPipelineContext(): IPipelineContext;
  48751. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48752. /** @hidden */
  48753. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48754. /** @hidden */
  48755. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48756. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48757. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48758. protected _setProgram(program: WebGLProgram): void;
  48759. _releaseEffect(effect: Effect): void;
  48760. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48761. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48762. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48763. bindSamplers(effect: Effect): void;
  48764. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48765. getRenderWidth(useScreen?: boolean): number;
  48766. getRenderHeight(useScreen?: boolean): number;
  48767. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48768. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48769. /**
  48770. * Set the z offset to apply to current rendering
  48771. * @param value defines the offset to apply
  48772. */
  48773. setZOffset(value: number): void;
  48774. /**
  48775. * Gets the current value of the zOffset
  48776. * @returns the current zOffset state
  48777. */
  48778. getZOffset(): number;
  48779. /**
  48780. * Enable or disable depth buffering
  48781. * @param enable defines the state to set
  48782. */
  48783. setDepthBuffer(enable: boolean): void;
  48784. /**
  48785. * Gets a boolean indicating if depth writing is enabled
  48786. * @returns the current depth writing state
  48787. */
  48788. getDepthWrite(): boolean;
  48789. /**
  48790. * Enable or disable depth writing
  48791. * @param enable defines the state to set
  48792. */
  48793. setDepthWrite(enable: boolean): void;
  48794. /**
  48795. * Enable or disable color writing
  48796. * @param enable defines the state to set
  48797. */
  48798. setColorWrite(enable: boolean): void;
  48799. /**
  48800. * Gets a boolean indicating if color writing is enabled
  48801. * @returns the current color writing state
  48802. */
  48803. getColorWrite(): boolean;
  48804. /**
  48805. * Sets alpha constants used by some alpha blending modes
  48806. * @param r defines the red component
  48807. * @param g defines the green component
  48808. * @param b defines the blue component
  48809. * @param a defines the alpha component
  48810. */
  48811. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48812. /**
  48813. * Sets the current alpha mode
  48814. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48815. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48816. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48817. */
  48818. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48819. /**
  48820. * Gets the current alpha mode
  48821. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48822. * @returns the current alpha mode
  48823. */
  48824. getAlphaMode(): number;
  48825. setInt(uniform: WebGLUniformLocation, int: number): void;
  48826. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48827. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48828. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48829. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48830. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48831. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48832. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48833. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48834. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48835. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48836. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48837. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48838. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48839. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48840. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48841. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48842. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48843. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48844. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48845. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48846. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48847. wipeCaches(bruteForce?: boolean): void;
  48848. _createTexture(): WebGLTexture;
  48849. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48850. /**
  48851. * Usually called from BABYLON.Texture.ts.
  48852. * Passed information to create a WebGLTexture
  48853. * @param urlArg defines a value which contains one of the following:
  48854. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48855. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48856. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48857. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48858. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48859. * @param scene needed for loading to the correct scene
  48860. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48861. * @param onLoad optional callback to be called upon successful completion
  48862. * @param onError optional callback to be called upon failure
  48863. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48864. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48865. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48866. * @param forcedExtension defines the extension to use to pick the right loader
  48867. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48868. */
  48869. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  48870. /**
  48871. * Creates a cube texture
  48872. * @param rootUrl defines the url where the files to load is located
  48873. * @param scene defines the current scene
  48874. * @param files defines the list of files to load (1 per face)
  48875. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48876. * @param onLoad defines an optional callback raised when the texture is loaded
  48877. * @param onError defines an optional callback raised if there is an issue to load the texture
  48878. * @param format defines the format of the data
  48879. * @param forcedExtension defines the extension to use to pick the right loader
  48880. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48881. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48882. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48883. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48884. * @returns the cube texture as an InternalTexture
  48885. */
  48886. 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, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  48887. private _getSamplingFilter;
  48888. private static _GetNativeTextureFormat;
  48889. createRenderTargetTexture(size: number | {
  48890. width: number;
  48891. height: number;
  48892. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48893. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48894. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48895. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48896. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48897. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48898. /**
  48899. * Updates a dynamic vertex buffer.
  48900. * @param vertexBuffer the vertex buffer to update
  48901. * @param data the data used to update the vertex buffer
  48902. * @param byteOffset the byte offset of the data (optional)
  48903. * @param byteLength the byte length of the data (optional)
  48904. */
  48905. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48906. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48907. private _updateAnisotropicLevel;
  48908. private _getAddressMode;
  48909. /** @hidden */
  48910. _bindTexture(channel: number, texture: InternalTexture): void;
  48911. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48912. releaseEffects(): void;
  48913. /** @hidden */
  48914. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48915. /** @hidden */
  48916. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48917. /** @hidden */
  48918. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48919. /** @hidden */
  48920. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48921. }
  48922. }
  48923. declare module "babylonjs/Engines/index" {
  48924. export * from "babylonjs/Engines/constants";
  48925. export * from "babylonjs/Engines/engineCapabilities";
  48926. export * from "babylonjs/Engines/instancingAttributeInfo";
  48927. export * from "babylonjs/Engines/thinEngine";
  48928. export * from "babylonjs/Engines/engine";
  48929. export * from "babylonjs/Engines/engineStore";
  48930. export * from "babylonjs/Engines/nullEngine";
  48931. export * from "babylonjs/Engines/Extensions/index";
  48932. export * from "babylonjs/Engines/IPipelineContext";
  48933. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  48934. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48935. export * from "babylonjs/Engines/nativeEngine";
  48936. }
  48937. declare module "babylonjs/Events/clipboardEvents" {
  48938. /**
  48939. * Gather the list of clipboard event types as constants.
  48940. */
  48941. export class ClipboardEventTypes {
  48942. /**
  48943. * The clipboard event is fired when a copy command is active (pressed).
  48944. */
  48945. static readonly COPY: number;
  48946. /**
  48947. * The clipboard event is fired when a cut command is active (pressed).
  48948. */
  48949. static readonly CUT: number;
  48950. /**
  48951. * The clipboard event is fired when a paste command is active (pressed).
  48952. */
  48953. static readonly PASTE: number;
  48954. }
  48955. /**
  48956. * This class is used to store clipboard related info for the onClipboardObservable event.
  48957. */
  48958. export class ClipboardInfo {
  48959. /**
  48960. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48961. */
  48962. type: number;
  48963. /**
  48964. * Defines the related dom event
  48965. */
  48966. event: ClipboardEvent;
  48967. /**
  48968. *Creates an instance of ClipboardInfo.
  48969. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48970. * @param event Defines the related dom event
  48971. */
  48972. constructor(
  48973. /**
  48974. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48975. */
  48976. type: number,
  48977. /**
  48978. * Defines the related dom event
  48979. */
  48980. event: ClipboardEvent);
  48981. /**
  48982. * Get the clipboard event's type from the keycode.
  48983. * @param keyCode Defines the keyCode for the current keyboard event.
  48984. * @return {number}
  48985. */
  48986. static GetTypeFromCharacter(keyCode: number): number;
  48987. }
  48988. }
  48989. declare module "babylonjs/Events/index" {
  48990. export * from "babylonjs/Events/keyboardEvents";
  48991. export * from "babylonjs/Events/pointerEvents";
  48992. export * from "babylonjs/Events/clipboardEvents";
  48993. }
  48994. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  48995. import { Scene } from "babylonjs/scene";
  48996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48997. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  48998. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  48999. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49000. /**
  49001. * Google Daydream controller
  49002. */
  49003. export class DaydreamController extends WebVRController {
  49004. /**
  49005. * Base Url for the controller model.
  49006. */
  49007. static MODEL_BASE_URL: string;
  49008. /**
  49009. * File name for the controller model.
  49010. */
  49011. static MODEL_FILENAME: string;
  49012. /**
  49013. * Gamepad Id prefix used to identify Daydream Controller.
  49014. */
  49015. static readonly GAMEPAD_ID_PREFIX: string;
  49016. /**
  49017. * Creates a new DaydreamController from a gamepad
  49018. * @param vrGamepad the gamepad that the controller should be created from
  49019. */
  49020. constructor(vrGamepad: any);
  49021. /**
  49022. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49023. * @param scene scene in which to add meshes
  49024. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49025. */
  49026. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49027. /**
  49028. * Called once for each button that changed state since the last frame
  49029. * @param buttonIdx Which button index changed
  49030. * @param state New state of the button
  49031. * @param changes Which properties on the state changed since last frame
  49032. */
  49033. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49034. }
  49035. }
  49036. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49037. import { Scene } from "babylonjs/scene";
  49038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49039. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49040. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49041. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49042. /**
  49043. * Gear VR Controller
  49044. */
  49045. export class GearVRController extends WebVRController {
  49046. /**
  49047. * Base Url for the controller model.
  49048. */
  49049. static MODEL_BASE_URL: string;
  49050. /**
  49051. * File name for the controller model.
  49052. */
  49053. static MODEL_FILENAME: string;
  49054. /**
  49055. * Gamepad Id prefix used to identify this controller.
  49056. */
  49057. static readonly GAMEPAD_ID_PREFIX: string;
  49058. private readonly _buttonIndexToObservableNameMap;
  49059. /**
  49060. * Creates a new GearVRController from a gamepad
  49061. * @param vrGamepad the gamepad that the controller should be created from
  49062. */
  49063. constructor(vrGamepad: any);
  49064. /**
  49065. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49066. * @param scene scene in which to add meshes
  49067. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49068. */
  49069. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49070. /**
  49071. * Called once for each button that changed state since the last frame
  49072. * @param buttonIdx Which button index changed
  49073. * @param state New state of the button
  49074. * @param changes Which properties on the state changed since last frame
  49075. */
  49076. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49077. }
  49078. }
  49079. declare module "babylonjs/Gamepads/Controllers/index" {
  49080. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49081. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49082. export * from "babylonjs/Gamepads/Controllers/genericController";
  49083. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49084. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49085. export * from "babylonjs/Gamepads/Controllers/viveController";
  49086. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49087. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49088. }
  49089. declare module "babylonjs/Gamepads/index" {
  49090. export * from "babylonjs/Gamepads/Controllers/index";
  49091. export * from "babylonjs/Gamepads/gamepad";
  49092. export * from "babylonjs/Gamepads/gamepadManager";
  49093. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49094. export * from "babylonjs/Gamepads/xboxGamepad";
  49095. export * from "babylonjs/Gamepads/dualShockGamepad";
  49096. }
  49097. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49098. import { Scene } from "babylonjs/scene";
  49099. import { Vector4 } from "babylonjs/Maths/math.vector";
  49100. import { Color4 } from "babylonjs/Maths/math.color";
  49101. import { Mesh } from "babylonjs/Meshes/mesh";
  49102. import { Nullable } from "babylonjs/types";
  49103. /**
  49104. * Class containing static functions to help procedurally build meshes
  49105. */
  49106. export class PolyhedronBuilder {
  49107. /**
  49108. * Creates a polyhedron mesh
  49109. * * 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
  49110. * * The parameter `size` (positive float, default 1) sets the polygon size
  49111. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49112. * * 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`
  49113. * * 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
  49114. * * 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)`)
  49115. * * 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
  49116. * * 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
  49117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49120. * @param name defines the name of the mesh
  49121. * @param options defines the options used to create the mesh
  49122. * @param scene defines the hosting scene
  49123. * @returns the polyhedron mesh
  49124. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49125. */
  49126. static CreatePolyhedron(name: string, options: {
  49127. type?: number;
  49128. size?: number;
  49129. sizeX?: number;
  49130. sizeY?: number;
  49131. sizeZ?: number;
  49132. custom?: any;
  49133. faceUV?: Vector4[];
  49134. faceColors?: Color4[];
  49135. flat?: boolean;
  49136. updatable?: boolean;
  49137. sideOrientation?: number;
  49138. frontUVs?: Vector4;
  49139. backUVs?: Vector4;
  49140. }, scene?: Nullable<Scene>): Mesh;
  49141. }
  49142. }
  49143. declare module "babylonjs/Gizmos/scaleGizmo" {
  49144. import { Observable } from "babylonjs/Misc/observable";
  49145. import { Nullable } from "babylonjs/types";
  49146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49147. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49148. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49149. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49150. /**
  49151. * Gizmo that enables scaling a mesh along 3 axis
  49152. */
  49153. export class ScaleGizmo extends Gizmo {
  49154. /**
  49155. * Internal gizmo used for interactions on the x axis
  49156. */
  49157. xGizmo: AxisScaleGizmo;
  49158. /**
  49159. * Internal gizmo used for interactions on the y axis
  49160. */
  49161. yGizmo: AxisScaleGizmo;
  49162. /**
  49163. * Internal gizmo used for interactions on the z axis
  49164. */
  49165. zGizmo: AxisScaleGizmo;
  49166. /**
  49167. * Internal gizmo used to scale all axis equally
  49168. */
  49169. uniformScaleGizmo: AxisScaleGizmo;
  49170. private _meshAttached;
  49171. private _updateGizmoRotationToMatchAttachedMesh;
  49172. private _snapDistance;
  49173. private _scaleRatio;
  49174. private _uniformScalingMesh;
  49175. private _octahedron;
  49176. private _sensitivity;
  49177. /** Fires an event when any of it's sub gizmos are dragged */
  49178. onDragStartObservable: Observable<unknown>;
  49179. /** Fires an event when any of it's sub gizmos are released from dragging */
  49180. onDragEndObservable: Observable<unknown>;
  49181. get attachedMesh(): Nullable<AbstractMesh>;
  49182. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49183. /**
  49184. * Creates a ScaleGizmo
  49185. * @param gizmoLayer The utility layer the gizmo will be added to
  49186. */
  49187. constructor(gizmoLayer?: UtilityLayerRenderer);
  49188. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49189. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49190. /**
  49191. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49192. */
  49193. set snapDistance(value: number);
  49194. get snapDistance(): number;
  49195. /**
  49196. * Ratio for the scale of the gizmo (Default: 1)
  49197. */
  49198. set scaleRatio(value: number);
  49199. get scaleRatio(): number;
  49200. /**
  49201. * Sensitivity factor for dragging (Default: 1)
  49202. */
  49203. set sensitivity(value: number);
  49204. get sensitivity(): number;
  49205. /**
  49206. * Disposes of the gizmo
  49207. */
  49208. dispose(): void;
  49209. }
  49210. }
  49211. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  49212. import { Observable } from "babylonjs/Misc/observable";
  49213. import { Nullable } from "babylonjs/types";
  49214. import { Vector3 } from "babylonjs/Maths/math.vector";
  49215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49216. import { Mesh } from "babylonjs/Meshes/mesh";
  49217. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49218. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49219. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49220. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49221. import { Color3 } from "babylonjs/Maths/math.color";
  49222. /**
  49223. * Single axis scale gizmo
  49224. */
  49225. export class AxisScaleGizmo extends Gizmo {
  49226. /**
  49227. * Drag behavior responsible for the gizmos dragging interactions
  49228. */
  49229. dragBehavior: PointerDragBehavior;
  49230. private _pointerObserver;
  49231. /**
  49232. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49233. */
  49234. snapDistance: number;
  49235. /**
  49236. * Event that fires each time the gizmo snaps to a new location.
  49237. * * snapDistance is the the change in distance
  49238. */
  49239. onSnapObservable: Observable<{
  49240. snapDistance: number;
  49241. }>;
  49242. /**
  49243. * If the scaling operation should be done on all axis (default: false)
  49244. */
  49245. uniformScaling: boolean;
  49246. /**
  49247. * Custom sensitivity value for the drag strength
  49248. */
  49249. sensitivity: number;
  49250. private _isEnabled;
  49251. private _parent;
  49252. private _arrow;
  49253. private _coloredMaterial;
  49254. private _hoverMaterial;
  49255. /**
  49256. * Creates an AxisScaleGizmo
  49257. * @param gizmoLayer The utility layer the gizmo will be added to
  49258. * @param dragAxis The axis which the gizmo will be able to scale on
  49259. * @param color The color of the gizmo
  49260. */
  49261. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49262. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49263. /**
  49264. * If the gizmo is enabled
  49265. */
  49266. set isEnabled(value: boolean);
  49267. get isEnabled(): boolean;
  49268. /**
  49269. * Disposes of the gizmo
  49270. */
  49271. dispose(): void;
  49272. /**
  49273. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49274. * @param mesh The mesh to replace the default mesh of the gizmo
  49275. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49276. */
  49277. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49278. }
  49279. }
  49280. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  49281. import { Observable } from "babylonjs/Misc/observable";
  49282. import { Nullable } from "babylonjs/types";
  49283. import { Vector3 } from "babylonjs/Maths/math.vector";
  49284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49285. import { Mesh } from "babylonjs/Meshes/mesh";
  49286. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49287. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49288. import { Color3 } from "babylonjs/Maths/math.color";
  49289. import "babylonjs/Meshes/Builders/boxBuilder";
  49290. /**
  49291. * Bounding box gizmo
  49292. */
  49293. export class BoundingBoxGizmo extends Gizmo {
  49294. private _lineBoundingBox;
  49295. private _rotateSpheresParent;
  49296. private _scaleBoxesParent;
  49297. private _boundingDimensions;
  49298. private _renderObserver;
  49299. private _pointerObserver;
  49300. private _scaleDragSpeed;
  49301. private _tmpQuaternion;
  49302. private _tmpVector;
  49303. private _tmpRotationMatrix;
  49304. /**
  49305. * 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)
  49306. */
  49307. ignoreChildren: boolean;
  49308. /**
  49309. * 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)
  49310. */
  49311. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49312. /**
  49313. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49314. */
  49315. rotationSphereSize: number;
  49316. /**
  49317. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49318. */
  49319. scaleBoxSize: number;
  49320. /**
  49321. * 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)
  49322. */
  49323. fixedDragMeshScreenSize: boolean;
  49324. /**
  49325. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49326. */
  49327. fixedDragMeshScreenSizeDistanceFactor: number;
  49328. /**
  49329. * Fired when a rotation sphere or scale box is dragged
  49330. */
  49331. onDragStartObservable: Observable<{}>;
  49332. /**
  49333. * Fired when a scale box is dragged
  49334. */
  49335. onScaleBoxDragObservable: Observable<{}>;
  49336. /**
  49337. * Fired when a scale box drag is ended
  49338. */
  49339. onScaleBoxDragEndObservable: Observable<{}>;
  49340. /**
  49341. * Fired when a rotation sphere is dragged
  49342. */
  49343. onRotationSphereDragObservable: Observable<{}>;
  49344. /**
  49345. * Fired when a rotation sphere drag is ended
  49346. */
  49347. onRotationSphereDragEndObservable: Observable<{}>;
  49348. /**
  49349. * 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)
  49350. */
  49351. scalePivot: Nullable<Vector3>;
  49352. /**
  49353. * Mesh used as a pivot to rotate the attached mesh
  49354. */
  49355. private _anchorMesh;
  49356. private _existingMeshScale;
  49357. private _dragMesh;
  49358. private pointerDragBehavior;
  49359. private coloredMaterial;
  49360. private hoverColoredMaterial;
  49361. /**
  49362. * Sets the color of the bounding box gizmo
  49363. * @param color the color to set
  49364. */
  49365. setColor(color: Color3): void;
  49366. /**
  49367. * Creates an BoundingBoxGizmo
  49368. * @param gizmoLayer The utility layer the gizmo will be added to
  49369. * @param color The color of the gizmo
  49370. */
  49371. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49372. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49373. private _selectNode;
  49374. /**
  49375. * Updates the bounding box information for the Gizmo
  49376. */
  49377. updateBoundingBox(): void;
  49378. private _updateRotationSpheres;
  49379. private _updateScaleBoxes;
  49380. /**
  49381. * Enables rotation on the specified axis and disables rotation on the others
  49382. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49383. */
  49384. setEnabledRotationAxis(axis: string): void;
  49385. /**
  49386. * Enables/disables scaling
  49387. * @param enable if scaling should be enabled
  49388. */
  49389. setEnabledScaling(enable: boolean): void;
  49390. private _updateDummy;
  49391. /**
  49392. * Enables a pointer drag behavior on the bounding box of the gizmo
  49393. */
  49394. enableDragBehavior(): void;
  49395. /**
  49396. * Disposes of the gizmo
  49397. */
  49398. dispose(): void;
  49399. /**
  49400. * 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)
  49401. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49402. * @returns the bounding box mesh with the passed in mesh as a child
  49403. */
  49404. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49405. /**
  49406. * CustomMeshes are not supported by this gizmo
  49407. * @param mesh The mesh to replace the default mesh of the gizmo
  49408. */
  49409. setCustomMesh(mesh: Mesh): void;
  49410. }
  49411. }
  49412. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  49413. import { Observable } from "babylonjs/Misc/observable";
  49414. import { Nullable } from "babylonjs/types";
  49415. import { Vector3 } from "babylonjs/Maths/math.vector";
  49416. import { Color3 } from "babylonjs/Maths/math.color";
  49417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49418. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49419. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49420. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49421. import "babylonjs/Meshes/Builders/linesBuilder";
  49422. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49423. /**
  49424. * Single plane rotation gizmo
  49425. */
  49426. export class PlaneRotationGizmo extends Gizmo {
  49427. /**
  49428. * Drag behavior responsible for the gizmos dragging interactions
  49429. */
  49430. dragBehavior: PointerDragBehavior;
  49431. private _pointerObserver;
  49432. /**
  49433. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49434. */
  49435. snapDistance: number;
  49436. /**
  49437. * Event that fires each time the gizmo snaps to a new location.
  49438. * * snapDistance is the the change in distance
  49439. */
  49440. onSnapObservable: Observable<{
  49441. snapDistance: number;
  49442. }>;
  49443. private _isEnabled;
  49444. private _parent;
  49445. /**
  49446. * Creates a PlaneRotationGizmo
  49447. * @param gizmoLayer The utility layer the gizmo will be added to
  49448. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49449. * @param color The color of the gizmo
  49450. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49451. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49452. */
  49453. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49454. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49455. /**
  49456. * If the gizmo is enabled
  49457. */
  49458. set isEnabled(value: boolean);
  49459. get isEnabled(): boolean;
  49460. /**
  49461. * Disposes of the gizmo
  49462. */
  49463. dispose(): void;
  49464. }
  49465. }
  49466. declare module "babylonjs/Gizmos/rotationGizmo" {
  49467. import { Observable } from "babylonjs/Misc/observable";
  49468. import { Nullable } from "babylonjs/types";
  49469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49470. import { Mesh } from "babylonjs/Meshes/mesh";
  49471. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49472. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  49473. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49474. /**
  49475. * Gizmo that enables rotating a mesh along 3 axis
  49476. */
  49477. export class RotationGizmo extends Gizmo {
  49478. /**
  49479. * Internal gizmo used for interactions on the x axis
  49480. */
  49481. xGizmo: PlaneRotationGizmo;
  49482. /**
  49483. * Internal gizmo used for interactions on the y axis
  49484. */
  49485. yGizmo: PlaneRotationGizmo;
  49486. /**
  49487. * Internal gizmo used for interactions on the z axis
  49488. */
  49489. zGizmo: PlaneRotationGizmo;
  49490. /** Fires an event when any of it's sub gizmos are dragged */
  49491. onDragStartObservable: Observable<unknown>;
  49492. /** Fires an event when any of it's sub gizmos are released from dragging */
  49493. onDragEndObservable: Observable<unknown>;
  49494. private _meshAttached;
  49495. get attachedMesh(): Nullable<AbstractMesh>;
  49496. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49497. /**
  49498. * Creates a RotationGizmo
  49499. * @param gizmoLayer The utility layer the gizmo will be added to
  49500. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49501. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49502. */
  49503. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49504. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49505. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49506. /**
  49507. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49508. */
  49509. set snapDistance(value: number);
  49510. get snapDistance(): number;
  49511. /**
  49512. * Ratio for the scale of the gizmo (Default: 1)
  49513. */
  49514. set scaleRatio(value: number);
  49515. get scaleRatio(): number;
  49516. /**
  49517. * Disposes of the gizmo
  49518. */
  49519. dispose(): void;
  49520. /**
  49521. * CustomMeshes are not supported by this gizmo
  49522. * @param mesh The mesh to replace the default mesh of the gizmo
  49523. */
  49524. setCustomMesh(mesh: Mesh): void;
  49525. }
  49526. }
  49527. declare module "babylonjs/Gizmos/gizmoManager" {
  49528. import { Observable } from "babylonjs/Misc/observable";
  49529. import { Nullable } from "babylonjs/types";
  49530. import { Scene, IDisposable } from "babylonjs/scene";
  49531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49532. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49533. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49534. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49535. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  49536. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49537. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  49538. /**
  49539. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49540. */
  49541. export class GizmoManager implements IDisposable {
  49542. private scene;
  49543. /**
  49544. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49545. */
  49546. gizmos: {
  49547. positionGizmo: Nullable<PositionGizmo>;
  49548. rotationGizmo: Nullable<RotationGizmo>;
  49549. scaleGizmo: Nullable<ScaleGizmo>;
  49550. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49551. };
  49552. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49553. clearGizmoOnEmptyPointerEvent: boolean;
  49554. /** Fires an event when the manager is attached to a mesh */
  49555. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49556. private _gizmosEnabled;
  49557. private _pointerObserver;
  49558. private _attachedMesh;
  49559. private _boundingBoxColor;
  49560. private _defaultUtilityLayer;
  49561. private _defaultKeepDepthUtilityLayer;
  49562. /**
  49563. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49564. */
  49565. boundingBoxDragBehavior: SixDofDragBehavior;
  49566. /**
  49567. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49568. */
  49569. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49570. /**
  49571. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49572. */
  49573. usePointerToAttachGizmos: boolean;
  49574. /**
  49575. * Utility layer that the bounding box gizmo belongs to
  49576. */
  49577. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49578. /**
  49579. * Utility layer that all gizmos besides bounding box belong to
  49580. */
  49581. get utilityLayer(): UtilityLayerRenderer;
  49582. /**
  49583. * Instatiates a gizmo manager
  49584. * @param scene the scene to overlay the gizmos on top of
  49585. */
  49586. constructor(scene: Scene);
  49587. /**
  49588. * Attaches a set of gizmos to the specified mesh
  49589. * @param mesh The mesh the gizmo's should be attached to
  49590. */
  49591. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49592. /**
  49593. * If the position gizmo is enabled
  49594. */
  49595. set positionGizmoEnabled(value: boolean);
  49596. get positionGizmoEnabled(): boolean;
  49597. /**
  49598. * If the rotation gizmo is enabled
  49599. */
  49600. set rotationGizmoEnabled(value: boolean);
  49601. get rotationGizmoEnabled(): boolean;
  49602. /**
  49603. * If the scale gizmo is enabled
  49604. */
  49605. set scaleGizmoEnabled(value: boolean);
  49606. get scaleGizmoEnabled(): boolean;
  49607. /**
  49608. * If the boundingBox gizmo is enabled
  49609. */
  49610. set boundingBoxGizmoEnabled(value: boolean);
  49611. get boundingBoxGizmoEnabled(): boolean;
  49612. /**
  49613. * Disposes of the gizmo manager
  49614. */
  49615. dispose(): void;
  49616. }
  49617. }
  49618. declare module "babylonjs/Lights/directionalLight" {
  49619. import { Camera } from "babylonjs/Cameras/camera";
  49620. import { Scene } from "babylonjs/scene";
  49621. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49623. import { Light } from "babylonjs/Lights/light";
  49624. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49625. import { Effect } from "babylonjs/Materials/effect";
  49626. /**
  49627. * A directional light is defined by a direction (what a surprise!).
  49628. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49629. * 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.
  49630. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49631. */
  49632. export class DirectionalLight extends ShadowLight {
  49633. private _shadowFrustumSize;
  49634. /**
  49635. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49636. */
  49637. get shadowFrustumSize(): number;
  49638. /**
  49639. * Specifies a fix frustum size for the shadow generation.
  49640. */
  49641. set shadowFrustumSize(value: number);
  49642. private _shadowOrthoScale;
  49643. /**
  49644. * Gets the shadow projection scale against the optimal computed one.
  49645. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49646. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49647. */
  49648. get shadowOrthoScale(): number;
  49649. /**
  49650. * Sets the shadow projection scale against the optimal computed one.
  49651. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49652. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49653. */
  49654. set shadowOrthoScale(value: number);
  49655. /**
  49656. * Automatically compute the projection matrix to best fit (including all the casters)
  49657. * on each frame.
  49658. */
  49659. autoUpdateExtends: boolean;
  49660. private _orthoLeft;
  49661. private _orthoRight;
  49662. private _orthoTop;
  49663. private _orthoBottom;
  49664. /**
  49665. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49666. * The directional light is emitted from everywhere in the given direction.
  49667. * It can cast shadows.
  49668. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49669. * @param name The friendly name of the light
  49670. * @param direction The direction of the light
  49671. * @param scene The scene the light belongs to
  49672. */
  49673. constructor(name: string, direction: Vector3, scene: Scene);
  49674. /**
  49675. * Returns the string "DirectionalLight".
  49676. * @return The class name
  49677. */
  49678. getClassName(): string;
  49679. /**
  49680. * Returns the integer 1.
  49681. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49682. */
  49683. getTypeID(): number;
  49684. /**
  49685. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49686. * Returns the DirectionalLight Shadow projection matrix.
  49687. */
  49688. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49689. /**
  49690. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49691. * Returns the DirectionalLight Shadow projection matrix.
  49692. */
  49693. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49694. /**
  49695. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49696. * Returns the DirectionalLight Shadow projection matrix.
  49697. */
  49698. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49699. protected _buildUniformLayout(): void;
  49700. /**
  49701. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49702. * @param effect The effect to update
  49703. * @param lightIndex The index of the light in the effect to update
  49704. * @returns The directional light
  49705. */
  49706. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49707. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49708. /**
  49709. * Gets the minZ used for shadow according to both the scene and the light.
  49710. *
  49711. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49712. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49713. * @param activeCamera The camera we are returning the min for
  49714. * @returns the depth min z
  49715. */
  49716. getDepthMinZ(activeCamera: Camera): number;
  49717. /**
  49718. * Gets the maxZ used for shadow according to both the scene and the light.
  49719. *
  49720. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49721. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49722. * @param activeCamera The camera we are returning the max for
  49723. * @returns the depth max z
  49724. */
  49725. getDepthMaxZ(activeCamera: Camera): number;
  49726. /**
  49727. * Prepares the list of defines specific to the light type.
  49728. * @param defines the list of defines
  49729. * @param lightIndex defines the index of the light for the effect
  49730. */
  49731. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49732. }
  49733. }
  49734. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  49735. import { Mesh } from "babylonjs/Meshes/mesh";
  49736. /**
  49737. * Class containing static functions to help procedurally build meshes
  49738. */
  49739. export class HemisphereBuilder {
  49740. /**
  49741. * Creates a hemisphere mesh
  49742. * @param name defines the name of the mesh
  49743. * @param options defines the options used to create the mesh
  49744. * @param scene defines the hosting scene
  49745. * @returns the hemisphere mesh
  49746. */
  49747. static CreateHemisphere(name: string, options: {
  49748. segments?: number;
  49749. diameter?: number;
  49750. sideOrientation?: number;
  49751. }, scene: any): Mesh;
  49752. }
  49753. }
  49754. declare module "babylonjs/Lights/spotLight" {
  49755. import { Nullable } from "babylonjs/types";
  49756. import { Scene } from "babylonjs/scene";
  49757. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49759. import { Effect } from "babylonjs/Materials/effect";
  49760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49761. import { Light } from "babylonjs/Lights/light";
  49762. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49763. /**
  49764. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49765. * These values define a cone of light starting from the position, emitting toward the direction.
  49766. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49767. * and the exponent defines the speed of the decay of the light with distance (reach).
  49768. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49769. */
  49770. export class SpotLight extends ShadowLight {
  49771. private _angle;
  49772. private _innerAngle;
  49773. private _cosHalfAngle;
  49774. private _lightAngleScale;
  49775. private _lightAngleOffset;
  49776. /**
  49777. * Gets the cone angle of the spot light in Radians.
  49778. */
  49779. get angle(): number;
  49780. /**
  49781. * Sets the cone angle of the spot light in Radians.
  49782. */
  49783. set angle(value: number);
  49784. /**
  49785. * Only used in gltf falloff mode, this defines the angle where
  49786. * the directional falloff will start before cutting at angle which could be seen
  49787. * as outer angle.
  49788. */
  49789. get innerAngle(): number;
  49790. /**
  49791. * Only used in gltf falloff mode, this defines the angle where
  49792. * the directional falloff will start before cutting at angle which could be seen
  49793. * as outer angle.
  49794. */
  49795. set innerAngle(value: number);
  49796. private _shadowAngleScale;
  49797. /**
  49798. * Allows scaling the angle of the light for shadow generation only.
  49799. */
  49800. get shadowAngleScale(): number;
  49801. /**
  49802. * Allows scaling the angle of the light for shadow generation only.
  49803. */
  49804. set shadowAngleScale(value: number);
  49805. /**
  49806. * The light decay speed with the distance from the emission spot.
  49807. */
  49808. exponent: number;
  49809. private _projectionTextureMatrix;
  49810. /**
  49811. * Allows reading the projecton texture
  49812. */
  49813. get projectionTextureMatrix(): Matrix;
  49814. protected _projectionTextureLightNear: number;
  49815. /**
  49816. * Gets the near clip of the Spotlight for texture projection.
  49817. */
  49818. get projectionTextureLightNear(): number;
  49819. /**
  49820. * Sets the near clip of the Spotlight for texture projection.
  49821. */
  49822. set projectionTextureLightNear(value: number);
  49823. protected _projectionTextureLightFar: number;
  49824. /**
  49825. * Gets the far clip of the Spotlight for texture projection.
  49826. */
  49827. get projectionTextureLightFar(): number;
  49828. /**
  49829. * Sets the far clip of the Spotlight for texture projection.
  49830. */
  49831. set projectionTextureLightFar(value: number);
  49832. protected _projectionTextureUpDirection: Vector3;
  49833. /**
  49834. * Gets the Up vector of the Spotlight for texture projection.
  49835. */
  49836. get projectionTextureUpDirection(): Vector3;
  49837. /**
  49838. * Sets the Up vector of the Spotlight for texture projection.
  49839. */
  49840. set projectionTextureUpDirection(value: Vector3);
  49841. private _projectionTexture;
  49842. /**
  49843. * Gets the projection texture of the light.
  49844. */
  49845. get projectionTexture(): Nullable<BaseTexture>;
  49846. /**
  49847. * Sets the projection texture of the light.
  49848. */
  49849. set projectionTexture(value: Nullable<BaseTexture>);
  49850. private _projectionTextureViewLightDirty;
  49851. private _projectionTextureProjectionLightDirty;
  49852. private _projectionTextureDirty;
  49853. private _projectionTextureViewTargetVector;
  49854. private _projectionTextureViewLightMatrix;
  49855. private _projectionTextureProjectionLightMatrix;
  49856. private _projectionTextureScalingMatrix;
  49857. /**
  49858. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49859. * It can cast shadows.
  49860. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49861. * @param name The light friendly name
  49862. * @param position The position of the spot light in the scene
  49863. * @param direction The direction of the light in the scene
  49864. * @param angle The cone angle of the light in Radians
  49865. * @param exponent The light decay speed with the distance from the emission spot
  49866. * @param scene The scene the lights belongs to
  49867. */
  49868. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49869. /**
  49870. * Returns the string "SpotLight".
  49871. * @returns the class name
  49872. */
  49873. getClassName(): string;
  49874. /**
  49875. * Returns the integer 2.
  49876. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49877. */
  49878. getTypeID(): number;
  49879. /**
  49880. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49881. */
  49882. protected _setDirection(value: Vector3): void;
  49883. /**
  49884. * Overrides the position setter to recompute the projection texture view light Matrix.
  49885. */
  49886. protected _setPosition(value: Vector3): void;
  49887. /**
  49888. * 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.
  49889. * Returns the SpotLight.
  49890. */
  49891. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49892. protected _computeProjectionTextureViewLightMatrix(): void;
  49893. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49894. /**
  49895. * Main function for light texture projection matrix computing.
  49896. */
  49897. protected _computeProjectionTextureMatrix(): void;
  49898. protected _buildUniformLayout(): void;
  49899. private _computeAngleValues;
  49900. /**
  49901. * Sets the passed Effect "effect" with the Light textures.
  49902. * @param effect The effect to update
  49903. * @param lightIndex The index of the light in the effect to update
  49904. * @returns The light
  49905. */
  49906. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49907. /**
  49908. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49909. * @param effect The effect to update
  49910. * @param lightIndex The index of the light in the effect to update
  49911. * @returns The spot light
  49912. */
  49913. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49914. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49915. /**
  49916. * Disposes the light and the associated resources.
  49917. */
  49918. dispose(): void;
  49919. /**
  49920. * Prepares the list of defines specific to the light type.
  49921. * @param defines the list of defines
  49922. * @param lightIndex defines the index of the light for the effect
  49923. */
  49924. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49925. }
  49926. }
  49927. declare module "babylonjs/Gizmos/lightGizmo" {
  49928. import { Nullable } from "babylonjs/types";
  49929. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49930. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49931. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  49932. import { Light } from "babylonjs/Lights/light";
  49933. /**
  49934. * Gizmo that enables viewing a light
  49935. */
  49936. export class LightGizmo extends Gizmo {
  49937. private _lightMesh;
  49938. private _material;
  49939. private _cachedPosition;
  49940. private _cachedForward;
  49941. private _attachedMeshParent;
  49942. /**
  49943. * Creates a LightGizmo
  49944. * @param gizmoLayer The utility layer the gizmo will be added to
  49945. */
  49946. constructor(gizmoLayer?: UtilityLayerRenderer);
  49947. private _light;
  49948. /**
  49949. * The light that the gizmo is attached to
  49950. */
  49951. set light(light: Nullable<Light>);
  49952. get light(): Nullable<Light>;
  49953. /**
  49954. * Gets the material used to render the light gizmo
  49955. */
  49956. get material(): StandardMaterial;
  49957. /**
  49958. * @hidden
  49959. * Updates the gizmo to match the attached mesh's position/rotation
  49960. */
  49961. protected _update(): void;
  49962. private static _Scale;
  49963. /**
  49964. * Creates the lines for a light mesh
  49965. */
  49966. private static _CreateLightLines;
  49967. /**
  49968. * Disposes of the light gizmo
  49969. */
  49970. dispose(): void;
  49971. private static _CreateHemisphericLightMesh;
  49972. private static _CreatePointLightMesh;
  49973. private static _CreateSpotLightMesh;
  49974. private static _CreateDirectionalLightMesh;
  49975. }
  49976. }
  49977. declare module "babylonjs/Gizmos/index" {
  49978. export * from "babylonjs/Gizmos/axisDragGizmo";
  49979. export * from "babylonjs/Gizmos/axisScaleGizmo";
  49980. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  49981. export * from "babylonjs/Gizmos/gizmo";
  49982. export * from "babylonjs/Gizmos/gizmoManager";
  49983. export * from "babylonjs/Gizmos/planeRotationGizmo";
  49984. export * from "babylonjs/Gizmos/positionGizmo";
  49985. export * from "babylonjs/Gizmos/rotationGizmo";
  49986. export * from "babylonjs/Gizmos/scaleGizmo";
  49987. export * from "babylonjs/Gizmos/lightGizmo";
  49988. export * from "babylonjs/Gizmos/planeDragGizmo";
  49989. }
  49990. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  49991. /** @hidden */
  49992. export var backgroundFragmentDeclaration: {
  49993. name: string;
  49994. shader: string;
  49995. };
  49996. }
  49997. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  49998. /** @hidden */
  49999. export var backgroundUboDeclaration: {
  50000. name: string;
  50001. shader: string;
  50002. };
  50003. }
  50004. declare module "babylonjs/Shaders/background.fragment" {
  50005. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50006. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50007. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50008. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50009. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50010. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50011. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50012. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50013. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50014. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50015. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50016. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50017. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50018. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50019. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50020. /** @hidden */
  50021. export var backgroundPixelShader: {
  50022. name: string;
  50023. shader: string;
  50024. };
  50025. }
  50026. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50027. /** @hidden */
  50028. export var backgroundVertexDeclaration: {
  50029. name: string;
  50030. shader: string;
  50031. };
  50032. }
  50033. declare module "babylonjs/Shaders/background.vertex" {
  50034. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50035. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50036. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50037. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50038. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50039. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50040. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50041. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50042. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50043. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50044. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50045. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50046. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50047. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50048. /** @hidden */
  50049. export var backgroundVertexShader: {
  50050. name: string;
  50051. shader: string;
  50052. };
  50053. }
  50054. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50055. import { Nullable, int, float } from "babylonjs/types";
  50056. import { Scene } from "babylonjs/scene";
  50057. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50058. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50060. import { Mesh } from "babylonjs/Meshes/mesh";
  50061. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50062. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50063. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50064. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50065. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50066. import { Color3 } from "babylonjs/Maths/math.color";
  50067. import "babylonjs/Shaders/background.fragment";
  50068. import "babylonjs/Shaders/background.vertex";
  50069. /**
  50070. * Background material used to create an efficient environement around your scene.
  50071. */
  50072. export class BackgroundMaterial extends PushMaterial {
  50073. /**
  50074. * Standard reflectance value at parallel view angle.
  50075. */
  50076. static StandardReflectance0: number;
  50077. /**
  50078. * Standard reflectance value at grazing angle.
  50079. */
  50080. static StandardReflectance90: number;
  50081. protected _primaryColor: Color3;
  50082. /**
  50083. * Key light Color (multiply against the environement texture)
  50084. */
  50085. primaryColor: Color3;
  50086. protected __perceptualColor: Nullable<Color3>;
  50087. /**
  50088. * Experimental Internal Use Only.
  50089. *
  50090. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50091. * This acts as a helper to set the primary color to a more "human friendly" value.
  50092. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50093. * output color as close as possible from the chosen value.
  50094. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50095. * part of lighting setup.)
  50096. */
  50097. get _perceptualColor(): Nullable<Color3>;
  50098. set _perceptualColor(value: Nullable<Color3>);
  50099. protected _primaryColorShadowLevel: float;
  50100. /**
  50101. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50102. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50103. */
  50104. get primaryColorShadowLevel(): float;
  50105. set primaryColorShadowLevel(value: float);
  50106. protected _primaryColorHighlightLevel: float;
  50107. /**
  50108. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50109. * The primary color is used at the level chosen to define what the white area would look.
  50110. */
  50111. get primaryColorHighlightLevel(): float;
  50112. set primaryColorHighlightLevel(value: float);
  50113. protected _reflectionTexture: Nullable<BaseTexture>;
  50114. /**
  50115. * Reflection Texture used in the material.
  50116. * Should be author in a specific way for the best result (refer to the documentation).
  50117. */
  50118. reflectionTexture: Nullable<BaseTexture>;
  50119. protected _reflectionBlur: float;
  50120. /**
  50121. * Reflection Texture level of blur.
  50122. *
  50123. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50124. * texture twice.
  50125. */
  50126. reflectionBlur: float;
  50127. protected _diffuseTexture: Nullable<BaseTexture>;
  50128. /**
  50129. * Diffuse Texture used in the material.
  50130. * Should be author in a specific way for the best result (refer to the documentation).
  50131. */
  50132. diffuseTexture: Nullable<BaseTexture>;
  50133. protected _shadowLights: Nullable<IShadowLight[]>;
  50134. /**
  50135. * Specify the list of lights casting shadow on the material.
  50136. * All scene shadow lights will be included if null.
  50137. */
  50138. shadowLights: Nullable<IShadowLight[]>;
  50139. protected _shadowLevel: float;
  50140. /**
  50141. * Helps adjusting the shadow to a softer level if required.
  50142. * 0 means black shadows and 1 means no shadows.
  50143. */
  50144. shadowLevel: float;
  50145. protected _sceneCenter: Vector3;
  50146. /**
  50147. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50148. * It is usually zero but might be interesting to modify according to your setup.
  50149. */
  50150. sceneCenter: Vector3;
  50151. protected _opacityFresnel: boolean;
  50152. /**
  50153. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50154. * This helps ensuring a nice transition when the camera goes under the ground.
  50155. */
  50156. opacityFresnel: boolean;
  50157. protected _reflectionFresnel: boolean;
  50158. /**
  50159. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50160. * This helps adding a mirror texture on the ground.
  50161. */
  50162. reflectionFresnel: boolean;
  50163. protected _reflectionFalloffDistance: number;
  50164. /**
  50165. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50166. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50167. */
  50168. reflectionFalloffDistance: number;
  50169. protected _reflectionAmount: number;
  50170. /**
  50171. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50172. */
  50173. reflectionAmount: number;
  50174. protected _reflectionReflectance0: number;
  50175. /**
  50176. * This specifies the weight of the reflection at grazing angle.
  50177. */
  50178. reflectionReflectance0: number;
  50179. protected _reflectionReflectance90: number;
  50180. /**
  50181. * This specifies the weight of the reflection at a perpendicular point of view.
  50182. */
  50183. reflectionReflectance90: number;
  50184. /**
  50185. * Sets the reflection reflectance fresnel values according to the default standard
  50186. * empirically know to work well :-)
  50187. */
  50188. set reflectionStandardFresnelWeight(value: number);
  50189. protected _useRGBColor: boolean;
  50190. /**
  50191. * Helps to directly use the maps channels instead of their level.
  50192. */
  50193. useRGBColor: boolean;
  50194. protected _enableNoise: boolean;
  50195. /**
  50196. * This helps reducing the banding effect that could occur on the background.
  50197. */
  50198. enableNoise: boolean;
  50199. /**
  50200. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50201. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50202. * Recommended to be keep at 1.0 except for special cases.
  50203. */
  50204. get fovMultiplier(): number;
  50205. set fovMultiplier(value: number);
  50206. private _fovMultiplier;
  50207. /**
  50208. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50209. */
  50210. useEquirectangularFOV: boolean;
  50211. private _maxSimultaneousLights;
  50212. /**
  50213. * Number of Simultaneous lights allowed on the material.
  50214. */
  50215. maxSimultaneousLights: int;
  50216. /**
  50217. * Default configuration related to image processing available in the Background Material.
  50218. */
  50219. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50220. /**
  50221. * Keep track of the image processing observer to allow dispose and replace.
  50222. */
  50223. private _imageProcessingObserver;
  50224. /**
  50225. * Attaches a new image processing configuration to the PBR Material.
  50226. * @param configuration (if null the scene configuration will be use)
  50227. */
  50228. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50229. /**
  50230. * Gets the image processing configuration used either in this material.
  50231. */
  50232. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50233. /**
  50234. * Sets the Default image processing configuration used either in the this material.
  50235. *
  50236. * If sets to null, the scene one is in use.
  50237. */
  50238. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50239. /**
  50240. * Gets wether the color curves effect is enabled.
  50241. */
  50242. get cameraColorCurvesEnabled(): boolean;
  50243. /**
  50244. * Sets wether the color curves effect is enabled.
  50245. */
  50246. set cameraColorCurvesEnabled(value: boolean);
  50247. /**
  50248. * Gets wether the color grading effect is enabled.
  50249. */
  50250. get cameraColorGradingEnabled(): boolean;
  50251. /**
  50252. * Gets wether the color grading effect is enabled.
  50253. */
  50254. set cameraColorGradingEnabled(value: boolean);
  50255. /**
  50256. * Gets wether tonemapping is enabled or not.
  50257. */
  50258. get cameraToneMappingEnabled(): boolean;
  50259. /**
  50260. * Sets wether tonemapping is enabled or not
  50261. */
  50262. set cameraToneMappingEnabled(value: boolean);
  50263. /**
  50264. * The camera exposure used on this material.
  50265. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50266. * This corresponds to a photographic exposure.
  50267. */
  50268. get cameraExposure(): float;
  50269. /**
  50270. * The camera exposure used on this material.
  50271. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50272. * This corresponds to a photographic exposure.
  50273. */
  50274. set cameraExposure(value: float);
  50275. /**
  50276. * Gets The camera contrast used on this material.
  50277. */
  50278. get cameraContrast(): float;
  50279. /**
  50280. * Sets The camera contrast used on this material.
  50281. */
  50282. set cameraContrast(value: float);
  50283. /**
  50284. * Gets the Color Grading 2D Lookup Texture.
  50285. */
  50286. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50287. /**
  50288. * Sets the Color Grading 2D Lookup Texture.
  50289. */
  50290. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50291. /**
  50292. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50293. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50294. * 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;
  50295. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50296. */
  50297. get cameraColorCurves(): Nullable<ColorCurves>;
  50298. /**
  50299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50301. * 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;
  50302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50303. */
  50304. set cameraColorCurves(value: Nullable<ColorCurves>);
  50305. /**
  50306. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50307. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50308. */
  50309. switchToBGR: boolean;
  50310. private _renderTargets;
  50311. private _reflectionControls;
  50312. private _white;
  50313. private _primaryShadowColor;
  50314. private _primaryHighlightColor;
  50315. /**
  50316. * Instantiates a Background Material in the given scene
  50317. * @param name The friendly name of the material
  50318. * @param scene The scene to add the material to
  50319. */
  50320. constructor(name: string, scene: Scene);
  50321. /**
  50322. * Gets a boolean indicating that current material needs to register RTT
  50323. */
  50324. get hasRenderTargetTextures(): boolean;
  50325. /**
  50326. * The entire material has been created in order to prevent overdraw.
  50327. * @returns false
  50328. */
  50329. needAlphaTesting(): boolean;
  50330. /**
  50331. * The entire material has been created in order to prevent overdraw.
  50332. * @returns true if blending is enable
  50333. */
  50334. needAlphaBlending(): boolean;
  50335. /**
  50336. * Checks wether the material is ready to be rendered for a given mesh.
  50337. * @param mesh The mesh to render
  50338. * @param subMesh The submesh to check against
  50339. * @param useInstances Specify wether or not the material is used with instances
  50340. * @returns true if all the dependencies are ready (Textures, Effects...)
  50341. */
  50342. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50343. /**
  50344. * Compute the primary color according to the chosen perceptual color.
  50345. */
  50346. private _computePrimaryColorFromPerceptualColor;
  50347. /**
  50348. * Compute the highlights and shadow colors according to their chosen levels.
  50349. */
  50350. private _computePrimaryColors;
  50351. /**
  50352. * Build the uniform buffer used in the material.
  50353. */
  50354. buildUniformLayout(): void;
  50355. /**
  50356. * Unbind the material.
  50357. */
  50358. unbind(): void;
  50359. /**
  50360. * Bind only the world matrix to the material.
  50361. * @param world The world matrix to bind.
  50362. */
  50363. bindOnlyWorldMatrix(world: Matrix): void;
  50364. /**
  50365. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50366. * @param world The world matrix to bind.
  50367. * @param subMesh The submesh to bind for.
  50368. */
  50369. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50370. /**
  50371. * Checks to see if a texture is used in the material.
  50372. * @param texture - Base texture to use.
  50373. * @returns - Boolean specifying if a texture is used in the material.
  50374. */
  50375. hasTexture(texture: BaseTexture): boolean;
  50376. /**
  50377. * Dispose the material.
  50378. * @param forceDisposeEffect Force disposal of the associated effect.
  50379. * @param forceDisposeTextures Force disposal of the associated textures.
  50380. */
  50381. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50382. /**
  50383. * Clones the material.
  50384. * @param name The cloned name.
  50385. * @returns The cloned material.
  50386. */
  50387. clone(name: string): BackgroundMaterial;
  50388. /**
  50389. * Serializes the current material to its JSON representation.
  50390. * @returns The JSON representation.
  50391. */
  50392. serialize(): any;
  50393. /**
  50394. * Gets the class name of the material
  50395. * @returns "BackgroundMaterial"
  50396. */
  50397. getClassName(): string;
  50398. /**
  50399. * Parse a JSON input to create back a background material.
  50400. * @param source The JSON data to parse
  50401. * @param scene The scene to create the parsed material in
  50402. * @param rootUrl The root url of the assets the material depends upon
  50403. * @returns the instantiated BackgroundMaterial.
  50404. */
  50405. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50406. }
  50407. }
  50408. declare module "babylonjs/Helpers/environmentHelper" {
  50409. import { Observable } from "babylonjs/Misc/observable";
  50410. import { Nullable } from "babylonjs/types";
  50411. import { Scene } from "babylonjs/scene";
  50412. import { Vector3 } from "babylonjs/Maths/math.vector";
  50413. import { Color3 } from "babylonjs/Maths/math.color";
  50414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50415. import { Mesh } from "babylonjs/Meshes/mesh";
  50416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50417. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  50418. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50419. import "babylonjs/Meshes/Builders/planeBuilder";
  50420. import "babylonjs/Meshes/Builders/boxBuilder";
  50421. /**
  50422. * Represents the different options available during the creation of
  50423. * a Environment helper.
  50424. *
  50425. * This can control the default ground, skybox and image processing setup of your scene.
  50426. */
  50427. export interface IEnvironmentHelperOptions {
  50428. /**
  50429. * Specifies wether or not to create a ground.
  50430. * True by default.
  50431. */
  50432. createGround: boolean;
  50433. /**
  50434. * Specifies the ground size.
  50435. * 15 by default.
  50436. */
  50437. groundSize: number;
  50438. /**
  50439. * The texture used on the ground for the main color.
  50440. * Comes from the BabylonJS CDN by default.
  50441. *
  50442. * Remarks: Can be either a texture or a url.
  50443. */
  50444. groundTexture: string | BaseTexture;
  50445. /**
  50446. * The color mixed in the ground texture by default.
  50447. * BabylonJS clearColor by default.
  50448. */
  50449. groundColor: Color3;
  50450. /**
  50451. * Specifies the ground opacity.
  50452. * 1 by default.
  50453. */
  50454. groundOpacity: number;
  50455. /**
  50456. * Enables the ground to receive shadows.
  50457. * True by default.
  50458. */
  50459. enableGroundShadow: boolean;
  50460. /**
  50461. * Helps preventing the shadow to be fully black on the ground.
  50462. * 0.5 by default.
  50463. */
  50464. groundShadowLevel: number;
  50465. /**
  50466. * Creates a mirror texture attach to the ground.
  50467. * false by default.
  50468. */
  50469. enableGroundMirror: boolean;
  50470. /**
  50471. * Specifies the ground mirror size ratio.
  50472. * 0.3 by default as the default kernel is 64.
  50473. */
  50474. groundMirrorSizeRatio: number;
  50475. /**
  50476. * Specifies the ground mirror blur kernel size.
  50477. * 64 by default.
  50478. */
  50479. groundMirrorBlurKernel: number;
  50480. /**
  50481. * Specifies the ground mirror visibility amount.
  50482. * 1 by default
  50483. */
  50484. groundMirrorAmount: number;
  50485. /**
  50486. * Specifies the ground mirror reflectance weight.
  50487. * This uses the standard weight of the background material to setup the fresnel effect
  50488. * of the mirror.
  50489. * 1 by default.
  50490. */
  50491. groundMirrorFresnelWeight: number;
  50492. /**
  50493. * Specifies the ground mirror Falloff distance.
  50494. * This can helps reducing the size of the reflection.
  50495. * 0 by Default.
  50496. */
  50497. groundMirrorFallOffDistance: number;
  50498. /**
  50499. * Specifies the ground mirror texture type.
  50500. * Unsigned Int by Default.
  50501. */
  50502. groundMirrorTextureType: number;
  50503. /**
  50504. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50505. * the shown objects.
  50506. */
  50507. groundYBias: number;
  50508. /**
  50509. * Specifies wether or not to create a skybox.
  50510. * True by default.
  50511. */
  50512. createSkybox: boolean;
  50513. /**
  50514. * Specifies the skybox size.
  50515. * 20 by default.
  50516. */
  50517. skyboxSize: number;
  50518. /**
  50519. * The texture used on the skybox for the main color.
  50520. * Comes from the BabylonJS CDN by default.
  50521. *
  50522. * Remarks: Can be either a texture or a url.
  50523. */
  50524. skyboxTexture: string | BaseTexture;
  50525. /**
  50526. * The color mixed in the skybox texture by default.
  50527. * BabylonJS clearColor by default.
  50528. */
  50529. skyboxColor: Color3;
  50530. /**
  50531. * The background rotation around the Y axis of the scene.
  50532. * This helps aligning the key lights of your scene with the background.
  50533. * 0 by default.
  50534. */
  50535. backgroundYRotation: number;
  50536. /**
  50537. * Compute automatically the size of the elements to best fit with the scene.
  50538. */
  50539. sizeAuto: boolean;
  50540. /**
  50541. * Default position of the rootMesh if autoSize is not true.
  50542. */
  50543. rootPosition: Vector3;
  50544. /**
  50545. * Sets up the image processing in the scene.
  50546. * true by default.
  50547. */
  50548. setupImageProcessing: boolean;
  50549. /**
  50550. * The texture used as your environment texture in the scene.
  50551. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50552. *
  50553. * Remarks: Can be either a texture or a url.
  50554. */
  50555. environmentTexture: string | BaseTexture;
  50556. /**
  50557. * The value of the exposure to apply to the scene.
  50558. * 0.6 by default if setupImageProcessing is true.
  50559. */
  50560. cameraExposure: number;
  50561. /**
  50562. * The value of the contrast to apply to the scene.
  50563. * 1.6 by default if setupImageProcessing is true.
  50564. */
  50565. cameraContrast: number;
  50566. /**
  50567. * Specifies wether or not tonemapping should be enabled in the scene.
  50568. * true by default if setupImageProcessing is true.
  50569. */
  50570. toneMappingEnabled: boolean;
  50571. }
  50572. /**
  50573. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50574. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50575. * It also helps with the default setup of your imageProcessing configuration.
  50576. */
  50577. export class EnvironmentHelper {
  50578. /**
  50579. * Default ground texture URL.
  50580. */
  50581. private static _groundTextureCDNUrl;
  50582. /**
  50583. * Default skybox texture URL.
  50584. */
  50585. private static _skyboxTextureCDNUrl;
  50586. /**
  50587. * Default environment texture URL.
  50588. */
  50589. private static _environmentTextureCDNUrl;
  50590. /**
  50591. * Creates the default options for the helper.
  50592. */
  50593. private static _getDefaultOptions;
  50594. private _rootMesh;
  50595. /**
  50596. * Gets the root mesh created by the helper.
  50597. */
  50598. get rootMesh(): Mesh;
  50599. private _skybox;
  50600. /**
  50601. * Gets the skybox created by the helper.
  50602. */
  50603. get skybox(): Nullable<Mesh>;
  50604. private _skyboxTexture;
  50605. /**
  50606. * Gets the skybox texture created by the helper.
  50607. */
  50608. get skyboxTexture(): Nullable<BaseTexture>;
  50609. private _skyboxMaterial;
  50610. /**
  50611. * Gets the skybox material created by the helper.
  50612. */
  50613. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50614. private _ground;
  50615. /**
  50616. * Gets the ground mesh created by the helper.
  50617. */
  50618. get ground(): Nullable<Mesh>;
  50619. private _groundTexture;
  50620. /**
  50621. * Gets the ground texture created by the helper.
  50622. */
  50623. get groundTexture(): Nullable<BaseTexture>;
  50624. private _groundMirror;
  50625. /**
  50626. * Gets the ground mirror created by the helper.
  50627. */
  50628. get groundMirror(): Nullable<MirrorTexture>;
  50629. /**
  50630. * Gets the ground mirror render list to helps pushing the meshes
  50631. * you wish in the ground reflection.
  50632. */
  50633. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50634. private _groundMaterial;
  50635. /**
  50636. * Gets the ground material created by the helper.
  50637. */
  50638. get groundMaterial(): Nullable<BackgroundMaterial>;
  50639. /**
  50640. * Stores the creation options.
  50641. */
  50642. private readonly _scene;
  50643. private _options;
  50644. /**
  50645. * This observable will be notified with any error during the creation of the environment,
  50646. * mainly texture creation errors.
  50647. */
  50648. onErrorObservable: Observable<{
  50649. message?: string;
  50650. exception?: any;
  50651. }>;
  50652. /**
  50653. * constructor
  50654. * @param options Defines the options we want to customize the helper
  50655. * @param scene The scene to add the material to
  50656. */
  50657. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50658. /**
  50659. * Updates the background according to the new options
  50660. * @param options
  50661. */
  50662. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50663. /**
  50664. * Sets the primary color of all the available elements.
  50665. * @param color the main color to affect to the ground and the background
  50666. */
  50667. setMainColor(color: Color3): void;
  50668. /**
  50669. * Setup the image processing according to the specified options.
  50670. */
  50671. private _setupImageProcessing;
  50672. /**
  50673. * Setup the environment texture according to the specified options.
  50674. */
  50675. private _setupEnvironmentTexture;
  50676. /**
  50677. * Setup the background according to the specified options.
  50678. */
  50679. private _setupBackground;
  50680. /**
  50681. * Get the scene sizes according to the setup.
  50682. */
  50683. private _getSceneSize;
  50684. /**
  50685. * Setup the ground according to the specified options.
  50686. */
  50687. private _setupGround;
  50688. /**
  50689. * Setup the ground material according to the specified options.
  50690. */
  50691. private _setupGroundMaterial;
  50692. /**
  50693. * Setup the ground diffuse texture according to the specified options.
  50694. */
  50695. private _setupGroundDiffuseTexture;
  50696. /**
  50697. * Setup the ground mirror texture according to the specified options.
  50698. */
  50699. private _setupGroundMirrorTexture;
  50700. /**
  50701. * Setup the ground to receive the mirror texture.
  50702. */
  50703. private _setupMirrorInGroundMaterial;
  50704. /**
  50705. * Setup the skybox according to the specified options.
  50706. */
  50707. private _setupSkybox;
  50708. /**
  50709. * Setup the skybox material according to the specified options.
  50710. */
  50711. private _setupSkyboxMaterial;
  50712. /**
  50713. * Setup the skybox reflection texture according to the specified options.
  50714. */
  50715. private _setupSkyboxReflectionTexture;
  50716. private _errorHandler;
  50717. /**
  50718. * Dispose all the elements created by the Helper.
  50719. */
  50720. dispose(): void;
  50721. }
  50722. }
  50723. declare module "babylonjs/Helpers/photoDome" {
  50724. import { Observable } from "babylonjs/Misc/observable";
  50725. import { Nullable } from "babylonjs/types";
  50726. import { Scene } from "babylonjs/scene";
  50727. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50728. import { Mesh } from "babylonjs/Meshes/mesh";
  50729. import { Texture } from "babylonjs/Materials/Textures/texture";
  50730. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50731. import "babylonjs/Meshes/Builders/sphereBuilder";
  50732. /**
  50733. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50734. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50735. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50736. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50737. */
  50738. export class PhotoDome extends TransformNode {
  50739. /**
  50740. * Define the image as a Monoscopic panoramic 360 image.
  50741. */
  50742. static readonly MODE_MONOSCOPIC: number;
  50743. /**
  50744. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50745. */
  50746. static readonly MODE_TOPBOTTOM: number;
  50747. /**
  50748. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50749. */
  50750. static readonly MODE_SIDEBYSIDE: number;
  50751. private _useDirectMapping;
  50752. /**
  50753. * The texture being displayed on the sphere
  50754. */
  50755. protected _photoTexture: Texture;
  50756. /**
  50757. * Gets or sets the texture being displayed on the sphere
  50758. */
  50759. get photoTexture(): Texture;
  50760. set photoTexture(value: Texture);
  50761. /**
  50762. * Observable raised when an error occured while loading the 360 image
  50763. */
  50764. onLoadErrorObservable: Observable<string>;
  50765. /**
  50766. * The skybox material
  50767. */
  50768. protected _material: BackgroundMaterial;
  50769. /**
  50770. * The surface used for the skybox
  50771. */
  50772. protected _mesh: Mesh;
  50773. /**
  50774. * Gets the mesh used for the skybox.
  50775. */
  50776. get mesh(): Mesh;
  50777. /**
  50778. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50779. * Also see the options.resolution property.
  50780. */
  50781. get fovMultiplier(): number;
  50782. set fovMultiplier(value: number);
  50783. private _imageMode;
  50784. /**
  50785. * Gets or set the current video mode for the video. It can be:
  50786. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50787. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50788. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50789. */
  50790. get imageMode(): number;
  50791. set imageMode(value: number);
  50792. /**
  50793. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50794. * @param name Element's name, child elements will append suffixes for their own names.
  50795. * @param urlsOfPhoto defines the url of the photo to display
  50796. * @param options defines an object containing optional or exposed sub element properties
  50797. * @param onError defines a callback called when an error occured while loading the texture
  50798. */
  50799. constructor(name: string, urlOfPhoto: string, options: {
  50800. resolution?: number;
  50801. size?: number;
  50802. useDirectMapping?: boolean;
  50803. faceForward?: boolean;
  50804. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50805. private _onBeforeCameraRenderObserver;
  50806. private _changeImageMode;
  50807. /**
  50808. * Releases resources associated with this node.
  50809. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50810. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50811. */
  50812. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50813. }
  50814. }
  50815. declare module "babylonjs/Misc/rgbdTextureTools" {
  50816. import "babylonjs/Shaders/rgbdDecode.fragment";
  50817. import "babylonjs/Engines/Extensions/engine.renderTarget";
  50818. import { Texture } from "babylonjs/Materials/Textures/texture";
  50819. /**
  50820. * Class used to host RGBD texture specific utilities
  50821. */
  50822. export class RGBDTextureTools {
  50823. /**
  50824. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50825. * @param texture the texture to expand.
  50826. */
  50827. static ExpandRGBDTexture(texture: Texture): void;
  50828. }
  50829. }
  50830. declare module "babylonjs/Misc/brdfTextureTools" {
  50831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50832. import { Scene } from "babylonjs/scene";
  50833. /**
  50834. * Class used to host texture specific utilities
  50835. */
  50836. export class BRDFTextureTools {
  50837. /**
  50838. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50839. * @param scene defines the hosting scene
  50840. * @returns the environment BRDF texture
  50841. */
  50842. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50843. private static _environmentBRDFBase64Texture;
  50844. }
  50845. }
  50846. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  50847. import { Nullable } from "babylonjs/types";
  50848. import { Color3 } from "babylonjs/Maths/math.color";
  50849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50850. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50851. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50852. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50853. import { Engine } from "babylonjs/Engines/engine";
  50854. import { Scene } from "babylonjs/scene";
  50855. /**
  50856. * @hidden
  50857. */
  50858. export interface IMaterialClearCoatDefines {
  50859. CLEARCOAT: boolean;
  50860. CLEARCOAT_DEFAULTIOR: boolean;
  50861. CLEARCOAT_TEXTURE: boolean;
  50862. CLEARCOAT_TEXTUREDIRECTUV: number;
  50863. CLEARCOAT_BUMP: boolean;
  50864. CLEARCOAT_BUMPDIRECTUV: number;
  50865. CLEARCOAT_TINT: boolean;
  50866. CLEARCOAT_TINT_TEXTURE: boolean;
  50867. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50868. /** @hidden */
  50869. _areTexturesDirty: boolean;
  50870. }
  50871. /**
  50872. * Define the code related to the clear coat parameters of the pbr material.
  50873. */
  50874. export class PBRClearCoatConfiguration {
  50875. /**
  50876. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50877. * The default fits with a polyurethane material.
  50878. */
  50879. private static readonly _DefaultIndexOfRefraction;
  50880. private _isEnabled;
  50881. /**
  50882. * Defines if the clear coat is enabled in the material.
  50883. */
  50884. isEnabled: boolean;
  50885. /**
  50886. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50887. */
  50888. intensity: number;
  50889. /**
  50890. * Defines the clear coat layer roughness.
  50891. */
  50892. roughness: number;
  50893. private _indexOfRefraction;
  50894. /**
  50895. * Defines the index of refraction of the clear coat.
  50896. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50897. * The default fits with a polyurethane material.
  50898. * Changing the default value is more performance intensive.
  50899. */
  50900. indexOfRefraction: number;
  50901. private _texture;
  50902. /**
  50903. * Stores the clear coat values in a texture.
  50904. */
  50905. texture: Nullable<BaseTexture>;
  50906. private _bumpTexture;
  50907. /**
  50908. * Define the clear coat specific bump texture.
  50909. */
  50910. bumpTexture: Nullable<BaseTexture>;
  50911. private _isTintEnabled;
  50912. /**
  50913. * Defines if the clear coat tint is enabled in the material.
  50914. */
  50915. isTintEnabled: boolean;
  50916. /**
  50917. * Defines the clear coat tint of the material.
  50918. * This is only use if tint is enabled
  50919. */
  50920. tintColor: Color3;
  50921. /**
  50922. * Defines the distance at which the tint color should be found in the
  50923. * clear coat media.
  50924. * This is only use if tint is enabled
  50925. */
  50926. tintColorAtDistance: number;
  50927. /**
  50928. * Defines the clear coat layer thickness.
  50929. * This is only use if tint is enabled
  50930. */
  50931. tintThickness: number;
  50932. private _tintTexture;
  50933. /**
  50934. * Stores the clear tint values in a texture.
  50935. * rgb is tint
  50936. * a is a thickness factor
  50937. */
  50938. tintTexture: Nullable<BaseTexture>;
  50939. /** @hidden */
  50940. private _internalMarkAllSubMeshesAsTexturesDirty;
  50941. /** @hidden */
  50942. _markAllSubMeshesAsTexturesDirty(): void;
  50943. /**
  50944. * Instantiate a new istance of clear coat configuration.
  50945. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50946. */
  50947. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50948. /**
  50949. * Gets wehter the submesh is ready to be used or not.
  50950. * @param defines the list of "defines" to update.
  50951. * @param scene defines the scene the material belongs to.
  50952. * @param engine defines the engine the material belongs to.
  50953. * @param disableBumpMap defines wether the material disables bump or not.
  50954. * @returns - boolean indicating that the submesh is ready or not.
  50955. */
  50956. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50957. /**
  50958. * Checks to see if a texture is used in the material.
  50959. * @param defines the list of "defines" to update.
  50960. * @param scene defines the scene to the material belongs to.
  50961. */
  50962. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50963. /**
  50964. * Binds the material data.
  50965. * @param uniformBuffer defines the Uniform buffer to fill in.
  50966. * @param scene defines the scene the material belongs to.
  50967. * @param engine defines the engine the material belongs to.
  50968. * @param disableBumpMap defines wether the material disables bump or not.
  50969. * @param isFrozen defines wether the material is frozen or not.
  50970. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50971. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50972. */
  50973. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50974. /**
  50975. * Checks to see if a texture is used in the material.
  50976. * @param texture - Base texture to use.
  50977. * @returns - Boolean specifying if a texture is used in the material.
  50978. */
  50979. hasTexture(texture: BaseTexture): boolean;
  50980. /**
  50981. * Returns an array of the actively used textures.
  50982. * @param activeTextures Array of BaseTextures
  50983. */
  50984. getActiveTextures(activeTextures: BaseTexture[]): void;
  50985. /**
  50986. * Returns the animatable textures.
  50987. * @param animatables Array of animatable textures.
  50988. */
  50989. getAnimatables(animatables: IAnimatable[]): void;
  50990. /**
  50991. * Disposes the resources of the material.
  50992. * @param forceDisposeTextures - Forces the disposal of all textures.
  50993. */
  50994. dispose(forceDisposeTextures?: boolean): void;
  50995. /**
  50996. * Get the current class name of the texture useful for serialization or dynamic coding.
  50997. * @returns "PBRClearCoatConfiguration"
  50998. */
  50999. getClassName(): string;
  51000. /**
  51001. * Add fallbacks to the effect fallbacks list.
  51002. * @param defines defines the Base texture to use.
  51003. * @param fallbacks defines the current fallback list.
  51004. * @param currentRank defines the current fallback rank.
  51005. * @returns the new fallback rank.
  51006. */
  51007. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51008. /**
  51009. * Add the required uniforms to the current list.
  51010. * @param uniforms defines the current uniform list.
  51011. */
  51012. static AddUniforms(uniforms: string[]): void;
  51013. /**
  51014. * Add the required samplers to the current list.
  51015. * @param samplers defines the current sampler list.
  51016. */
  51017. static AddSamplers(samplers: string[]): void;
  51018. /**
  51019. * Add the required uniforms to the current buffer.
  51020. * @param uniformBuffer defines the current uniform buffer.
  51021. */
  51022. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51023. /**
  51024. * Makes a duplicate of the current configuration into another one.
  51025. * @param clearCoatConfiguration define the config where to copy the info
  51026. */
  51027. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51028. /**
  51029. * Serializes this clear coat configuration.
  51030. * @returns - An object with the serialized config.
  51031. */
  51032. serialize(): any;
  51033. /**
  51034. * Parses a anisotropy Configuration from a serialized object.
  51035. * @param source - Serialized object.
  51036. * @param scene Defines the scene we are parsing for
  51037. * @param rootUrl Defines the rootUrl to load from
  51038. */
  51039. parse(source: any, scene: Scene, rootUrl: string): void;
  51040. }
  51041. }
  51042. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51043. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51045. import { Vector2 } from "babylonjs/Maths/math.vector";
  51046. import { Scene } from "babylonjs/scene";
  51047. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51048. import { Nullable } from "babylonjs/types";
  51049. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51050. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51051. /**
  51052. * @hidden
  51053. */
  51054. export interface IMaterialAnisotropicDefines {
  51055. ANISOTROPIC: boolean;
  51056. ANISOTROPIC_TEXTURE: boolean;
  51057. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51058. MAINUV1: boolean;
  51059. _areTexturesDirty: boolean;
  51060. _needUVs: boolean;
  51061. }
  51062. /**
  51063. * Define the code related to the anisotropic parameters of the pbr material.
  51064. */
  51065. export class PBRAnisotropicConfiguration {
  51066. private _isEnabled;
  51067. /**
  51068. * Defines if the anisotropy is enabled in the material.
  51069. */
  51070. isEnabled: boolean;
  51071. /**
  51072. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51073. */
  51074. intensity: number;
  51075. /**
  51076. * Defines if the effect is along the tangents, bitangents or in between.
  51077. * By default, the effect is "strectching" the highlights along the tangents.
  51078. */
  51079. direction: Vector2;
  51080. private _texture;
  51081. /**
  51082. * Stores the anisotropy values in a texture.
  51083. * rg is direction (like normal from -1 to 1)
  51084. * b is a intensity
  51085. */
  51086. texture: Nullable<BaseTexture>;
  51087. /** @hidden */
  51088. private _internalMarkAllSubMeshesAsTexturesDirty;
  51089. /** @hidden */
  51090. _markAllSubMeshesAsTexturesDirty(): void;
  51091. /**
  51092. * Instantiate a new istance of anisotropy configuration.
  51093. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51094. */
  51095. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51096. /**
  51097. * Specifies that the submesh is ready to be used.
  51098. * @param defines the list of "defines" to update.
  51099. * @param scene defines the scene the material belongs to.
  51100. * @returns - boolean indicating that the submesh is ready or not.
  51101. */
  51102. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51103. /**
  51104. * Checks to see if a texture is used in the material.
  51105. * @param defines the list of "defines" to update.
  51106. * @param mesh the mesh we are preparing the defines for.
  51107. * @param scene defines the scene the material belongs to.
  51108. */
  51109. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51110. /**
  51111. * Binds the material data.
  51112. * @param uniformBuffer defines the Uniform buffer to fill in.
  51113. * @param scene defines the scene the material belongs to.
  51114. * @param isFrozen defines wether the material is frozen or not.
  51115. */
  51116. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51117. /**
  51118. * Checks to see if a texture is used in the material.
  51119. * @param texture - Base texture to use.
  51120. * @returns - Boolean specifying if a texture is used in the material.
  51121. */
  51122. hasTexture(texture: BaseTexture): boolean;
  51123. /**
  51124. * Returns an array of the actively used textures.
  51125. * @param activeTextures Array of BaseTextures
  51126. */
  51127. getActiveTextures(activeTextures: BaseTexture[]): void;
  51128. /**
  51129. * Returns the animatable textures.
  51130. * @param animatables Array of animatable textures.
  51131. */
  51132. getAnimatables(animatables: IAnimatable[]): void;
  51133. /**
  51134. * Disposes the resources of the material.
  51135. * @param forceDisposeTextures - Forces the disposal of all textures.
  51136. */
  51137. dispose(forceDisposeTextures?: boolean): void;
  51138. /**
  51139. * Get the current class name of the texture useful for serialization or dynamic coding.
  51140. * @returns "PBRAnisotropicConfiguration"
  51141. */
  51142. getClassName(): string;
  51143. /**
  51144. * Add fallbacks to the effect fallbacks list.
  51145. * @param defines defines the Base texture to use.
  51146. * @param fallbacks defines the current fallback list.
  51147. * @param currentRank defines the current fallback rank.
  51148. * @returns the new fallback rank.
  51149. */
  51150. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51151. /**
  51152. * Add the required uniforms to the current list.
  51153. * @param uniforms defines the current uniform list.
  51154. */
  51155. static AddUniforms(uniforms: string[]): void;
  51156. /**
  51157. * Add the required uniforms to the current buffer.
  51158. * @param uniformBuffer defines the current uniform buffer.
  51159. */
  51160. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51161. /**
  51162. * Add the required samplers to the current list.
  51163. * @param samplers defines the current sampler list.
  51164. */
  51165. static AddSamplers(samplers: string[]): void;
  51166. /**
  51167. * Makes a duplicate of the current configuration into another one.
  51168. * @param anisotropicConfiguration define the config where to copy the info
  51169. */
  51170. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51171. /**
  51172. * Serializes this anisotropy configuration.
  51173. * @returns - An object with the serialized config.
  51174. */
  51175. serialize(): any;
  51176. /**
  51177. * Parses a anisotropy Configuration from a serialized object.
  51178. * @param source - Serialized object.
  51179. * @param scene Defines the scene we are parsing for
  51180. * @param rootUrl Defines the rootUrl to load from
  51181. */
  51182. parse(source: any, scene: Scene, rootUrl: string): void;
  51183. }
  51184. }
  51185. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  51186. import { Scene } from "babylonjs/scene";
  51187. /**
  51188. * @hidden
  51189. */
  51190. export interface IMaterialBRDFDefines {
  51191. BRDF_V_HEIGHT_CORRELATED: boolean;
  51192. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51193. SPHERICAL_HARMONICS: boolean;
  51194. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51195. /** @hidden */
  51196. _areMiscDirty: boolean;
  51197. }
  51198. /**
  51199. * Define the code related to the BRDF parameters of the pbr material.
  51200. */
  51201. export class PBRBRDFConfiguration {
  51202. /**
  51203. * Default value used for the energy conservation.
  51204. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51205. */
  51206. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  51207. /**
  51208. * Default value used for the Smith Visibility Height Correlated mode.
  51209. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51210. */
  51211. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  51212. /**
  51213. * Default value used for the IBL diffuse part.
  51214. * This can help switching back to the polynomials mode globally which is a tiny bit
  51215. * less GPU intensive at the drawback of a lower quality.
  51216. */
  51217. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  51218. /**
  51219. * Default value used for activating energy conservation for the specular workflow.
  51220. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51221. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51222. */
  51223. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  51224. private _useEnergyConservation;
  51225. /**
  51226. * Defines if the material uses energy conservation.
  51227. */
  51228. useEnergyConservation: boolean;
  51229. private _useSmithVisibilityHeightCorrelated;
  51230. /**
  51231. * LEGACY Mode set to false
  51232. * Defines if the material uses height smith correlated visibility term.
  51233. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51234. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51235. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51236. * Not relying on height correlated will also disable energy conservation.
  51237. */
  51238. useSmithVisibilityHeightCorrelated: boolean;
  51239. private _useSphericalHarmonics;
  51240. /**
  51241. * LEGACY Mode set to false
  51242. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51243. * diffuse part of the IBL.
  51244. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51245. * to the ground truth.
  51246. */
  51247. useSphericalHarmonics: boolean;
  51248. private _useSpecularGlossinessInputEnergyConservation;
  51249. /**
  51250. * Defines if the material uses energy conservation, when the specular workflow is active.
  51251. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51252. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51253. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51254. */
  51255. useSpecularGlossinessInputEnergyConservation: boolean;
  51256. /** @hidden */
  51257. private _internalMarkAllSubMeshesAsMiscDirty;
  51258. /** @hidden */
  51259. _markAllSubMeshesAsMiscDirty(): void;
  51260. /**
  51261. * Instantiate a new istance of clear coat configuration.
  51262. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51263. */
  51264. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51265. /**
  51266. * Checks to see if a texture is used in the material.
  51267. * @param defines the list of "defines" to update.
  51268. */
  51269. prepareDefines(defines: IMaterialBRDFDefines): void;
  51270. /**
  51271. * Get the current class name of the texture useful for serialization or dynamic coding.
  51272. * @returns "PBRClearCoatConfiguration"
  51273. */
  51274. getClassName(): string;
  51275. /**
  51276. * Makes a duplicate of the current configuration into another one.
  51277. * @param brdfConfiguration define the config where to copy the info
  51278. */
  51279. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51280. /**
  51281. * Serializes this BRDF configuration.
  51282. * @returns - An object with the serialized config.
  51283. */
  51284. serialize(): any;
  51285. /**
  51286. * Parses a anisotropy Configuration from a serialized object.
  51287. * @param source - Serialized object.
  51288. * @param scene Defines the scene we are parsing for
  51289. * @param rootUrl Defines the rootUrl to load from
  51290. */
  51291. parse(source: any, scene: Scene, rootUrl: string): void;
  51292. }
  51293. }
  51294. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  51295. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51296. import { Color3 } from "babylonjs/Maths/math.color";
  51297. import { Scene } from "babylonjs/scene";
  51298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51299. import { Nullable } from "babylonjs/types";
  51300. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51301. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51302. /**
  51303. * @hidden
  51304. */
  51305. export interface IMaterialSheenDefines {
  51306. SHEEN: boolean;
  51307. SHEEN_TEXTURE: boolean;
  51308. SHEEN_TEXTUREDIRECTUV: number;
  51309. SHEEN_LINKWITHALBEDO: boolean;
  51310. /** @hidden */
  51311. _areTexturesDirty: boolean;
  51312. }
  51313. /**
  51314. * Define the code related to the Sheen parameters of the pbr material.
  51315. */
  51316. export class PBRSheenConfiguration {
  51317. private _isEnabled;
  51318. /**
  51319. * Defines if the material uses sheen.
  51320. */
  51321. isEnabled: boolean;
  51322. private _linkSheenWithAlbedo;
  51323. /**
  51324. * Defines if the sheen is linked to the sheen color.
  51325. */
  51326. linkSheenWithAlbedo: boolean;
  51327. /**
  51328. * Defines the sheen intensity.
  51329. */
  51330. intensity: number;
  51331. /**
  51332. * Defines the sheen color.
  51333. */
  51334. color: Color3;
  51335. private _texture;
  51336. /**
  51337. * Stores the sheen tint values in a texture.
  51338. * rgb is tint
  51339. * a is a intensity
  51340. */
  51341. texture: Nullable<BaseTexture>;
  51342. /** @hidden */
  51343. private _internalMarkAllSubMeshesAsTexturesDirty;
  51344. /** @hidden */
  51345. _markAllSubMeshesAsTexturesDirty(): void;
  51346. /**
  51347. * Instantiate a new istance of clear coat configuration.
  51348. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51349. */
  51350. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51351. /**
  51352. * Specifies that the submesh is ready to be used.
  51353. * @param defines the list of "defines" to update.
  51354. * @param scene defines the scene the material belongs to.
  51355. * @returns - boolean indicating that the submesh is ready or not.
  51356. */
  51357. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51358. /**
  51359. * Checks to see if a texture is used in the material.
  51360. * @param defines the list of "defines" to update.
  51361. * @param scene defines the scene the material belongs to.
  51362. */
  51363. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51364. /**
  51365. * Binds the material data.
  51366. * @param uniformBuffer defines the Uniform buffer to fill in.
  51367. * @param scene defines the scene the material belongs to.
  51368. * @param isFrozen defines wether the material is frozen or not.
  51369. */
  51370. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51371. /**
  51372. * Checks to see if a texture is used in the material.
  51373. * @param texture - Base texture to use.
  51374. * @returns - Boolean specifying if a texture is used in the material.
  51375. */
  51376. hasTexture(texture: BaseTexture): boolean;
  51377. /**
  51378. * Returns an array of the actively used textures.
  51379. * @param activeTextures Array of BaseTextures
  51380. */
  51381. getActiveTextures(activeTextures: BaseTexture[]): void;
  51382. /**
  51383. * Returns the animatable textures.
  51384. * @param animatables Array of animatable textures.
  51385. */
  51386. getAnimatables(animatables: IAnimatable[]): void;
  51387. /**
  51388. * Disposes the resources of the material.
  51389. * @param forceDisposeTextures - Forces the disposal of all textures.
  51390. */
  51391. dispose(forceDisposeTextures?: boolean): void;
  51392. /**
  51393. * Get the current class name of the texture useful for serialization or dynamic coding.
  51394. * @returns "PBRSheenConfiguration"
  51395. */
  51396. getClassName(): string;
  51397. /**
  51398. * Add fallbacks to the effect fallbacks list.
  51399. * @param defines defines the Base texture to use.
  51400. * @param fallbacks defines the current fallback list.
  51401. * @param currentRank defines the current fallback rank.
  51402. * @returns the new fallback rank.
  51403. */
  51404. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51405. /**
  51406. * Add the required uniforms to the current list.
  51407. * @param uniforms defines the current uniform list.
  51408. */
  51409. static AddUniforms(uniforms: string[]): void;
  51410. /**
  51411. * Add the required uniforms to the current buffer.
  51412. * @param uniformBuffer defines the current uniform buffer.
  51413. */
  51414. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51415. /**
  51416. * Add the required samplers to the current list.
  51417. * @param samplers defines the current sampler list.
  51418. */
  51419. static AddSamplers(samplers: string[]): void;
  51420. /**
  51421. * Makes a duplicate of the current configuration into another one.
  51422. * @param sheenConfiguration define the config where to copy the info
  51423. */
  51424. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51425. /**
  51426. * Serializes this BRDF configuration.
  51427. * @returns - An object with the serialized config.
  51428. */
  51429. serialize(): any;
  51430. /**
  51431. * Parses a anisotropy Configuration from a serialized object.
  51432. * @param source - Serialized object.
  51433. * @param scene Defines the scene we are parsing for
  51434. * @param rootUrl Defines the rootUrl to load from
  51435. */
  51436. parse(source: any, scene: Scene, rootUrl: string): void;
  51437. }
  51438. }
  51439. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  51440. import { Nullable } from "babylonjs/types";
  51441. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51442. import { Color3 } from "babylonjs/Maths/math.color";
  51443. import { SmartArray } from "babylonjs/Misc/smartArray";
  51444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51445. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51446. import { Effect } from "babylonjs/Materials/effect";
  51447. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51448. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51449. import { Engine } from "babylonjs/Engines/engine";
  51450. import { Scene } from "babylonjs/scene";
  51451. /**
  51452. * @hidden
  51453. */
  51454. export interface IMaterialSubSurfaceDefines {
  51455. SUBSURFACE: boolean;
  51456. SS_REFRACTION: boolean;
  51457. SS_TRANSLUCENCY: boolean;
  51458. SS_SCATERRING: boolean;
  51459. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51460. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51461. SS_REFRACTIONMAP_3D: boolean;
  51462. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51463. SS_LODINREFRACTIONALPHA: boolean;
  51464. SS_GAMMAREFRACTION: boolean;
  51465. SS_RGBDREFRACTION: boolean;
  51466. SS_LINEARSPECULARREFRACTION: boolean;
  51467. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51468. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51469. /** @hidden */
  51470. _areTexturesDirty: boolean;
  51471. }
  51472. /**
  51473. * Define the code related to the sub surface parameters of the pbr material.
  51474. */
  51475. export class PBRSubSurfaceConfiguration {
  51476. private _isRefractionEnabled;
  51477. /**
  51478. * Defines if the refraction is enabled in the material.
  51479. */
  51480. isRefractionEnabled: boolean;
  51481. private _isTranslucencyEnabled;
  51482. /**
  51483. * Defines if the translucency is enabled in the material.
  51484. */
  51485. isTranslucencyEnabled: boolean;
  51486. private _isScatteringEnabled;
  51487. /**
  51488. * Defines the refraction intensity of the material.
  51489. * The refraction when enabled replaces the Diffuse part of the material.
  51490. * The intensity helps transitionning between diffuse and refraction.
  51491. */
  51492. refractionIntensity: number;
  51493. /**
  51494. * Defines the translucency intensity of the material.
  51495. * When translucency has been enabled, this defines how much of the "translucency"
  51496. * is addded to the diffuse part of the material.
  51497. */
  51498. translucencyIntensity: number;
  51499. /**
  51500. * Defines the scattering intensity of the material.
  51501. * When scattering has been enabled, this defines how much of the "scattered light"
  51502. * is addded to the diffuse part of the material.
  51503. */
  51504. scatteringIntensity: number;
  51505. private _thicknessTexture;
  51506. /**
  51507. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51508. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51509. * 0 would mean minimumThickness
  51510. * 1 would mean maximumThickness
  51511. * The other channels might be use as a mask to vary the different effects intensity.
  51512. */
  51513. thicknessTexture: Nullable<BaseTexture>;
  51514. private _refractionTexture;
  51515. /**
  51516. * Defines the texture to use for refraction.
  51517. */
  51518. refractionTexture: Nullable<BaseTexture>;
  51519. private _indexOfRefraction;
  51520. /**
  51521. * Defines the index of refraction used in the material.
  51522. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51523. */
  51524. indexOfRefraction: number;
  51525. private _invertRefractionY;
  51526. /**
  51527. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51528. */
  51529. invertRefractionY: boolean;
  51530. private _linkRefractionWithTransparency;
  51531. /**
  51532. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51533. * Materials half opaque for instance using refraction could benefit from this control.
  51534. */
  51535. linkRefractionWithTransparency: boolean;
  51536. /**
  51537. * Defines the minimum thickness stored in the thickness map.
  51538. * If no thickness map is defined, this value will be used to simulate thickness.
  51539. */
  51540. minimumThickness: number;
  51541. /**
  51542. * Defines the maximum thickness stored in the thickness map.
  51543. */
  51544. maximumThickness: number;
  51545. /**
  51546. * Defines the volume tint of the material.
  51547. * This is used for both translucency and scattering.
  51548. */
  51549. tintColor: Color3;
  51550. /**
  51551. * Defines the distance at which the tint color should be found in the media.
  51552. * This is used for refraction only.
  51553. */
  51554. tintColorAtDistance: number;
  51555. /**
  51556. * Defines how far each channel transmit through the media.
  51557. * It is defined as a color to simplify it selection.
  51558. */
  51559. diffusionDistance: Color3;
  51560. private _useMaskFromThicknessTexture;
  51561. /**
  51562. * Stores the intensity of the different subsurface effects in the thickness texture.
  51563. * * the green channel is the translucency intensity.
  51564. * * the blue channel is the scattering intensity.
  51565. * * the alpha channel is the refraction intensity.
  51566. */
  51567. useMaskFromThicknessTexture: boolean;
  51568. /** @hidden */
  51569. private _internalMarkAllSubMeshesAsTexturesDirty;
  51570. /** @hidden */
  51571. _markAllSubMeshesAsTexturesDirty(): void;
  51572. /**
  51573. * Instantiate a new istance of sub surface configuration.
  51574. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51575. */
  51576. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51577. /**
  51578. * Gets wehter the submesh is ready to be used or not.
  51579. * @param defines the list of "defines" to update.
  51580. * @param scene defines the scene the material belongs to.
  51581. * @returns - boolean indicating that the submesh is ready or not.
  51582. */
  51583. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51584. /**
  51585. * Checks to see if a texture is used in the material.
  51586. * @param defines the list of "defines" to update.
  51587. * @param scene defines the scene to the material belongs to.
  51588. */
  51589. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51590. /**
  51591. * Binds the material data.
  51592. * @param uniformBuffer defines the Uniform buffer to fill in.
  51593. * @param scene defines the scene the material belongs to.
  51594. * @param engine defines the engine the material belongs to.
  51595. * @param isFrozen defines wether the material is frozen or not.
  51596. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51597. */
  51598. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51599. /**
  51600. * Unbinds the material from the mesh.
  51601. * @param activeEffect defines the effect that should be unbound from.
  51602. * @returns true if unbound, otherwise false
  51603. */
  51604. unbind(activeEffect: Effect): boolean;
  51605. /**
  51606. * Returns the texture used for refraction or null if none is used.
  51607. * @param scene defines the scene the material belongs to.
  51608. * @returns - Refraction texture if present. If no refraction texture and refraction
  51609. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51610. */
  51611. private _getRefractionTexture;
  51612. /**
  51613. * Returns true if alpha blending should be disabled.
  51614. */
  51615. get disableAlphaBlending(): boolean;
  51616. /**
  51617. * Fills the list of render target textures.
  51618. * @param renderTargets the list of render targets to update
  51619. */
  51620. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51621. /**
  51622. * Checks to see if a texture is used in the material.
  51623. * @param texture - Base texture to use.
  51624. * @returns - Boolean specifying if a texture is used in the material.
  51625. */
  51626. hasTexture(texture: BaseTexture): boolean;
  51627. /**
  51628. * Gets a boolean indicating that current material needs to register RTT
  51629. * @returns true if this uses a render target otherwise false.
  51630. */
  51631. hasRenderTargetTextures(): boolean;
  51632. /**
  51633. * Returns an array of the actively used textures.
  51634. * @param activeTextures Array of BaseTextures
  51635. */
  51636. getActiveTextures(activeTextures: BaseTexture[]): void;
  51637. /**
  51638. * Returns the animatable textures.
  51639. * @param animatables Array of animatable textures.
  51640. */
  51641. getAnimatables(animatables: IAnimatable[]): void;
  51642. /**
  51643. * Disposes the resources of the material.
  51644. * @param forceDisposeTextures - Forces the disposal of all textures.
  51645. */
  51646. dispose(forceDisposeTextures?: boolean): void;
  51647. /**
  51648. * Get the current class name of the texture useful for serialization or dynamic coding.
  51649. * @returns "PBRSubSurfaceConfiguration"
  51650. */
  51651. getClassName(): string;
  51652. /**
  51653. * Add fallbacks to the effect fallbacks list.
  51654. * @param defines defines the Base texture to use.
  51655. * @param fallbacks defines the current fallback list.
  51656. * @param currentRank defines the current fallback rank.
  51657. * @returns the new fallback rank.
  51658. */
  51659. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51660. /**
  51661. * Add the required uniforms to the current list.
  51662. * @param uniforms defines the current uniform list.
  51663. */
  51664. static AddUniforms(uniforms: string[]): void;
  51665. /**
  51666. * Add the required samplers to the current list.
  51667. * @param samplers defines the current sampler list.
  51668. */
  51669. static AddSamplers(samplers: string[]): void;
  51670. /**
  51671. * Add the required uniforms to the current buffer.
  51672. * @param uniformBuffer defines the current uniform buffer.
  51673. */
  51674. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51675. /**
  51676. * Makes a duplicate of the current configuration into another one.
  51677. * @param configuration define the config where to copy the info
  51678. */
  51679. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51680. /**
  51681. * Serializes this Sub Surface configuration.
  51682. * @returns - An object with the serialized config.
  51683. */
  51684. serialize(): any;
  51685. /**
  51686. * Parses a anisotropy Configuration from a serialized object.
  51687. * @param source - Serialized object.
  51688. * @param scene Defines the scene we are parsing for
  51689. * @param rootUrl Defines the rootUrl to load from
  51690. */
  51691. parse(source: any, scene: Scene, rootUrl: string): void;
  51692. }
  51693. }
  51694. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  51695. /** @hidden */
  51696. export var pbrFragmentDeclaration: {
  51697. name: string;
  51698. shader: string;
  51699. };
  51700. }
  51701. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  51702. /** @hidden */
  51703. export var pbrUboDeclaration: {
  51704. name: string;
  51705. shader: string;
  51706. };
  51707. }
  51708. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  51709. /** @hidden */
  51710. export var pbrFragmentExtraDeclaration: {
  51711. name: string;
  51712. shader: string;
  51713. };
  51714. }
  51715. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  51716. /** @hidden */
  51717. export var pbrFragmentSamplersDeclaration: {
  51718. name: string;
  51719. shader: string;
  51720. };
  51721. }
  51722. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  51723. /** @hidden */
  51724. export var pbrHelperFunctions: {
  51725. name: string;
  51726. shader: string;
  51727. };
  51728. }
  51729. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  51730. /** @hidden */
  51731. export var harmonicsFunctions: {
  51732. name: string;
  51733. shader: string;
  51734. };
  51735. }
  51736. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  51737. /** @hidden */
  51738. export var pbrDirectLightingSetupFunctions: {
  51739. name: string;
  51740. shader: string;
  51741. };
  51742. }
  51743. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  51744. /** @hidden */
  51745. export var pbrDirectLightingFalloffFunctions: {
  51746. name: string;
  51747. shader: string;
  51748. };
  51749. }
  51750. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  51751. /** @hidden */
  51752. export var pbrBRDFFunctions: {
  51753. name: string;
  51754. shader: string;
  51755. };
  51756. }
  51757. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  51758. /** @hidden */
  51759. export var pbrDirectLightingFunctions: {
  51760. name: string;
  51761. shader: string;
  51762. };
  51763. }
  51764. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  51765. /** @hidden */
  51766. export var pbrIBLFunctions: {
  51767. name: string;
  51768. shader: string;
  51769. };
  51770. }
  51771. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  51772. /** @hidden */
  51773. export var pbrDebug: {
  51774. name: string;
  51775. shader: string;
  51776. };
  51777. }
  51778. declare module "babylonjs/Shaders/pbr.fragment" {
  51779. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  51780. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51781. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  51782. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51783. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51784. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  51785. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51786. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51787. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51788. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51789. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51790. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  51791. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51792. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51793. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51794. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  51795. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  51796. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  51797. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  51798. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  51799. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  51800. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51801. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51802. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  51803. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  51804. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51805. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  51806. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51807. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  51808. /** @hidden */
  51809. export var pbrPixelShader: {
  51810. name: string;
  51811. shader: string;
  51812. };
  51813. }
  51814. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  51815. /** @hidden */
  51816. export var pbrVertexDeclaration: {
  51817. name: string;
  51818. shader: string;
  51819. };
  51820. }
  51821. declare module "babylonjs/Shaders/pbr.vertex" {
  51822. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  51823. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51824. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51825. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51826. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51827. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51828. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  51829. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51830. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51831. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51832. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51833. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51834. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51835. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51836. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51837. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51838. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51839. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  51840. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51841. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51842. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51843. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  51844. /** @hidden */
  51845. export var pbrVertexShader: {
  51846. name: string;
  51847. shader: string;
  51848. };
  51849. }
  51850. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  51851. import { Nullable } from "babylonjs/types";
  51852. import { Scene } from "babylonjs/scene";
  51853. import { Matrix } from "babylonjs/Maths/math.vector";
  51854. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51856. import { Mesh } from "babylonjs/Meshes/mesh";
  51857. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  51858. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  51859. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  51860. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  51861. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  51862. import { Color3 } from "babylonjs/Maths/math.color";
  51863. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  51864. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  51865. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  51866. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51868. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51869. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  51870. import "babylonjs/Shaders/pbr.fragment";
  51871. import "babylonjs/Shaders/pbr.vertex";
  51872. /**
  51873. * Manages the defines for the PBR Material.
  51874. * @hidden
  51875. */
  51876. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51877. PBR: boolean;
  51878. MAINUV1: boolean;
  51879. MAINUV2: boolean;
  51880. UV1: boolean;
  51881. UV2: boolean;
  51882. ALBEDO: boolean;
  51883. ALBEDODIRECTUV: number;
  51884. VERTEXCOLOR: boolean;
  51885. AMBIENT: boolean;
  51886. AMBIENTDIRECTUV: number;
  51887. AMBIENTINGRAYSCALE: boolean;
  51888. OPACITY: boolean;
  51889. VERTEXALPHA: boolean;
  51890. OPACITYDIRECTUV: number;
  51891. OPACITYRGB: boolean;
  51892. ALPHATEST: boolean;
  51893. DEPTHPREPASS: boolean;
  51894. ALPHABLEND: boolean;
  51895. ALPHAFROMALBEDO: boolean;
  51896. ALPHATESTVALUE: string;
  51897. SPECULAROVERALPHA: boolean;
  51898. RADIANCEOVERALPHA: boolean;
  51899. ALPHAFRESNEL: boolean;
  51900. LINEARALPHAFRESNEL: boolean;
  51901. PREMULTIPLYALPHA: boolean;
  51902. EMISSIVE: boolean;
  51903. EMISSIVEDIRECTUV: number;
  51904. REFLECTIVITY: boolean;
  51905. REFLECTIVITYDIRECTUV: number;
  51906. SPECULARTERM: boolean;
  51907. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51908. MICROSURFACEAUTOMATIC: boolean;
  51909. LODBASEDMICROSFURACE: boolean;
  51910. MICROSURFACEMAP: boolean;
  51911. MICROSURFACEMAPDIRECTUV: number;
  51912. METALLICWORKFLOW: boolean;
  51913. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51914. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51915. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51916. AOSTOREINMETALMAPRED: boolean;
  51917. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51918. ENVIRONMENTBRDF: boolean;
  51919. ENVIRONMENTBRDF_RGBD: boolean;
  51920. NORMAL: boolean;
  51921. TANGENT: boolean;
  51922. BUMP: boolean;
  51923. BUMPDIRECTUV: number;
  51924. OBJECTSPACE_NORMALMAP: boolean;
  51925. PARALLAX: boolean;
  51926. PARALLAXOCCLUSION: boolean;
  51927. NORMALXYSCALE: boolean;
  51928. LIGHTMAP: boolean;
  51929. LIGHTMAPDIRECTUV: number;
  51930. USELIGHTMAPASSHADOWMAP: boolean;
  51931. GAMMALIGHTMAP: boolean;
  51932. RGBDLIGHTMAP: boolean;
  51933. REFLECTION: boolean;
  51934. REFLECTIONMAP_3D: boolean;
  51935. REFLECTIONMAP_SPHERICAL: boolean;
  51936. REFLECTIONMAP_PLANAR: boolean;
  51937. REFLECTIONMAP_CUBIC: boolean;
  51938. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51939. REFLECTIONMAP_PROJECTION: boolean;
  51940. REFLECTIONMAP_SKYBOX: boolean;
  51941. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  51942. REFLECTIONMAP_EXPLICIT: boolean;
  51943. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51944. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51945. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51946. INVERTCUBICMAP: boolean;
  51947. USESPHERICALFROMREFLECTIONMAP: boolean;
  51948. USEIRRADIANCEMAP: boolean;
  51949. SPHERICAL_HARMONICS: boolean;
  51950. USESPHERICALINVERTEX: boolean;
  51951. REFLECTIONMAP_OPPOSITEZ: boolean;
  51952. LODINREFLECTIONALPHA: boolean;
  51953. GAMMAREFLECTION: boolean;
  51954. RGBDREFLECTION: boolean;
  51955. LINEARSPECULARREFLECTION: boolean;
  51956. RADIANCEOCCLUSION: boolean;
  51957. HORIZONOCCLUSION: boolean;
  51958. INSTANCES: boolean;
  51959. NUM_BONE_INFLUENCERS: number;
  51960. BonesPerMesh: number;
  51961. BONETEXTURE: boolean;
  51962. NONUNIFORMSCALING: boolean;
  51963. MORPHTARGETS: boolean;
  51964. MORPHTARGETS_NORMAL: boolean;
  51965. MORPHTARGETS_TANGENT: boolean;
  51966. MORPHTARGETS_UV: boolean;
  51967. NUM_MORPH_INFLUENCERS: number;
  51968. IMAGEPROCESSING: boolean;
  51969. VIGNETTE: boolean;
  51970. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51971. VIGNETTEBLENDMODEOPAQUE: boolean;
  51972. TONEMAPPING: boolean;
  51973. TONEMAPPING_ACES: boolean;
  51974. CONTRAST: boolean;
  51975. COLORCURVES: boolean;
  51976. COLORGRADING: boolean;
  51977. COLORGRADING3D: boolean;
  51978. SAMPLER3DGREENDEPTH: boolean;
  51979. SAMPLER3DBGRMAP: boolean;
  51980. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51981. EXPOSURE: boolean;
  51982. MULTIVIEW: boolean;
  51983. USEPHYSICALLIGHTFALLOFF: boolean;
  51984. USEGLTFLIGHTFALLOFF: boolean;
  51985. TWOSIDEDLIGHTING: boolean;
  51986. SHADOWFLOAT: boolean;
  51987. CLIPPLANE: boolean;
  51988. CLIPPLANE2: boolean;
  51989. CLIPPLANE3: boolean;
  51990. CLIPPLANE4: boolean;
  51991. POINTSIZE: boolean;
  51992. FOG: boolean;
  51993. LOGARITHMICDEPTH: boolean;
  51994. FORCENORMALFORWARD: boolean;
  51995. SPECULARAA: boolean;
  51996. CLEARCOAT: boolean;
  51997. CLEARCOAT_DEFAULTIOR: boolean;
  51998. CLEARCOAT_TEXTURE: boolean;
  51999. CLEARCOAT_TEXTUREDIRECTUV: number;
  52000. CLEARCOAT_BUMP: boolean;
  52001. CLEARCOAT_BUMPDIRECTUV: number;
  52002. CLEARCOAT_TINT: boolean;
  52003. CLEARCOAT_TINT_TEXTURE: boolean;
  52004. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52005. ANISOTROPIC: boolean;
  52006. ANISOTROPIC_TEXTURE: boolean;
  52007. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52008. BRDF_V_HEIGHT_CORRELATED: boolean;
  52009. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52010. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52011. SHEEN: boolean;
  52012. SHEEN_TEXTURE: boolean;
  52013. SHEEN_TEXTUREDIRECTUV: number;
  52014. SHEEN_LINKWITHALBEDO: boolean;
  52015. SUBSURFACE: boolean;
  52016. SS_REFRACTION: boolean;
  52017. SS_TRANSLUCENCY: boolean;
  52018. SS_SCATERRING: boolean;
  52019. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52020. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52021. SS_REFRACTIONMAP_3D: boolean;
  52022. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52023. SS_LODINREFRACTIONALPHA: boolean;
  52024. SS_GAMMAREFRACTION: boolean;
  52025. SS_RGBDREFRACTION: boolean;
  52026. SS_LINEARSPECULARREFRACTION: boolean;
  52027. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52028. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52029. UNLIT: boolean;
  52030. DEBUGMODE: number;
  52031. /**
  52032. * Initializes the PBR Material defines.
  52033. */
  52034. constructor();
  52035. /**
  52036. * Resets the PBR Material defines.
  52037. */
  52038. reset(): void;
  52039. }
  52040. /**
  52041. * The Physically based material base class of BJS.
  52042. *
  52043. * This offers the main features of a standard PBR material.
  52044. * For more information, please refer to the documentation :
  52045. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52046. */
  52047. export abstract class PBRBaseMaterial extends PushMaterial {
  52048. /**
  52049. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52050. */
  52051. static readonly PBRMATERIAL_OPAQUE: number;
  52052. /**
  52053. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52054. */
  52055. static readonly PBRMATERIAL_ALPHATEST: number;
  52056. /**
  52057. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52058. */
  52059. static readonly PBRMATERIAL_ALPHABLEND: number;
  52060. /**
  52061. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52062. * They are also discarded below the alpha cutoff threshold to improve performances.
  52063. */
  52064. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52065. /**
  52066. * Defines the default value of how much AO map is occluding the analytical lights
  52067. * (point spot...).
  52068. */
  52069. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52070. /**
  52071. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52072. */
  52073. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52074. /**
  52075. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52076. * to enhance interoperability with other engines.
  52077. */
  52078. static readonly LIGHTFALLOFF_GLTF: number;
  52079. /**
  52080. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52081. * to enhance interoperability with other materials.
  52082. */
  52083. static readonly LIGHTFALLOFF_STANDARD: number;
  52084. /**
  52085. * Intensity of the direct lights e.g. the four lights available in your scene.
  52086. * This impacts both the direct diffuse and specular highlights.
  52087. */
  52088. protected _directIntensity: number;
  52089. /**
  52090. * Intensity of the emissive part of the material.
  52091. * This helps controlling the emissive effect without modifying the emissive color.
  52092. */
  52093. protected _emissiveIntensity: number;
  52094. /**
  52095. * Intensity of the environment e.g. how much the environment will light the object
  52096. * either through harmonics for rough material or through the refelction for shiny ones.
  52097. */
  52098. protected _environmentIntensity: number;
  52099. /**
  52100. * This is a special control allowing the reduction of the specular highlights coming from the
  52101. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52102. */
  52103. protected _specularIntensity: number;
  52104. /**
  52105. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52106. */
  52107. private _lightingInfos;
  52108. /**
  52109. * Debug Control allowing disabling the bump map on this material.
  52110. */
  52111. protected _disableBumpMap: boolean;
  52112. /**
  52113. * AKA Diffuse Texture in standard nomenclature.
  52114. */
  52115. protected _albedoTexture: Nullable<BaseTexture>;
  52116. /**
  52117. * AKA Occlusion Texture in other nomenclature.
  52118. */
  52119. protected _ambientTexture: Nullable<BaseTexture>;
  52120. /**
  52121. * AKA Occlusion Texture Intensity in other nomenclature.
  52122. */
  52123. protected _ambientTextureStrength: number;
  52124. /**
  52125. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52126. * 1 means it completely occludes it
  52127. * 0 mean it has no impact
  52128. */
  52129. protected _ambientTextureImpactOnAnalyticalLights: number;
  52130. /**
  52131. * Stores the alpha values in a texture.
  52132. */
  52133. protected _opacityTexture: Nullable<BaseTexture>;
  52134. /**
  52135. * Stores the reflection values in a texture.
  52136. */
  52137. protected _reflectionTexture: Nullable<BaseTexture>;
  52138. /**
  52139. * Stores the emissive values in a texture.
  52140. */
  52141. protected _emissiveTexture: Nullable<BaseTexture>;
  52142. /**
  52143. * AKA Specular texture in other nomenclature.
  52144. */
  52145. protected _reflectivityTexture: Nullable<BaseTexture>;
  52146. /**
  52147. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52148. */
  52149. protected _metallicTexture: Nullable<BaseTexture>;
  52150. /**
  52151. * Specifies the metallic scalar of the metallic/roughness workflow.
  52152. * Can also be used to scale the metalness values of the metallic texture.
  52153. */
  52154. protected _metallic: Nullable<number>;
  52155. /**
  52156. * Specifies the roughness scalar of the metallic/roughness workflow.
  52157. * Can also be used to scale the roughness values of the metallic texture.
  52158. */
  52159. protected _roughness: Nullable<number>;
  52160. /**
  52161. * Specifies the an F0 factor to help configuring the material F0.
  52162. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52163. * to 0.5 the previously hard coded value stays the same.
  52164. * Can also be used to scale the F0 values of the metallic texture.
  52165. */
  52166. protected _metallicF0Factor: number;
  52167. /**
  52168. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52169. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52170. * your expectation as it multiplies with the texture data.
  52171. */
  52172. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52173. /**
  52174. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52175. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52176. */
  52177. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52178. /**
  52179. * Stores surface normal data used to displace a mesh in a texture.
  52180. */
  52181. protected _bumpTexture: Nullable<BaseTexture>;
  52182. /**
  52183. * Stores the pre-calculated light information of a mesh in a texture.
  52184. */
  52185. protected _lightmapTexture: Nullable<BaseTexture>;
  52186. /**
  52187. * The color of a material in ambient lighting.
  52188. */
  52189. protected _ambientColor: Color3;
  52190. /**
  52191. * AKA Diffuse Color in other nomenclature.
  52192. */
  52193. protected _albedoColor: Color3;
  52194. /**
  52195. * AKA Specular Color in other nomenclature.
  52196. */
  52197. protected _reflectivityColor: Color3;
  52198. /**
  52199. * The color applied when light is reflected from a material.
  52200. */
  52201. protected _reflectionColor: Color3;
  52202. /**
  52203. * The color applied when light is emitted from a material.
  52204. */
  52205. protected _emissiveColor: Color3;
  52206. /**
  52207. * AKA Glossiness in other nomenclature.
  52208. */
  52209. protected _microSurface: number;
  52210. /**
  52211. * Specifies that the material will use the light map as a show map.
  52212. */
  52213. protected _useLightmapAsShadowmap: boolean;
  52214. /**
  52215. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52216. * makes the reflect vector face the model (under horizon).
  52217. */
  52218. protected _useHorizonOcclusion: boolean;
  52219. /**
  52220. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52221. * too much the area relying on ambient texture to define their ambient occlusion.
  52222. */
  52223. protected _useRadianceOcclusion: boolean;
  52224. /**
  52225. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52226. */
  52227. protected _useAlphaFromAlbedoTexture: boolean;
  52228. /**
  52229. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52230. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52231. */
  52232. protected _useSpecularOverAlpha: boolean;
  52233. /**
  52234. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52235. */
  52236. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52237. /**
  52238. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52239. */
  52240. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52241. /**
  52242. * Specifies if the metallic texture contains the roughness information in its green channel.
  52243. */
  52244. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52245. /**
  52246. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52247. */
  52248. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52249. /**
  52250. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52251. */
  52252. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52253. /**
  52254. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52255. */
  52256. protected _useAmbientInGrayScale: boolean;
  52257. /**
  52258. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52259. * The material will try to infer what glossiness each pixel should be.
  52260. */
  52261. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52262. /**
  52263. * Defines the falloff type used in this material.
  52264. * It by default is Physical.
  52265. */
  52266. protected _lightFalloff: number;
  52267. /**
  52268. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52269. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52270. */
  52271. protected _useRadianceOverAlpha: boolean;
  52272. /**
  52273. * Allows using an object space normal map (instead of tangent space).
  52274. */
  52275. protected _useObjectSpaceNormalMap: boolean;
  52276. /**
  52277. * Allows using the bump map in parallax mode.
  52278. */
  52279. protected _useParallax: boolean;
  52280. /**
  52281. * Allows using the bump map in parallax occlusion mode.
  52282. */
  52283. protected _useParallaxOcclusion: boolean;
  52284. /**
  52285. * Controls the scale bias of the parallax mode.
  52286. */
  52287. protected _parallaxScaleBias: number;
  52288. /**
  52289. * If sets to true, disables all the lights affecting the material.
  52290. */
  52291. protected _disableLighting: boolean;
  52292. /**
  52293. * Number of Simultaneous lights allowed on the material.
  52294. */
  52295. protected _maxSimultaneousLights: number;
  52296. /**
  52297. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52298. */
  52299. protected _invertNormalMapX: boolean;
  52300. /**
  52301. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52302. */
  52303. protected _invertNormalMapY: boolean;
  52304. /**
  52305. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52306. */
  52307. protected _twoSidedLighting: boolean;
  52308. /**
  52309. * Defines the alpha limits in alpha test mode.
  52310. */
  52311. protected _alphaCutOff: number;
  52312. /**
  52313. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52314. */
  52315. protected _forceAlphaTest: boolean;
  52316. /**
  52317. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52318. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52319. */
  52320. protected _useAlphaFresnel: boolean;
  52321. /**
  52322. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52323. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52324. */
  52325. protected _useLinearAlphaFresnel: boolean;
  52326. /**
  52327. * The transparency mode of the material.
  52328. */
  52329. protected _transparencyMode: Nullable<number>;
  52330. /**
  52331. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52332. * from cos thetav and roughness:
  52333. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52334. */
  52335. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52336. /**
  52337. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52338. */
  52339. protected _forceIrradianceInFragment: boolean;
  52340. /**
  52341. * Force normal to face away from face.
  52342. */
  52343. protected _forceNormalForward: boolean;
  52344. /**
  52345. * Enables specular anti aliasing in the PBR shader.
  52346. * It will both interacts on the Geometry for analytical and IBL lighting.
  52347. * It also prefilter the roughness map based on the bump values.
  52348. */
  52349. protected _enableSpecularAntiAliasing: boolean;
  52350. /**
  52351. * Default configuration related to image processing available in the PBR Material.
  52352. */
  52353. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52354. /**
  52355. * Keep track of the image processing observer to allow dispose and replace.
  52356. */
  52357. private _imageProcessingObserver;
  52358. /**
  52359. * Attaches a new image processing configuration to the PBR Material.
  52360. * @param configuration
  52361. */
  52362. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52363. /**
  52364. * Stores the available render targets.
  52365. */
  52366. private _renderTargets;
  52367. /**
  52368. * Sets the global ambient color for the material used in lighting calculations.
  52369. */
  52370. private _globalAmbientColor;
  52371. /**
  52372. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52373. */
  52374. private _useLogarithmicDepth;
  52375. /**
  52376. * If set to true, no lighting calculations will be applied.
  52377. */
  52378. private _unlit;
  52379. private _debugMode;
  52380. /**
  52381. * @hidden
  52382. * This is reserved for the inspector.
  52383. * Defines the material debug mode.
  52384. * It helps seeing only some components of the material while troubleshooting.
  52385. */
  52386. debugMode: number;
  52387. /**
  52388. * @hidden
  52389. * This is reserved for the inspector.
  52390. * Specify from where on screen the debug mode should start.
  52391. * The value goes from -1 (full screen) to 1 (not visible)
  52392. * It helps with side by side comparison against the final render
  52393. * This defaults to -1
  52394. */
  52395. private debugLimit;
  52396. /**
  52397. * @hidden
  52398. * This is reserved for the inspector.
  52399. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52400. * You can use the factor to better multiply the final value.
  52401. */
  52402. private debugFactor;
  52403. /**
  52404. * Defines the clear coat layer parameters for the material.
  52405. */
  52406. readonly clearCoat: PBRClearCoatConfiguration;
  52407. /**
  52408. * Defines the anisotropic parameters for the material.
  52409. */
  52410. readonly anisotropy: PBRAnisotropicConfiguration;
  52411. /**
  52412. * Defines the BRDF parameters for the material.
  52413. */
  52414. readonly brdf: PBRBRDFConfiguration;
  52415. /**
  52416. * Defines the Sheen parameters for the material.
  52417. */
  52418. readonly sheen: PBRSheenConfiguration;
  52419. /**
  52420. * Defines the SubSurface parameters for the material.
  52421. */
  52422. readonly subSurface: PBRSubSurfaceConfiguration;
  52423. /**
  52424. * Custom callback helping to override the default shader used in the material.
  52425. */
  52426. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  52427. protected _rebuildInParallel: boolean;
  52428. /**
  52429. * Instantiates a new PBRMaterial instance.
  52430. *
  52431. * @param name The material name
  52432. * @param scene The scene the material will be use in.
  52433. */
  52434. constructor(name: string, scene: Scene);
  52435. /**
  52436. * Gets a boolean indicating that current material needs to register RTT
  52437. */
  52438. get hasRenderTargetTextures(): boolean;
  52439. /**
  52440. * Gets the name of the material class.
  52441. */
  52442. getClassName(): string;
  52443. /**
  52444. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52445. */
  52446. get useLogarithmicDepth(): boolean;
  52447. /**
  52448. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52449. */
  52450. set useLogarithmicDepth(value: boolean);
  52451. /**
  52452. * Gets the current transparency mode.
  52453. */
  52454. get transparencyMode(): Nullable<number>;
  52455. /**
  52456. * Sets the transparency mode of the material.
  52457. *
  52458. * | Value | Type | Description |
  52459. * | ----- | ----------------------------------- | ----------- |
  52460. * | 0 | OPAQUE | |
  52461. * | 1 | ALPHATEST | |
  52462. * | 2 | ALPHABLEND | |
  52463. * | 3 | ALPHATESTANDBLEND | |
  52464. *
  52465. */
  52466. set transparencyMode(value: Nullable<number>);
  52467. /**
  52468. * Returns true if alpha blending should be disabled.
  52469. */
  52470. private get _disableAlphaBlending();
  52471. /**
  52472. * Specifies whether or not this material should be rendered in alpha blend mode.
  52473. */
  52474. needAlphaBlending(): boolean;
  52475. /**
  52476. * Specifies if the mesh will require alpha blending.
  52477. * @param mesh - BJS mesh.
  52478. */
  52479. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  52480. /**
  52481. * Specifies whether or not this material should be rendered in alpha test mode.
  52482. */
  52483. needAlphaTesting(): boolean;
  52484. /**
  52485. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52486. */
  52487. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52488. /**
  52489. * Gets the texture used for the alpha test.
  52490. */
  52491. getAlphaTestTexture(): Nullable<BaseTexture>;
  52492. /**
  52493. * Specifies that the submesh is ready to be used.
  52494. * @param mesh - BJS mesh.
  52495. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52496. * @param useInstances - Specifies that instances should be used.
  52497. * @returns - boolean indicating that the submesh is ready or not.
  52498. */
  52499. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52500. /**
  52501. * Specifies if the material uses metallic roughness workflow.
  52502. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52503. */
  52504. isMetallicWorkflow(): boolean;
  52505. private _prepareEffect;
  52506. private _prepareDefines;
  52507. /**
  52508. * Force shader compilation
  52509. */
  52510. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52511. /**
  52512. * Initializes the uniform buffer layout for the shader.
  52513. */
  52514. buildUniformLayout(): void;
  52515. /**
  52516. * Unbinds the material from the mesh
  52517. */
  52518. unbind(): void;
  52519. /**
  52520. * Binds the submesh data.
  52521. * @param world - The world matrix.
  52522. * @param mesh - The BJS mesh.
  52523. * @param subMesh - A submesh of the BJS mesh.
  52524. */
  52525. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52526. /**
  52527. * Returns the animatable textures.
  52528. * @returns - Array of animatable textures.
  52529. */
  52530. getAnimatables(): IAnimatable[];
  52531. /**
  52532. * Returns the texture used for reflections.
  52533. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52534. */
  52535. private _getReflectionTexture;
  52536. /**
  52537. * Returns an array of the actively used textures.
  52538. * @returns - Array of BaseTextures
  52539. */
  52540. getActiveTextures(): BaseTexture[];
  52541. /**
  52542. * Checks to see if a texture is used in the material.
  52543. * @param texture - Base texture to use.
  52544. * @returns - Boolean specifying if a texture is used in the material.
  52545. */
  52546. hasTexture(texture: BaseTexture): boolean;
  52547. /**
  52548. * Disposes the resources of the material.
  52549. * @param forceDisposeEffect - Forces the disposal of effects.
  52550. * @param forceDisposeTextures - Forces the disposal of all textures.
  52551. */
  52552. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52553. }
  52554. }
  52555. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  52556. import { Nullable } from "babylonjs/types";
  52557. import { Scene } from "babylonjs/scene";
  52558. import { Color3 } from "babylonjs/Maths/math.color";
  52559. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52560. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52562. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52563. /**
  52564. * The Physically based material of BJS.
  52565. *
  52566. * This offers the main features of a standard PBR material.
  52567. * For more information, please refer to the documentation :
  52568. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52569. */
  52570. export class PBRMaterial extends PBRBaseMaterial {
  52571. /**
  52572. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52573. */
  52574. static readonly PBRMATERIAL_OPAQUE: number;
  52575. /**
  52576. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52577. */
  52578. static readonly PBRMATERIAL_ALPHATEST: number;
  52579. /**
  52580. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52581. */
  52582. static readonly PBRMATERIAL_ALPHABLEND: number;
  52583. /**
  52584. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52585. * They are also discarded below the alpha cutoff threshold to improve performances.
  52586. */
  52587. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52588. /**
  52589. * Defines the default value of how much AO map is occluding the analytical lights
  52590. * (point spot...).
  52591. */
  52592. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52593. /**
  52594. * Intensity of the direct lights e.g. the four lights available in your scene.
  52595. * This impacts both the direct diffuse and specular highlights.
  52596. */
  52597. directIntensity: number;
  52598. /**
  52599. * Intensity of the emissive part of the material.
  52600. * This helps controlling the emissive effect without modifying the emissive color.
  52601. */
  52602. emissiveIntensity: number;
  52603. /**
  52604. * Intensity of the environment e.g. how much the environment will light the object
  52605. * either through harmonics for rough material or through the refelction for shiny ones.
  52606. */
  52607. environmentIntensity: number;
  52608. /**
  52609. * This is a special control allowing the reduction of the specular highlights coming from the
  52610. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52611. */
  52612. specularIntensity: number;
  52613. /**
  52614. * Debug Control allowing disabling the bump map on this material.
  52615. */
  52616. disableBumpMap: boolean;
  52617. /**
  52618. * AKA Diffuse Texture in standard nomenclature.
  52619. */
  52620. albedoTexture: BaseTexture;
  52621. /**
  52622. * AKA Occlusion Texture in other nomenclature.
  52623. */
  52624. ambientTexture: BaseTexture;
  52625. /**
  52626. * AKA Occlusion Texture Intensity in other nomenclature.
  52627. */
  52628. ambientTextureStrength: number;
  52629. /**
  52630. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52631. * 1 means it completely occludes it
  52632. * 0 mean it has no impact
  52633. */
  52634. ambientTextureImpactOnAnalyticalLights: number;
  52635. /**
  52636. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52637. */
  52638. opacityTexture: BaseTexture;
  52639. /**
  52640. * Stores the reflection values in a texture.
  52641. */
  52642. reflectionTexture: Nullable<BaseTexture>;
  52643. /**
  52644. * Stores the emissive values in a texture.
  52645. */
  52646. emissiveTexture: BaseTexture;
  52647. /**
  52648. * AKA Specular texture in other nomenclature.
  52649. */
  52650. reflectivityTexture: BaseTexture;
  52651. /**
  52652. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52653. */
  52654. metallicTexture: BaseTexture;
  52655. /**
  52656. * Specifies the metallic scalar of the metallic/roughness workflow.
  52657. * Can also be used to scale the metalness values of the metallic texture.
  52658. */
  52659. metallic: Nullable<number>;
  52660. /**
  52661. * Specifies the roughness scalar of the metallic/roughness workflow.
  52662. * Can also be used to scale the roughness values of the metallic texture.
  52663. */
  52664. roughness: Nullable<number>;
  52665. /**
  52666. * Specifies the an F0 factor to help configuring the material F0.
  52667. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52668. * to 0.5 the previously hard coded value stays the same.
  52669. * Can also be used to scale the F0 values of the metallic texture.
  52670. */
  52671. metallicF0Factor: number;
  52672. /**
  52673. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52674. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52675. * your expectation as it multiplies with the texture data.
  52676. */
  52677. useMetallicF0FactorFromMetallicTexture: boolean;
  52678. /**
  52679. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52680. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52681. */
  52682. microSurfaceTexture: BaseTexture;
  52683. /**
  52684. * Stores surface normal data used to displace a mesh in a texture.
  52685. */
  52686. bumpTexture: BaseTexture;
  52687. /**
  52688. * Stores the pre-calculated light information of a mesh in a texture.
  52689. */
  52690. lightmapTexture: BaseTexture;
  52691. /**
  52692. * Stores the refracted light information in a texture.
  52693. */
  52694. get refractionTexture(): Nullable<BaseTexture>;
  52695. set refractionTexture(value: Nullable<BaseTexture>);
  52696. /**
  52697. * The color of a material in ambient lighting.
  52698. */
  52699. ambientColor: Color3;
  52700. /**
  52701. * AKA Diffuse Color in other nomenclature.
  52702. */
  52703. albedoColor: Color3;
  52704. /**
  52705. * AKA Specular Color in other nomenclature.
  52706. */
  52707. reflectivityColor: Color3;
  52708. /**
  52709. * The color reflected from the material.
  52710. */
  52711. reflectionColor: Color3;
  52712. /**
  52713. * The color emitted from the material.
  52714. */
  52715. emissiveColor: Color3;
  52716. /**
  52717. * AKA Glossiness in other nomenclature.
  52718. */
  52719. microSurface: number;
  52720. /**
  52721. * source material index of refraction (IOR)' / 'destination material IOR.
  52722. */
  52723. get indexOfRefraction(): number;
  52724. set indexOfRefraction(value: number);
  52725. /**
  52726. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52727. */
  52728. get invertRefractionY(): boolean;
  52729. set invertRefractionY(value: boolean);
  52730. /**
  52731. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52732. * Materials half opaque for instance using refraction could benefit from this control.
  52733. */
  52734. get linkRefractionWithTransparency(): boolean;
  52735. set linkRefractionWithTransparency(value: boolean);
  52736. /**
  52737. * If true, the light map contains occlusion information instead of lighting info.
  52738. */
  52739. useLightmapAsShadowmap: boolean;
  52740. /**
  52741. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52742. */
  52743. useAlphaFromAlbedoTexture: boolean;
  52744. /**
  52745. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52746. */
  52747. forceAlphaTest: boolean;
  52748. /**
  52749. * Defines the alpha limits in alpha test mode.
  52750. */
  52751. alphaCutOff: number;
  52752. /**
  52753. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52754. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52755. */
  52756. useSpecularOverAlpha: boolean;
  52757. /**
  52758. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52759. */
  52760. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52761. /**
  52762. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52763. */
  52764. useRoughnessFromMetallicTextureAlpha: boolean;
  52765. /**
  52766. * Specifies if the metallic texture contains the roughness information in its green channel.
  52767. */
  52768. useRoughnessFromMetallicTextureGreen: boolean;
  52769. /**
  52770. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52771. */
  52772. useMetallnessFromMetallicTextureBlue: boolean;
  52773. /**
  52774. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52775. */
  52776. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52777. /**
  52778. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52779. */
  52780. useAmbientInGrayScale: boolean;
  52781. /**
  52782. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52783. * The material will try to infer what glossiness each pixel should be.
  52784. */
  52785. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52786. /**
  52787. * BJS is using an harcoded light falloff based on a manually sets up range.
  52788. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52789. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52790. */
  52791. get usePhysicalLightFalloff(): boolean;
  52792. /**
  52793. * BJS is using an harcoded light falloff based on a manually sets up range.
  52794. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52795. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52796. */
  52797. set usePhysicalLightFalloff(value: boolean);
  52798. /**
  52799. * In order to support the falloff compatibility with gltf, a special mode has been added
  52800. * to reproduce the gltf light falloff.
  52801. */
  52802. get useGLTFLightFalloff(): boolean;
  52803. /**
  52804. * In order to support the falloff compatibility with gltf, a special mode has been added
  52805. * to reproduce the gltf light falloff.
  52806. */
  52807. set useGLTFLightFalloff(value: boolean);
  52808. /**
  52809. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52810. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52811. */
  52812. useRadianceOverAlpha: boolean;
  52813. /**
  52814. * Allows using an object space normal map (instead of tangent space).
  52815. */
  52816. useObjectSpaceNormalMap: boolean;
  52817. /**
  52818. * Allows using the bump map in parallax mode.
  52819. */
  52820. useParallax: boolean;
  52821. /**
  52822. * Allows using the bump map in parallax occlusion mode.
  52823. */
  52824. useParallaxOcclusion: boolean;
  52825. /**
  52826. * Controls the scale bias of the parallax mode.
  52827. */
  52828. parallaxScaleBias: number;
  52829. /**
  52830. * If sets to true, disables all the lights affecting the material.
  52831. */
  52832. disableLighting: boolean;
  52833. /**
  52834. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52835. */
  52836. forceIrradianceInFragment: boolean;
  52837. /**
  52838. * Number of Simultaneous lights allowed on the material.
  52839. */
  52840. maxSimultaneousLights: number;
  52841. /**
  52842. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52843. */
  52844. invertNormalMapX: boolean;
  52845. /**
  52846. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52847. */
  52848. invertNormalMapY: boolean;
  52849. /**
  52850. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52851. */
  52852. twoSidedLighting: boolean;
  52853. /**
  52854. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52855. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52856. */
  52857. useAlphaFresnel: boolean;
  52858. /**
  52859. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52860. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52861. */
  52862. useLinearAlphaFresnel: boolean;
  52863. /**
  52864. * Let user defines the brdf lookup texture used for IBL.
  52865. * A default 8bit version is embedded but you could point at :
  52866. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52867. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52868. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52869. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52870. */
  52871. environmentBRDFTexture: Nullable<BaseTexture>;
  52872. /**
  52873. * Force normal to face away from face.
  52874. */
  52875. forceNormalForward: boolean;
  52876. /**
  52877. * Enables specular anti aliasing in the PBR shader.
  52878. * It will both interacts on the Geometry for analytical and IBL lighting.
  52879. * It also prefilter the roughness map based on the bump values.
  52880. */
  52881. enableSpecularAntiAliasing: boolean;
  52882. /**
  52883. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52884. * makes the reflect vector face the model (under horizon).
  52885. */
  52886. useHorizonOcclusion: boolean;
  52887. /**
  52888. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52889. * too much the area relying on ambient texture to define their ambient occlusion.
  52890. */
  52891. useRadianceOcclusion: boolean;
  52892. /**
  52893. * If set to true, no lighting calculations will be applied.
  52894. */
  52895. unlit: boolean;
  52896. /**
  52897. * Gets the image processing configuration used either in this material.
  52898. */
  52899. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52900. /**
  52901. * Sets the Default image processing configuration used either in the this material.
  52902. *
  52903. * If sets to null, the scene one is in use.
  52904. */
  52905. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52906. /**
  52907. * Gets wether the color curves effect is enabled.
  52908. */
  52909. get cameraColorCurvesEnabled(): boolean;
  52910. /**
  52911. * Sets wether the color curves effect is enabled.
  52912. */
  52913. set cameraColorCurvesEnabled(value: boolean);
  52914. /**
  52915. * Gets wether the color grading effect is enabled.
  52916. */
  52917. get cameraColorGradingEnabled(): boolean;
  52918. /**
  52919. * Gets wether the color grading effect is enabled.
  52920. */
  52921. set cameraColorGradingEnabled(value: boolean);
  52922. /**
  52923. * Gets wether tonemapping is enabled or not.
  52924. */
  52925. get cameraToneMappingEnabled(): boolean;
  52926. /**
  52927. * Sets wether tonemapping is enabled or not
  52928. */
  52929. set cameraToneMappingEnabled(value: boolean);
  52930. /**
  52931. * The camera exposure used on this material.
  52932. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52933. * This corresponds to a photographic exposure.
  52934. */
  52935. get cameraExposure(): number;
  52936. /**
  52937. * The camera exposure used on this material.
  52938. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52939. * This corresponds to a photographic exposure.
  52940. */
  52941. set cameraExposure(value: number);
  52942. /**
  52943. * Gets The camera contrast used on this material.
  52944. */
  52945. get cameraContrast(): number;
  52946. /**
  52947. * Sets The camera contrast used on this material.
  52948. */
  52949. set cameraContrast(value: number);
  52950. /**
  52951. * Gets the Color Grading 2D Lookup Texture.
  52952. */
  52953. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52954. /**
  52955. * Sets the Color Grading 2D Lookup Texture.
  52956. */
  52957. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52958. /**
  52959. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52960. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52961. * 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;
  52962. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52963. */
  52964. get cameraColorCurves(): Nullable<ColorCurves>;
  52965. /**
  52966. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52967. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52968. * 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;
  52969. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52970. */
  52971. set cameraColorCurves(value: Nullable<ColorCurves>);
  52972. /**
  52973. * Instantiates a new PBRMaterial instance.
  52974. *
  52975. * @param name The material name
  52976. * @param scene The scene the material will be use in.
  52977. */
  52978. constructor(name: string, scene: Scene);
  52979. /**
  52980. * Returns the name of this material class.
  52981. */
  52982. getClassName(): string;
  52983. /**
  52984. * Makes a duplicate of the current material.
  52985. * @param name - name to use for the new material.
  52986. */
  52987. clone(name: string): PBRMaterial;
  52988. /**
  52989. * Serializes this PBR Material.
  52990. * @returns - An object with the serialized material.
  52991. */
  52992. serialize(): any;
  52993. /**
  52994. * Parses a PBR Material from a serialized object.
  52995. * @param source - Serialized object.
  52996. * @param scene - BJS scene instance.
  52997. * @param rootUrl - url for the scene object
  52998. * @returns - PBRMaterial
  52999. */
  53000. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53001. }
  53002. }
  53003. declare module "babylonjs/Misc/dds" {
  53004. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53006. import { Nullable } from "babylonjs/types";
  53007. import { Scene } from "babylonjs/scene";
  53008. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53009. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53010. /**
  53011. * Direct draw surface info
  53012. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53013. */
  53014. export interface DDSInfo {
  53015. /**
  53016. * Width of the texture
  53017. */
  53018. width: number;
  53019. /**
  53020. * Width of the texture
  53021. */
  53022. height: number;
  53023. /**
  53024. * Number of Mipmaps for the texture
  53025. * @see https://en.wikipedia.org/wiki/Mipmap
  53026. */
  53027. mipmapCount: number;
  53028. /**
  53029. * If the textures format is a known fourCC format
  53030. * @see https://www.fourcc.org/
  53031. */
  53032. isFourCC: boolean;
  53033. /**
  53034. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53035. */
  53036. isRGB: boolean;
  53037. /**
  53038. * If the texture is a lumincance format
  53039. */
  53040. isLuminance: boolean;
  53041. /**
  53042. * If this is a cube texture
  53043. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53044. */
  53045. isCube: boolean;
  53046. /**
  53047. * If the texture is a compressed format eg. FOURCC_DXT1
  53048. */
  53049. isCompressed: boolean;
  53050. /**
  53051. * The dxgiFormat of the texture
  53052. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53053. */
  53054. dxgiFormat: number;
  53055. /**
  53056. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53057. */
  53058. textureType: number;
  53059. /**
  53060. * Sphericle polynomial created for the dds texture
  53061. */
  53062. sphericalPolynomial?: SphericalPolynomial;
  53063. }
  53064. /**
  53065. * Class used to provide DDS decompression tools
  53066. */
  53067. export class DDSTools {
  53068. /**
  53069. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53070. */
  53071. static StoreLODInAlphaChannel: boolean;
  53072. /**
  53073. * Gets DDS information from an array buffer
  53074. * @param arrayBuffer defines the array buffer to read data from
  53075. * @returns the DDS information
  53076. */
  53077. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53078. private static _FloatView;
  53079. private static _Int32View;
  53080. private static _ToHalfFloat;
  53081. private static _FromHalfFloat;
  53082. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53083. private static _GetHalfFloatRGBAArrayBuffer;
  53084. private static _GetFloatRGBAArrayBuffer;
  53085. private static _GetFloatAsUIntRGBAArrayBuffer;
  53086. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53087. private static _GetRGBAArrayBuffer;
  53088. private static _ExtractLongWordOrder;
  53089. private static _GetRGBArrayBuffer;
  53090. private static _GetLuminanceArrayBuffer;
  53091. /**
  53092. * Uploads DDS Levels to a Babylon Texture
  53093. * @hidden
  53094. */
  53095. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53096. }
  53097. module "babylonjs/Engines/thinEngine" {
  53098. interface ThinEngine {
  53099. /**
  53100. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53101. * @param rootUrl defines the url where the file to load is located
  53102. * @param scene defines the current scene
  53103. * @param lodScale defines scale to apply to the mip map selection
  53104. * @param lodOffset defines offset to apply to the mip map selection
  53105. * @param onLoad defines an optional callback raised when the texture is loaded
  53106. * @param onError defines an optional callback raised if there is an issue to load the texture
  53107. * @param format defines the format of the data
  53108. * @param forcedExtension defines the extension to use to pick the right loader
  53109. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53110. * @returns the cube texture as an InternalTexture
  53111. */
  53112. 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;
  53113. }
  53114. }
  53115. }
  53116. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53117. import { Nullable } from "babylonjs/types";
  53118. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53119. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53120. /**
  53121. * Implementation of the DDS Texture Loader.
  53122. * @hidden
  53123. */
  53124. export class _DDSTextureLoader implements IInternalTextureLoader {
  53125. /**
  53126. * Defines wether the loader supports cascade loading the different faces.
  53127. */
  53128. readonly supportCascades: boolean;
  53129. /**
  53130. * This returns if the loader support the current file information.
  53131. * @param extension defines the file extension of the file being loaded
  53132. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53133. * @param fallback defines the fallback internal texture if any
  53134. * @param isBase64 defines whether the texture is encoded as a base64
  53135. * @param isBuffer defines whether the texture data are stored as a buffer
  53136. * @returns true if the loader can load the specified file
  53137. */
  53138. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53139. /**
  53140. * Transform the url before loading if required.
  53141. * @param rootUrl the url of the texture
  53142. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53143. * @returns the transformed texture
  53144. */
  53145. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53146. /**
  53147. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53148. * @param rootUrl the url of the texture
  53149. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53150. * @returns the fallback texture
  53151. */
  53152. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53153. /**
  53154. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53155. * @param data contains the texture data
  53156. * @param texture defines the BabylonJS internal texture
  53157. * @param createPolynomials will be true if polynomials have been requested
  53158. * @param onLoad defines the callback to trigger once the texture is ready
  53159. * @param onError defines the callback to trigger in case of error
  53160. */
  53161. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53162. /**
  53163. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53164. * @param data contains the texture data
  53165. * @param texture defines the BabylonJS internal texture
  53166. * @param callback defines the method to call once ready to upload
  53167. */
  53168. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53169. }
  53170. }
  53171. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  53172. import { Nullable } from "babylonjs/types";
  53173. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53174. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53175. /**
  53176. * Implementation of the ENV Texture Loader.
  53177. * @hidden
  53178. */
  53179. export class _ENVTextureLoader implements IInternalTextureLoader {
  53180. /**
  53181. * Defines wether the loader supports cascade loading the different faces.
  53182. */
  53183. readonly supportCascades: boolean;
  53184. /**
  53185. * This returns if the loader support the current file information.
  53186. * @param extension defines the file extension of the file being loaded
  53187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53188. * @param fallback defines the fallback internal texture if any
  53189. * @param isBase64 defines whether the texture is encoded as a base64
  53190. * @param isBuffer defines whether the texture data are stored as a buffer
  53191. * @returns true if the loader can load the specified file
  53192. */
  53193. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53194. /**
  53195. * Transform the url before loading if required.
  53196. * @param rootUrl the url of the texture
  53197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53198. * @returns the transformed texture
  53199. */
  53200. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53201. /**
  53202. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53203. * @param rootUrl the url of the texture
  53204. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53205. * @returns the fallback texture
  53206. */
  53207. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53208. /**
  53209. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53210. * @param data contains the texture data
  53211. * @param texture defines the BabylonJS internal texture
  53212. * @param createPolynomials will be true if polynomials have been requested
  53213. * @param onLoad defines the callback to trigger once the texture is ready
  53214. * @param onError defines the callback to trigger in case of error
  53215. */
  53216. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53217. /**
  53218. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53219. * @param data contains the texture data
  53220. * @param texture defines the BabylonJS internal texture
  53221. * @param callback defines the method to call once ready to upload
  53222. */
  53223. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53224. }
  53225. }
  53226. declare module "babylonjs/Misc/khronosTextureContainer" {
  53227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53228. /**
  53229. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53230. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53231. */
  53232. export class KhronosTextureContainer {
  53233. /** contents of the KTX container file */
  53234. arrayBuffer: any;
  53235. private static HEADER_LEN;
  53236. private static COMPRESSED_2D;
  53237. private static COMPRESSED_3D;
  53238. private static TEX_2D;
  53239. private static TEX_3D;
  53240. /**
  53241. * Gets the openGL type
  53242. */
  53243. glType: number;
  53244. /**
  53245. * Gets the openGL type size
  53246. */
  53247. glTypeSize: number;
  53248. /**
  53249. * Gets the openGL format
  53250. */
  53251. glFormat: number;
  53252. /**
  53253. * Gets the openGL internal format
  53254. */
  53255. glInternalFormat: number;
  53256. /**
  53257. * Gets the base internal format
  53258. */
  53259. glBaseInternalFormat: number;
  53260. /**
  53261. * Gets image width in pixel
  53262. */
  53263. pixelWidth: number;
  53264. /**
  53265. * Gets image height in pixel
  53266. */
  53267. pixelHeight: number;
  53268. /**
  53269. * Gets image depth in pixels
  53270. */
  53271. pixelDepth: number;
  53272. /**
  53273. * Gets the number of array elements
  53274. */
  53275. numberOfArrayElements: number;
  53276. /**
  53277. * Gets the number of faces
  53278. */
  53279. numberOfFaces: number;
  53280. /**
  53281. * Gets the number of mipmap levels
  53282. */
  53283. numberOfMipmapLevels: number;
  53284. /**
  53285. * Gets the bytes of key value data
  53286. */
  53287. bytesOfKeyValueData: number;
  53288. /**
  53289. * Gets the load type
  53290. */
  53291. loadType: number;
  53292. /**
  53293. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53294. */
  53295. isInvalid: boolean;
  53296. /**
  53297. * Creates a new KhronosTextureContainer
  53298. * @param arrayBuffer contents of the KTX container file
  53299. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53300. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53301. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53302. */
  53303. constructor(
  53304. /** contents of the KTX container file */
  53305. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53306. /**
  53307. * Uploads KTX content to a Babylon Texture.
  53308. * It is assumed that the texture has already been created & is currently bound
  53309. * @hidden
  53310. */
  53311. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53312. private _upload2DCompressedLevels;
  53313. }
  53314. }
  53315. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  53316. import { Nullable } from "babylonjs/types";
  53317. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53318. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53319. /**
  53320. * Implementation of the KTX Texture Loader.
  53321. * @hidden
  53322. */
  53323. export class _KTXTextureLoader implements IInternalTextureLoader {
  53324. /**
  53325. * Defines wether the loader supports cascade loading the different faces.
  53326. */
  53327. readonly supportCascades: boolean;
  53328. /**
  53329. * This returns if the loader support the current file information.
  53330. * @param extension defines the file extension of the file being loaded
  53331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53332. * @param fallback defines the fallback internal texture if any
  53333. * @param isBase64 defines whether the texture is encoded as a base64
  53334. * @param isBuffer defines whether the texture data are stored as a buffer
  53335. * @returns true if the loader can load the specified file
  53336. */
  53337. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53338. /**
  53339. * Transform the url before loading if required.
  53340. * @param rootUrl the url of the texture
  53341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53342. * @returns the transformed texture
  53343. */
  53344. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53345. /**
  53346. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53347. * @param rootUrl the url of the texture
  53348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53349. * @returns the fallback texture
  53350. */
  53351. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53352. /**
  53353. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53354. * @param data contains the texture data
  53355. * @param texture defines the BabylonJS internal texture
  53356. * @param createPolynomials will be true if polynomials have been requested
  53357. * @param onLoad defines the callback to trigger once the texture is ready
  53358. * @param onError defines the callback to trigger in case of error
  53359. */
  53360. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53361. /**
  53362. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53363. * @param data contains the texture data
  53364. * @param texture defines the BabylonJS internal texture
  53365. * @param callback defines the method to call once ready to upload
  53366. */
  53367. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53368. }
  53369. }
  53370. declare module "babylonjs/Helpers/sceneHelpers" {
  53371. import { Nullable } from "babylonjs/types";
  53372. import { Mesh } from "babylonjs/Meshes/mesh";
  53373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53374. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  53375. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  53376. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53377. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53378. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53379. import "babylonjs/Meshes/Builders/boxBuilder";
  53380. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  53381. /** @hidden */
  53382. export var _forceSceneHelpersToBundle: boolean;
  53383. module "babylonjs/scene" {
  53384. interface Scene {
  53385. /**
  53386. * Creates a default light for the scene.
  53387. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53388. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53389. */
  53390. createDefaultLight(replace?: boolean): void;
  53391. /**
  53392. * Creates a default camera for the scene.
  53393. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53394. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53395. * @param replace has default false, when true replaces the active camera in the scene
  53396. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53397. */
  53398. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53399. /**
  53400. * Creates a default camera and a default light.
  53401. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53402. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53403. * @param replace has the default false, when true replaces the active camera/light in the scene
  53404. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53405. */
  53406. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53407. /**
  53408. * Creates a new sky box
  53409. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53410. * @param environmentTexture defines the texture to use as environment texture
  53411. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53412. * @param scale defines the overall scale of the skybox
  53413. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53414. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53415. * @returns a new mesh holding the sky box
  53416. */
  53417. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53418. /**
  53419. * Creates a new environment
  53420. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53421. * @param options defines the options you can use to configure the environment
  53422. * @returns the new EnvironmentHelper
  53423. */
  53424. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53425. /**
  53426. * Creates a new VREXperienceHelper
  53427. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53428. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53429. * @returns a new VREXperienceHelper
  53430. */
  53431. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53432. /**
  53433. * Creates a new WebXRDefaultExperience
  53434. * @see http://doc.babylonjs.com/how_to/webxr
  53435. * @param options experience options
  53436. * @returns a promise for a new WebXRDefaultExperience
  53437. */
  53438. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53439. }
  53440. }
  53441. }
  53442. declare module "babylonjs/Helpers/videoDome" {
  53443. import { Scene } from "babylonjs/scene";
  53444. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53445. import { Mesh } from "babylonjs/Meshes/mesh";
  53446. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  53447. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  53448. import "babylonjs/Meshes/Builders/sphereBuilder";
  53449. /**
  53450. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53451. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53452. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53453. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53454. */
  53455. export class VideoDome extends TransformNode {
  53456. /**
  53457. * Define the video source as a Monoscopic panoramic 360 video.
  53458. */
  53459. static readonly MODE_MONOSCOPIC: number;
  53460. /**
  53461. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53462. */
  53463. static readonly MODE_TOPBOTTOM: number;
  53464. /**
  53465. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53466. */
  53467. static readonly MODE_SIDEBYSIDE: number;
  53468. private _halfDome;
  53469. private _useDirectMapping;
  53470. /**
  53471. * The video texture being displayed on the sphere
  53472. */
  53473. protected _videoTexture: VideoTexture;
  53474. /**
  53475. * Gets the video texture being displayed on the sphere
  53476. */
  53477. get videoTexture(): VideoTexture;
  53478. /**
  53479. * The skybox material
  53480. */
  53481. protected _material: BackgroundMaterial;
  53482. /**
  53483. * The surface used for the skybox
  53484. */
  53485. protected _mesh: Mesh;
  53486. /**
  53487. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53488. */
  53489. private _halfDomeMask;
  53490. /**
  53491. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53492. * Also see the options.resolution property.
  53493. */
  53494. get fovMultiplier(): number;
  53495. set fovMultiplier(value: number);
  53496. private _videoMode;
  53497. /**
  53498. * Gets or set the current video mode for the video. It can be:
  53499. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53500. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53501. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53502. */
  53503. get videoMode(): number;
  53504. set videoMode(value: number);
  53505. /**
  53506. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53507. *
  53508. */
  53509. get halfDome(): boolean;
  53510. /**
  53511. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53512. */
  53513. set halfDome(enabled: boolean);
  53514. /**
  53515. * Oberserver used in Stereoscopic VR Mode.
  53516. */
  53517. private _onBeforeCameraRenderObserver;
  53518. /**
  53519. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53520. * @param name Element's name, child elements will append suffixes for their own names.
  53521. * @param urlsOrVideo defines the url(s) or the video element to use
  53522. * @param options An object containing optional or exposed sub element properties
  53523. */
  53524. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53525. resolution?: number;
  53526. clickToPlay?: boolean;
  53527. autoPlay?: boolean;
  53528. loop?: boolean;
  53529. size?: number;
  53530. poster?: string;
  53531. faceForward?: boolean;
  53532. useDirectMapping?: boolean;
  53533. halfDomeMode?: boolean;
  53534. }, scene: Scene);
  53535. private _changeVideoMode;
  53536. /**
  53537. * Releases resources associated with this node.
  53538. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53539. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53540. */
  53541. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53542. }
  53543. }
  53544. declare module "babylonjs/Helpers/index" {
  53545. export * from "babylonjs/Helpers/environmentHelper";
  53546. export * from "babylonjs/Helpers/photoDome";
  53547. export * from "babylonjs/Helpers/sceneHelpers";
  53548. export * from "babylonjs/Helpers/videoDome";
  53549. }
  53550. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  53551. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53552. import { IDisposable } from "babylonjs/scene";
  53553. import { Engine } from "babylonjs/Engines/engine";
  53554. /**
  53555. * This class can be used to get instrumentation data from a Babylon engine
  53556. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53557. */
  53558. export class EngineInstrumentation implements IDisposable {
  53559. /**
  53560. * Define the instrumented engine.
  53561. */
  53562. engine: Engine;
  53563. private _captureGPUFrameTime;
  53564. private _gpuFrameTimeToken;
  53565. private _gpuFrameTime;
  53566. private _captureShaderCompilationTime;
  53567. private _shaderCompilationTime;
  53568. private _onBeginFrameObserver;
  53569. private _onEndFrameObserver;
  53570. private _onBeforeShaderCompilationObserver;
  53571. private _onAfterShaderCompilationObserver;
  53572. /**
  53573. * Gets the perf counter used for GPU frame time
  53574. */
  53575. get gpuFrameTimeCounter(): PerfCounter;
  53576. /**
  53577. * Gets the GPU frame time capture status
  53578. */
  53579. get captureGPUFrameTime(): boolean;
  53580. /**
  53581. * Enable or disable the GPU frame time capture
  53582. */
  53583. set captureGPUFrameTime(value: boolean);
  53584. /**
  53585. * Gets the perf counter used for shader compilation time
  53586. */
  53587. get shaderCompilationTimeCounter(): PerfCounter;
  53588. /**
  53589. * Gets the shader compilation time capture status
  53590. */
  53591. get captureShaderCompilationTime(): boolean;
  53592. /**
  53593. * Enable or disable the shader compilation time capture
  53594. */
  53595. set captureShaderCompilationTime(value: boolean);
  53596. /**
  53597. * Instantiates a new engine instrumentation.
  53598. * This class can be used to get instrumentation data from a Babylon engine
  53599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53600. * @param engine Defines the engine to instrument
  53601. */
  53602. constructor(
  53603. /**
  53604. * Define the instrumented engine.
  53605. */
  53606. engine: Engine);
  53607. /**
  53608. * Dispose and release associated resources.
  53609. */
  53610. dispose(): void;
  53611. }
  53612. }
  53613. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  53614. import { Scene, IDisposable } from "babylonjs/scene";
  53615. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53616. /**
  53617. * This class can be used to get instrumentation data from a Babylon engine
  53618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53619. */
  53620. export class SceneInstrumentation implements IDisposable {
  53621. /**
  53622. * Defines the scene to instrument
  53623. */
  53624. scene: Scene;
  53625. private _captureActiveMeshesEvaluationTime;
  53626. private _activeMeshesEvaluationTime;
  53627. private _captureRenderTargetsRenderTime;
  53628. private _renderTargetsRenderTime;
  53629. private _captureFrameTime;
  53630. private _frameTime;
  53631. private _captureRenderTime;
  53632. private _renderTime;
  53633. private _captureInterFrameTime;
  53634. private _interFrameTime;
  53635. private _captureParticlesRenderTime;
  53636. private _particlesRenderTime;
  53637. private _captureSpritesRenderTime;
  53638. private _spritesRenderTime;
  53639. private _capturePhysicsTime;
  53640. private _physicsTime;
  53641. private _captureAnimationsTime;
  53642. private _animationsTime;
  53643. private _captureCameraRenderTime;
  53644. private _cameraRenderTime;
  53645. private _onBeforeActiveMeshesEvaluationObserver;
  53646. private _onAfterActiveMeshesEvaluationObserver;
  53647. private _onBeforeRenderTargetsRenderObserver;
  53648. private _onAfterRenderTargetsRenderObserver;
  53649. private _onAfterRenderObserver;
  53650. private _onBeforeDrawPhaseObserver;
  53651. private _onAfterDrawPhaseObserver;
  53652. private _onBeforeAnimationsObserver;
  53653. private _onBeforeParticlesRenderingObserver;
  53654. private _onAfterParticlesRenderingObserver;
  53655. private _onBeforeSpritesRenderingObserver;
  53656. private _onAfterSpritesRenderingObserver;
  53657. private _onBeforePhysicsObserver;
  53658. private _onAfterPhysicsObserver;
  53659. private _onAfterAnimationsObserver;
  53660. private _onBeforeCameraRenderObserver;
  53661. private _onAfterCameraRenderObserver;
  53662. /**
  53663. * Gets the perf counter used for active meshes evaluation time
  53664. */
  53665. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53666. /**
  53667. * Gets the active meshes evaluation time capture status
  53668. */
  53669. get captureActiveMeshesEvaluationTime(): boolean;
  53670. /**
  53671. * Enable or disable the active meshes evaluation time capture
  53672. */
  53673. set captureActiveMeshesEvaluationTime(value: boolean);
  53674. /**
  53675. * Gets the perf counter used for render targets render time
  53676. */
  53677. get renderTargetsRenderTimeCounter(): PerfCounter;
  53678. /**
  53679. * Gets the render targets render time capture status
  53680. */
  53681. get captureRenderTargetsRenderTime(): boolean;
  53682. /**
  53683. * Enable or disable the render targets render time capture
  53684. */
  53685. set captureRenderTargetsRenderTime(value: boolean);
  53686. /**
  53687. * Gets the perf counter used for particles render time
  53688. */
  53689. get particlesRenderTimeCounter(): PerfCounter;
  53690. /**
  53691. * Gets the particles render time capture status
  53692. */
  53693. get captureParticlesRenderTime(): boolean;
  53694. /**
  53695. * Enable or disable the particles render time capture
  53696. */
  53697. set captureParticlesRenderTime(value: boolean);
  53698. /**
  53699. * Gets the perf counter used for sprites render time
  53700. */
  53701. get spritesRenderTimeCounter(): PerfCounter;
  53702. /**
  53703. * Gets the sprites render time capture status
  53704. */
  53705. get captureSpritesRenderTime(): boolean;
  53706. /**
  53707. * Enable or disable the sprites render time capture
  53708. */
  53709. set captureSpritesRenderTime(value: boolean);
  53710. /**
  53711. * Gets the perf counter used for physics time
  53712. */
  53713. get physicsTimeCounter(): PerfCounter;
  53714. /**
  53715. * Gets the physics time capture status
  53716. */
  53717. get capturePhysicsTime(): boolean;
  53718. /**
  53719. * Enable or disable the physics time capture
  53720. */
  53721. set capturePhysicsTime(value: boolean);
  53722. /**
  53723. * Gets the perf counter used for animations time
  53724. */
  53725. get animationsTimeCounter(): PerfCounter;
  53726. /**
  53727. * Gets the animations time capture status
  53728. */
  53729. get captureAnimationsTime(): boolean;
  53730. /**
  53731. * Enable or disable the animations time capture
  53732. */
  53733. set captureAnimationsTime(value: boolean);
  53734. /**
  53735. * Gets the perf counter used for frame time capture
  53736. */
  53737. get frameTimeCounter(): PerfCounter;
  53738. /**
  53739. * Gets the frame time capture status
  53740. */
  53741. get captureFrameTime(): boolean;
  53742. /**
  53743. * Enable or disable the frame time capture
  53744. */
  53745. set captureFrameTime(value: boolean);
  53746. /**
  53747. * Gets the perf counter used for inter-frames time capture
  53748. */
  53749. get interFrameTimeCounter(): PerfCounter;
  53750. /**
  53751. * Gets the inter-frames time capture status
  53752. */
  53753. get captureInterFrameTime(): boolean;
  53754. /**
  53755. * Enable or disable the inter-frames time capture
  53756. */
  53757. set captureInterFrameTime(value: boolean);
  53758. /**
  53759. * Gets the perf counter used for render time capture
  53760. */
  53761. get renderTimeCounter(): PerfCounter;
  53762. /**
  53763. * Gets the render time capture status
  53764. */
  53765. get captureRenderTime(): boolean;
  53766. /**
  53767. * Enable or disable the render time capture
  53768. */
  53769. set captureRenderTime(value: boolean);
  53770. /**
  53771. * Gets the perf counter used for camera render time capture
  53772. */
  53773. get cameraRenderTimeCounter(): PerfCounter;
  53774. /**
  53775. * Gets the camera render time capture status
  53776. */
  53777. get captureCameraRenderTime(): boolean;
  53778. /**
  53779. * Enable or disable the camera render time capture
  53780. */
  53781. set captureCameraRenderTime(value: boolean);
  53782. /**
  53783. * Gets the perf counter used for draw calls
  53784. */
  53785. get drawCallsCounter(): PerfCounter;
  53786. /**
  53787. * Instantiates a new scene instrumentation.
  53788. * This class can be used to get instrumentation data from a Babylon engine
  53789. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53790. * @param scene Defines the scene to instrument
  53791. */
  53792. constructor(
  53793. /**
  53794. * Defines the scene to instrument
  53795. */
  53796. scene: Scene);
  53797. /**
  53798. * Dispose and release associated resources.
  53799. */
  53800. dispose(): void;
  53801. }
  53802. }
  53803. declare module "babylonjs/Instrumentation/index" {
  53804. export * from "babylonjs/Instrumentation/engineInstrumentation";
  53805. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  53806. export * from "babylonjs/Instrumentation/timeToken";
  53807. }
  53808. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  53809. /** @hidden */
  53810. export var glowMapGenerationPixelShader: {
  53811. name: string;
  53812. shader: string;
  53813. };
  53814. }
  53815. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  53816. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53818. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53819. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53820. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53821. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53822. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53823. /** @hidden */
  53824. export var glowMapGenerationVertexShader: {
  53825. name: string;
  53826. shader: string;
  53827. };
  53828. }
  53829. declare module "babylonjs/Layers/effectLayer" {
  53830. import { Observable } from "babylonjs/Misc/observable";
  53831. import { Nullable } from "babylonjs/types";
  53832. import { Camera } from "babylonjs/Cameras/camera";
  53833. import { Scene } from "babylonjs/scene";
  53834. import { ISize } from "babylonjs/Maths/math.size";
  53835. import { Color4 } from "babylonjs/Maths/math.color";
  53836. import { Engine } from "babylonjs/Engines/engine";
  53837. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53839. import { Mesh } from "babylonjs/Meshes/mesh";
  53840. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53841. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53842. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53843. import { Effect } from "babylonjs/Materials/effect";
  53844. import { Material } from "babylonjs/Materials/material";
  53845. import "babylonjs/Shaders/glowMapGeneration.fragment";
  53846. import "babylonjs/Shaders/glowMapGeneration.vertex";
  53847. /**
  53848. * Effect layer options. This helps customizing the behaviour
  53849. * of the effect layer.
  53850. */
  53851. export interface IEffectLayerOptions {
  53852. /**
  53853. * Multiplication factor apply to the canvas size to compute the render target size
  53854. * used to generated the objects (the smaller the faster).
  53855. */
  53856. mainTextureRatio: number;
  53857. /**
  53858. * Enforces a fixed size texture to ensure effect stability across devices.
  53859. */
  53860. mainTextureFixedSize?: number;
  53861. /**
  53862. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53863. */
  53864. alphaBlendingMode: number;
  53865. /**
  53866. * The camera attached to the layer.
  53867. */
  53868. camera: Nullable<Camera>;
  53869. /**
  53870. * The rendering group to draw the layer in.
  53871. */
  53872. renderingGroupId: number;
  53873. }
  53874. /**
  53875. * The effect layer Helps adding post process effect blended with the main pass.
  53876. *
  53877. * This can be for instance use to generate glow or higlight effects on the scene.
  53878. *
  53879. * The effect layer class can not be used directly and is intented to inherited from to be
  53880. * customized per effects.
  53881. */
  53882. export abstract class EffectLayer {
  53883. private _vertexBuffers;
  53884. private _indexBuffer;
  53885. private _cachedDefines;
  53886. private _effectLayerMapGenerationEffect;
  53887. private _effectLayerOptions;
  53888. private _mergeEffect;
  53889. protected _scene: Scene;
  53890. protected _engine: Engine;
  53891. protected _maxSize: number;
  53892. protected _mainTextureDesiredSize: ISize;
  53893. protected _mainTexture: RenderTargetTexture;
  53894. protected _shouldRender: boolean;
  53895. protected _postProcesses: PostProcess[];
  53896. protected _textures: BaseTexture[];
  53897. protected _emissiveTextureAndColor: {
  53898. texture: Nullable<BaseTexture>;
  53899. color: Color4;
  53900. };
  53901. /**
  53902. * The name of the layer
  53903. */
  53904. name: string;
  53905. /**
  53906. * The clear color of the texture used to generate the glow map.
  53907. */
  53908. neutralColor: Color4;
  53909. /**
  53910. * Specifies wether the highlight layer is enabled or not.
  53911. */
  53912. isEnabled: boolean;
  53913. /**
  53914. * Gets the camera attached to the layer.
  53915. */
  53916. get camera(): Nullable<Camera>;
  53917. /**
  53918. * Gets the rendering group id the layer should render in.
  53919. */
  53920. get renderingGroupId(): number;
  53921. set renderingGroupId(renderingGroupId: number);
  53922. /**
  53923. * An event triggered when the effect layer has been disposed.
  53924. */
  53925. onDisposeObservable: Observable<EffectLayer>;
  53926. /**
  53927. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53928. */
  53929. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53930. /**
  53931. * An event triggered when the generated texture is being merged in the scene.
  53932. */
  53933. onBeforeComposeObservable: Observable<EffectLayer>;
  53934. /**
  53935. * An event triggered when the mesh is rendered into the effect render target.
  53936. */
  53937. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53938. /**
  53939. * An event triggered after the mesh has been rendered into the effect render target.
  53940. */
  53941. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53942. /**
  53943. * An event triggered when the generated texture has been merged in the scene.
  53944. */
  53945. onAfterComposeObservable: Observable<EffectLayer>;
  53946. /**
  53947. * An event triggered when the efffect layer changes its size.
  53948. */
  53949. onSizeChangedObservable: Observable<EffectLayer>;
  53950. /** @hidden */
  53951. static _SceneComponentInitialization: (scene: Scene) => void;
  53952. /**
  53953. * Instantiates a new effect Layer and references it in the scene.
  53954. * @param name The name of the layer
  53955. * @param scene The scene to use the layer in
  53956. */
  53957. constructor(
  53958. /** The Friendly of the effect in the scene */
  53959. name: string, scene: Scene);
  53960. /**
  53961. * Get the effect name of the layer.
  53962. * @return The effect name
  53963. */
  53964. abstract getEffectName(): string;
  53965. /**
  53966. * Checks for the readiness of the element composing the layer.
  53967. * @param subMesh the mesh to check for
  53968. * @param useInstances specify wether or not to use instances to render the mesh
  53969. * @return true if ready otherwise, false
  53970. */
  53971. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53972. /**
  53973. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53974. * @returns true if the effect requires stencil during the main canvas render pass.
  53975. */
  53976. abstract needStencil(): boolean;
  53977. /**
  53978. * Create the merge effect. This is the shader use to blit the information back
  53979. * to the main canvas at the end of the scene rendering.
  53980. * @returns The effect containing the shader used to merge the effect on the main canvas
  53981. */
  53982. protected abstract _createMergeEffect(): Effect;
  53983. /**
  53984. * Creates the render target textures and post processes used in the effect layer.
  53985. */
  53986. protected abstract _createTextureAndPostProcesses(): void;
  53987. /**
  53988. * Implementation specific of rendering the generating effect on the main canvas.
  53989. * @param effect The effect used to render through
  53990. */
  53991. protected abstract _internalRender(effect: Effect): void;
  53992. /**
  53993. * Sets the required values for both the emissive texture and and the main color.
  53994. */
  53995. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53996. /**
  53997. * Free any resources and references associated to a mesh.
  53998. * Internal use
  53999. * @param mesh The mesh to free.
  54000. */
  54001. abstract _disposeMesh(mesh: Mesh): void;
  54002. /**
  54003. * Serializes this layer (Glow or Highlight for example)
  54004. * @returns a serialized layer object
  54005. */
  54006. abstract serialize?(): any;
  54007. /**
  54008. * Initializes the effect layer with the required options.
  54009. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54010. */
  54011. protected _init(options: Partial<IEffectLayerOptions>): void;
  54012. /**
  54013. * Generates the index buffer of the full screen quad blending to the main canvas.
  54014. */
  54015. private _generateIndexBuffer;
  54016. /**
  54017. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54018. */
  54019. private _generateVertexBuffer;
  54020. /**
  54021. * Sets the main texture desired size which is the closest power of two
  54022. * of the engine canvas size.
  54023. */
  54024. private _setMainTextureSize;
  54025. /**
  54026. * Creates the main texture for the effect layer.
  54027. */
  54028. protected _createMainTexture(): void;
  54029. /**
  54030. * Adds specific effects defines.
  54031. * @param defines The defines to add specifics to.
  54032. */
  54033. protected _addCustomEffectDefines(defines: string[]): void;
  54034. /**
  54035. * Checks for the readiness of the element composing the layer.
  54036. * @param subMesh the mesh to check for
  54037. * @param useInstances specify wether or not to use instances to render the mesh
  54038. * @param emissiveTexture the associated emissive texture used to generate the glow
  54039. * @return true if ready otherwise, false
  54040. */
  54041. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54042. /**
  54043. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54044. */
  54045. render(): void;
  54046. /**
  54047. * Determine if a given mesh will be used in the current effect.
  54048. * @param mesh mesh to test
  54049. * @returns true if the mesh will be used
  54050. */
  54051. hasMesh(mesh: AbstractMesh): boolean;
  54052. /**
  54053. * Returns true if the layer contains information to display, otherwise false.
  54054. * @returns true if the glow layer should be rendered
  54055. */
  54056. shouldRender(): boolean;
  54057. /**
  54058. * Returns true if the mesh should render, otherwise false.
  54059. * @param mesh The mesh to render
  54060. * @returns true if it should render otherwise false
  54061. */
  54062. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54063. /**
  54064. * Returns true if the mesh can be rendered, otherwise false.
  54065. * @param mesh The mesh to render
  54066. * @param material The material used on the mesh
  54067. * @returns true if it can be rendered otherwise false
  54068. */
  54069. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54070. /**
  54071. * Returns true if the mesh should render, otherwise false.
  54072. * @param mesh The mesh to render
  54073. * @returns true if it should render otherwise false
  54074. */
  54075. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54076. /**
  54077. * Renders the submesh passed in parameter to the generation map.
  54078. */
  54079. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54080. /**
  54081. * Defines wether the current material of the mesh should be use to render the effect.
  54082. * @param mesh defines the current mesh to render
  54083. */
  54084. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54085. /**
  54086. * Rebuild the required buffers.
  54087. * @hidden Internal use only.
  54088. */
  54089. _rebuild(): void;
  54090. /**
  54091. * Dispose only the render target textures and post process.
  54092. */
  54093. private _disposeTextureAndPostProcesses;
  54094. /**
  54095. * Dispose the highlight layer and free resources.
  54096. */
  54097. dispose(): void;
  54098. /**
  54099. * Gets the class name of the effect layer
  54100. * @returns the string with the class name of the effect layer
  54101. */
  54102. getClassName(): string;
  54103. /**
  54104. * Creates an effect layer from parsed effect layer data
  54105. * @param parsedEffectLayer defines effect layer data
  54106. * @param scene defines the current scene
  54107. * @param rootUrl defines the root URL containing the effect layer information
  54108. * @returns a parsed effect Layer
  54109. */
  54110. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54111. }
  54112. }
  54113. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54114. import { Scene } from "babylonjs/scene";
  54115. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54116. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54117. import { AbstractScene } from "babylonjs/abstractScene";
  54118. module "babylonjs/abstractScene" {
  54119. interface AbstractScene {
  54120. /**
  54121. * The list of effect layers (highlights/glow) added to the scene
  54122. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54123. * @see http://doc.babylonjs.com/how_to/glow_layer
  54124. */
  54125. effectLayers: Array<EffectLayer>;
  54126. /**
  54127. * Removes the given effect layer from this scene.
  54128. * @param toRemove defines the effect layer to remove
  54129. * @returns the index of the removed effect layer
  54130. */
  54131. removeEffectLayer(toRemove: EffectLayer): number;
  54132. /**
  54133. * Adds the given effect layer to this scene
  54134. * @param newEffectLayer defines the effect layer to add
  54135. */
  54136. addEffectLayer(newEffectLayer: EffectLayer): void;
  54137. }
  54138. }
  54139. /**
  54140. * Defines the layer scene component responsible to manage any effect layers
  54141. * in a given scene.
  54142. */
  54143. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54144. /**
  54145. * The component name helpfull to identify the component in the list of scene components.
  54146. */
  54147. readonly name: string;
  54148. /**
  54149. * The scene the component belongs to.
  54150. */
  54151. scene: Scene;
  54152. private _engine;
  54153. private _renderEffects;
  54154. private _needStencil;
  54155. private _previousStencilState;
  54156. /**
  54157. * Creates a new instance of the component for the given scene
  54158. * @param scene Defines the scene to register the component in
  54159. */
  54160. constructor(scene: Scene);
  54161. /**
  54162. * Registers the component in a given scene
  54163. */
  54164. register(): void;
  54165. /**
  54166. * Rebuilds the elements related to this component in case of
  54167. * context lost for instance.
  54168. */
  54169. rebuild(): void;
  54170. /**
  54171. * Serializes the component data to the specified json object
  54172. * @param serializationObject The object to serialize to
  54173. */
  54174. serialize(serializationObject: any): void;
  54175. /**
  54176. * Adds all the elements from the container to the scene
  54177. * @param container the container holding the elements
  54178. */
  54179. addFromContainer(container: AbstractScene): void;
  54180. /**
  54181. * Removes all the elements in the container from the scene
  54182. * @param container contains the elements to remove
  54183. * @param dispose if the removed element should be disposed (default: false)
  54184. */
  54185. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54186. /**
  54187. * Disposes the component and the associated ressources.
  54188. */
  54189. dispose(): void;
  54190. private _isReadyForMesh;
  54191. private _renderMainTexture;
  54192. private _setStencil;
  54193. private _setStencilBack;
  54194. private _draw;
  54195. private _drawCamera;
  54196. private _drawRenderingGroup;
  54197. }
  54198. }
  54199. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  54200. /** @hidden */
  54201. export var glowMapMergePixelShader: {
  54202. name: string;
  54203. shader: string;
  54204. };
  54205. }
  54206. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  54207. /** @hidden */
  54208. export var glowMapMergeVertexShader: {
  54209. name: string;
  54210. shader: string;
  54211. };
  54212. }
  54213. declare module "babylonjs/Layers/glowLayer" {
  54214. import { Nullable } from "babylonjs/types";
  54215. import { Camera } from "babylonjs/Cameras/camera";
  54216. import { Scene } from "babylonjs/scene";
  54217. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54219. import { Mesh } from "babylonjs/Meshes/mesh";
  54220. import { Texture } from "babylonjs/Materials/Textures/texture";
  54221. import { Effect } from "babylonjs/Materials/effect";
  54222. import { Material } from "babylonjs/Materials/material";
  54223. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54224. import { Color4 } from "babylonjs/Maths/math.color";
  54225. import "babylonjs/Shaders/glowMapMerge.fragment";
  54226. import "babylonjs/Shaders/glowMapMerge.vertex";
  54227. import "babylonjs/Layers/effectLayerSceneComponent";
  54228. module "babylonjs/abstractScene" {
  54229. interface AbstractScene {
  54230. /**
  54231. * Return a the first highlight layer of the scene with a given name.
  54232. * @param name The name of the highlight layer to look for.
  54233. * @return The highlight layer if found otherwise null.
  54234. */
  54235. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  54236. }
  54237. }
  54238. /**
  54239. * Glow layer options. This helps customizing the behaviour
  54240. * of the glow layer.
  54241. */
  54242. export interface IGlowLayerOptions {
  54243. /**
  54244. * Multiplication factor apply to the canvas size to compute the render target size
  54245. * used to generated the glowing objects (the smaller the faster).
  54246. */
  54247. mainTextureRatio: number;
  54248. /**
  54249. * Enforces a fixed size texture to ensure resize independant blur.
  54250. */
  54251. mainTextureFixedSize?: number;
  54252. /**
  54253. * How big is the kernel of the blur texture.
  54254. */
  54255. blurKernelSize: number;
  54256. /**
  54257. * The camera attached to the layer.
  54258. */
  54259. camera: Nullable<Camera>;
  54260. /**
  54261. * Enable MSAA by chosing the number of samples.
  54262. */
  54263. mainTextureSamples?: number;
  54264. /**
  54265. * The rendering group to draw the layer in.
  54266. */
  54267. renderingGroupId: number;
  54268. }
  54269. /**
  54270. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  54271. *
  54272. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  54273. *
  54274. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  54275. */
  54276. export class GlowLayer extends EffectLayer {
  54277. /**
  54278. * Effect Name of the layer.
  54279. */
  54280. static readonly EffectName: string;
  54281. /**
  54282. * The default blur kernel size used for the glow.
  54283. */
  54284. static DefaultBlurKernelSize: number;
  54285. /**
  54286. * The default texture size ratio used for the glow.
  54287. */
  54288. static DefaultTextureRatio: number;
  54289. /**
  54290. * Sets the kernel size of the blur.
  54291. */
  54292. set blurKernelSize(value: number);
  54293. /**
  54294. * Gets the kernel size of the blur.
  54295. */
  54296. get blurKernelSize(): number;
  54297. /**
  54298. * Sets the glow intensity.
  54299. */
  54300. set intensity(value: number);
  54301. /**
  54302. * Gets the glow intensity.
  54303. */
  54304. get intensity(): number;
  54305. private _options;
  54306. private _intensity;
  54307. private _horizontalBlurPostprocess1;
  54308. private _verticalBlurPostprocess1;
  54309. private _horizontalBlurPostprocess2;
  54310. private _verticalBlurPostprocess2;
  54311. private _blurTexture1;
  54312. private _blurTexture2;
  54313. private _postProcesses1;
  54314. private _postProcesses2;
  54315. private _includedOnlyMeshes;
  54316. private _excludedMeshes;
  54317. private _meshesUsingTheirOwnMaterials;
  54318. /**
  54319. * Callback used to let the user override the color selection on a per mesh basis
  54320. */
  54321. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  54322. /**
  54323. * Callback used to let the user override the texture selection on a per mesh basis
  54324. */
  54325. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  54326. /**
  54327. * Instantiates a new glow Layer and references it to the scene.
  54328. * @param name The name of the layer
  54329. * @param scene The scene to use the layer in
  54330. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  54331. */
  54332. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  54333. /**
  54334. * Get the effect name of the layer.
  54335. * @return The effect name
  54336. */
  54337. getEffectName(): string;
  54338. /**
  54339. * Create the merge effect. This is the shader use to blit the information back
  54340. * to the main canvas at the end of the scene rendering.
  54341. */
  54342. protected _createMergeEffect(): Effect;
  54343. /**
  54344. * Creates the render target textures and post processes used in the glow layer.
  54345. */
  54346. protected _createTextureAndPostProcesses(): void;
  54347. /**
  54348. * Checks for the readiness of the element composing the layer.
  54349. * @param subMesh the mesh to check for
  54350. * @param useInstances specify wether or not to use instances to render the mesh
  54351. * @param emissiveTexture the associated emissive texture used to generate the glow
  54352. * @return true if ready otherwise, false
  54353. */
  54354. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54355. /**
  54356. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54357. */
  54358. needStencil(): boolean;
  54359. /**
  54360. * Returns true if the mesh can be rendered, otherwise false.
  54361. * @param mesh The mesh to render
  54362. * @param material The material used on the mesh
  54363. * @returns true if it can be rendered otherwise false
  54364. */
  54365. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54366. /**
  54367. * Implementation specific of rendering the generating effect on the main canvas.
  54368. * @param effect The effect used to render through
  54369. */
  54370. protected _internalRender(effect: Effect): void;
  54371. /**
  54372. * Sets the required values for both the emissive texture and and the main color.
  54373. */
  54374. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54375. /**
  54376. * Returns true if the mesh should render, otherwise false.
  54377. * @param mesh The mesh to render
  54378. * @returns true if it should render otherwise false
  54379. */
  54380. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54381. /**
  54382. * Adds specific effects defines.
  54383. * @param defines The defines to add specifics to.
  54384. */
  54385. protected _addCustomEffectDefines(defines: string[]): void;
  54386. /**
  54387. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54388. * @param mesh The mesh to exclude from the glow layer
  54389. */
  54390. addExcludedMesh(mesh: Mesh): void;
  54391. /**
  54392. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54393. * @param mesh The mesh to remove
  54394. */
  54395. removeExcludedMesh(mesh: Mesh): void;
  54396. /**
  54397. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54398. * @param mesh The mesh to include in the glow layer
  54399. */
  54400. addIncludedOnlyMesh(mesh: Mesh): void;
  54401. /**
  54402. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54403. * @param mesh The mesh to remove
  54404. */
  54405. removeIncludedOnlyMesh(mesh: Mesh): void;
  54406. /**
  54407. * Determine if a given mesh will be used in the glow layer
  54408. * @param mesh The mesh to test
  54409. * @returns true if the mesh will be highlighted by the current glow layer
  54410. */
  54411. hasMesh(mesh: AbstractMesh): boolean;
  54412. /**
  54413. * Defines wether the current material of the mesh should be use to render the effect.
  54414. * @param mesh defines the current mesh to render
  54415. */
  54416. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54417. /**
  54418. * Add a mesh to be rendered through its own material and not with emissive only.
  54419. * @param mesh The mesh for which we need to use its material
  54420. */
  54421. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54422. /**
  54423. * Remove a mesh from being rendered through its own material and not with emissive only.
  54424. * @param mesh The mesh for which we need to not use its material
  54425. */
  54426. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54427. /**
  54428. * Free any resources and references associated to a mesh.
  54429. * Internal use
  54430. * @param mesh The mesh to free.
  54431. * @hidden
  54432. */
  54433. _disposeMesh(mesh: Mesh): void;
  54434. /**
  54435. * Gets the class name of the effect layer
  54436. * @returns the string with the class name of the effect layer
  54437. */
  54438. getClassName(): string;
  54439. /**
  54440. * Serializes this glow layer
  54441. * @returns a serialized glow layer object
  54442. */
  54443. serialize(): any;
  54444. /**
  54445. * Creates a Glow Layer from parsed glow layer data
  54446. * @param parsedGlowLayer defines glow layer data
  54447. * @param scene defines the current scene
  54448. * @param rootUrl defines the root URL containing the glow layer information
  54449. * @returns a parsed Glow Layer
  54450. */
  54451. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54452. }
  54453. }
  54454. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  54455. /** @hidden */
  54456. export var glowBlurPostProcessPixelShader: {
  54457. name: string;
  54458. shader: string;
  54459. };
  54460. }
  54461. declare module "babylonjs/Layers/highlightLayer" {
  54462. import { Observable } from "babylonjs/Misc/observable";
  54463. import { Nullable } from "babylonjs/types";
  54464. import { Camera } from "babylonjs/Cameras/camera";
  54465. import { Scene } from "babylonjs/scene";
  54466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54468. import { Mesh } from "babylonjs/Meshes/mesh";
  54469. import { Effect } from "babylonjs/Materials/effect";
  54470. import { Material } from "babylonjs/Materials/material";
  54471. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54472. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  54473. import "babylonjs/Shaders/glowMapMerge.fragment";
  54474. import "babylonjs/Shaders/glowMapMerge.vertex";
  54475. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  54476. module "babylonjs/abstractScene" {
  54477. interface AbstractScene {
  54478. /**
  54479. * Return a the first highlight layer of the scene with a given name.
  54480. * @param name The name of the highlight layer to look for.
  54481. * @return The highlight layer if found otherwise null.
  54482. */
  54483. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54484. }
  54485. }
  54486. /**
  54487. * Highlight layer options. This helps customizing the behaviour
  54488. * of the highlight layer.
  54489. */
  54490. export interface IHighlightLayerOptions {
  54491. /**
  54492. * Multiplication factor apply to the canvas size to compute the render target size
  54493. * used to generated the glowing objects (the smaller the faster).
  54494. */
  54495. mainTextureRatio: number;
  54496. /**
  54497. * Enforces a fixed size texture to ensure resize independant blur.
  54498. */
  54499. mainTextureFixedSize?: number;
  54500. /**
  54501. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54502. * of the picture to blur (the smaller the faster).
  54503. */
  54504. blurTextureSizeRatio: number;
  54505. /**
  54506. * How big in texel of the blur texture is the vertical blur.
  54507. */
  54508. blurVerticalSize: number;
  54509. /**
  54510. * How big in texel of the blur texture is the horizontal blur.
  54511. */
  54512. blurHorizontalSize: number;
  54513. /**
  54514. * Alpha blending mode used to apply the blur. Default is combine.
  54515. */
  54516. alphaBlendingMode: number;
  54517. /**
  54518. * The camera attached to the layer.
  54519. */
  54520. camera: Nullable<Camera>;
  54521. /**
  54522. * Should we display highlight as a solid stroke?
  54523. */
  54524. isStroke?: boolean;
  54525. /**
  54526. * The rendering group to draw the layer in.
  54527. */
  54528. renderingGroupId: number;
  54529. }
  54530. /**
  54531. * The highlight layer Helps adding a glow effect around a mesh.
  54532. *
  54533. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54534. * glowy meshes to your scene.
  54535. *
  54536. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54537. */
  54538. export class HighlightLayer extends EffectLayer {
  54539. name: string;
  54540. /**
  54541. * Effect Name of the highlight layer.
  54542. */
  54543. static readonly EffectName: string;
  54544. /**
  54545. * The neutral color used during the preparation of the glow effect.
  54546. * This is black by default as the blend operation is a blend operation.
  54547. */
  54548. static NeutralColor: Color4;
  54549. /**
  54550. * Stencil value used for glowing meshes.
  54551. */
  54552. static GlowingMeshStencilReference: number;
  54553. /**
  54554. * Stencil value used for the other meshes in the scene.
  54555. */
  54556. static NormalMeshStencilReference: number;
  54557. /**
  54558. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54559. */
  54560. innerGlow: boolean;
  54561. /**
  54562. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54563. */
  54564. outerGlow: boolean;
  54565. /**
  54566. * Specifies the horizontal size of the blur.
  54567. */
  54568. set blurHorizontalSize(value: number);
  54569. /**
  54570. * Specifies the vertical size of the blur.
  54571. */
  54572. set blurVerticalSize(value: number);
  54573. /**
  54574. * Gets the horizontal size of the blur.
  54575. */
  54576. get blurHorizontalSize(): number;
  54577. /**
  54578. * Gets the vertical size of the blur.
  54579. */
  54580. get blurVerticalSize(): number;
  54581. /**
  54582. * An event triggered when the highlight layer is being blurred.
  54583. */
  54584. onBeforeBlurObservable: Observable<HighlightLayer>;
  54585. /**
  54586. * An event triggered when the highlight layer has been blurred.
  54587. */
  54588. onAfterBlurObservable: Observable<HighlightLayer>;
  54589. private _instanceGlowingMeshStencilReference;
  54590. private _options;
  54591. private _downSamplePostprocess;
  54592. private _horizontalBlurPostprocess;
  54593. private _verticalBlurPostprocess;
  54594. private _blurTexture;
  54595. private _meshes;
  54596. private _excludedMeshes;
  54597. /**
  54598. * Instantiates a new highlight Layer and references it to the scene..
  54599. * @param name The name of the layer
  54600. * @param scene The scene to use the layer in
  54601. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54602. */
  54603. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54604. /**
  54605. * Get the effect name of the layer.
  54606. * @return The effect name
  54607. */
  54608. getEffectName(): string;
  54609. /**
  54610. * Create the merge effect. This is the shader use to blit the information back
  54611. * to the main canvas at the end of the scene rendering.
  54612. */
  54613. protected _createMergeEffect(): Effect;
  54614. /**
  54615. * Creates the render target textures and post processes used in the highlight layer.
  54616. */
  54617. protected _createTextureAndPostProcesses(): void;
  54618. /**
  54619. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54620. */
  54621. needStencil(): boolean;
  54622. /**
  54623. * Checks for the readiness of the element composing the layer.
  54624. * @param subMesh the mesh to check for
  54625. * @param useInstances specify wether or not to use instances to render the mesh
  54626. * @param emissiveTexture the associated emissive texture used to generate the glow
  54627. * @return true if ready otherwise, false
  54628. */
  54629. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54630. /**
  54631. * Implementation specific of rendering the generating effect on the main canvas.
  54632. * @param effect The effect used to render through
  54633. */
  54634. protected _internalRender(effect: Effect): void;
  54635. /**
  54636. * Returns true if the layer contains information to display, otherwise false.
  54637. */
  54638. shouldRender(): boolean;
  54639. /**
  54640. * Returns true if the mesh should render, otherwise false.
  54641. * @param mesh The mesh to render
  54642. * @returns true if it should render otherwise false
  54643. */
  54644. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54645. /**
  54646. * Sets the required values for both the emissive texture and and the main color.
  54647. */
  54648. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54649. /**
  54650. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54651. * @param mesh The mesh to exclude from the highlight layer
  54652. */
  54653. addExcludedMesh(mesh: Mesh): void;
  54654. /**
  54655. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54656. * @param mesh The mesh to highlight
  54657. */
  54658. removeExcludedMesh(mesh: Mesh): void;
  54659. /**
  54660. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54661. * @param mesh mesh to test
  54662. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54663. */
  54664. hasMesh(mesh: AbstractMesh): boolean;
  54665. /**
  54666. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54667. * @param mesh The mesh to highlight
  54668. * @param color The color of the highlight
  54669. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54670. */
  54671. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54672. /**
  54673. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54674. * @param mesh The mesh to highlight
  54675. */
  54676. removeMesh(mesh: Mesh): void;
  54677. /**
  54678. * Force the stencil to the normal expected value for none glowing parts
  54679. */
  54680. private _defaultStencilReference;
  54681. /**
  54682. * Free any resources and references associated to a mesh.
  54683. * Internal use
  54684. * @param mesh The mesh to free.
  54685. * @hidden
  54686. */
  54687. _disposeMesh(mesh: Mesh): void;
  54688. /**
  54689. * Dispose the highlight layer and free resources.
  54690. */
  54691. dispose(): void;
  54692. /**
  54693. * Gets the class name of the effect layer
  54694. * @returns the string with the class name of the effect layer
  54695. */
  54696. getClassName(): string;
  54697. /**
  54698. * Serializes this Highlight layer
  54699. * @returns a serialized Highlight layer object
  54700. */
  54701. serialize(): any;
  54702. /**
  54703. * Creates a Highlight layer from parsed Highlight layer data
  54704. * @param parsedHightlightLayer defines the Highlight layer data
  54705. * @param scene defines the current scene
  54706. * @param rootUrl defines the root URL containing the Highlight layer information
  54707. * @returns a parsed Highlight layer
  54708. */
  54709. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54710. }
  54711. }
  54712. declare module "babylonjs/Layers/layerSceneComponent" {
  54713. import { Scene } from "babylonjs/scene";
  54714. import { ISceneComponent } from "babylonjs/sceneComponent";
  54715. import { Layer } from "babylonjs/Layers/layer";
  54716. import { AbstractScene } from "babylonjs/abstractScene";
  54717. module "babylonjs/abstractScene" {
  54718. interface AbstractScene {
  54719. /**
  54720. * The list of layers (background and foreground) of the scene
  54721. */
  54722. layers: Array<Layer>;
  54723. }
  54724. }
  54725. /**
  54726. * Defines the layer scene component responsible to manage any layers
  54727. * in a given scene.
  54728. */
  54729. export class LayerSceneComponent implements ISceneComponent {
  54730. /**
  54731. * The component name helpfull to identify the component in the list of scene components.
  54732. */
  54733. readonly name: string;
  54734. /**
  54735. * The scene the component belongs to.
  54736. */
  54737. scene: Scene;
  54738. private _engine;
  54739. /**
  54740. * Creates a new instance of the component for the given scene
  54741. * @param scene Defines the scene to register the component in
  54742. */
  54743. constructor(scene: Scene);
  54744. /**
  54745. * Registers the component in a given scene
  54746. */
  54747. register(): void;
  54748. /**
  54749. * Rebuilds the elements related to this component in case of
  54750. * context lost for instance.
  54751. */
  54752. rebuild(): void;
  54753. /**
  54754. * Disposes the component and the associated ressources.
  54755. */
  54756. dispose(): void;
  54757. private _draw;
  54758. private _drawCameraPredicate;
  54759. private _drawCameraBackground;
  54760. private _drawCameraForeground;
  54761. private _drawRenderTargetPredicate;
  54762. private _drawRenderTargetBackground;
  54763. private _drawRenderTargetForeground;
  54764. /**
  54765. * Adds all the elements from the container to the scene
  54766. * @param container the container holding the elements
  54767. */
  54768. addFromContainer(container: AbstractScene): void;
  54769. /**
  54770. * Removes all the elements in the container from the scene
  54771. * @param container contains the elements to remove
  54772. * @param dispose if the removed element should be disposed (default: false)
  54773. */
  54774. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54775. }
  54776. }
  54777. declare module "babylonjs/Shaders/layer.fragment" {
  54778. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54779. /** @hidden */
  54780. export var layerPixelShader: {
  54781. name: string;
  54782. shader: string;
  54783. };
  54784. }
  54785. declare module "babylonjs/Shaders/layer.vertex" {
  54786. /** @hidden */
  54787. export var layerVertexShader: {
  54788. name: string;
  54789. shader: string;
  54790. };
  54791. }
  54792. declare module "babylonjs/Layers/layer" {
  54793. import { Observable } from "babylonjs/Misc/observable";
  54794. import { Nullable } from "babylonjs/types";
  54795. import { Scene } from "babylonjs/scene";
  54796. import { Vector2 } from "babylonjs/Maths/math.vector";
  54797. import { Color4 } from "babylonjs/Maths/math.color";
  54798. import { Texture } from "babylonjs/Materials/Textures/texture";
  54799. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54800. import "babylonjs/Shaders/layer.fragment";
  54801. import "babylonjs/Shaders/layer.vertex";
  54802. /**
  54803. * This represents a full screen 2d layer.
  54804. * This can be useful to display a picture in the background of your scene for instance.
  54805. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54806. */
  54807. export class Layer {
  54808. /**
  54809. * Define the name of the layer.
  54810. */
  54811. name: string;
  54812. /**
  54813. * Define the texture the layer should display.
  54814. */
  54815. texture: Nullable<Texture>;
  54816. /**
  54817. * Is the layer in background or foreground.
  54818. */
  54819. isBackground: boolean;
  54820. /**
  54821. * Define the color of the layer (instead of texture).
  54822. */
  54823. color: Color4;
  54824. /**
  54825. * Define the scale of the layer in order to zoom in out of the texture.
  54826. */
  54827. scale: Vector2;
  54828. /**
  54829. * Define an offset for the layer in order to shift the texture.
  54830. */
  54831. offset: Vector2;
  54832. /**
  54833. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54834. */
  54835. alphaBlendingMode: number;
  54836. /**
  54837. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54838. * Alpha test will not mix with the background color in case of transparency.
  54839. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54840. */
  54841. alphaTest: boolean;
  54842. /**
  54843. * Define a mask to restrict the layer to only some of the scene cameras.
  54844. */
  54845. layerMask: number;
  54846. /**
  54847. * Define the list of render target the layer is visible into.
  54848. */
  54849. renderTargetTextures: RenderTargetTexture[];
  54850. /**
  54851. * Define if the layer is only used in renderTarget or if it also
  54852. * renders in the main frame buffer of the canvas.
  54853. */
  54854. renderOnlyInRenderTargetTextures: boolean;
  54855. private _scene;
  54856. private _vertexBuffers;
  54857. private _indexBuffer;
  54858. private _effect;
  54859. private _previousDefines;
  54860. /**
  54861. * An event triggered when the layer is disposed.
  54862. */
  54863. onDisposeObservable: Observable<Layer>;
  54864. private _onDisposeObserver;
  54865. /**
  54866. * Back compatibility with callback before the onDisposeObservable existed.
  54867. * The set callback will be triggered when the layer has been disposed.
  54868. */
  54869. set onDispose(callback: () => void);
  54870. /**
  54871. * An event triggered before rendering the scene
  54872. */
  54873. onBeforeRenderObservable: Observable<Layer>;
  54874. private _onBeforeRenderObserver;
  54875. /**
  54876. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54877. * The set callback will be triggered just before rendering the layer.
  54878. */
  54879. set onBeforeRender(callback: () => void);
  54880. /**
  54881. * An event triggered after rendering the scene
  54882. */
  54883. onAfterRenderObservable: Observable<Layer>;
  54884. private _onAfterRenderObserver;
  54885. /**
  54886. * Back compatibility with callback before the onAfterRenderObservable existed.
  54887. * The set callback will be triggered just after rendering the layer.
  54888. */
  54889. set onAfterRender(callback: () => void);
  54890. /**
  54891. * Instantiates a new layer.
  54892. * This represents a full screen 2d layer.
  54893. * This can be useful to display a picture in the background of your scene for instance.
  54894. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54895. * @param name Define the name of the layer in the scene
  54896. * @param imgUrl Define the url of the texture to display in the layer
  54897. * @param scene Define the scene the layer belongs to
  54898. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54899. * @param color Defines a color for the layer
  54900. */
  54901. constructor(
  54902. /**
  54903. * Define the name of the layer.
  54904. */
  54905. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54906. private _createIndexBuffer;
  54907. /** @hidden */
  54908. _rebuild(): void;
  54909. /**
  54910. * Renders the layer in the scene.
  54911. */
  54912. render(): void;
  54913. /**
  54914. * Disposes and releases the associated ressources.
  54915. */
  54916. dispose(): void;
  54917. }
  54918. }
  54919. declare module "babylonjs/Layers/index" {
  54920. export * from "babylonjs/Layers/effectLayer";
  54921. export * from "babylonjs/Layers/effectLayerSceneComponent";
  54922. export * from "babylonjs/Layers/glowLayer";
  54923. export * from "babylonjs/Layers/highlightLayer";
  54924. export * from "babylonjs/Layers/layer";
  54925. export * from "babylonjs/Layers/layerSceneComponent";
  54926. }
  54927. declare module "babylonjs/Shaders/lensFlare.fragment" {
  54928. /** @hidden */
  54929. export var lensFlarePixelShader: {
  54930. name: string;
  54931. shader: string;
  54932. };
  54933. }
  54934. declare module "babylonjs/Shaders/lensFlare.vertex" {
  54935. /** @hidden */
  54936. export var lensFlareVertexShader: {
  54937. name: string;
  54938. shader: string;
  54939. };
  54940. }
  54941. declare module "babylonjs/LensFlares/lensFlareSystem" {
  54942. import { Scene } from "babylonjs/scene";
  54943. import { Vector3 } from "babylonjs/Maths/math.vector";
  54944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54945. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  54946. import "babylonjs/Shaders/lensFlare.fragment";
  54947. import "babylonjs/Shaders/lensFlare.vertex";
  54948. import { Viewport } from "babylonjs/Maths/math.viewport";
  54949. /**
  54950. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54951. * It is usually composed of several `lensFlare`.
  54952. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54953. */
  54954. export class LensFlareSystem {
  54955. /**
  54956. * Define the name of the lens flare system
  54957. */
  54958. name: string;
  54959. /**
  54960. * List of lens flares used in this system.
  54961. */
  54962. lensFlares: LensFlare[];
  54963. /**
  54964. * Define a limit from the border the lens flare can be visible.
  54965. */
  54966. borderLimit: number;
  54967. /**
  54968. * Define a viewport border we do not want to see the lens flare in.
  54969. */
  54970. viewportBorder: number;
  54971. /**
  54972. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54973. */
  54974. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54975. /**
  54976. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54977. */
  54978. layerMask: number;
  54979. /**
  54980. * Define the id of the lens flare system in the scene.
  54981. * (equal to name by default)
  54982. */
  54983. id: string;
  54984. private _scene;
  54985. private _emitter;
  54986. private _vertexBuffers;
  54987. private _indexBuffer;
  54988. private _effect;
  54989. private _positionX;
  54990. private _positionY;
  54991. private _isEnabled;
  54992. /** @hidden */
  54993. static _SceneComponentInitialization: (scene: Scene) => void;
  54994. /**
  54995. * Instantiates a lens flare system.
  54996. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54997. * It is usually composed of several `lensFlare`.
  54998. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54999. * @param name Define the name of the lens flare system in the scene
  55000. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55001. * @param scene Define the scene the lens flare system belongs to
  55002. */
  55003. constructor(
  55004. /**
  55005. * Define the name of the lens flare system
  55006. */
  55007. name: string, emitter: any, scene: Scene);
  55008. /**
  55009. * Define if the lens flare system is enabled.
  55010. */
  55011. get isEnabled(): boolean;
  55012. set isEnabled(value: boolean);
  55013. /**
  55014. * Get the scene the effects belongs to.
  55015. * @returns the scene holding the lens flare system
  55016. */
  55017. getScene(): Scene;
  55018. /**
  55019. * Get the emitter of the lens flare system.
  55020. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55021. * @returns the emitter of the lens flare system
  55022. */
  55023. getEmitter(): any;
  55024. /**
  55025. * Set the emitter of the lens flare system.
  55026. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55027. * @param newEmitter Define the new emitter of the system
  55028. */
  55029. setEmitter(newEmitter: any): void;
  55030. /**
  55031. * Get the lens flare system emitter position.
  55032. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55033. * @returns the position
  55034. */
  55035. getEmitterPosition(): Vector3;
  55036. /**
  55037. * @hidden
  55038. */
  55039. computeEffectivePosition(globalViewport: Viewport): boolean;
  55040. /** @hidden */
  55041. _isVisible(): boolean;
  55042. /**
  55043. * @hidden
  55044. */
  55045. render(): boolean;
  55046. /**
  55047. * Dispose and release the lens flare with its associated resources.
  55048. */
  55049. dispose(): void;
  55050. /**
  55051. * Parse a lens flare system from a JSON repressentation
  55052. * @param parsedLensFlareSystem Define the JSON to parse
  55053. * @param scene Define the scene the parsed system should be instantiated in
  55054. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55055. * @returns the parsed system
  55056. */
  55057. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55058. /**
  55059. * Serialize the current Lens Flare System into a JSON representation.
  55060. * @returns the serialized JSON
  55061. */
  55062. serialize(): any;
  55063. }
  55064. }
  55065. declare module "babylonjs/LensFlares/lensFlare" {
  55066. import { Nullable } from "babylonjs/types";
  55067. import { Color3 } from "babylonjs/Maths/math.color";
  55068. import { Texture } from "babylonjs/Materials/Textures/texture";
  55069. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55070. /**
  55071. * This represents one of the lens effect in a `lensFlareSystem`.
  55072. * It controls one of the indiviual texture used in the effect.
  55073. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55074. */
  55075. export class LensFlare {
  55076. /**
  55077. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55078. */
  55079. size: number;
  55080. /**
  55081. * 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.
  55082. */
  55083. position: number;
  55084. /**
  55085. * Define the lens color.
  55086. */
  55087. color: Color3;
  55088. /**
  55089. * Define the lens texture.
  55090. */
  55091. texture: Nullable<Texture>;
  55092. /**
  55093. * Define the alpha mode to render this particular lens.
  55094. */
  55095. alphaMode: number;
  55096. private _system;
  55097. /**
  55098. * Creates a new Lens Flare.
  55099. * This represents one of the lens effect in a `lensFlareSystem`.
  55100. * It controls one of the indiviual texture used in the effect.
  55101. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55102. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55103. * @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.
  55104. * @param color Define the lens color
  55105. * @param imgUrl Define the lens texture url
  55106. * @param system Define the `lensFlareSystem` this flare is part of
  55107. * @returns The newly created Lens Flare
  55108. */
  55109. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55110. /**
  55111. * Instantiates a new Lens Flare.
  55112. * This represents one of the lens effect in a `lensFlareSystem`.
  55113. * It controls one of the indiviual texture used in the effect.
  55114. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55115. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55116. * @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.
  55117. * @param color Define the lens color
  55118. * @param imgUrl Define the lens texture url
  55119. * @param system Define the `lensFlareSystem` this flare is part of
  55120. */
  55121. constructor(
  55122. /**
  55123. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55124. */
  55125. size: number,
  55126. /**
  55127. * 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.
  55128. */
  55129. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55130. /**
  55131. * Dispose and release the lens flare with its associated resources.
  55132. */
  55133. dispose(): void;
  55134. }
  55135. }
  55136. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55137. import { Nullable } from "babylonjs/types";
  55138. import { Scene } from "babylonjs/scene";
  55139. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55140. import { AbstractScene } from "babylonjs/abstractScene";
  55141. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55142. module "babylonjs/abstractScene" {
  55143. interface AbstractScene {
  55144. /**
  55145. * The list of lens flare system added to the scene
  55146. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55147. */
  55148. lensFlareSystems: Array<LensFlareSystem>;
  55149. /**
  55150. * Removes the given lens flare system from this scene.
  55151. * @param toRemove The lens flare system to remove
  55152. * @returns The index of the removed lens flare system
  55153. */
  55154. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55155. /**
  55156. * Adds the given lens flare system to this scene
  55157. * @param newLensFlareSystem The lens flare system to add
  55158. */
  55159. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  55160. /**
  55161. * Gets a lens flare system using its name
  55162. * @param name defines the name to look for
  55163. * @returns the lens flare system or null if not found
  55164. */
  55165. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  55166. /**
  55167. * Gets a lens flare system using its id
  55168. * @param id defines the id to look for
  55169. * @returns the lens flare system or null if not found
  55170. */
  55171. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  55172. }
  55173. }
  55174. /**
  55175. * Defines the lens flare scene component responsible to manage any lens flares
  55176. * in a given scene.
  55177. */
  55178. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  55179. /**
  55180. * The component name helpfull to identify the component in the list of scene components.
  55181. */
  55182. readonly name: string;
  55183. /**
  55184. * The scene the component belongs to.
  55185. */
  55186. scene: Scene;
  55187. /**
  55188. * Creates a new instance of the component for the given scene
  55189. * @param scene Defines the scene to register the component in
  55190. */
  55191. constructor(scene: Scene);
  55192. /**
  55193. * Registers the component in a given scene
  55194. */
  55195. register(): void;
  55196. /**
  55197. * Rebuilds the elements related to this component in case of
  55198. * context lost for instance.
  55199. */
  55200. rebuild(): void;
  55201. /**
  55202. * Adds all the elements from the container to the scene
  55203. * @param container the container holding the elements
  55204. */
  55205. addFromContainer(container: AbstractScene): void;
  55206. /**
  55207. * Removes all the elements in the container from the scene
  55208. * @param container contains the elements to remove
  55209. * @param dispose if the removed element should be disposed (default: false)
  55210. */
  55211. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55212. /**
  55213. * Serializes the component data to the specified json object
  55214. * @param serializationObject The object to serialize to
  55215. */
  55216. serialize(serializationObject: any): void;
  55217. /**
  55218. * Disposes the component and the associated ressources.
  55219. */
  55220. dispose(): void;
  55221. private _draw;
  55222. }
  55223. }
  55224. declare module "babylonjs/LensFlares/index" {
  55225. export * from "babylonjs/LensFlares/lensFlare";
  55226. export * from "babylonjs/LensFlares/lensFlareSystem";
  55227. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  55228. }
  55229. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  55230. import { Scene } from "babylonjs/scene";
  55231. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55232. import { AbstractScene } from "babylonjs/abstractScene";
  55233. /**
  55234. * Defines the shadow generator component responsible to manage any shadow generators
  55235. * in a given scene.
  55236. */
  55237. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55238. /**
  55239. * The component name helpfull to identify the component in the list of scene components.
  55240. */
  55241. readonly name: string;
  55242. /**
  55243. * The scene the component belongs to.
  55244. */
  55245. scene: Scene;
  55246. /**
  55247. * Creates a new instance of the component for the given scene
  55248. * @param scene Defines the scene to register the component in
  55249. */
  55250. constructor(scene: Scene);
  55251. /**
  55252. * Registers the component in a given scene
  55253. */
  55254. register(): void;
  55255. /**
  55256. * Rebuilds the elements related to this component in case of
  55257. * context lost for instance.
  55258. */
  55259. rebuild(): void;
  55260. /**
  55261. * Serializes the component data to the specified json object
  55262. * @param serializationObject The object to serialize to
  55263. */
  55264. serialize(serializationObject: any): void;
  55265. /**
  55266. * Adds all the elements from the container to the scene
  55267. * @param container the container holding the elements
  55268. */
  55269. addFromContainer(container: AbstractScene): void;
  55270. /**
  55271. * Removes all the elements in the container from the scene
  55272. * @param container contains the elements to remove
  55273. * @param dispose if the removed element should be disposed (default: false)
  55274. */
  55275. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55276. /**
  55277. * Rebuilds the elements related to this component in case of
  55278. * context lost for instance.
  55279. */
  55280. dispose(): void;
  55281. private _gatherRenderTargets;
  55282. }
  55283. }
  55284. declare module "babylonjs/Lights/Shadows/index" {
  55285. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  55286. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  55287. }
  55288. declare module "babylonjs/Lights/pointLight" {
  55289. import { Scene } from "babylonjs/scene";
  55290. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55292. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55293. import { Effect } from "babylonjs/Materials/effect";
  55294. /**
  55295. * A point light is a light defined by an unique point in world space.
  55296. * The light is emitted in every direction from this point.
  55297. * A good example of a point light is a standard light bulb.
  55298. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55299. */
  55300. export class PointLight extends ShadowLight {
  55301. private _shadowAngle;
  55302. /**
  55303. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55304. * This specifies what angle the shadow will use to be created.
  55305. *
  55306. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55307. */
  55308. get shadowAngle(): number;
  55309. /**
  55310. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55311. * This specifies what angle the shadow will use to be created.
  55312. *
  55313. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55314. */
  55315. set shadowAngle(value: number);
  55316. /**
  55317. * Gets the direction if it has been set.
  55318. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55319. */
  55320. get direction(): Vector3;
  55321. /**
  55322. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55323. */
  55324. set direction(value: Vector3);
  55325. /**
  55326. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55327. * A PointLight emits the light in every direction.
  55328. * It can cast shadows.
  55329. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55330. * ```javascript
  55331. * var pointLight = new PointLight("pl", camera.position, scene);
  55332. * ```
  55333. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55334. * @param name The light friendly name
  55335. * @param position The position of the point light in the scene
  55336. * @param scene The scene the lights belongs to
  55337. */
  55338. constructor(name: string, position: Vector3, scene: Scene);
  55339. /**
  55340. * Returns the string "PointLight"
  55341. * @returns the class name
  55342. */
  55343. getClassName(): string;
  55344. /**
  55345. * Returns the integer 0.
  55346. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55347. */
  55348. getTypeID(): number;
  55349. /**
  55350. * Specifies wether or not the shadowmap should be a cube texture.
  55351. * @returns true if the shadowmap needs to be a cube texture.
  55352. */
  55353. needCube(): boolean;
  55354. /**
  55355. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55356. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55357. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55358. */
  55359. getShadowDirection(faceIndex?: number): Vector3;
  55360. /**
  55361. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55362. * - fov = PI / 2
  55363. * - aspect ratio : 1.0
  55364. * - z-near and far equal to the active camera minZ and maxZ.
  55365. * Returns the PointLight.
  55366. */
  55367. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55368. protected _buildUniformLayout(): void;
  55369. /**
  55370. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55371. * @param effect The effect to update
  55372. * @param lightIndex The index of the light in the effect to update
  55373. * @returns The point light
  55374. */
  55375. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55376. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55377. /**
  55378. * Prepares the list of defines specific to the light type.
  55379. * @param defines the list of defines
  55380. * @param lightIndex defines the index of the light for the effect
  55381. */
  55382. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55383. }
  55384. }
  55385. declare module "babylonjs/Lights/index" {
  55386. export * from "babylonjs/Lights/light";
  55387. export * from "babylonjs/Lights/shadowLight";
  55388. export * from "babylonjs/Lights/Shadows/index";
  55389. export * from "babylonjs/Lights/directionalLight";
  55390. export * from "babylonjs/Lights/hemisphericLight";
  55391. export * from "babylonjs/Lights/pointLight";
  55392. export * from "babylonjs/Lights/spotLight";
  55393. }
  55394. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  55395. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55396. /**
  55397. * Header information of HDR texture files.
  55398. */
  55399. export interface HDRInfo {
  55400. /**
  55401. * The height of the texture in pixels.
  55402. */
  55403. height: number;
  55404. /**
  55405. * The width of the texture in pixels.
  55406. */
  55407. width: number;
  55408. /**
  55409. * The index of the beginning of the data in the binary file.
  55410. */
  55411. dataPosition: number;
  55412. }
  55413. /**
  55414. * This groups tools to convert HDR texture to native colors array.
  55415. */
  55416. export class HDRTools {
  55417. private static Ldexp;
  55418. private static Rgbe2float;
  55419. private static readStringLine;
  55420. /**
  55421. * Reads header information from an RGBE texture stored in a native array.
  55422. * More information on this format are available here:
  55423. * https://en.wikipedia.org/wiki/RGBE_image_format
  55424. *
  55425. * @param uint8array The binary file stored in native array.
  55426. * @return The header information.
  55427. */
  55428. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55429. /**
  55430. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55431. * This RGBE texture needs to store the information as a panorama.
  55432. *
  55433. * More information on this format are available here:
  55434. * https://en.wikipedia.org/wiki/RGBE_image_format
  55435. *
  55436. * @param buffer The binary file stored in an array buffer.
  55437. * @param size The expected size of the extracted cubemap.
  55438. * @return The Cube Map information.
  55439. */
  55440. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55441. /**
  55442. * Returns the pixels data extracted from an RGBE texture.
  55443. * This pixels will be stored left to right up to down in the R G B order in one array.
  55444. *
  55445. * More information on this format are available here:
  55446. * https://en.wikipedia.org/wiki/RGBE_image_format
  55447. *
  55448. * @param uint8array The binary file stored in an array buffer.
  55449. * @param hdrInfo The header information of the file.
  55450. * @return The pixels data in RGB right to left up to down order.
  55451. */
  55452. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55453. private static RGBE_ReadPixels_RLE;
  55454. }
  55455. }
  55456. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  55457. import { Nullable } from "babylonjs/types";
  55458. import { Scene } from "babylonjs/scene";
  55459. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55461. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55462. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  55463. /**
  55464. * This represents a texture coming from an HDR input.
  55465. *
  55466. * The only supported format is currently panorama picture stored in RGBE format.
  55467. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55468. */
  55469. export class HDRCubeTexture extends BaseTexture {
  55470. private static _facesMapping;
  55471. private _generateHarmonics;
  55472. private _noMipmap;
  55473. private _textureMatrix;
  55474. private _size;
  55475. private _onLoad;
  55476. private _onError;
  55477. /**
  55478. * The texture URL.
  55479. */
  55480. url: string;
  55481. /**
  55482. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55483. */
  55484. coordinatesMode: number;
  55485. protected _isBlocking: boolean;
  55486. /**
  55487. * Sets wether or not the texture is blocking during loading.
  55488. */
  55489. set isBlocking(value: boolean);
  55490. /**
  55491. * Gets wether or not the texture is blocking during loading.
  55492. */
  55493. get isBlocking(): boolean;
  55494. protected _rotationY: number;
  55495. /**
  55496. * Sets texture matrix rotation angle around Y axis in radians.
  55497. */
  55498. set rotationY(value: number);
  55499. /**
  55500. * Gets texture matrix rotation angle around Y axis radians.
  55501. */
  55502. get rotationY(): number;
  55503. /**
  55504. * Gets or sets the center of the bounding box associated with the cube texture
  55505. * It must define where the camera used to render the texture was set
  55506. */
  55507. boundingBoxPosition: Vector3;
  55508. private _boundingBoxSize;
  55509. /**
  55510. * Gets or sets the size of the bounding box associated with the cube texture
  55511. * When defined, the cubemap will switch to local mode
  55512. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55513. * @example https://www.babylonjs-playground.com/#RNASML
  55514. */
  55515. set boundingBoxSize(value: Vector3);
  55516. get boundingBoxSize(): Vector3;
  55517. /**
  55518. * Instantiates an HDRTexture from the following parameters.
  55519. *
  55520. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55521. * @param scene The scene the texture will be used in
  55522. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55523. * @param noMipmap Forces to not generate the mipmap if true
  55524. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55525. * @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)
  55526. * @param reserved Reserved flag for internal use.
  55527. */
  55528. 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>);
  55529. /**
  55530. * Get the current class name of the texture useful for serialization or dynamic coding.
  55531. * @returns "HDRCubeTexture"
  55532. */
  55533. getClassName(): string;
  55534. /**
  55535. * Occurs when the file is raw .hdr file.
  55536. */
  55537. private loadTexture;
  55538. clone(): HDRCubeTexture;
  55539. delayLoad(): void;
  55540. /**
  55541. * Get the texture reflection matrix used to rotate/transform the reflection.
  55542. * @returns the reflection matrix
  55543. */
  55544. getReflectionTextureMatrix(): Matrix;
  55545. /**
  55546. * Set the texture reflection matrix used to rotate/transform the reflection.
  55547. * @param value Define the reflection matrix to set
  55548. */
  55549. setReflectionTextureMatrix(value: Matrix): void;
  55550. /**
  55551. * Parses a JSON representation of an HDR Texture in order to create the texture
  55552. * @param parsedTexture Define the JSON representation
  55553. * @param scene Define the scene the texture should be created in
  55554. * @param rootUrl Define the root url in case we need to load relative dependencies
  55555. * @returns the newly created texture after parsing
  55556. */
  55557. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55558. serialize(): any;
  55559. }
  55560. }
  55561. declare module "babylonjs/Physics/physicsEngine" {
  55562. import { Nullable } from "babylonjs/types";
  55563. import { Vector3 } from "babylonjs/Maths/math.vector";
  55564. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  55565. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  55566. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  55567. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55568. /**
  55569. * Class used to control physics engine
  55570. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55571. */
  55572. export class PhysicsEngine implements IPhysicsEngine {
  55573. private _physicsPlugin;
  55574. /**
  55575. * Global value used to control the smallest number supported by the simulation
  55576. */
  55577. static Epsilon: number;
  55578. private _impostors;
  55579. private _joints;
  55580. private _subTimeStep;
  55581. /**
  55582. * Gets the gravity vector used by the simulation
  55583. */
  55584. gravity: Vector3;
  55585. /**
  55586. * Factory used to create the default physics plugin.
  55587. * @returns The default physics plugin
  55588. */
  55589. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55590. /**
  55591. * Creates a new Physics Engine
  55592. * @param gravity defines the gravity vector used by the simulation
  55593. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55594. */
  55595. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55596. /**
  55597. * Sets the gravity vector used by the simulation
  55598. * @param gravity defines the gravity vector to use
  55599. */
  55600. setGravity(gravity: Vector3): void;
  55601. /**
  55602. * Set the time step of the physics engine.
  55603. * Default is 1/60.
  55604. * To slow it down, enter 1/600 for example.
  55605. * To speed it up, 1/30
  55606. * @param newTimeStep defines the new timestep to apply to this world.
  55607. */
  55608. setTimeStep(newTimeStep?: number): void;
  55609. /**
  55610. * Get the time step of the physics engine.
  55611. * @returns the current time step
  55612. */
  55613. getTimeStep(): number;
  55614. /**
  55615. * Set the sub time step of the physics engine.
  55616. * Default is 0 meaning there is no sub steps
  55617. * To increase physics resolution precision, set a small value (like 1 ms)
  55618. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55619. */
  55620. setSubTimeStep(subTimeStep?: number): void;
  55621. /**
  55622. * Get the sub time step of the physics engine.
  55623. * @returns the current sub time step
  55624. */
  55625. getSubTimeStep(): number;
  55626. /**
  55627. * Release all resources
  55628. */
  55629. dispose(): void;
  55630. /**
  55631. * Gets the name of the current physics plugin
  55632. * @returns the name of the plugin
  55633. */
  55634. getPhysicsPluginName(): string;
  55635. /**
  55636. * Adding a new impostor for the impostor tracking.
  55637. * This will be done by the impostor itself.
  55638. * @param impostor the impostor to add
  55639. */
  55640. addImpostor(impostor: PhysicsImpostor): void;
  55641. /**
  55642. * Remove an impostor from the engine.
  55643. * This impostor and its mesh will not longer be updated by the physics engine.
  55644. * @param impostor the impostor to remove
  55645. */
  55646. removeImpostor(impostor: PhysicsImpostor): void;
  55647. /**
  55648. * Add a joint to the physics engine
  55649. * @param mainImpostor defines the main impostor to which the joint is added.
  55650. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55651. * @param joint defines the joint that will connect both impostors.
  55652. */
  55653. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55654. /**
  55655. * Removes a joint from the simulation
  55656. * @param mainImpostor defines the impostor used with the joint
  55657. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55658. * @param joint defines the joint to remove
  55659. */
  55660. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55661. /**
  55662. * Called by the scene. No need to call it.
  55663. * @param delta defines the timespam between frames
  55664. */
  55665. _step(delta: number): void;
  55666. /**
  55667. * Gets the current plugin used to run the simulation
  55668. * @returns current plugin
  55669. */
  55670. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55671. /**
  55672. * Gets the list of physic impostors
  55673. * @returns an array of PhysicsImpostor
  55674. */
  55675. getImpostors(): Array<PhysicsImpostor>;
  55676. /**
  55677. * Gets the impostor for a physics enabled object
  55678. * @param object defines the object impersonated by the impostor
  55679. * @returns the PhysicsImpostor or null if not found
  55680. */
  55681. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55682. /**
  55683. * Gets the impostor for a physics body object
  55684. * @param body defines physics body used by the impostor
  55685. * @returns the PhysicsImpostor or null if not found
  55686. */
  55687. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55688. /**
  55689. * Does a raycast in the physics world
  55690. * @param from when should the ray start?
  55691. * @param to when should the ray end?
  55692. * @returns PhysicsRaycastResult
  55693. */
  55694. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55695. }
  55696. }
  55697. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  55698. import { Nullable } from "babylonjs/types";
  55699. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55701. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55702. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55703. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55704. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55705. /** @hidden */
  55706. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55707. private _useDeltaForWorldStep;
  55708. world: any;
  55709. name: string;
  55710. private _physicsMaterials;
  55711. private _fixedTimeStep;
  55712. private _cannonRaycastResult;
  55713. private _raycastResult;
  55714. private _physicsBodysToRemoveAfterStep;
  55715. BJSCANNON: any;
  55716. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55717. setGravity(gravity: Vector3): void;
  55718. setTimeStep(timeStep: number): void;
  55719. getTimeStep(): number;
  55720. executeStep(delta: number): void;
  55721. private _removeMarkedPhysicsBodiesFromWorld;
  55722. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55723. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55724. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55725. private _processChildMeshes;
  55726. removePhysicsBody(impostor: PhysicsImpostor): void;
  55727. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55728. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55729. private _addMaterial;
  55730. private _checkWithEpsilon;
  55731. private _createShape;
  55732. private _createHeightmap;
  55733. private _minus90X;
  55734. private _plus90X;
  55735. private _tmpPosition;
  55736. private _tmpDeltaPosition;
  55737. private _tmpUnityRotation;
  55738. private _updatePhysicsBodyTransformation;
  55739. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55740. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55741. isSupported(): boolean;
  55742. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55743. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55744. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55745. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55746. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55747. getBodyMass(impostor: PhysicsImpostor): number;
  55748. getBodyFriction(impostor: PhysicsImpostor): number;
  55749. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55750. getBodyRestitution(impostor: PhysicsImpostor): number;
  55751. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55752. sleepBody(impostor: PhysicsImpostor): void;
  55753. wakeUpBody(impostor: PhysicsImpostor): void;
  55754. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55755. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55756. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55757. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55758. getRadius(impostor: PhysicsImpostor): number;
  55759. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55760. dispose(): void;
  55761. private _extendNamespace;
  55762. /**
  55763. * Does a raycast in the physics world
  55764. * @param from when should the ray start?
  55765. * @param to when should the ray end?
  55766. * @returns PhysicsRaycastResult
  55767. */
  55768. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55769. }
  55770. }
  55771. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  55772. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55773. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55774. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55776. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55777. import { Nullable } from "babylonjs/types";
  55778. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55779. /** @hidden */
  55780. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55781. world: any;
  55782. name: string;
  55783. BJSOIMO: any;
  55784. private _raycastResult;
  55785. constructor(iterations?: number, oimoInjection?: any);
  55786. setGravity(gravity: Vector3): void;
  55787. setTimeStep(timeStep: number): void;
  55788. getTimeStep(): number;
  55789. private _tmpImpostorsArray;
  55790. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55791. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55792. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55793. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55794. private _tmpPositionVector;
  55795. removePhysicsBody(impostor: PhysicsImpostor): void;
  55796. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55797. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55798. isSupported(): boolean;
  55799. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55800. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55801. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55802. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55803. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55804. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55805. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55806. getBodyMass(impostor: PhysicsImpostor): number;
  55807. getBodyFriction(impostor: PhysicsImpostor): number;
  55808. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55809. getBodyRestitution(impostor: PhysicsImpostor): number;
  55810. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55811. sleepBody(impostor: PhysicsImpostor): void;
  55812. wakeUpBody(impostor: PhysicsImpostor): void;
  55813. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55814. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55815. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55816. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55817. getRadius(impostor: PhysicsImpostor): number;
  55818. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55819. dispose(): void;
  55820. /**
  55821. * Does a raycast in the physics world
  55822. * @param from when should the ray start?
  55823. * @param to when should the ray end?
  55824. * @returns PhysicsRaycastResult
  55825. */
  55826. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55827. }
  55828. }
  55829. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  55830. import { Nullable } from "babylonjs/types";
  55831. import { Scene } from "babylonjs/scene";
  55832. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  55833. import { Color4 } from "babylonjs/Maths/math.color";
  55834. import { Mesh } from "babylonjs/Meshes/mesh";
  55835. /**
  55836. * Class containing static functions to help procedurally build meshes
  55837. */
  55838. export class RibbonBuilder {
  55839. /**
  55840. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55841. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55842. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55843. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55844. * * 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
  55845. * * 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
  55846. * * 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
  55847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55849. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55850. * * 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
  55851. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55852. * * 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
  55853. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55855. * @param name defines the name of the mesh
  55856. * @param options defines the options used to create the mesh
  55857. * @param scene defines the hosting scene
  55858. * @returns the ribbon mesh
  55859. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55860. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55861. */
  55862. static CreateRibbon(name: string, options: {
  55863. pathArray: Vector3[][];
  55864. closeArray?: boolean;
  55865. closePath?: boolean;
  55866. offset?: number;
  55867. updatable?: boolean;
  55868. sideOrientation?: number;
  55869. frontUVs?: Vector4;
  55870. backUVs?: Vector4;
  55871. instance?: Mesh;
  55872. invertUV?: boolean;
  55873. uvs?: Vector2[];
  55874. colors?: Color4[];
  55875. }, scene?: Nullable<Scene>): Mesh;
  55876. }
  55877. }
  55878. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  55879. import { Nullable } from "babylonjs/types";
  55880. import { Scene } from "babylonjs/scene";
  55881. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55882. import { Mesh } from "babylonjs/Meshes/mesh";
  55883. /**
  55884. * Class containing static functions to help procedurally build meshes
  55885. */
  55886. export class ShapeBuilder {
  55887. /**
  55888. * 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.
  55889. * * 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.
  55890. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55891. * * 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.
  55892. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55893. * * 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
  55894. * * 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
  55895. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55898. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55900. * @param name defines the name of the mesh
  55901. * @param options defines the options used to create the mesh
  55902. * @param scene defines the hosting scene
  55903. * @returns the extruded shape mesh
  55904. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55906. */
  55907. static ExtrudeShape(name: string, options: {
  55908. shape: Vector3[];
  55909. path: Vector3[];
  55910. scale?: number;
  55911. rotation?: number;
  55912. cap?: number;
  55913. updatable?: boolean;
  55914. sideOrientation?: number;
  55915. frontUVs?: Vector4;
  55916. backUVs?: Vector4;
  55917. instance?: Mesh;
  55918. invertUV?: boolean;
  55919. }, scene?: Nullable<Scene>): Mesh;
  55920. /**
  55921. * Creates an custom extruded shape mesh.
  55922. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55923. * * 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.
  55924. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55925. * * 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
  55926. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55927. * * 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
  55928. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55929. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55930. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55931. * * 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
  55932. * * 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
  55933. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55936. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55938. * @param name defines the name of the mesh
  55939. * @param options defines the options used to create the mesh
  55940. * @param scene defines the hosting scene
  55941. * @returns the custom extruded shape mesh
  55942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55943. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55945. */
  55946. static ExtrudeShapeCustom(name: string, options: {
  55947. shape: Vector3[];
  55948. path: Vector3[];
  55949. scaleFunction?: any;
  55950. rotationFunction?: any;
  55951. ribbonCloseArray?: boolean;
  55952. ribbonClosePath?: boolean;
  55953. cap?: number;
  55954. updatable?: boolean;
  55955. sideOrientation?: number;
  55956. frontUVs?: Vector4;
  55957. backUVs?: Vector4;
  55958. instance?: Mesh;
  55959. invertUV?: boolean;
  55960. }, scene?: Nullable<Scene>): Mesh;
  55961. private static _ExtrudeShapeGeneric;
  55962. }
  55963. }
  55964. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  55965. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  55966. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55967. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55968. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55969. import { Nullable } from "babylonjs/types";
  55970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55971. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55972. /**
  55973. * AmmoJS Physics plugin
  55974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55975. * @see https://github.com/kripken/ammo.js/
  55976. */
  55977. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55978. private _useDeltaForWorldStep;
  55979. /**
  55980. * Reference to the Ammo library
  55981. */
  55982. bjsAMMO: any;
  55983. /**
  55984. * Created ammoJS world which physics bodies are added to
  55985. */
  55986. world: any;
  55987. /**
  55988. * Name of the plugin
  55989. */
  55990. name: string;
  55991. private _timeStep;
  55992. private _fixedTimeStep;
  55993. private _maxSteps;
  55994. private _tmpQuaternion;
  55995. private _tmpAmmoTransform;
  55996. private _tmpAmmoQuaternion;
  55997. private _tmpAmmoConcreteContactResultCallback;
  55998. private _collisionConfiguration;
  55999. private _dispatcher;
  56000. private _overlappingPairCache;
  56001. private _solver;
  56002. private _softBodySolver;
  56003. private _tmpAmmoVectorA;
  56004. private _tmpAmmoVectorB;
  56005. private _tmpAmmoVectorC;
  56006. private _tmpAmmoVectorD;
  56007. private _tmpContactCallbackResult;
  56008. private _tmpAmmoVectorRCA;
  56009. private _tmpAmmoVectorRCB;
  56010. private _raycastResult;
  56011. private static readonly DISABLE_COLLISION_FLAG;
  56012. private static readonly KINEMATIC_FLAG;
  56013. private static readonly DISABLE_DEACTIVATION_FLAG;
  56014. /**
  56015. * Initializes the ammoJS plugin
  56016. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56017. * @param ammoInjection can be used to inject your own ammo reference
  56018. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56019. */
  56020. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56021. /**
  56022. * Sets the gravity of the physics world (m/(s^2))
  56023. * @param gravity Gravity to set
  56024. */
  56025. setGravity(gravity: Vector3): void;
  56026. /**
  56027. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56028. * @param timeStep timestep to use in seconds
  56029. */
  56030. setTimeStep(timeStep: number): void;
  56031. /**
  56032. * 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)
  56033. * @param fixedTimeStep fixedTimeStep to use in seconds
  56034. */
  56035. setFixedTimeStep(fixedTimeStep: number): void;
  56036. /**
  56037. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56038. * @param maxSteps the maximum number of steps by the physics engine per frame
  56039. */
  56040. setMaxSteps(maxSteps: number): void;
  56041. /**
  56042. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56043. * @returns the current timestep in seconds
  56044. */
  56045. getTimeStep(): number;
  56046. /**
  56047. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56048. */
  56049. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56050. private _isImpostorInContact;
  56051. private _isImpostorPairInContact;
  56052. private _stepSimulation;
  56053. /**
  56054. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56055. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56056. * After the step the babylon meshes are set to the position of the physics imposters
  56057. * @param delta amount of time to step forward
  56058. * @param impostors array of imposters to update before/after the step
  56059. */
  56060. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56061. /**
  56062. * Update babylon mesh to match physics world object
  56063. * @param impostor imposter to match
  56064. */
  56065. private _afterSoftStep;
  56066. /**
  56067. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56068. * @param impostor imposter to match
  56069. */
  56070. private _ropeStep;
  56071. /**
  56072. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56073. * @param impostor imposter to match
  56074. */
  56075. private _softbodyOrClothStep;
  56076. private _tmpVector;
  56077. private _tmpMatrix;
  56078. /**
  56079. * Applies an impulse on the imposter
  56080. * @param impostor imposter to apply impulse to
  56081. * @param force amount of force to be applied to the imposter
  56082. * @param contactPoint the location to apply the impulse on the imposter
  56083. */
  56084. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56085. /**
  56086. * Applies a force on the imposter
  56087. * @param impostor imposter to apply force
  56088. * @param force amount of force to be applied to the imposter
  56089. * @param contactPoint the location to apply the force on the imposter
  56090. */
  56091. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56092. /**
  56093. * Creates a physics body using the plugin
  56094. * @param impostor the imposter to create the physics body on
  56095. */
  56096. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56097. /**
  56098. * Removes the physics body from the imposter and disposes of the body's memory
  56099. * @param impostor imposter to remove the physics body from
  56100. */
  56101. removePhysicsBody(impostor: PhysicsImpostor): void;
  56102. /**
  56103. * Generates a joint
  56104. * @param impostorJoint the imposter joint to create the joint with
  56105. */
  56106. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56107. /**
  56108. * Removes a joint
  56109. * @param impostorJoint the imposter joint to remove the joint from
  56110. */
  56111. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56112. private _addMeshVerts;
  56113. /**
  56114. * Initialise the soft body vertices to match its object's (mesh) vertices
  56115. * Softbody vertices (nodes) are in world space and to match this
  56116. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56117. * @param impostor to create the softbody for
  56118. */
  56119. private _softVertexData;
  56120. /**
  56121. * Create an impostor's soft body
  56122. * @param impostor to create the softbody for
  56123. */
  56124. private _createSoftbody;
  56125. /**
  56126. * Create cloth for an impostor
  56127. * @param impostor to create the softbody for
  56128. */
  56129. private _createCloth;
  56130. /**
  56131. * Create rope for an impostor
  56132. * @param impostor to create the softbody for
  56133. */
  56134. private _createRope;
  56135. /**
  56136. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56137. * @param impostor to create the custom physics shape for
  56138. */
  56139. private _createCustom;
  56140. private _addHullVerts;
  56141. private _createShape;
  56142. /**
  56143. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56144. * @param impostor imposter containing the physics body and babylon object
  56145. */
  56146. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56147. /**
  56148. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56149. * @param impostor imposter containing the physics body and babylon object
  56150. * @param newPosition new position
  56151. * @param newRotation new rotation
  56152. */
  56153. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56154. /**
  56155. * If this plugin is supported
  56156. * @returns true if its supported
  56157. */
  56158. isSupported(): boolean;
  56159. /**
  56160. * Sets the linear velocity of the physics body
  56161. * @param impostor imposter to set the velocity on
  56162. * @param velocity velocity to set
  56163. */
  56164. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56165. /**
  56166. * Sets the angular velocity of the physics body
  56167. * @param impostor imposter to set the velocity on
  56168. * @param velocity velocity to set
  56169. */
  56170. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56171. /**
  56172. * gets the linear velocity
  56173. * @param impostor imposter to get linear velocity from
  56174. * @returns linear velocity
  56175. */
  56176. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56177. /**
  56178. * gets the angular velocity
  56179. * @param impostor imposter to get angular velocity from
  56180. * @returns angular velocity
  56181. */
  56182. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56183. /**
  56184. * Sets the mass of physics body
  56185. * @param impostor imposter to set the mass on
  56186. * @param mass mass to set
  56187. */
  56188. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56189. /**
  56190. * Gets the mass of the physics body
  56191. * @param impostor imposter to get the mass from
  56192. * @returns mass
  56193. */
  56194. getBodyMass(impostor: PhysicsImpostor): number;
  56195. /**
  56196. * Gets friction of the impostor
  56197. * @param impostor impostor to get friction from
  56198. * @returns friction value
  56199. */
  56200. getBodyFriction(impostor: PhysicsImpostor): number;
  56201. /**
  56202. * Sets friction of the impostor
  56203. * @param impostor impostor to set friction on
  56204. * @param friction friction value
  56205. */
  56206. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56207. /**
  56208. * Gets restitution of the impostor
  56209. * @param impostor impostor to get restitution from
  56210. * @returns restitution value
  56211. */
  56212. getBodyRestitution(impostor: PhysicsImpostor): number;
  56213. /**
  56214. * Sets resitution of the impostor
  56215. * @param impostor impostor to set resitution on
  56216. * @param restitution resitution value
  56217. */
  56218. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56219. /**
  56220. * Gets pressure inside the impostor
  56221. * @param impostor impostor to get pressure from
  56222. * @returns pressure value
  56223. */
  56224. getBodyPressure(impostor: PhysicsImpostor): number;
  56225. /**
  56226. * Sets pressure inside a soft body impostor
  56227. * Cloth and rope must remain 0 pressure
  56228. * @param impostor impostor to set pressure on
  56229. * @param pressure pressure value
  56230. */
  56231. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56232. /**
  56233. * Gets stiffness of the impostor
  56234. * @param impostor impostor to get stiffness from
  56235. * @returns pressure value
  56236. */
  56237. getBodyStiffness(impostor: PhysicsImpostor): number;
  56238. /**
  56239. * Sets stiffness of the impostor
  56240. * @param impostor impostor to set stiffness on
  56241. * @param stiffness stiffness value from 0 to 1
  56242. */
  56243. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56244. /**
  56245. * Gets velocityIterations of the impostor
  56246. * @param impostor impostor to get velocity iterations from
  56247. * @returns velocityIterations value
  56248. */
  56249. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56250. /**
  56251. * Sets velocityIterations of the impostor
  56252. * @param impostor impostor to set velocity iterations on
  56253. * @param velocityIterations velocityIterations value
  56254. */
  56255. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56256. /**
  56257. * Gets positionIterations of the impostor
  56258. * @param impostor impostor to get position iterations from
  56259. * @returns positionIterations value
  56260. */
  56261. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56262. /**
  56263. * Sets positionIterations of the impostor
  56264. * @param impostor impostor to set position on
  56265. * @param positionIterations positionIterations value
  56266. */
  56267. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56268. /**
  56269. * Append an anchor to a cloth object
  56270. * @param impostor is the cloth impostor to add anchor to
  56271. * @param otherImpostor is the rigid impostor to anchor to
  56272. * @param width ratio across width from 0 to 1
  56273. * @param height ratio up height from 0 to 1
  56274. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56275. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56276. */
  56277. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56278. /**
  56279. * Append an hook to a rope object
  56280. * @param impostor is the rope impostor to add hook to
  56281. * @param otherImpostor is the rigid impostor to hook to
  56282. * @param length ratio along the rope from 0 to 1
  56283. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56284. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56285. */
  56286. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56287. /**
  56288. * Sleeps the physics body and stops it from being active
  56289. * @param impostor impostor to sleep
  56290. */
  56291. sleepBody(impostor: PhysicsImpostor): void;
  56292. /**
  56293. * Activates the physics body
  56294. * @param impostor impostor to activate
  56295. */
  56296. wakeUpBody(impostor: PhysicsImpostor): void;
  56297. /**
  56298. * Updates the distance parameters of the joint
  56299. * @param joint joint to update
  56300. * @param maxDistance maximum distance of the joint
  56301. * @param minDistance minimum distance of the joint
  56302. */
  56303. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56304. /**
  56305. * Sets a motor on the joint
  56306. * @param joint joint to set motor on
  56307. * @param speed speed of the motor
  56308. * @param maxForce maximum force of the motor
  56309. * @param motorIndex index of the motor
  56310. */
  56311. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56312. /**
  56313. * Sets the motors limit
  56314. * @param joint joint to set limit on
  56315. * @param upperLimit upper limit
  56316. * @param lowerLimit lower limit
  56317. */
  56318. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56319. /**
  56320. * Syncs the position and rotation of a mesh with the impostor
  56321. * @param mesh mesh to sync
  56322. * @param impostor impostor to update the mesh with
  56323. */
  56324. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56325. /**
  56326. * Gets the radius of the impostor
  56327. * @param impostor impostor to get radius from
  56328. * @returns the radius
  56329. */
  56330. getRadius(impostor: PhysicsImpostor): number;
  56331. /**
  56332. * Gets the box size of the impostor
  56333. * @param impostor impostor to get box size from
  56334. * @param result the resulting box size
  56335. */
  56336. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56337. /**
  56338. * Disposes of the impostor
  56339. */
  56340. dispose(): void;
  56341. /**
  56342. * Does a raycast in the physics world
  56343. * @param from when should the ray start?
  56344. * @param to when should the ray end?
  56345. * @returns PhysicsRaycastResult
  56346. */
  56347. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56348. }
  56349. }
  56350. declare module "babylonjs/Probes/reflectionProbe" {
  56351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56352. import { Vector3 } from "babylonjs/Maths/math.vector";
  56353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56354. import { Nullable } from "babylonjs/types";
  56355. import { Scene } from "babylonjs/scene";
  56356. module "babylonjs/abstractScene" {
  56357. interface AbstractScene {
  56358. /**
  56359. * The list of reflection probes added to the scene
  56360. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56361. */
  56362. reflectionProbes: Array<ReflectionProbe>;
  56363. /**
  56364. * Removes the given reflection probe from this scene.
  56365. * @param toRemove The reflection probe to remove
  56366. * @returns The index of the removed reflection probe
  56367. */
  56368. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56369. /**
  56370. * Adds the given reflection probe to this scene.
  56371. * @param newReflectionProbe The reflection probe to add
  56372. */
  56373. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56374. }
  56375. }
  56376. /**
  56377. * Class used to generate realtime reflection / refraction cube textures
  56378. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56379. */
  56380. export class ReflectionProbe {
  56381. /** defines the name of the probe */
  56382. name: string;
  56383. private _scene;
  56384. private _renderTargetTexture;
  56385. private _projectionMatrix;
  56386. private _viewMatrix;
  56387. private _target;
  56388. private _add;
  56389. private _attachedMesh;
  56390. private _invertYAxis;
  56391. /** Gets or sets probe position (center of the cube map) */
  56392. position: Vector3;
  56393. /**
  56394. * Creates a new reflection probe
  56395. * @param name defines the name of the probe
  56396. * @param size defines the texture resolution (for each face)
  56397. * @param scene defines the hosting scene
  56398. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56399. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56400. */
  56401. constructor(
  56402. /** defines the name of the probe */
  56403. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56404. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56405. get samples(): number;
  56406. set samples(value: number);
  56407. /** Gets or sets the refresh rate to use (on every frame by default) */
  56408. get refreshRate(): number;
  56409. set refreshRate(value: number);
  56410. /**
  56411. * Gets the hosting scene
  56412. * @returns a Scene
  56413. */
  56414. getScene(): Scene;
  56415. /** Gets the internal CubeTexture used to render to */
  56416. get cubeTexture(): RenderTargetTexture;
  56417. /** Gets the list of meshes to render */
  56418. get renderList(): Nullable<AbstractMesh[]>;
  56419. /**
  56420. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56421. * @param mesh defines the mesh to attach to
  56422. */
  56423. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56424. /**
  56425. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56426. * @param renderingGroupId The rendering group id corresponding to its index
  56427. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56428. */
  56429. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56430. /**
  56431. * Clean all associated resources
  56432. */
  56433. dispose(): void;
  56434. /**
  56435. * Converts the reflection probe information to a readable string for debug purpose.
  56436. * @param fullDetails Supports for multiple levels of logging within scene loading
  56437. * @returns the human readable reflection probe info
  56438. */
  56439. toString(fullDetails?: boolean): string;
  56440. /**
  56441. * Get the class name of the relfection probe.
  56442. * @returns "ReflectionProbe"
  56443. */
  56444. getClassName(): string;
  56445. /**
  56446. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56447. * @returns The JSON representation of the texture
  56448. */
  56449. serialize(): any;
  56450. /**
  56451. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56452. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56453. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56454. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56455. * @returns The parsed reflection probe if successful
  56456. */
  56457. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56458. }
  56459. }
  56460. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  56461. /** @hidden */
  56462. export var _BabylonLoaderRegistered: boolean;
  56463. /**
  56464. * Helps setting up some configuration for the babylon file loader.
  56465. */
  56466. export class BabylonFileLoaderConfiguration {
  56467. /**
  56468. * The loader does not allow injecting custom physix engine into the plugins.
  56469. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56470. * So you could set this variable to your engine import to make it work.
  56471. */
  56472. static LoaderInjectedPhysicsEngine: any;
  56473. }
  56474. }
  56475. declare module "babylonjs/Loading/Plugins/index" {
  56476. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  56477. }
  56478. declare module "babylonjs/Loading/index" {
  56479. export * from "babylonjs/Loading/loadingScreen";
  56480. export * from "babylonjs/Loading/Plugins/index";
  56481. export * from "babylonjs/Loading/sceneLoader";
  56482. export * from "babylonjs/Loading/sceneLoaderFlags";
  56483. }
  56484. declare module "babylonjs/Materials/Background/index" {
  56485. export * from "babylonjs/Materials/Background/backgroundMaterial";
  56486. }
  56487. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  56488. import { Scene } from "babylonjs/scene";
  56489. import { Color3 } from "babylonjs/Maths/math.color";
  56490. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56491. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56492. /**
  56493. * The Physically based simple base material of BJS.
  56494. *
  56495. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56496. * It is used as the base class for both the specGloss and metalRough conventions.
  56497. */
  56498. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56499. /**
  56500. * Number of Simultaneous lights allowed on the material.
  56501. */
  56502. maxSimultaneousLights: number;
  56503. /**
  56504. * If sets to true, disables all the lights affecting the material.
  56505. */
  56506. disableLighting: boolean;
  56507. /**
  56508. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56509. */
  56510. environmentTexture: BaseTexture;
  56511. /**
  56512. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56513. */
  56514. invertNormalMapX: boolean;
  56515. /**
  56516. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56517. */
  56518. invertNormalMapY: boolean;
  56519. /**
  56520. * Normal map used in the model.
  56521. */
  56522. normalTexture: BaseTexture;
  56523. /**
  56524. * Emissivie color used to self-illuminate the model.
  56525. */
  56526. emissiveColor: Color3;
  56527. /**
  56528. * Emissivie texture used to self-illuminate the model.
  56529. */
  56530. emissiveTexture: BaseTexture;
  56531. /**
  56532. * Occlusion Channel Strenght.
  56533. */
  56534. occlusionStrength: number;
  56535. /**
  56536. * Occlusion Texture of the material (adding extra occlusion effects).
  56537. */
  56538. occlusionTexture: BaseTexture;
  56539. /**
  56540. * Defines the alpha limits in alpha test mode.
  56541. */
  56542. alphaCutOff: number;
  56543. /**
  56544. * Gets the current double sided mode.
  56545. */
  56546. get doubleSided(): boolean;
  56547. /**
  56548. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56549. */
  56550. set doubleSided(value: boolean);
  56551. /**
  56552. * Stores the pre-calculated light information of a mesh in a texture.
  56553. */
  56554. lightmapTexture: BaseTexture;
  56555. /**
  56556. * If true, the light map contains occlusion information instead of lighting info.
  56557. */
  56558. useLightmapAsShadowmap: boolean;
  56559. /**
  56560. * Instantiates a new PBRMaterial instance.
  56561. *
  56562. * @param name The material name
  56563. * @param scene The scene the material will be use in.
  56564. */
  56565. constructor(name: string, scene: Scene);
  56566. getClassName(): string;
  56567. }
  56568. }
  56569. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  56570. import { Scene } from "babylonjs/scene";
  56571. import { Color3 } from "babylonjs/Maths/math.color";
  56572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56573. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56574. /**
  56575. * The PBR material of BJS following the metal roughness convention.
  56576. *
  56577. * This fits to the PBR convention in the GLTF definition:
  56578. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56579. */
  56580. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56581. /**
  56582. * The base color has two different interpretations depending on the value of metalness.
  56583. * When the material is a metal, the base color is the specific measured reflectance value
  56584. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56585. * of the material.
  56586. */
  56587. baseColor: Color3;
  56588. /**
  56589. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56590. * well as opacity information in the alpha channel.
  56591. */
  56592. baseTexture: BaseTexture;
  56593. /**
  56594. * Specifies the metallic scalar value of the material.
  56595. * Can also be used to scale the metalness values of the metallic texture.
  56596. */
  56597. metallic: number;
  56598. /**
  56599. * Specifies the roughness scalar value of the material.
  56600. * Can also be used to scale the roughness values of the metallic texture.
  56601. */
  56602. roughness: number;
  56603. /**
  56604. * Texture containing both the metallic value in the B channel and the
  56605. * roughness value in the G channel to keep better precision.
  56606. */
  56607. metallicRoughnessTexture: BaseTexture;
  56608. /**
  56609. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56610. *
  56611. * @param name The material name
  56612. * @param scene The scene the material will be use in.
  56613. */
  56614. constructor(name: string, scene: Scene);
  56615. /**
  56616. * Return the currrent class name of the material.
  56617. */
  56618. getClassName(): string;
  56619. /**
  56620. * Makes a duplicate of the current material.
  56621. * @param name - name to use for the new material.
  56622. */
  56623. clone(name: string): PBRMetallicRoughnessMaterial;
  56624. /**
  56625. * Serialize the material to a parsable JSON object.
  56626. */
  56627. serialize(): any;
  56628. /**
  56629. * Parses a JSON object correponding to the serialize function.
  56630. */
  56631. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56632. }
  56633. }
  56634. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  56635. import { Scene } from "babylonjs/scene";
  56636. import { Color3 } from "babylonjs/Maths/math.color";
  56637. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56638. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56639. /**
  56640. * The PBR material of BJS following the specular glossiness convention.
  56641. *
  56642. * This fits to the PBR convention in the GLTF definition:
  56643. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56644. */
  56645. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56646. /**
  56647. * Specifies the diffuse color of the material.
  56648. */
  56649. diffuseColor: Color3;
  56650. /**
  56651. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56652. * channel.
  56653. */
  56654. diffuseTexture: BaseTexture;
  56655. /**
  56656. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56657. */
  56658. specularColor: Color3;
  56659. /**
  56660. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56661. */
  56662. glossiness: number;
  56663. /**
  56664. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56665. */
  56666. specularGlossinessTexture: BaseTexture;
  56667. /**
  56668. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56669. *
  56670. * @param name The material name
  56671. * @param scene The scene the material will be use in.
  56672. */
  56673. constructor(name: string, scene: Scene);
  56674. /**
  56675. * Return the currrent class name of the material.
  56676. */
  56677. getClassName(): string;
  56678. /**
  56679. * Makes a duplicate of the current material.
  56680. * @param name - name to use for the new material.
  56681. */
  56682. clone(name: string): PBRSpecularGlossinessMaterial;
  56683. /**
  56684. * Serialize the material to a parsable JSON object.
  56685. */
  56686. serialize(): any;
  56687. /**
  56688. * Parses a JSON object correponding to the serialize function.
  56689. */
  56690. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56691. }
  56692. }
  56693. declare module "babylonjs/Materials/PBR/index" {
  56694. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56695. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56696. export * from "babylonjs/Materials/PBR/pbrMaterial";
  56697. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  56698. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  56699. }
  56700. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  56701. import { Nullable } from "babylonjs/types";
  56702. import { Scene } from "babylonjs/scene";
  56703. import { Matrix } from "babylonjs/Maths/math.vector";
  56704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56705. /**
  56706. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56707. * It can help converting any input color in a desired output one. This can then be used to create effects
  56708. * from sepia, black and white to sixties or futuristic rendering...
  56709. *
  56710. * The only supported format is currently 3dl.
  56711. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56712. */
  56713. export class ColorGradingTexture extends BaseTexture {
  56714. /**
  56715. * The current texture matrix. (will always be identity in color grading texture)
  56716. */
  56717. private _textureMatrix;
  56718. /**
  56719. * The texture URL.
  56720. */
  56721. url: string;
  56722. /**
  56723. * Empty line regex stored for GC.
  56724. */
  56725. private static _noneEmptyLineRegex;
  56726. private _engine;
  56727. /**
  56728. * Instantiates a ColorGradingTexture from the following parameters.
  56729. *
  56730. * @param url The location of the color gradind data (currently only supporting 3dl)
  56731. * @param scene The scene the texture will be used in
  56732. */
  56733. constructor(url: string, scene: Scene);
  56734. /**
  56735. * Returns the texture matrix used in most of the material.
  56736. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56737. */
  56738. getTextureMatrix(): Matrix;
  56739. /**
  56740. * Occurs when the file being loaded is a .3dl LUT file.
  56741. */
  56742. private load3dlTexture;
  56743. /**
  56744. * Starts the loading process of the texture.
  56745. */
  56746. private loadTexture;
  56747. /**
  56748. * Clones the color gradind texture.
  56749. */
  56750. clone(): ColorGradingTexture;
  56751. /**
  56752. * Called during delayed load for textures.
  56753. */
  56754. delayLoad(): void;
  56755. /**
  56756. * Parses a color grading texture serialized by Babylon.
  56757. * @param parsedTexture The texture information being parsedTexture
  56758. * @param scene The scene to load the texture in
  56759. * @param rootUrl The root url of the data assets to load
  56760. * @return A color gradind texture
  56761. */
  56762. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56763. /**
  56764. * Serializes the LUT texture to json format.
  56765. */
  56766. serialize(): any;
  56767. }
  56768. }
  56769. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  56770. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56771. import { Scene } from "babylonjs/scene";
  56772. import { Nullable } from "babylonjs/types";
  56773. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56774. /**
  56775. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56776. */
  56777. export class EquiRectangularCubeTexture extends BaseTexture {
  56778. /** The six faces of the cube. */
  56779. private static _FacesMapping;
  56780. private _noMipmap;
  56781. private _onLoad;
  56782. private _onError;
  56783. /** The size of the cubemap. */
  56784. private _size;
  56785. /** The buffer of the image. */
  56786. private _buffer;
  56787. /** The width of the input image. */
  56788. private _width;
  56789. /** The height of the input image. */
  56790. private _height;
  56791. /** The URL to the image. */
  56792. url: string;
  56793. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56794. coordinatesMode: number;
  56795. /**
  56796. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56797. * @param url The location of the image
  56798. * @param scene The scene the texture will be used in
  56799. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56800. * @param noMipmap Forces to not generate the mipmap if true
  56801. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56802. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56803. * @param onLoad — defines a callback called when texture is loaded
  56804. * @param onError — defines a callback called if there is an error
  56805. */
  56806. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56807. /**
  56808. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56809. */
  56810. private loadImage;
  56811. /**
  56812. * Convert the image buffer into a cubemap and create a CubeTexture.
  56813. */
  56814. private loadTexture;
  56815. /**
  56816. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56817. * @param buffer The ArrayBuffer that should be converted.
  56818. * @returns The buffer as Float32Array.
  56819. */
  56820. private getFloat32ArrayFromArrayBuffer;
  56821. /**
  56822. * Get the current class name of the texture useful for serialization or dynamic coding.
  56823. * @returns "EquiRectangularCubeTexture"
  56824. */
  56825. getClassName(): string;
  56826. /**
  56827. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56828. * @returns A clone of the current EquiRectangularCubeTexture.
  56829. */
  56830. clone(): EquiRectangularCubeTexture;
  56831. }
  56832. }
  56833. declare module "babylonjs/Misc/tga" {
  56834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56835. /**
  56836. * Based on jsTGALoader - Javascript loader for TGA file
  56837. * By Vincent Thibault
  56838. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56839. */
  56840. export class TGATools {
  56841. private static _TYPE_INDEXED;
  56842. private static _TYPE_RGB;
  56843. private static _TYPE_GREY;
  56844. private static _TYPE_RLE_INDEXED;
  56845. private static _TYPE_RLE_RGB;
  56846. private static _TYPE_RLE_GREY;
  56847. private static _ORIGIN_MASK;
  56848. private static _ORIGIN_SHIFT;
  56849. private static _ORIGIN_BL;
  56850. private static _ORIGIN_BR;
  56851. private static _ORIGIN_UL;
  56852. private static _ORIGIN_UR;
  56853. /**
  56854. * Gets the header of a TGA file
  56855. * @param data defines the TGA data
  56856. * @returns the header
  56857. */
  56858. static GetTGAHeader(data: Uint8Array): any;
  56859. /**
  56860. * Uploads TGA content to a Babylon Texture
  56861. * @hidden
  56862. */
  56863. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56864. /** @hidden */
  56865. 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;
  56866. /** @hidden */
  56867. 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;
  56868. /** @hidden */
  56869. 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;
  56870. /** @hidden */
  56871. 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;
  56872. /** @hidden */
  56873. 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;
  56874. /** @hidden */
  56875. 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;
  56876. }
  56877. }
  56878. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  56879. import { Nullable } from "babylonjs/types";
  56880. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56881. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  56882. /**
  56883. * Implementation of the TGA Texture Loader.
  56884. * @hidden
  56885. */
  56886. export class _TGATextureLoader implements IInternalTextureLoader {
  56887. /**
  56888. * Defines wether the loader supports cascade loading the different faces.
  56889. */
  56890. readonly supportCascades: boolean;
  56891. /**
  56892. * This returns if the loader support the current file information.
  56893. * @param extension defines the file extension of the file being loaded
  56894. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56895. * @param fallback defines the fallback internal texture if any
  56896. * @param isBase64 defines whether the texture is encoded as a base64
  56897. * @param isBuffer defines whether the texture data are stored as a buffer
  56898. * @returns true if the loader can load the specified file
  56899. */
  56900. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56901. /**
  56902. * Transform the url before loading if required.
  56903. * @param rootUrl the url of the texture
  56904. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56905. * @returns the transformed texture
  56906. */
  56907. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56908. /**
  56909. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56910. * @param rootUrl the url of the texture
  56911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56912. * @returns the fallback texture
  56913. */
  56914. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56915. /**
  56916. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56917. * @param data contains the texture data
  56918. * @param texture defines the BabylonJS internal texture
  56919. * @param createPolynomials will be true if polynomials have been requested
  56920. * @param onLoad defines the callback to trigger once the texture is ready
  56921. * @param onError defines the callback to trigger in case of error
  56922. */
  56923. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56924. /**
  56925. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56926. * @param data contains the texture data
  56927. * @param texture defines the BabylonJS internal texture
  56928. * @param callback defines the method to call once ready to upload
  56929. */
  56930. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56931. }
  56932. }
  56933. declare module "babylonjs/Misc/basis" {
  56934. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56935. /**
  56936. * Info about the .basis files
  56937. */
  56938. class BasisFileInfo {
  56939. /**
  56940. * If the file has alpha
  56941. */
  56942. hasAlpha: boolean;
  56943. /**
  56944. * Info about each image of the basis file
  56945. */
  56946. images: Array<{
  56947. levels: Array<{
  56948. width: number;
  56949. height: number;
  56950. transcodedPixels: ArrayBufferView;
  56951. }>;
  56952. }>;
  56953. }
  56954. /**
  56955. * Result of transcoding a basis file
  56956. */
  56957. class TranscodeResult {
  56958. /**
  56959. * Info about the .basis file
  56960. */
  56961. fileInfo: BasisFileInfo;
  56962. /**
  56963. * Format to use when loading the file
  56964. */
  56965. format: number;
  56966. }
  56967. /**
  56968. * Configuration options for the Basis transcoder
  56969. */
  56970. export class BasisTranscodeConfiguration {
  56971. /**
  56972. * Supported compression formats used to determine the supported output format of the transcoder
  56973. */
  56974. supportedCompressionFormats?: {
  56975. /**
  56976. * etc1 compression format
  56977. */
  56978. etc1?: boolean;
  56979. /**
  56980. * s3tc compression format
  56981. */
  56982. s3tc?: boolean;
  56983. /**
  56984. * pvrtc compression format
  56985. */
  56986. pvrtc?: boolean;
  56987. /**
  56988. * etc2 compression format
  56989. */
  56990. etc2?: boolean;
  56991. };
  56992. /**
  56993. * If mipmap levels should be loaded for transcoded images (Default: true)
  56994. */
  56995. loadMipmapLevels?: boolean;
  56996. /**
  56997. * Index of a single image to load (Default: all images)
  56998. */
  56999. loadSingleImage?: number;
  57000. }
  57001. /**
  57002. * Used to load .Basis files
  57003. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57004. */
  57005. export class BasisTools {
  57006. private static _IgnoreSupportedFormats;
  57007. /**
  57008. * URL to use when loading the basis transcoder
  57009. */
  57010. static JSModuleURL: string;
  57011. /**
  57012. * URL to use when loading the wasm module for the transcoder
  57013. */
  57014. static WasmModuleURL: string;
  57015. /**
  57016. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57017. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57018. * @returns internal format corresponding to the Basis format
  57019. */
  57020. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57021. private static _WorkerPromise;
  57022. private static _Worker;
  57023. private static _actionId;
  57024. private static _CreateWorkerAsync;
  57025. /**
  57026. * Transcodes a loaded image file to compressed pixel data
  57027. * @param imageData image data to transcode
  57028. * @param config configuration options for the transcoding
  57029. * @returns a promise resulting in the transcoded image
  57030. */
  57031. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57032. /**
  57033. * Loads a texture from the transcode result
  57034. * @param texture texture load to
  57035. * @param transcodeResult the result of transcoding the basis file to load from
  57036. */
  57037. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57038. }
  57039. }
  57040. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57041. import { Nullable } from "babylonjs/types";
  57042. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57043. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57044. /**
  57045. * Loader for .basis file format
  57046. */
  57047. export class _BasisTextureLoader implements IInternalTextureLoader {
  57048. /**
  57049. * Defines whether the loader supports cascade loading the different faces.
  57050. */
  57051. readonly supportCascades: boolean;
  57052. /**
  57053. * This returns if the loader support the current file information.
  57054. * @param extension defines the file extension of the file being loaded
  57055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57056. * @param fallback defines the fallback internal texture if any
  57057. * @param isBase64 defines whether the texture is encoded as a base64
  57058. * @param isBuffer defines whether the texture data are stored as a buffer
  57059. * @returns true if the loader can load the specified file
  57060. */
  57061. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57062. /**
  57063. * Transform the url before loading if required.
  57064. * @param rootUrl the url of the texture
  57065. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57066. * @returns the transformed texture
  57067. */
  57068. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57069. /**
  57070. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57071. * @param rootUrl the url of the texture
  57072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57073. * @returns the fallback texture
  57074. */
  57075. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57076. /**
  57077. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57078. * @param data contains the texture data
  57079. * @param texture defines the BabylonJS internal texture
  57080. * @param createPolynomials will be true if polynomials have been requested
  57081. * @param onLoad defines the callback to trigger once the texture is ready
  57082. * @param onError defines the callback to trigger in case of error
  57083. */
  57084. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57085. /**
  57086. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57087. * @param data contains the texture data
  57088. * @param texture defines the BabylonJS internal texture
  57089. * @param callback defines the method to call once ready to upload
  57090. */
  57091. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57092. }
  57093. }
  57094. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57095. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57096. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57097. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57098. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57099. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57100. }
  57101. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57102. import { Scene } from "babylonjs/scene";
  57103. import { Texture } from "babylonjs/Materials/Textures/texture";
  57104. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57105. /**
  57106. * 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.
  57107. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57108. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57109. */
  57110. export class CustomProceduralTexture extends ProceduralTexture {
  57111. private _animate;
  57112. private _time;
  57113. private _config;
  57114. private _texturePath;
  57115. /**
  57116. * Instantiates a new Custom Procedural Texture.
  57117. * 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.
  57118. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57119. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57120. * @param name Define the name of the texture
  57121. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57122. * @param size Define the size of the texture to create
  57123. * @param scene Define the scene the texture belongs to
  57124. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57125. * @param generateMipMaps Define if the texture should creates mip maps or not
  57126. */
  57127. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57128. private _loadJson;
  57129. /**
  57130. * Is the texture ready to be used ? (rendered at least once)
  57131. * @returns true if ready, otherwise, false.
  57132. */
  57133. isReady(): boolean;
  57134. /**
  57135. * Render the texture to its associated render target.
  57136. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57137. */
  57138. render(useCameraPostProcess?: boolean): void;
  57139. /**
  57140. * Update the list of dependant textures samplers in the shader.
  57141. */
  57142. updateTextures(): void;
  57143. /**
  57144. * Update the uniform values of the procedural texture in the shader.
  57145. */
  57146. updateShaderUniforms(): void;
  57147. /**
  57148. * Define if the texture animates or not.
  57149. */
  57150. get animate(): boolean;
  57151. set animate(value: boolean);
  57152. }
  57153. }
  57154. declare module "babylonjs/Shaders/noise.fragment" {
  57155. /** @hidden */
  57156. export var noisePixelShader: {
  57157. name: string;
  57158. shader: string;
  57159. };
  57160. }
  57161. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  57162. import { Nullable } from "babylonjs/types";
  57163. import { Scene } from "babylonjs/scene";
  57164. import { Texture } from "babylonjs/Materials/Textures/texture";
  57165. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57166. import "babylonjs/Shaders/noise.fragment";
  57167. /**
  57168. * Class used to generate noise procedural textures
  57169. */
  57170. export class NoiseProceduralTexture extends ProceduralTexture {
  57171. private _time;
  57172. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57173. brightness: number;
  57174. /** Defines the number of octaves to process */
  57175. octaves: number;
  57176. /** Defines the level of persistence (0.8 by default) */
  57177. persistence: number;
  57178. /** Gets or sets animation speed factor (default is 1) */
  57179. animationSpeedFactor: number;
  57180. /**
  57181. * Creates a new NoiseProceduralTexture
  57182. * @param name defines the name fo the texture
  57183. * @param size defines the size of the texture (default is 256)
  57184. * @param scene defines the hosting scene
  57185. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57186. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57187. */
  57188. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57189. private _updateShaderUniforms;
  57190. protected _getDefines(): string;
  57191. /** Generate the current state of the procedural texture */
  57192. render(useCameraPostProcess?: boolean): void;
  57193. /**
  57194. * Serializes this noise procedural texture
  57195. * @returns a serialized noise procedural texture object
  57196. */
  57197. serialize(): any;
  57198. /**
  57199. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57200. * @param parsedTexture defines parsed texture data
  57201. * @param scene defines the current scene
  57202. * @param rootUrl defines the root URL containing noise procedural texture information
  57203. * @returns a parsed NoiseProceduralTexture
  57204. */
  57205. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57206. }
  57207. }
  57208. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  57209. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  57210. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  57211. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57212. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  57213. }
  57214. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  57215. import { Nullable } from "babylonjs/types";
  57216. import { Scene } from "babylonjs/scene";
  57217. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57218. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57219. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57220. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57221. /**
  57222. * Raw cube texture where the raw buffers are passed in
  57223. */
  57224. export class RawCubeTexture extends CubeTexture {
  57225. /**
  57226. * Creates a cube texture where the raw buffers are passed in.
  57227. * @param scene defines the scene the texture is attached to
  57228. * @param data defines the array of data to use to create each face
  57229. * @param size defines the size of the textures
  57230. * @param format defines the format of the data
  57231. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57232. * @param generateMipMaps defines if the engine should generate the mip levels
  57233. * @param invertY defines if data must be stored with Y axis inverted
  57234. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57235. * @param compression defines the compression used (null by default)
  57236. */
  57237. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57238. /**
  57239. * Updates the raw cube texture.
  57240. * @param data defines the data to store
  57241. * @param format defines the data format
  57242. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57243. * @param invertY defines if data must be stored with Y axis inverted
  57244. * @param compression defines the compression used (null by default)
  57245. * @param level defines which level of the texture to update
  57246. */
  57247. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57248. /**
  57249. * Updates a raw cube texture with RGBD encoded data.
  57250. * @param data defines the array of data [mipmap][face] to use to create each face
  57251. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57252. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57253. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57254. * @returns a promsie that resolves when the operation is complete
  57255. */
  57256. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57257. /**
  57258. * Clones the raw cube texture.
  57259. * @return a new cube texture
  57260. */
  57261. clone(): CubeTexture;
  57262. /** @hidden */
  57263. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57264. }
  57265. }
  57266. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  57267. import { Scene } from "babylonjs/scene";
  57268. import { Texture } from "babylonjs/Materials/Textures/texture";
  57269. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57270. /**
  57271. * Class used to store 3D textures containing user data
  57272. */
  57273. export class RawTexture3D extends Texture {
  57274. /** Gets or sets the texture format to use */
  57275. format: number;
  57276. private _engine;
  57277. /**
  57278. * Create a new RawTexture3D
  57279. * @param data defines the data of the texture
  57280. * @param width defines the width of the texture
  57281. * @param height defines the height of the texture
  57282. * @param depth defines the depth of the texture
  57283. * @param format defines the texture format to use
  57284. * @param scene defines the hosting scene
  57285. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57286. * @param invertY defines if texture must be stored with Y axis inverted
  57287. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57288. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57289. */
  57290. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57291. /** Gets or sets the texture format to use */
  57292. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57293. /**
  57294. * Update the texture with new data
  57295. * @param data defines the data to store in the texture
  57296. */
  57297. update(data: ArrayBufferView): void;
  57298. }
  57299. }
  57300. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  57301. import { Scene } from "babylonjs/scene";
  57302. import { Texture } from "babylonjs/Materials/Textures/texture";
  57303. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57304. /**
  57305. * Class used to store 2D array textures containing user data
  57306. */
  57307. export class RawTexture2DArray extends Texture {
  57308. /** Gets or sets the texture format to use */
  57309. format: number;
  57310. private _engine;
  57311. /**
  57312. * Create a new RawTexture2DArray
  57313. * @param data defines the data of the texture
  57314. * @param width defines the width of the texture
  57315. * @param height defines the height of the texture
  57316. * @param depth defines the number of layers of the texture
  57317. * @param format defines the texture format to use
  57318. * @param scene defines the hosting scene
  57319. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57320. * @param invertY defines if texture must be stored with Y axis inverted
  57321. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57322. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57323. */
  57324. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57325. /** Gets or sets the texture format to use */
  57326. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57327. /**
  57328. * Update the texture with new data
  57329. * @param data defines the data to store in the texture
  57330. */
  57331. update(data: ArrayBufferView): void;
  57332. }
  57333. }
  57334. declare module "babylonjs/Materials/Textures/refractionTexture" {
  57335. import { Scene } from "babylonjs/scene";
  57336. import { Plane } from "babylonjs/Maths/math.plane";
  57337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57338. /**
  57339. * Creates a refraction texture used by refraction channel of the standard material.
  57340. * It is like a mirror but to see through a material.
  57341. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57342. */
  57343. export class RefractionTexture extends RenderTargetTexture {
  57344. /**
  57345. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57346. * 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.
  57347. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57348. */
  57349. refractionPlane: Plane;
  57350. /**
  57351. * Define how deep under the surface we should see.
  57352. */
  57353. depth: number;
  57354. /**
  57355. * Creates a refraction texture used by refraction channel of the standard material.
  57356. * It is like a mirror but to see through a material.
  57357. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57358. * @param name Define the texture name
  57359. * @param size Define the size of the underlying texture
  57360. * @param scene Define the scene the refraction belongs to
  57361. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57362. */
  57363. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57364. /**
  57365. * Clone the refraction texture.
  57366. * @returns the cloned texture
  57367. */
  57368. clone(): RefractionTexture;
  57369. /**
  57370. * Serialize the texture to a JSON representation you could use in Parse later on
  57371. * @returns the serialized JSON representation
  57372. */
  57373. serialize(): any;
  57374. }
  57375. }
  57376. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  57377. import { Nullable } from "babylonjs/types";
  57378. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57379. import { Matrix } from "babylonjs/Maths/math.vector";
  57380. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57381. import "babylonjs/Engines/Extensions/engine.videoTexture";
  57382. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  57383. import { Scene } from "babylonjs/scene";
  57384. /**
  57385. * Defines the options related to the creation of an HtmlElementTexture
  57386. */
  57387. export interface IHtmlElementTextureOptions {
  57388. /**
  57389. * Defines wether mip maps should be created or not.
  57390. */
  57391. generateMipMaps?: boolean;
  57392. /**
  57393. * Defines the sampling mode of the texture.
  57394. */
  57395. samplingMode?: number;
  57396. /**
  57397. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57398. */
  57399. engine: Nullable<ThinEngine>;
  57400. /**
  57401. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57402. */
  57403. scene: Nullable<Scene>;
  57404. }
  57405. /**
  57406. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57407. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57408. * is automatically managed.
  57409. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57410. * in your application.
  57411. *
  57412. * As the update is not automatic, you need to call them manually.
  57413. */
  57414. export class HtmlElementTexture extends BaseTexture {
  57415. /**
  57416. * The texture URL.
  57417. */
  57418. element: HTMLVideoElement | HTMLCanvasElement;
  57419. private static readonly DefaultOptions;
  57420. private _textureMatrix;
  57421. private _engine;
  57422. private _isVideo;
  57423. private _generateMipMaps;
  57424. private _samplingMode;
  57425. /**
  57426. * Instantiates a HtmlElementTexture from the following parameters.
  57427. *
  57428. * @param name Defines the name of the texture
  57429. * @param element Defines the video or canvas the texture is filled with
  57430. * @param options Defines the other none mandatory texture creation options
  57431. */
  57432. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57433. private _createInternalTexture;
  57434. /**
  57435. * Returns the texture matrix used in most of the material.
  57436. */
  57437. getTextureMatrix(): Matrix;
  57438. /**
  57439. * Updates the content of the texture.
  57440. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57441. */
  57442. update(invertY?: Nullable<boolean>): void;
  57443. }
  57444. }
  57445. declare module "babylonjs/Materials/Textures/index" {
  57446. export * from "babylonjs/Materials/Textures/baseTexture";
  57447. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  57448. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  57449. export * from "babylonjs/Materials/Textures/cubeTexture";
  57450. export * from "babylonjs/Materials/Textures/dynamicTexture";
  57451. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57452. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  57453. export * from "babylonjs/Materials/Textures/internalTexture";
  57454. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  57455. export * from "babylonjs/Materials/Textures/Loaders/index";
  57456. export * from "babylonjs/Materials/Textures/mirrorTexture";
  57457. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  57458. export * from "babylonjs/Materials/Textures/Procedurals/index";
  57459. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  57460. export * from "babylonjs/Materials/Textures/rawTexture";
  57461. export * from "babylonjs/Materials/Textures/rawTexture3D";
  57462. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  57463. export * from "babylonjs/Materials/Textures/refractionTexture";
  57464. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  57465. export * from "babylonjs/Materials/Textures/texture";
  57466. export * from "babylonjs/Materials/Textures/videoTexture";
  57467. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  57468. }
  57469. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  57470. /**
  57471. * Enum used to define the target of a block
  57472. */
  57473. export enum NodeMaterialBlockTargets {
  57474. /** Vertex shader */
  57475. Vertex = 1,
  57476. /** Fragment shader */
  57477. Fragment = 2,
  57478. /** Neutral */
  57479. Neutral = 4,
  57480. /** Vertex and Fragment */
  57481. VertexAndFragment = 3
  57482. }
  57483. }
  57484. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  57485. /**
  57486. * Defines the kind of connection point for node based material
  57487. */
  57488. export enum NodeMaterialBlockConnectionPointTypes {
  57489. /** Float */
  57490. Float = 1,
  57491. /** Int */
  57492. Int = 2,
  57493. /** Vector2 */
  57494. Vector2 = 4,
  57495. /** Vector3 */
  57496. Vector3 = 8,
  57497. /** Vector4 */
  57498. Vector4 = 16,
  57499. /** Color3 */
  57500. Color3 = 32,
  57501. /** Color4 */
  57502. Color4 = 64,
  57503. /** Matrix */
  57504. Matrix = 128,
  57505. /** Detect type based on connection */
  57506. AutoDetect = 1024,
  57507. /** Output type that will be defined by input type */
  57508. BasedOnInput = 2048
  57509. }
  57510. }
  57511. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  57512. /**
  57513. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57514. */
  57515. export enum NodeMaterialBlockConnectionPointMode {
  57516. /** Value is an uniform */
  57517. Uniform = 0,
  57518. /** Value is a mesh attribute */
  57519. Attribute = 1,
  57520. /** Value is a varying between vertex and fragment shaders */
  57521. Varying = 2,
  57522. /** Mode is undefined */
  57523. Undefined = 3
  57524. }
  57525. }
  57526. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  57527. /**
  57528. * Enum used to define system values e.g. values automatically provided by the system
  57529. */
  57530. export enum NodeMaterialSystemValues {
  57531. /** World */
  57532. World = 1,
  57533. /** View */
  57534. View = 2,
  57535. /** Projection */
  57536. Projection = 3,
  57537. /** ViewProjection */
  57538. ViewProjection = 4,
  57539. /** WorldView */
  57540. WorldView = 5,
  57541. /** WorldViewProjection */
  57542. WorldViewProjection = 6,
  57543. /** CameraPosition */
  57544. CameraPosition = 7,
  57545. /** Fog Color */
  57546. FogColor = 8,
  57547. /** Delta time */
  57548. DeltaTime = 9
  57549. }
  57550. }
  57551. declare module "babylonjs/Materials/Node/Enums/index" {
  57552. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57553. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57554. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  57555. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57556. }
  57557. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  57558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57559. /**
  57560. * Root class for all node material optimizers
  57561. */
  57562. export class NodeMaterialOptimizer {
  57563. /**
  57564. * Function used to optimize a NodeMaterial graph
  57565. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57566. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57567. */
  57568. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57569. }
  57570. }
  57571. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  57572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57575. import { Scene } from "babylonjs/scene";
  57576. /**
  57577. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57578. */
  57579. export class TransformBlock extends NodeMaterialBlock {
  57580. /**
  57581. * Defines the value to use to complement W value to transform it to a Vector4
  57582. */
  57583. complementW: number;
  57584. /**
  57585. * Defines the value to use to complement z value to transform it to a Vector4
  57586. */
  57587. complementZ: number;
  57588. /**
  57589. * Creates a new TransformBlock
  57590. * @param name defines the block name
  57591. */
  57592. constructor(name: string);
  57593. /**
  57594. * Gets the current class name
  57595. * @returns the class name
  57596. */
  57597. getClassName(): string;
  57598. /**
  57599. * Gets the vector input
  57600. */
  57601. get vector(): NodeMaterialConnectionPoint;
  57602. /**
  57603. * Gets the output component
  57604. */
  57605. get output(): NodeMaterialConnectionPoint;
  57606. /**
  57607. * Gets the matrix transform input
  57608. */
  57609. get transform(): NodeMaterialConnectionPoint;
  57610. protected _buildBlock(state: NodeMaterialBuildState): this;
  57611. serialize(): any;
  57612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57613. protected _dumpPropertiesCode(): string;
  57614. }
  57615. }
  57616. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  57617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57620. /**
  57621. * Block used to output the vertex position
  57622. */
  57623. export class VertexOutputBlock extends NodeMaterialBlock {
  57624. /**
  57625. * Creates a new VertexOutputBlock
  57626. * @param name defines the block name
  57627. */
  57628. constructor(name: string);
  57629. /**
  57630. * Gets the current class name
  57631. * @returns the class name
  57632. */
  57633. getClassName(): string;
  57634. /**
  57635. * Gets the vector input component
  57636. */
  57637. get vector(): NodeMaterialConnectionPoint;
  57638. protected _buildBlock(state: NodeMaterialBuildState): this;
  57639. }
  57640. }
  57641. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  57642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57645. /**
  57646. * Block used to output the final color
  57647. */
  57648. export class FragmentOutputBlock extends NodeMaterialBlock {
  57649. /**
  57650. * Create a new FragmentOutputBlock
  57651. * @param name defines the block name
  57652. */
  57653. constructor(name: string);
  57654. /**
  57655. * Gets the current class name
  57656. * @returns the class name
  57657. */
  57658. getClassName(): string;
  57659. /**
  57660. * Gets the rgba input component
  57661. */
  57662. get rgba(): NodeMaterialConnectionPoint;
  57663. /**
  57664. * Gets the rgb input component
  57665. */
  57666. get rgb(): NodeMaterialConnectionPoint;
  57667. /**
  57668. * Gets the a input component
  57669. */
  57670. get a(): NodeMaterialConnectionPoint;
  57671. protected _buildBlock(state: NodeMaterialBuildState): this;
  57672. }
  57673. }
  57674. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  57675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57676. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57677. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57680. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57681. import { Effect } from "babylonjs/Materials/effect";
  57682. import { Mesh } from "babylonjs/Meshes/mesh";
  57683. import { Nullable } from "babylonjs/types";
  57684. import { Scene } from "babylonjs/scene";
  57685. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57686. /**
  57687. * Block used to read a reflection texture from a sampler
  57688. */
  57689. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57690. private _define3DName;
  57691. private _defineCubicName;
  57692. private _defineExplicitName;
  57693. private _defineProjectionName;
  57694. private _defineLocalCubicName;
  57695. private _defineSphericalName;
  57696. private _definePlanarName;
  57697. private _defineEquirectangularName;
  57698. private _defineMirroredEquirectangularFixedName;
  57699. private _defineEquirectangularFixedName;
  57700. private _defineSkyboxName;
  57701. private _cubeSamplerName;
  57702. private _2DSamplerName;
  57703. private _positionUVWName;
  57704. private _directionWName;
  57705. private _reflectionCoordsName;
  57706. private _reflection2DCoordsName;
  57707. private _reflectionColorName;
  57708. private _reflectionMatrixName;
  57709. /**
  57710. * Gets or sets the texture associated with the node
  57711. */
  57712. texture: Nullable<BaseTexture>;
  57713. /**
  57714. * Create a new TextureBlock
  57715. * @param name defines the block name
  57716. */
  57717. constructor(name: string);
  57718. /**
  57719. * Gets the current class name
  57720. * @returns the class name
  57721. */
  57722. getClassName(): string;
  57723. /**
  57724. * Gets the world position input component
  57725. */
  57726. get position(): NodeMaterialConnectionPoint;
  57727. /**
  57728. * Gets the world position input component
  57729. */
  57730. get worldPosition(): NodeMaterialConnectionPoint;
  57731. /**
  57732. * Gets the world normal input component
  57733. */
  57734. get worldNormal(): NodeMaterialConnectionPoint;
  57735. /**
  57736. * Gets the world input component
  57737. */
  57738. get world(): NodeMaterialConnectionPoint;
  57739. /**
  57740. * Gets the camera (or eye) position component
  57741. */
  57742. get cameraPosition(): NodeMaterialConnectionPoint;
  57743. /**
  57744. * Gets the view input component
  57745. */
  57746. get view(): NodeMaterialConnectionPoint;
  57747. /**
  57748. * Gets the rgb output component
  57749. */
  57750. get rgb(): NodeMaterialConnectionPoint;
  57751. /**
  57752. * Gets the r output component
  57753. */
  57754. get r(): NodeMaterialConnectionPoint;
  57755. /**
  57756. * Gets the g output component
  57757. */
  57758. get g(): NodeMaterialConnectionPoint;
  57759. /**
  57760. * Gets the b output component
  57761. */
  57762. get b(): NodeMaterialConnectionPoint;
  57763. autoConfigure(material: NodeMaterial): void;
  57764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57765. isReady(): boolean;
  57766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57767. private _injectVertexCode;
  57768. private _writeOutput;
  57769. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57770. protected _dumpPropertiesCode(): string;
  57771. serialize(): any;
  57772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57773. }
  57774. }
  57775. declare module "babylonjs/Materials/Node/nodeMaterial" {
  57776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57777. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57778. import { Scene } from "babylonjs/scene";
  57779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57780. import { Matrix } from "babylonjs/Maths/math.vector";
  57781. import { Mesh } from "babylonjs/Meshes/mesh";
  57782. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57783. import { Observable } from "babylonjs/Misc/observable";
  57784. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57785. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57786. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57787. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57788. import { Nullable } from "babylonjs/types";
  57789. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57790. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57791. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57792. /**
  57793. * Interface used to configure the node material editor
  57794. */
  57795. export interface INodeMaterialEditorOptions {
  57796. /** Define the URl to load node editor script */
  57797. editorURL?: string;
  57798. }
  57799. /** @hidden */
  57800. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57801. /** BONES */
  57802. NUM_BONE_INFLUENCERS: number;
  57803. BonesPerMesh: number;
  57804. BONETEXTURE: boolean;
  57805. /** MORPH TARGETS */
  57806. MORPHTARGETS: boolean;
  57807. MORPHTARGETS_NORMAL: boolean;
  57808. MORPHTARGETS_TANGENT: boolean;
  57809. MORPHTARGETS_UV: boolean;
  57810. NUM_MORPH_INFLUENCERS: number;
  57811. /** IMAGE PROCESSING */
  57812. IMAGEPROCESSING: boolean;
  57813. VIGNETTE: boolean;
  57814. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57815. VIGNETTEBLENDMODEOPAQUE: boolean;
  57816. TONEMAPPING: boolean;
  57817. TONEMAPPING_ACES: boolean;
  57818. CONTRAST: boolean;
  57819. EXPOSURE: boolean;
  57820. COLORCURVES: boolean;
  57821. COLORGRADING: boolean;
  57822. COLORGRADING3D: boolean;
  57823. SAMPLER3DGREENDEPTH: boolean;
  57824. SAMPLER3DBGRMAP: boolean;
  57825. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57826. /** MISC. */
  57827. BUMPDIRECTUV: number;
  57828. constructor();
  57829. setValue(name: string, value: boolean): void;
  57830. }
  57831. /**
  57832. * Class used to configure NodeMaterial
  57833. */
  57834. export interface INodeMaterialOptions {
  57835. /**
  57836. * Defines if blocks should emit comments
  57837. */
  57838. emitComments: boolean;
  57839. }
  57840. /**
  57841. * Class used to create a node based material built by assembling shader blocks
  57842. */
  57843. export class NodeMaterial extends PushMaterial {
  57844. private static _BuildIdGenerator;
  57845. private _options;
  57846. private _vertexCompilationState;
  57847. private _fragmentCompilationState;
  57848. private _sharedData;
  57849. private _buildId;
  57850. private _buildWasSuccessful;
  57851. private _cachedWorldViewMatrix;
  57852. private _cachedWorldViewProjectionMatrix;
  57853. private _optimizers;
  57854. private _animationFrame;
  57855. /** Define the URl to load node editor script */
  57856. static EditorURL: string;
  57857. private BJSNODEMATERIALEDITOR;
  57858. /** Get the inspector from bundle or global */
  57859. private _getGlobalNodeMaterialEditor;
  57860. /**
  57861. * Gets or sets data used by visual editor
  57862. * @see https://nme.babylonjs.com
  57863. */
  57864. editorData: any;
  57865. /**
  57866. * 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)
  57867. */
  57868. ignoreAlpha: boolean;
  57869. /**
  57870. * Defines the maximum number of lights that can be used in the material
  57871. */
  57872. maxSimultaneousLights: number;
  57873. /**
  57874. * Observable raised when the material is built
  57875. */
  57876. onBuildObservable: Observable<NodeMaterial>;
  57877. /**
  57878. * Gets or sets the root nodes of the material vertex shader
  57879. */
  57880. _vertexOutputNodes: NodeMaterialBlock[];
  57881. /**
  57882. * Gets or sets the root nodes of the material fragment (pixel) shader
  57883. */
  57884. _fragmentOutputNodes: NodeMaterialBlock[];
  57885. /** Gets or sets options to control the node material overall behavior */
  57886. get options(): INodeMaterialOptions;
  57887. set options(options: INodeMaterialOptions);
  57888. /**
  57889. * Default configuration related to image processing available in the standard Material.
  57890. */
  57891. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57892. /**
  57893. * Gets the image processing configuration used either in this material.
  57894. */
  57895. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57896. /**
  57897. * Sets the Default image processing configuration used either in the this material.
  57898. *
  57899. * If sets to null, the scene one is in use.
  57900. */
  57901. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57902. /**
  57903. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57904. */
  57905. attachedBlocks: NodeMaterialBlock[];
  57906. /**
  57907. * Create a new node based material
  57908. * @param name defines the material name
  57909. * @param scene defines the hosting scene
  57910. * @param options defines creation option
  57911. */
  57912. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57913. /**
  57914. * Gets the current class name of the material e.g. "NodeMaterial"
  57915. * @returns the class name
  57916. */
  57917. getClassName(): string;
  57918. /**
  57919. * Keep track of the image processing observer to allow dispose and replace.
  57920. */
  57921. private _imageProcessingObserver;
  57922. /**
  57923. * Attaches a new image processing configuration to the Standard Material.
  57924. * @param configuration
  57925. */
  57926. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57927. /**
  57928. * Get a block by its name
  57929. * @param name defines the name of the block to retrieve
  57930. * @returns the required block or null if not found
  57931. */
  57932. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57933. /**
  57934. * Get a block by its name
  57935. * @param predicate defines the predicate used to find the good candidate
  57936. * @returns the required block or null if not found
  57937. */
  57938. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57939. /**
  57940. * Get an input block by its name
  57941. * @param predicate defines the predicate used to find the good candidate
  57942. * @returns the required input block or null if not found
  57943. */
  57944. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57945. /**
  57946. * Gets the list of input blocks attached to this material
  57947. * @returns an array of InputBlocks
  57948. */
  57949. getInputBlocks(): InputBlock[];
  57950. /**
  57951. * Adds a new optimizer to the list of optimizers
  57952. * @param optimizer defines the optimizers to add
  57953. * @returns the current material
  57954. */
  57955. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57956. /**
  57957. * Remove an optimizer from the list of optimizers
  57958. * @param optimizer defines the optimizers to remove
  57959. * @returns the current material
  57960. */
  57961. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57962. /**
  57963. * Add a new block to the list of output nodes
  57964. * @param node defines the node to add
  57965. * @returns the current material
  57966. */
  57967. addOutputNode(node: NodeMaterialBlock): this;
  57968. /**
  57969. * Remove a block from the list of root nodes
  57970. * @param node defines the node to remove
  57971. * @returns the current material
  57972. */
  57973. removeOutputNode(node: NodeMaterialBlock): this;
  57974. private _addVertexOutputNode;
  57975. private _removeVertexOutputNode;
  57976. private _addFragmentOutputNode;
  57977. private _removeFragmentOutputNode;
  57978. /**
  57979. * Specifies if the material will require alpha blending
  57980. * @returns a boolean specifying if alpha blending is needed
  57981. */
  57982. needAlphaBlending(): boolean;
  57983. /**
  57984. * Specifies if this material should be rendered in alpha test mode
  57985. * @returns a boolean specifying if an alpha test is needed.
  57986. */
  57987. needAlphaTesting(): boolean;
  57988. private _initializeBlock;
  57989. private _resetDualBlocks;
  57990. /**
  57991. * Remove a block from the current node material
  57992. * @param block defines the block to remove
  57993. */
  57994. removeBlock(block: NodeMaterialBlock): void;
  57995. /**
  57996. * Build the material and generates the inner effect
  57997. * @param verbose defines if the build should log activity
  57998. */
  57999. build(verbose?: boolean): void;
  58000. /**
  58001. * Runs an otpimization phase to try to improve the shader code
  58002. */
  58003. optimize(): void;
  58004. private _prepareDefinesForAttributes;
  58005. /**
  58006. * Get if the submesh is ready to be used and all its information available.
  58007. * Child classes can use it to update shaders
  58008. * @param mesh defines the mesh to check
  58009. * @param subMesh defines which submesh to check
  58010. * @param useInstances specifies that instances should be used
  58011. * @returns a boolean indicating that the submesh is ready or not
  58012. */
  58013. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58014. /**
  58015. * Get a string representing the shaders built by the current node graph
  58016. */
  58017. get compiledShaders(): string;
  58018. /**
  58019. * Binds the world matrix to the material
  58020. * @param world defines the world transformation matrix
  58021. */
  58022. bindOnlyWorldMatrix(world: Matrix): void;
  58023. /**
  58024. * Binds the submesh to this material by preparing the effect and shader to draw
  58025. * @param world defines the world transformation matrix
  58026. * @param mesh defines the mesh containing the submesh
  58027. * @param subMesh defines the submesh to bind the material to
  58028. */
  58029. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58030. /**
  58031. * Gets the active textures from the material
  58032. * @returns an array of textures
  58033. */
  58034. getActiveTextures(): BaseTexture[];
  58035. /**
  58036. * Gets the list of texture blocks
  58037. * @returns an array of texture blocks
  58038. */
  58039. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58040. /**
  58041. * Specifies if the material uses a texture
  58042. * @param texture defines the texture to check against the material
  58043. * @returns a boolean specifying if the material uses the texture
  58044. */
  58045. hasTexture(texture: BaseTexture): boolean;
  58046. /**
  58047. * Disposes the material
  58048. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58049. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58050. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58051. */
  58052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58053. /** Creates the node editor window. */
  58054. private _createNodeEditor;
  58055. /**
  58056. * Launch the node material editor
  58057. * @param config Define the configuration of the editor
  58058. * @return a promise fulfilled when the node editor is visible
  58059. */
  58060. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58061. /**
  58062. * Clear the current material
  58063. */
  58064. clear(): void;
  58065. /**
  58066. * Clear the current material and set it to a default state
  58067. */
  58068. setToDefault(): void;
  58069. /**
  58070. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58071. * @param url defines the url to load from
  58072. * @returns a promise that will fullfil when the material is fully loaded
  58073. */
  58074. loadAsync(url: string): Promise<void>;
  58075. private _gatherBlocks;
  58076. /**
  58077. * Generate a string containing the code declaration required to create an equivalent of this material
  58078. * @returns a string
  58079. */
  58080. generateCode(): string;
  58081. /**
  58082. * Serializes this material in a JSON representation
  58083. * @returns the serialized material object
  58084. */
  58085. serialize(): any;
  58086. private _restoreConnections;
  58087. /**
  58088. * Clear the current graph and load a new one from a serialization object
  58089. * @param source defines the JSON representation of the material
  58090. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58091. */
  58092. loadFromSerialization(source: any, rootUrl?: string): void;
  58093. /**
  58094. * Creates a node material from parsed material data
  58095. * @param source defines the JSON representation of the material
  58096. * @param scene defines the hosting scene
  58097. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58098. * @returns a new node material
  58099. */
  58100. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58101. /**
  58102. * Creates a new node material set to default basic configuration
  58103. * @param name defines the name of the material
  58104. * @param scene defines the hosting scene
  58105. * @returns a new NodeMaterial
  58106. */
  58107. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58108. }
  58109. }
  58110. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58113. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58116. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58117. import { Effect } from "babylonjs/Materials/effect";
  58118. import { Mesh } from "babylonjs/Meshes/mesh";
  58119. import { Nullable } from "babylonjs/types";
  58120. import { Texture } from "babylonjs/Materials/Textures/texture";
  58121. import { Scene } from "babylonjs/scene";
  58122. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58123. /**
  58124. * Block used to read a texture from a sampler
  58125. */
  58126. export class TextureBlock extends NodeMaterialBlock {
  58127. private _defineName;
  58128. private _linearDefineName;
  58129. private _tempTextureRead;
  58130. private _samplerName;
  58131. private _transformedUVName;
  58132. private _textureTransformName;
  58133. private _textureInfoName;
  58134. private _mainUVName;
  58135. private _mainUVDefineName;
  58136. /**
  58137. * Gets or sets the texture associated with the node
  58138. */
  58139. texture: Nullable<Texture>;
  58140. /**
  58141. * Create a new TextureBlock
  58142. * @param name defines the block name
  58143. */
  58144. constructor(name: string);
  58145. /**
  58146. * Gets the current class name
  58147. * @returns the class name
  58148. */
  58149. getClassName(): string;
  58150. /**
  58151. * Gets the uv input component
  58152. */
  58153. get uv(): NodeMaterialConnectionPoint;
  58154. /**
  58155. * Gets the rgba output component
  58156. */
  58157. get rgba(): NodeMaterialConnectionPoint;
  58158. /**
  58159. * Gets the rgb output component
  58160. */
  58161. get rgb(): NodeMaterialConnectionPoint;
  58162. /**
  58163. * Gets the r output component
  58164. */
  58165. get r(): NodeMaterialConnectionPoint;
  58166. /**
  58167. * Gets the g output component
  58168. */
  58169. get g(): NodeMaterialConnectionPoint;
  58170. /**
  58171. * Gets the b output component
  58172. */
  58173. get b(): NodeMaterialConnectionPoint;
  58174. /**
  58175. * Gets the a output component
  58176. */
  58177. get a(): NodeMaterialConnectionPoint;
  58178. get target(): NodeMaterialBlockTargets;
  58179. autoConfigure(material: NodeMaterial): void;
  58180. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58182. private _getTextureBase;
  58183. isReady(): boolean;
  58184. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58185. private get _isMixed();
  58186. private _injectVertexCode;
  58187. private _writeTextureRead;
  58188. private _writeOutput;
  58189. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58190. protected _dumpPropertiesCode(): string;
  58191. serialize(): any;
  58192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58193. }
  58194. }
  58195. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  58196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58198. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58199. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58200. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58201. import { Scene } from "babylonjs/scene";
  58202. /**
  58203. * Class used to store shared data between 2 NodeMaterialBuildState
  58204. */
  58205. export class NodeMaterialBuildStateSharedData {
  58206. /**
  58207. * Gets the list of emitted varyings
  58208. */
  58209. temps: string[];
  58210. /**
  58211. * Gets the list of emitted varyings
  58212. */
  58213. varyings: string[];
  58214. /**
  58215. * Gets the varying declaration string
  58216. */
  58217. varyingDeclaration: string;
  58218. /**
  58219. * Input blocks
  58220. */
  58221. inputBlocks: InputBlock[];
  58222. /**
  58223. * Input blocks
  58224. */
  58225. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58226. /**
  58227. * Bindable blocks (Blocks that need to set data to the effect)
  58228. */
  58229. bindableBlocks: NodeMaterialBlock[];
  58230. /**
  58231. * List of blocks that can provide a compilation fallback
  58232. */
  58233. blocksWithFallbacks: NodeMaterialBlock[];
  58234. /**
  58235. * List of blocks that can provide a define update
  58236. */
  58237. blocksWithDefines: NodeMaterialBlock[];
  58238. /**
  58239. * List of blocks that can provide a repeatable content
  58240. */
  58241. repeatableContentBlocks: NodeMaterialBlock[];
  58242. /**
  58243. * List of blocks that can provide a dynamic list of uniforms
  58244. */
  58245. dynamicUniformBlocks: NodeMaterialBlock[];
  58246. /**
  58247. * List of blocks that can block the isReady function for the material
  58248. */
  58249. blockingBlocks: NodeMaterialBlock[];
  58250. /**
  58251. * Gets the list of animated inputs
  58252. */
  58253. animatedInputs: InputBlock[];
  58254. /**
  58255. * Build Id used to avoid multiple recompilations
  58256. */
  58257. buildId: number;
  58258. /** List of emitted variables */
  58259. variableNames: {
  58260. [key: string]: number;
  58261. };
  58262. /** List of emitted defines */
  58263. defineNames: {
  58264. [key: string]: number;
  58265. };
  58266. /** Should emit comments? */
  58267. emitComments: boolean;
  58268. /** Emit build activity */
  58269. verbose: boolean;
  58270. /** Gets or sets the hosting scene */
  58271. scene: Scene;
  58272. /**
  58273. * Gets the compilation hints emitted at compilation time
  58274. */
  58275. hints: {
  58276. needWorldViewMatrix: boolean;
  58277. needWorldViewProjectionMatrix: boolean;
  58278. needAlphaBlending: boolean;
  58279. needAlphaTesting: boolean;
  58280. };
  58281. /**
  58282. * List of compilation checks
  58283. */
  58284. checks: {
  58285. emitVertex: boolean;
  58286. emitFragment: boolean;
  58287. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58288. };
  58289. /** Creates a new shared data */
  58290. constructor();
  58291. /**
  58292. * Emits console errors and exceptions if there is a failing check
  58293. */
  58294. emitErrors(): void;
  58295. }
  58296. }
  58297. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  58298. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58299. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58300. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  58301. /**
  58302. * Class used to store node based material build state
  58303. */
  58304. export class NodeMaterialBuildState {
  58305. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58306. supportUniformBuffers: boolean;
  58307. /**
  58308. * Gets the list of emitted attributes
  58309. */
  58310. attributes: string[];
  58311. /**
  58312. * Gets the list of emitted uniforms
  58313. */
  58314. uniforms: string[];
  58315. /**
  58316. * Gets the list of emitted constants
  58317. */
  58318. constants: string[];
  58319. /**
  58320. * Gets the list of emitted samplers
  58321. */
  58322. samplers: string[];
  58323. /**
  58324. * Gets the list of emitted functions
  58325. */
  58326. functions: {
  58327. [key: string]: string;
  58328. };
  58329. /**
  58330. * Gets the list of emitted extensions
  58331. */
  58332. extensions: {
  58333. [key: string]: string;
  58334. };
  58335. /**
  58336. * Gets the target of the compilation state
  58337. */
  58338. target: NodeMaterialBlockTargets;
  58339. /**
  58340. * Gets the list of emitted counters
  58341. */
  58342. counters: {
  58343. [key: string]: number;
  58344. };
  58345. /**
  58346. * Shared data between multiple NodeMaterialBuildState instances
  58347. */
  58348. sharedData: NodeMaterialBuildStateSharedData;
  58349. /** @hidden */
  58350. _vertexState: NodeMaterialBuildState;
  58351. /** @hidden */
  58352. _attributeDeclaration: string;
  58353. /** @hidden */
  58354. _uniformDeclaration: string;
  58355. /** @hidden */
  58356. _constantDeclaration: string;
  58357. /** @hidden */
  58358. _samplerDeclaration: string;
  58359. /** @hidden */
  58360. _varyingTransfer: string;
  58361. private _repeatableContentAnchorIndex;
  58362. /** @hidden */
  58363. _builtCompilationString: string;
  58364. /**
  58365. * Gets the emitted compilation strings
  58366. */
  58367. compilationString: string;
  58368. /**
  58369. * Finalize the compilation strings
  58370. * @param state defines the current compilation state
  58371. */
  58372. finalize(state: NodeMaterialBuildState): void;
  58373. /** @hidden */
  58374. get _repeatableContentAnchor(): string;
  58375. /** @hidden */
  58376. _getFreeVariableName(prefix: string): string;
  58377. /** @hidden */
  58378. _getFreeDefineName(prefix: string): string;
  58379. /** @hidden */
  58380. _excludeVariableName(name: string): void;
  58381. /** @hidden */
  58382. _emit2DSampler(name: string): void;
  58383. /** @hidden */
  58384. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58385. /** @hidden */
  58386. _emitExtension(name: string, extension: string): void;
  58387. /** @hidden */
  58388. _emitFunction(name: string, code: string, comments: string): void;
  58389. /** @hidden */
  58390. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58391. replaceStrings?: {
  58392. search: RegExp;
  58393. replace: string;
  58394. }[];
  58395. repeatKey?: string;
  58396. }): string;
  58397. /** @hidden */
  58398. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58399. repeatKey?: string;
  58400. removeAttributes?: boolean;
  58401. removeUniforms?: boolean;
  58402. removeVaryings?: boolean;
  58403. removeIfDef?: boolean;
  58404. replaceStrings?: {
  58405. search: RegExp;
  58406. replace: string;
  58407. }[];
  58408. }, storeKey?: string): void;
  58409. /** @hidden */
  58410. _registerTempVariable(name: string): boolean;
  58411. /** @hidden */
  58412. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58413. /** @hidden */
  58414. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58415. /** @hidden */
  58416. _emitFloat(value: number): string;
  58417. }
  58418. }
  58419. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  58420. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58422. import { Nullable } from "babylonjs/types";
  58423. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58424. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58425. import { Effect } from "babylonjs/Materials/effect";
  58426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58427. import { Mesh } from "babylonjs/Meshes/mesh";
  58428. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58429. import { Scene } from "babylonjs/scene";
  58430. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58431. /**
  58432. * Defines a block that can be used inside a node based material
  58433. */
  58434. export class NodeMaterialBlock {
  58435. private _buildId;
  58436. private _buildTarget;
  58437. private _target;
  58438. private _isFinalMerger;
  58439. private _isInput;
  58440. protected _isUnique: boolean;
  58441. /** @hidden */
  58442. _codeVariableName: string;
  58443. /** @hidden */
  58444. _inputs: NodeMaterialConnectionPoint[];
  58445. /** @hidden */
  58446. _outputs: NodeMaterialConnectionPoint[];
  58447. /** @hidden */
  58448. _preparationId: number;
  58449. /**
  58450. * Gets or sets the name of the block
  58451. */
  58452. name: string;
  58453. /**
  58454. * Gets or sets the unique id of the node
  58455. */
  58456. uniqueId: number;
  58457. /**
  58458. * Gets or sets the comments associated with this block
  58459. */
  58460. comments: string;
  58461. /**
  58462. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58463. */
  58464. get isUnique(): boolean;
  58465. /**
  58466. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58467. */
  58468. get isFinalMerger(): boolean;
  58469. /**
  58470. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58471. */
  58472. get isInput(): boolean;
  58473. /**
  58474. * Gets or sets the build Id
  58475. */
  58476. get buildId(): number;
  58477. set buildId(value: number);
  58478. /**
  58479. * Gets or sets the target of the block
  58480. */
  58481. get target(): NodeMaterialBlockTargets;
  58482. set target(value: NodeMaterialBlockTargets);
  58483. /**
  58484. * Gets the list of input points
  58485. */
  58486. get inputs(): NodeMaterialConnectionPoint[];
  58487. /** Gets the list of output points */
  58488. get outputs(): NodeMaterialConnectionPoint[];
  58489. /**
  58490. * Find an input by its name
  58491. * @param name defines the name of the input to look for
  58492. * @returns the input or null if not found
  58493. */
  58494. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58495. /**
  58496. * Find an output by its name
  58497. * @param name defines the name of the outputto look for
  58498. * @returns the output or null if not found
  58499. */
  58500. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58501. /**
  58502. * Creates a new NodeMaterialBlock
  58503. * @param name defines the block name
  58504. * @param target defines the target of that block (Vertex by default)
  58505. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58506. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58507. */
  58508. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58509. /**
  58510. * Initialize the block and prepare the context for build
  58511. * @param state defines the state that will be used for the build
  58512. */
  58513. initialize(state: NodeMaterialBuildState): void;
  58514. /**
  58515. * Bind data to effect. Will only be called for blocks with isBindable === true
  58516. * @param effect defines the effect to bind data to
  58517. * @param nodeMaterial defines the hosting NodeMaterial
  58518. * @param mesh defines the mesh that will be rendered
  58519. */
  58520. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58521. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58522. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58523. protected _writeFloat(value: number): string;
  58524. /**
  58525. * Gets the current class name e.g. "NodeMaterialBlock"
  58526. * @returns the class name
  58527. */
  58528. getClassName(): string;
  58529. /**
  58530. * Register a new input. Must be called inside a block constructor
  58531. * @param name defines the connection point name
  58532. * @param type defines the connection point type
  58533. * @param isOptional defines a boolean indicating that this input can be omitted
  58534. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58535. * @returns the current block
  58536. */
  58537. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58538. /**
  58539. * Register a new output. Must be called inside a block constructor
  58540. * @param name defines the connection point name
  58541. * @param type defines the connection point type
  58542. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58543. * @returns the current block
  58544. */
  58545. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58546. /**
  58547. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58548. * @param forOutput defines an optional connection point to check compatibility with
  58549. * @returns the first available input or null
  58550. */
  58551. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58552. /**
  58553. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58554. * @param forBlock defines an optional block to check compatibility with
  58555. * @returns the first available input or null
  58556. */
  58557. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58558. /**
  58559. * Gets the sibling of the given output
  58560. * @param current defines the current output
  58561. * @returns the next output in the list or null
  58562. */
  58563. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58564. /**
  58565. * Connect current block with another block
  58566. * @param other defines the block to connect with
  58567. * @param options define the various options to help pick the right connections
  58568. * @returns the current block
  58569. */
  58570. connectTo(other: NodeMaterialBlock, options?: {
  58571. input?: string;
  58572. output?: string;
  58573. outputSwizzle?: string;
  58574. }): this | undefined;
  58575. protected _buildBlock(state: NodeMaterialBuildState): void;
  58576. /**
  58577. * Add uniforms, samplers and uniform buffers at compilation time
  58578. * @param state defines the state to update
  58579. * @param nodeMaterial defines the node material requesting the update
  58580. * @param defines defines the material defines to update
  58581. * @param uniformBuffers defines the list of uniform buffer names
  58582. */
  58583. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58584. /**
  58585. * Add potential fallbacks if shader compilation fails
  58586. * @param mesh defines the mesh to be rendered
  58587. * @param fallbacks defines the current prioritized list of fallbacks
  58588. */
  58589. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58590. /**
  58591. * Initialize defines for shader compilation
  58592. * @param mesh defines the mesh to be rendered
  58593. * @param nodeMaterial defines the node material requesting the update
  58594. * @param defines defines the material defines to update
  58595. * @param useInstances specifies that instances should be used
  58596. */
  58597. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58598. /**
  58599. * Update defines for shader compilation
  58600. * @param mesh defines the mesh to be rendered
  58601. * @param nodeMaterial defines the node material requesting the update
  58602. * @param defines defines the material defines to update
  58603. * @param useInstances specifies that instances should be used
  58604. */
  58605. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58606. /**
  58607. * Lets the block try to connect some inputs automatically
  58608. * @param material defines the hosting NodeMaterial
  58609. */
  58610. autoConfigure(material: NodeMaterial): void;
  58611. /**
  58612. * Function called when a block is declared as repeatable content generator
  58613. * @param vertexShaderState defines the current compilation state for the vertex shader
  58614. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58615. * @param mesh defines the mesh to be rendered
  58616. * @param defines defines the material defines to update
  58617. */
  58618. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58619. /**
  58620. * Checks if the block is ready
  58621. * @param mesh defines the mesh to be rendered
  58622. * @param nodeMaterial defines the node material requesting the update
  58623. * @param defines defines the material defines to update
  58624. * @param useInstances specifies that instances should be used
  58625. * @returns true if the block is ready
  58626. */
  58627. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58628. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58629. private _processBuild;
  58630. /**
  58631. * Compile the current node and generate the shader code
  58632. * @param state defines the current compilation state (uniforms, samplers, current string)
  58633. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58634. * @returns true if already built
  58635. */
  58636. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58637. protected _inputRename(name: string): string;
  58638. protected _outputRename(name: string): string;
  58639. protected _dumpPropertiesCode(): string;
  58640. /** @hidden */
  58641. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58642. /** @hidden */
  58643. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58644. /**
  58645. * Clone the current block to a new identical block
  58646. * @param scene defines the hosting scene
  58647. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58648. * @returns a copy of the current block
  58649. */
  58650. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58651. /**
  58652. * Serializes this block in a JSON representation
  58653. * @returns the serialized block object
  58654. */
  58655. serialize(): any;
  58656. /** @hidden */
  58657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58658. /**
  58659. * Release resources
  58660. */
  58661. dispose(): void;
  58662. }
  58663. }
  58664. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  58665. /**
  58666. * Enum defining the type of animations supported by InputBlock
  58667. */
  58668. export enum AnimatedInputBlockTypes {
  58669. /** No animation */
  58670. None = 0,
  58671. /** Time based animation. Will only work for floats */
  58672. Time = 1
  58673. }
  58674. }
  58675. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  58676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58677. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58678. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58679. import { Nullable } from "babylonjs/types";
  58680. import { Effect } from "babylonjs/Materials/effect";
  58681. import { Matrix } from "babylonjs/Maths/math.vector";
  58682. import { Scene } from "babylonjs/scene";
  58683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58684. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58685. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58686. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58687. /**
  58688. * Block used to expose an input value
  58689. */
  58690. export class InputBlock extends NodeMaterialBlock {
  58691. private _mode;
  58692. private _associatedVariableName;
  58693. private _storedValue;
  58694. private _valueCallback;
  58695. private _type;
  58696. private _animationType;
  58697. /** Gets or set a value used to limit the range of float values */
  58698. min: number;
  58699. /** Gets or set a value used to limit the range of float values */
  58700. max: number;
  58701. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58702. matrixMode: number;
  58703. /** @hidden */
  58704. _systemValue: Nullable<NodeMaterialSystemValues>;
  58705. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58706. visibleInInspector: boolean;
  58707. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58708. isConstant: boolean;
  58709. /** Gets or sets the group to use to display this block in the Inspector */
  58710. groupInInspector: string;
  58711. /**
  58712. * Gets or sets the connection point type (default is float)
  58713. */
  58714. get type(): NodeMaterialBlockConnectionPointTypes;
  58715. /**
  58716. * Creates a new InputBlock
  58717. * @param name defines the block name
  58718. * @param target defines the target of that block (Vertex by default)
  58719. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58720. */
  58721. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58722. /**
  58723. * Gets the output component
  58724. */
  58725. get output(): NodeMaterialConnectionPoint;
  58726. /**
  58727. * Set the source of this connection point to a vertex attribute
  58728. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58729. * @returns the current connection point
  58730. */
  58731. setAsAttribute(attributeName?: string): InputBlock;
  58732. /**
  58733. * Set the source of this connection point to a system value
  58734. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58735. * @returns the current connection point
  58736. */
  58737. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58738. /**
  58739. * Gets or sets the value of that point.
  58740. * Please note that this value will be ignored if valueCallback is defined
  58741. */
  58742. get value(): any;
  58743. set value(value: any);
  58744. /**
  58745. * Gets or sets a callback used to get the value of that point.
  58746. * Please note that setting this value will force the connection point to ignore the value property
  58747. */
  58748. get valueCallback(): () => any;
  58749. set valueCallback(value: () => any);
  58750. /**
  58751. * Gets or sets the associated variable name in the shader
  58752. */
  58753. get associatedVariableName(): string;
  58754. set associatedVariableName(value: string);
  58755. /** Gets or sets the type of animation applied to the input */
  58756. get animationType(): AnimatedInputBlockTypes;
  58757. set animationType(value: AnimatedInputBlockTypes);
  58758. /**
  58759. * Gets a boolean indicating that this connection point not defined yet
  58760. */
  58761. get isUndefined(): boolean;
  58762. /**
  58763. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58764. * In this case the connection point name must be the name of the uniform to use.
  58765. * Can only be set on inputs
  58766. */
  58767. get isUniform(): boolean;
  58768. set isUniform(value: boolean);
  58769. /**
  58770. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58771. * In this case the connection point name must be the name of the attribute to use
  58772. * Can only be set on inputs
  58773. */
  58774. get isAttribute(): boolean;
  58775. set isAttribute(value: boolean);
  58776. /**
  58777. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58778. * Can only be set on exit points
  58779. */
  58780. get isVarying(): boolean;
  58781. set isVarying(value: boolean);
  58782. /**
  58783. * Gets a boolean indicating that the current connection point is a system value
  58784. */
  58785. get isSystemValue(): boolean;
  58786. /**
  58787. * Gets or sets the current well known value or null if not defined as a system value
  58788. */
  58789. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58790. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58791. /**
  58792. * Gets the current class name
  58793. * @returns the class name
  58794. */
  58795. getClassName(): string;
  58796. /**
  58797. * Animate the input if animationType !== None
  58798. * @param scene defines the rendering scene
  58799. */
  58800. animate(scene: Scene): void;
  58801. private _emitDefine;
  58802. initialize(state: NodeMaterialBuildState): void;
  58803. /**
  58804. * Set the input block to its default value (based on its type)
  58805. */
  58806. setDefaultValue(): void;
  58807. private _emitConstant;
  58808. private _emit;
  58809. /** @hidden */
  58810. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58811. /** @hidden */
  58812. _transmit(effect: Effect, scene: Scene): void;
  58813. protected _buildBlock(state: NodeMaterialBuildState): void;
  58814. protected _dumpPropertiesCode(): string;
  58815. serialize(): any;
  58816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58817. }
  58818. }
  58819. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  58820. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58821. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58822. import { Nullable } from "babylonjs/types";
  58823. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58824. import { Observable } from "babylonjs/Misc/observable";
  58825. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58826. /**
  58827. * Enum used to define the compatibility state between two connection points
  58828. */
  58829. export enum NodeMaterialConnectionPointCompatibilityStates {
  58830. /** Points are compatibles */
  58831. Compatible = 0,
  58832. /** Points are incompatible because of their types */
  58833. TypeIncompatible = 1,
  58834. /** Points are incompatible because of their targets (vertex vs fragment) */
  58835. TargetIncompatible = 2
  58836. }
  58837. /**
  58838. * Defines the direction of a connection point
  58839. */
  58840. export enum NodeMaterialConnectionPointDirection {
  58841. /** Input */
  58842. Input = 0,
  58843. /** Output */
  58844. Output = 1
  58845. }
  58846. /**
  58847. * Defines a connection point for a block
  58848. */
  58849. export class NodeMaterialConnectionPoint {
  58850. /** @hidden */
  58851. _ownerBlock: NodeMaterialBlock;
  58852. /** @hidden */
  58853. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58854. private _endpoints;
  58855. private _associatedVariableName;
  58856. private _direction;
  58857. /** @hidden */
  58858. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58859. /** @hidden */
  58860. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58861. private _type;
  58862. /** @hidden */
  58863. _enforceAssociatedVariableName: boolean;
  58864. /** Gets the direction of the point */
  58865. get direction(): NodeMaterialConnectionPointDirection;
  58866. /**
  58867. * Gets or sets the additional types supported by this connection point
  58868. */
  58869. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58870. /**
  58871. * Gets or sets the additional types excluded by this connection point
  58872. */
  58873. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58874. /**
  58875. * Observable triggered when this point is connected
  58876. */
  58877. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58878. /**
  58879. * Gets or sets the associated variable name in the shader
  58880. */
  58881. get associatedVariableName(): string;
  58882. set associatedVariableName(value: string);
  58883. /**
  58884. * Gets or sets the connection point type (default is float)
  58885. */
  58886. get type(): NodeMaterialBlockConnectionPointTypes;
  58887. set type(value: NodeMaterialBlockConnectionPointTypes);
  58888. /**
  58889. * Gets or sets the connection point name
  58890. */
  58891. name: string;
  58892. /**
  58893. * Gets or sets a boolean indicating that this connection point can be omitted
  58894. */
  58895. isOptional: boolean;
  58896. /**
  58897. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58898. */
  58899. define: string;
  58900. /** @hidden */
  58901. _prioritizeVertex: boolean;
  58902. private _target;
  58903. /** Gets or sets the target of that connection point */
  58904. get target(): NodeMaterialBlockTargets;
  58905. set target(value: NodeMaterialBlockTargets);
  58906. /**
  58907. * Gets a boolean indicating that the current point is connected
  58908. */
  58909. get isConnected(): boolean;
  58910. /**
  58911. * Gets a boolean indicating that the current point is connected to an input block
  58912. */
  58913. get isConnectedToInputBlock(): boolean;
  58914. /**
  58915. * Gets a the connected input block (if any)
  58916. */
  58917. get connectInputBlock(): Nullable<InputBlock>;
  58918. /** Get the other side of the connection (if any) */
  58919. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58920. /** Get the block that owns this connection point */
  58921. get ownerBlock(): NodeMaterialBlock;
  58922. /** Get the block connected on the other side of this connection (if any) */
  58923. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58924. /** Get the block connected on the endpoints of this connection (if any) */
  58925. get connectedBlocks(): Array<NodeMaterialBlock>;
  58926. /** Gets the list of connected endpoints */
  58927. get endpoints(): NodeMaterialConnectionPoint[];
  58928. /** Gets a boolean indicating if that output point is connected to at least one input */
  58929. get hasEndpoints(): boolean;
  58930. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58931. get isConnectedInVertexShader(): boolean;
  58932. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58933. get isConnectedInFragmentShader(): boolean;
  58934. /**
  58935. * Creates a new connection point
  58936. * @param name defines the connection point name
  58937. * @param ownerBlock defines the block hosting this connection point
  58938. * @param direction defines the direction of the connection point
  58939. */
  58940. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58941. /**
  58942. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58943. * @returns the class name
  58944. */
  58945. getClassName(): string;
  58946. /**
  58947. * Gets a boolean indicating if the current point can be connected to another point
  58948. * @param connectionPoint defines the other connection point
  58949. * @returns a boolean
  58950. */
  58951. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58952. /**
  58953. * Gets a number indicating if the current point can be connected to another point
  58954. * @param connectionPoint defines the other connection point
  58955. * @returns a number defining the compatibility state
  58956. */
  58957. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58958. /**
  58959. * Connect this point to another connection point
  58960. * @param connectionPoint defines the other connection point
  58961. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58962. * @returns the current connection point
  58963. */
  58964. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58965. /**
  58966. * Disconnect this point from one of his endpoint
  58967. * @param endpoint defines the other connection point
  58968. * @returns the current connection point
  58969. */
  58970. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58971. /**
  58972. * Serializes this point in a JSON representation
  58973. * @returns the serialized point object
  58974. */
  58975. serialize(): any;
  58976. /**
  58977. * Release resources
  58978. */
  58979. dispose(): void;
  58980. }
  58981. }
  58982. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  58983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58986. import { Mesh } from "babylonjs/Meshes/mesh";
  58987. import { Effect } from "babylonjs/Materials/effect";
  58988. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58989. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58990. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58991. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58992. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58993. /**
  58994. * Block used to add support for vertex skinning (bones)
  58995. */
  58996. export class BonesBlock extends NodeMaterialBlock {
  58997. /**
  58998. * Creates a new BonesBlock
  58999. * @param name defines the block name
  59000. */
  59001. constructor(name: string);
  59002. /**
  59003. * Initialize the block and prepare the context for build
  59004. * @param state defines the state that will be used for the build
  59005. */
  59006. initialize(state: NodeMaterialBuildState): void;
  59007. /**
  59008. * Gets the current class name
  59009. * @returns the class name
  59010. */
  59011. getClassName(): string;
  59012. /**
  59013. * Gets the matrix indices input component
  59014. */
  59015. get matricesIndices(): NodeMaterialConnectionPoint;
  59016. /**
  59017. * Gets the matrix weights input component
  59018. */
  59019. get matricesWeights(): NodeMaterialConnectionPoint;
  59020. /**
  59021. * Gets the extra matrix indices input component
  59022. */
  59023. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59024. /**
  59025. * Gets the extra matrix weights input component
  59026. */
  59027. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59028. /**
  59029. * Gets the world input component
  59030. */
  59031. get world(): NodeMaterialConnectionPoint;
  59032. /**
  59033. * Gets the output component
  59034. */
  59035. get output(): NodeMaterialConnectionPoint;
  59036. autoConfigure(material: NodeMaterial): void;
  59037. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59038. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59039. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59040. protected _buildBlock(state: NodeMaterialBuildState): this;
  59041. }
  59042. }
  59043. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59048. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59049. /**
  59050. * Block used to add support for instances
  59051. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59052. */
  59053. export class InstancesBlock extends NodeMaterialBlock {
  59054. /**
  59055. * Creates a new InstancesBlock
  59056. * @param name defines the block name
  59057. */
  59058. constructor(name: string);
  59059. /**
  59060. * Gets the current class name
  59061. * @returns the class name
  59062. */
  59063. getClassName(): string;
  59064. /**
  59065. * Gets the first world row input component
  59066. */
  59067. get world0(): NodeMaterialConnectionPoint;
  59068. /**
  59069. * Gets the second world row input component
  59070. */
  59071. get world1(): NodeMaterialConnectionPoint;
  59072. /**
  59073. * Gets the third world row input component
  59074. */
  59075. get world2(): NodeMaterialConnectionPoint;
  59076. /**
  59077. * Gets the forth world row input component
  59078. */
  59079. get world3(): NodeMaterialConnectionPoint;
  59080. /**
  59081. * Gets the world input component
  59082. */
  59083. get world(): NodeMaterialConnectionPoint;
  59084. /**
  59085. * Gets the output component
  59086. */
  59087. get output(): NodeMaterialConnectionPoint;
  59088. autoConfigure(material: NodeMaterial): void;
  59089. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59090. protected _buildBlock(state: NodeMaterialBuildState): this;
  59091. }
  59092. }
  59093. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59098. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59099. import { Effect } from "babylonjs/Materials/effect";
  59100. import { Mesh } from "babylonjs/Meshes/mesh";
  59101. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59102. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59103. /**
  59104. * Block used to add morph targets support to vertex shader
  59105. */
  59106. export class MorphTargetsBlock extends NodeMaterialBlock {
  59107. private _repeatableContentAnchor;
  59108. private _repeatebleContentGenerated;
  59109. /**
  59110. * Create a new MorphTargetsBlock
  59111. * @param name defines the block name
  59112. */
  59113. constructor(name: string);
  59114. /**
  59115. * Gets the current class name
  59116. * @returns the class name
  59117. */
  59118. getClassName(): string;
  59119. /**
  59120. * Gets the position input component
  59121. */
  59122. get position(): NodeMaterialConnectionPoint;
  59123. /**
  59124. * Gets the normal input component
  59125. */
  59126. get normal(): NodeMaterialConnectionPoint;
  59127. /**
  59128. * Gets the tangent input component
  59129. */
  59130. get tangent(): NodeMaterialConnectionPoint;
  59131. /**
  59132. * Gets the tangent input component
  59133. */
  59134. get uv(): NodeMaterialConnectionPoint;
  59135. /**
  59136. * Gets the position output component
  59137. */
  59138. get positionOutput(): NodeMaterialConnectionPoint;
  59139. /**
  59140. * Gets the normal output component
  59141. */
  59142. get normalOutput(): NodeMaterialConnectionPoint;
  59143. /**
  59144. * Gets the tangent output component
  59145. */
  59146. get tangentOutput(): NodeMaterialConnectionPoint;
  59147. /**
  59148. * Gets the tangent output component
  59149. */
  59150. get uvOutput(): NodeMaterialConnectionPoint;
  59151. initialize(state: NodeMaterialBuildState): void;
  59152. autoConfigure(material: NodeMaterial): void;
  59153. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59154. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59155. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59156. protected _buildBlock(state: NodeMaterialBuildState): this;
  59157. }
  59158. }
  59159. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  59160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59163. import { Nullable } from "babylonjs/types";
  59164. import { Scene } from "babylonjs/scene";
  59165. import { Effect } from "babylonjs/Materials/effect";
  59166. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59167. import { Mesh } from "babylonjs/Meshes/mesh";
  59168. import { Light } from "babylonjs/Lights/light";
  59169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59170. /**
  59171. * Block used to get data information from a light
  59172. */
  59173. export class LightInformationBlock extends NodeMaterialBlock {
  59174. private _lightDataUniformName;
  59175. private _lightColorUniformName;
  59176. private _lightTypeDefineName;
  59177. /**
  59178. * Gets or sets the light associated with this block
  59179. */
  59180. light: Nullable<Light>;
  59181. /**
  59182. * Creates a new LightInformationBlock
  59183. * @param name defines the block name
  59184. */
  59185. constructor(name: string);
  59186. /**
  59187. * Gets the current class name
  59188. * @returns the class name
  59189. */
  59190. getClassName(): string;
  59191. /**
  59192. * Gets the world position input component
  59193. */
  59194. get worldPosition(): NodeMaterialConnectionPoint;
  59195. /**
  59196. * Gets the direction output component
  59197. */
  59198. get direction(): NodeMaterialConnectionPoint;
  59199. /**
  59200. * Gets the direction output component
  59201. */
  59202. get color(): NodeMaterialConnectionPoint;
  59203. /**
  59204. * Gets the direction output component
  59205. */
  59206. get intensity(): NodeMaterialConnectionPoint;
  59207. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59208. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59209. protected _buildBlock(state: NodeMaterialBuildState): this;
  59210. serialize(): any;
  59211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59212. }
  59213. }
  59214. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  59215. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  59216. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  59217. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  59218. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  59219. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  59220. }
  59221. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  59222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59226. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59227. import { Effect } from "babylonjs/Materials/effect";
  59228. import { Mesh } from "babylonjs/Meshes/mesh";
  59229. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59230. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59231. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59232. /**
  59233. * Block used to add image processing support to fragment shader
  59234. */
  59235. export class ImageProcessingBlock extends NodeMaterialBlock {
  59236. /**
  59237. * Create a new ImageProcessingBlock
  59238. * @param name defines the block name
  59239. */
  59240. constructor(name: string);
  59241. /**
  59242. * Gets the current class name
  59243. * @returns the class name
  59244. */
  59245. getClassName(): string;
  59246. /**
  59247. * Gets the color input component
  59248. */
  59249. get color(): NodeMaterialConnectionPoint;
  59250. /**
  59251. * Gets the output component
  59252. */
  59253. get output(): NodeMaterialConnectionPoint;
  59254. /**
  59255. * Initialize the block and prepare the context for build
  59256. * @param state defines the state that will be used for the build
  59257. */
  59258. initialize(state: NodeMaterialBuildState): void;
  59259. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59260. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59262. protected _buildBlock(state: NodeMaterialBuildState): this;
  59263. }
  59264. }
  59265. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  59266. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59267. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59268. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59269. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59271. import { Effect } from "babylonjs/Materials/effect";
  59272. import { Mesh } from "babylonjs/Meshes/mesh";
  59273. import { Scene } from "babylonjs/scene";
  59274. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59275. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59276. /**
  59277. * Block used to pertub normals based on a normal map
  59278. */
  59279. export class PerturbNormalBlock extends NodeMaterialBlock {
  59280. private _tangentSpaceParameterName;
  59281. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59282. invertX: boolean;
  59283. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59284. invertY: boolean;
  59285. /**
  59286. * Create a new PerturbNormalBlock
  59287. * @param name defines the block name
  59288. */
  59289. constructor(name: string);
  59290. /**
  59291. * Gets the current class name
  59292. * @returns the class name
  59293. */
  59294. getClassName(): string;
  59295. /**
  59296. * Gets the world position input component
  59297. */
  59298. get worldPosition(): NodeMaterialConnectionPoint;
  59299. /**
  59300. * Gets the world normal input component
  59301. */
  59302. get worldNormal(): NodeMaterialConnectionPoint;
  59303. /**
  59304. * Gets the uv input component
  59305. */
  59306. get uv(): NodeMaterialConnectionPoint;
  59307. /**
  59308. * Gets the normal map color input component
  59309. */
  59310. get normalMapColor(): NodeMaterialConnectionPoint;
  59311. /**
  59312. * Gets the strength input component
  59313. */
  59314. get strength(): NodeMaterialConnectionPoint;
  59315. /**
  59316. * Gets the output component
  59317. */
  59318. get output(): NodeMaterialConnectionPoint;
  59319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59320. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59321. autoConfigure(material: NodeMaterial): void;
  59322. protected _buildBlock(state: NodeMaterialBuildState): this;
  59323. protected _dumpPropertiesCode(): string;
  59324. serialize(): any;
  59325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59326. }
  59327. }
  59328. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  59329. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59330. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59331. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59332. /**
  59333. * Block used to discard a pixel if a value is smaller than a cutoff
  59334. */
  59335. export class DiscardBlock extends NodeMaterialBlock {
  59336. /**
  59337. * Create a new DiscardBlock
  59338. * @param name defines the block name
  59339. */
  59340. constructor(name: string);
  59341. /**
  59342. * Gets the current class name
  59343. * @returns the class name
  59344. */
  59345. getClassName(): string;
  59346. /**
  59347. * Gets the color input component
  59348. */
  59349. get value(): NodeMaterialConnectionPoint;
  59350. /**
  59351. * Gets the cutoff input component
  59352. */
  59353. get cutoff(): NodeMaterialConnectionPoint;
  59354. protected _buildBlock(state: NodeMaterialBuildState): this;
  59355. }
  59356. }
  59357. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  59358. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59359. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59360. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59361. /**
  59362. * Block used to test if the fragment shader is front facing
  59363. */
  59364. export class FrontFacingBlock extends NodeMaterialBlock {
  59365. /**
  59366. * Creates a new FrontFacingBlock
  59367. * @param name defines the block name
  59368. */
  59369. constructor(name: string);
  59370. /**
  59371. * Gets the current class name
  59372. * @returns the class name
  59373. */
  59374. getClassName(): string;
  59375. /**
  59376. * Gets the output component
  59377. */
  59378. get output(): NodeMaterialConnectionPoint;
  59379. protected _buildBlock(state: NodeMaterialBuildState): this;
  59380. }
  59381. }
  59382. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  59383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59386. /**
  59387. * Block used to get the derivative value on x and y of a given input
  59388. */
  59389. export class DerivativeBlock extends NodeMaterialBlock {
  59390. /**
  59391. * Create a new DerivativeBlock
  59392. * @param name defines the block name
  59393. */
  59394. constructor(name: string);
  59395. /**
  59396. * Gets the current class name
  59397. * @returns the class name
  59398. */
  59399. getClassName(): string;
  59400. /**
  59401. * Gets the input component
  59402. */
  59403. get input(): NodeMaterialConnectionPoint;
  59404. /**
  59405. * Gets the derivative output on x
  59406. */
  59407. get dx(): NodeMaterialConnectionPoint;
  59408. /**
  59409. * Gets the derivative output on y
  59410. */
  59411. get dy(): NodeMaterialConnectionPoint;
  59412. protected _buildBlock(state: NodeMaterialBuildState): this;
  59413. }
  59414. }
  59415. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  59416. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  59417. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  59418. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  59419. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  59420. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  59421. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  59422. }
  59423. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  59424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59426. import { Mesh } from "babylonjs/Meshes/mesh";
  59427. import { Effect } from "babylonjs/Materials/effect";
  59428. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59430. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59431. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59432. /**
  59433. * Block used to add support for scene fog
  59434. */
  59435. export class FogBlock extends NodeMaterialBlock {
  59436. private _fogDistanceName;
  59437. private _fogParameters;
  59438. /**
  59439. * Create a new FogBlock
  59440. * @param name defines the block name
  59441. */
  59442. constructor(name: string);
  59443. /**
  59444. * Gets the current class name
  59445. * @returns the class name
  59446. */
  59447. getClassName(): string;
  59448. /**
  59449. * Gets the world position input component
  59450. */
  59451. get worldPosition(): NodeMaterialConnectionPoint;
  59452. /**
  59453. * Gets the view input component
  59454. */
  59455. get view(): NodeMaterialConnectionPoint;
  59456. /**
  59457. * Gets the color input component
  59458. */
  59459. get input(): NodeMaterialConnectionPoint;
  59460. /**
  59461. * Gets the fog color input component
  59462. */
  59463. get fogColor(): NodeMaterialConnectionPoint;
  59464. /**
  59465. * Gets the output component
  59466. */
  59467. get output(): NodeMaterialConnectionPoint;
  59468. autoConfigure(material: NodeMaterial): void;
  59469. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59470. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59471. protected _buildBlock(state: NodeMaterialBuildState): this;
  59472. }
  59473. }
  59474. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  59475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59479. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59480. import { Effect } from "babylonjs/Materials/effect";
  59481. import { Mesh } from "babylonjs/Meshes/mesh";
  59482. import { Light } from "babylonjs/Lights/light";
  59483. import { Nullable } from "babylonjs/types";
  59484. import { Scene } from "babylonjs/scene";
  59485. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59486. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59487. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59488. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59489. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59490. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59491. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59492. /**
  59493. * Block used to add light in the fragment shader
  59494. */
  59495. export class LightBlock extends NodeMaterialBlock {
  59496. private _lightId;
  59497. /**
  59498. * Gets or sets the light associated with this block
  59499. */
  59500. light: Nullable<Light>;
  59501. /**
  59502. * Create a new LightBlock
  59503. * @param name defines the block name
  59504. */
  59505. constructor(name: string);
  59506. /**
  59507. * Gets the current class name
  59508. * @returns the class name
  59509. */
  59510. getClassName(): string;
  59511. /**
  59512. * Gets the world position input component
  59513. */
  59514. get worldPosition(): NodeMaterialConnectionPoint;
  59515. /**
  59516. * Gets the world normal input component
  59517. */
  59518. get worldNormal(): NodeMaterialConnectionPoint;
  59519. /**
  59520. * Gets the camera (or eye) position component
  59521. */
  59522. get cameraPosition(): NodeMaterialConnectionPoint;
  59523. /**
  59524. * Gets the glossiness component
  59525. */
  59526. get glossiness(): NodeMaterialConnectionPoint;
  59527. /**
  59528. * Gets the glossinness power component
  59529. */
  59530. get glossPower(): NodeMaterialConnectionPoint;
  59531. /**
  59532. * Gets the diffuse color component
  59533. */
  59534. get diffuseColor(): NodeMaterialConnectionPoint;
  59535. /**
  59536. * Gets the specular color component
  59537. */
  59538. get specularColor(): NodeMaterialConnectionPoint;
  59539. /**
  59540. * Gets the diffuse output component
  59541. */
  59542. get diffuseOutput(): NodeMaterialConnectionPoint;
  59543. /**
  59544. * Gets the specular output component
  59545. */
  59546. get specularOutput(): NodeMaterialConnectionPoint;
  59547. autoConfigure(material: NodeMaterial): void;
  59548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59549. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59551. private _injectVertexCode;
  59552. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59553. serialize(): any;
  59554. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59555. }
  59556. }
  59557. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  59558. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  59559. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  59560. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59561. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59562. }
  59563. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  59564. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59565. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59566. }
  59567. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  59568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59571. /**
  59572. * Block used to multiply 2 values
  59573. */
  59574. export class MultiplyBlock extends NodeMaterialBlock {
  59575. /**
  59576. * Creates a new MultiplyBlock
  59577. * @param name defines the block name
  59578. */
  59579. constructor(name: string);
  59580. /**
  59581. * Gets the current class name
  59582. * @returns the class name
  59583. */
  59584. getClassName(): string;
  59585. /**
  59586. * Gets the left operand input component
  59587. */
  59588. get left(): NodeMaterialConnectionPoint;
  59589. /**
  59590. * Gets the right operand input component
  59591. */
  59592. get right(): NodeMaterialConnectionPoint;
  59593. /**
  59594. * Gets the output component
  59595. */
  59596. get output(): NodeMaterialConnectionPoint;
  59597. protected _buildBlock(state: NodeMaterialBuildState): this;
  59598. }
  59599. }
  59600. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  59601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59604. /**
  59605. * Block used to add 2 vectors
  59606. */
  59607. export class AddBlock extends NodeMaterialBlock {
  59608. /**
  59609. * Creates a new AddBlock
  59610. * @param name defines the block name
  59611. */
  59612. constructor(name: string);
  59613. /**
  59614. * Gets the current class name
  59615. * @returns the class name
  59616. */
  59617. getClassName(): string;
  59618. /**
  59619. * Gets the left operand input component
  59620. */
  59621. get left(): NodeMaterialConnectionPoint;
  59622. /**
  59623. * Gets the right operand input component
  59624. */
  59625. get right(): NodeMaterialConnectionPoint;
  59626. /**
  59627. * Gets the output component
  59628. */
  59629. get output(): NodeMaterialConnectionPoint;
  59630. protected _buildBlock(state: NodeMaterialBuildState): this;
  59631. }
  59632. }
  59633. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  59634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59635. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59637. /**
  59638. * Block used to scale a vector by a float
  59639. */
  59640. export class ScaleBlock extends NodeMaterialBlock {
  59641. /**
  59642. * Creates a new ScaleBlock
  59643. * @param name defines the block name
  59644. */
  59645. constructor(name: string);
  59646. /**
  59647. * Gets the current class name
  59648. * @returns the class name
  59649. */
  59650. getClassName(): string;
  59651. /**
  59652. * Gets the input component
  59653. */
  59654. get input(): NodeMaterialConnectionPoint;
  59655. /**
  59656. * Gets the factor input component
  59657. */
  59658. get factor(): NodeMaterialConnectionPoint;
  59659. /**
  59660. * Gets the output component
  59661. */
  59662. get output(): NodeMaterialConnectionPoint;
  59663. protected _buildBlock(state: NodeMaterialBuildState): this;
  59664. }
  59665. }
  59666. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  59667. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59668. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59669. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59670. import { Scene } from "babylonjs/scene";
  59671. /**
  59672. * Block used to clamp a float
  59673. */
  59674. export class ClampBlock extends NodeMaterialBlock {
  59675. /** Gets or sets the minimum range */
  59676. minimum: number;
  59677. /** Gets or sets the maximum range */
  59678. maximum: number;
  59679. /**
  59680. * Creates a new ClampBlock
  59681. * @param name defines the block name
  59682. */
  59683. constructor(name: string);
  59684. /**
  59685. * Gets the current class name
  59686. * @returns the class name
  59687. */
  59688. getClassName(): string;
  59689. /**
  59690. * Gets the value input component
  59691. */
  59692. get value(): NodeMaterialConnectionPoint;
  59693. /**
  59694. * Gets the output component
  59695. */
  59696. get output(): NodeMaterialConnectionPoint;
  59697. protected _buildBlock(state: NodeMaterialBuildState): this;
  59698. protected _dumpPropertiesCode(): string;
  59699. serialize(): any;
  59700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59701. }
  59702. }
  59703. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  59704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59707. /**
  59708. * Block used to apply a cross product between 2 vectors
  59709. */
  59710. export class CrossBlock extends NodeMaterialBlock {
  59711. /**
  59712. * Creates a new CrossBlock
  59713. * @param name defines the block name
  59714. */
  59715. constructor(name: string);
  59716. /**
  59717. * Gets the current class name
  59718. * @returns the class name
  59719. */
  59720. getClassName(): string;
  59721. /**
  59722. * Gets the left operand input component
  59723. */
  59724. get left(): NodeMaterialConnectionPoint;
  59725. /**
  59726. * Gets the right operand input component
  59727. */
  59728. get right(): NodeMaterialConnectionPoint;
  59729. /**
  59730. * Gets the output component
  59731. */
  59732. get output(): NodeMaterialConnectionPoint;
  59733. protected _buildBlock(state: NodeMaterialBuildState): this;
  59734. }
  59735. }
  59736. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  59737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59738. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59740. /**
  59741. * Block used to apply a dot product between 2 vectors
  59742. */
  59743. export class DotBlock extends NodeMaterialBlock {
  59744. /**
  59745. * Creates a new DotBlock
  59746. * @param name defines the block name
  59747. */
  59748. constructor(name: string);
  59749. /**
  59750. * Gets the current class name
  59751. * @returns the class name
  59752. */
  59753. getClassName(): string;
  59754. /**
  59755. * Gets the left operand input component
  59756. */
  59757. get left(): NodeMaterialConnectionPoint;
  59758. /**
  59759. * Gets the right operand input component
  59760. */
  59761. get right(): NodeMaterialConnectionPoint;
  59762. /**
  59763. * Gets the output component
  59764. */
  59765. get output(): NodeMaterialConnectionPoint;
  59766. protected _buildBlock(state: NodeMaterialBuildState): this;
  59767. }
  59768. }
  59769. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  59770. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59771. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59772. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59773. import { Vector2 } from "babylonjs/Maths/math.vector";
  59774. import { Scene } from "babylonjs/scene";
  59775. /**
  59776. * Block used to remap a float from a range to a new one
  59777. */
  59778. export class RemapBlock extends NodeMaterialBlock {
  59779. /**
  59780. * Gets or sets the source range
  59781. */
  59782. sourceRange: Vector2;
  59783. /**
  59784. * Gets or sets the target range
  59785. */
  59786. targetRange: Vector2;
  59787. /**
  59788. * Creates a new RemapBlock
  59789. * @param name defines the block name
  59790. */
  59791. constructor(name: string);
  59792. /**
  59793. * Gets the current class name
  59794. * @returns the class name
  59795. */
  59796. getClassName(): string;
  59797. /**
  59798. * Gets the input component
  59799. */
  59800. get input(): NodeMaterialConnectionPoint;
  59801. /**
  59802. * Gets the source min input component
  59803. */
  59804. get sourceMin(): NodeMaterialConnectionPoint;
  59805. /**
  59806. * Gets the source max input component
  59807. */
  59808. get sourceMax(): NodeMaterialConnectionPoint;
  59809. /**
  59810. * Gets the target min input component
  59811. */
  59812. get targetMin(): NodeMaterialConnectionPoint;
  59813. /**
  59814. * Gets the target max input component
  59815. */
  59816. get targetMax(): NodeMaterialConnectionPoint;
  59817. /**
  59818. * Gets the output component
  59819. */
  59820. get output(): NodeMaterialConnectionPoint;
  59821. protected _buildBlock(state: NodeMaterialBuildState): this;
  59822. protected _dumpPropertiesCode(): string;
  59823. serialize(): any;
  59824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59825. }
  59826. }
  59827. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  59828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59831. /**
  59832. * Block used to normalize a vector
  59833. */
  59834. export class NormalizeBlock extends NodeMaterialBlock {
  59835. /**
  59836. * Creates a new NormalizeBlock
  59837. * @param name defines the block name
  59838. */
  59839. constructor(name: string);
  59840. /**
  59841. * Gets the current class name
  59842. * @returns the class name
  59843. */
  59844. getClassName(): string;
  59845. /**
  59846. * Gets the input component
  59847. */
  59848. get input(): NodeMaterialConnectionPoint;
  59849. /**
  59850. * Gets the output component
  59851. */
  59852. get output(): NodeMaterialConnectionPoint;
  59853. protected _buildBlock(state: NodeMaterialBuildState): this;
  59854. }
  59855. }
  59856. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  59857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59860. import { Scene } from "babylonjs/scene";
  59861. /**
  59862. * Operations supported by the Trigonometry block
  59863. */
  59864. export enum TrigonometryBlockOperations {
  59865. /** Cos */
  59866. Cos = 0,
  59867. /** Sin */
  59868. Sin = 1,
  59869. /** Abs */
  59870. Abs = 2,
  59871. /** Exp */
  59872. Exp = 3,
  59873. /** Exp2 */
  59874. Exp2 = 4,
  59875. /** Round */
  59876. Round = 5,
  59877. /** Floor */
  59878. Floor = 6,
  59879. /** Ceiling */
  59880. Ceiling = 7,
  59881. /** Square root */
  59882. Sqrt = 8,
  59883. /** Log */
  59884. Log = 9,
  59885. /** Tangent */
  59886. Tan = 10,
  59887. /** Arc tangent */
  59888. ArcTan = 11,
  59889. /** Arc cosinus */
  59890. ArcCos = 12,
  59891. /** Arc sinus */
  59892. ArcSin = 13,
  59893. /** Fraction */
  59894. Fract = 14,
  59895. /** Sign */
  59896. Sign = 15,
  59897. /** To radians (from degrees) */
  59898. Radians = 16,
  59899. /** To degrees (from radians) */
  59900. Degrees = 17
  59901. }
  59902. /**
  59903. * Block used to apply trigonometry operation to floats
  59904. */
  59905. export class TrigonometryBlock extends NodeMaterialBlock {
  59906. /**
  59907. * Gets or sets the operation applied by the block
  59908. */
  59909. operation: TrigonometryBlockOperations;
  59910. /**
  59911. * Creates a new TrigonometryBlock
  59912. * @param name defines the block name
  59913. */
  59914. constructor(name: string);
  59915. /**
  59916. * Gets the current class name
  59917. * @returns the class name
  59918. */
  59919. getClassName(): string;
  59920. /**
  59921. * Gets the input component
  59922. */
  59923. get input(): NodeMaterialConnectionPoint;
  59924. /**
  59925. * Gets the output component
  59926. */
  59927. get output(): NodeMaterialConnectionPoint;
  59928. protected _buildBlock(state: NodeMaterialBuildState): this;
  59929. serialize(): any;
  59930. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59931. protected _dumpPropertiesCode(): string;
  59932. }
  59933. }
  59934. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  59935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59938. /**
  59939. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59940. */
  59941. export class ColorMergerBlock extends NodeMaterialBlock {
  59942. /**
  59943. * Create a new ColorMergerBlock
  59944. * @param name defines the block name
  59945. */
  59946. constructor(name: string);
  59947. /**
  59948. * Gets the current class name
  59949. * @returns the class name
  59950. */
  59951. getClassName(): string;
  59952. /**
  59953. * Gets the rgb component (input)
  59954. */
  59955. get rgbIn(): NodeMaterialConnectionPoint;
  59956. /**
  59957. * Gets the r component (input)
  59958. */
  59959. get r(): NodeMaterialConnectionPoint;
  59960. /**
  59961. * Gets the g component (input)
  59962. */
  59963. get g(): NodeMaterialConnectionPoint;
  59964. /**
  59965. * Gets the b component (input)
  59966. */
  59967. get b(): NodeMaterialConnectionPoint;
  59968. /**
  59969. * Gets the a component (input)
  59970. */
  59971. get a(): NodeMaterialConnectionPoint;
  59972. /**
  59973. * Gets the rgba component (output)
  59974. */
  59975. get rgba(): NodeMaterialConnectionPoint;
  59976. /**
  59977. * Gets the rgb component (output)
  59978. */
  59979. get rgbOut(): NodeMaterialConnectionPoint;
  59980. /**
  59981. * Gets the rgb component (output)
  59982. * @deprecated Please use rgbOut instead.
  59983. */
  59984. get rgb(): NodeMaterialConnectionPoint;
  59985. protected _buildBlock(state: NodeMaterialBuildState): this;
  59986. }
  59987. }
  59988. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  59989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59991. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59992. /**
  59993. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59994. */
  59995. export class VectorMergerBlock extends NodeMaterialBlock {
  59996. /**
  59997. * Create a new VectorMergerBlock
  59998. * @param name defines the block name
  59999. */
  60000. constructor(name: string);
  60001. /**
  60002. * Gets the current class name
  60003. * @returns the class name
  60004. */
  60005. getClassName(): string;
  60006. /**
  60007. * Gets the xyz component (input)
  60008. */
  60009. get xyzIn(): NodeMaterialConnectionPoint;
  60010. /**
  60011. * Gets the xy component (input)
  60012. */
  60013. get xyIn(): NodeMaterialConnectionPoint;
  60014. /**
  60015. * Gets the x component (input)
  60016. */
  60017. get x(): NodeMaterialConnectionPoint;
  60018. /**
  60019. * Gets the y component (input)
  60020. */
  60021. get y(): NodeMaterialConnectionPoint;
  60022. /**
  60023. * Gets the z component (input)
  60024. */
  60025. get z(): NodeMaterialConnectionPoint;
  60026. /**
  60027. * Gets the w component (input)
  60028. */
  60029. get w(): NodeMaterialConnectionPoint;
  60030. /**
  60031. * Gets the xyzw component (output)
  60032. */
  60033. get xyzw(): NodeMaterialConnectionPoint;
  60034. /**
  60035. * Gets the xyz component (output)
  60036. */
  60037. get xyzOut(): NodeMaterialConnectionPoint;
  60038. /**
  60039. * Gets the xy component (output)
  60040. */
  60041. get xyOut(): NodeMaterialConnectionPoint;
  60042. /**
  60043. * Gets the xy component (output)
  60044. * @deprecated Please use xyOut instead.
  60045. */
  60046. get xy(): NodeMaterialConnectionPoint;
  60047. /**
  60048. * Gets the xyz component (output)
  60049. * @deprecated Please use xyzOut instead.
  60050. */
  60051. get xyz(): NodeMaterialConnectionPoint;
  60052. protected _buildBlock(state: NodeMaterialBuildState): this;
  60053. }
  60054. }
  60055. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60059. /**
  60060. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60061. */
  60062. export class ColorSplitterBlock extends NodeMaterialBlock {
  60063. /**
  60064. * Create a new ColorSplitterBlock
  60065. * @param name defines the block name
  60066. */
  60067. constructor(name: string);
  60068. /**
  60069. * Gets the current class name
  60070. * @returns the class name
  60071. */
  60072. getClassName(): string;
  60073. /**
  60074. * Gets the rgba component (input)
  60075. */
  60076. get rgba(): NodeMaterialConnectionPoint;
  60077. /**
  60078. * Gets the rgb component (input)
  60079. */
  60080. get rgbIn(): NodeMaterialConnectionPoint;
  60081. /**
  60082. * Gets the rgb component (output)
  60083. */
  60084. get rgbOut(): NodeMaterialConnectionPoint;
  60085. /**
  60086. * Gets the r component (output)
  60087. */
  60088. get r(): NodeMaterialConnectionPoint;
  60089. /**
  60090. * Gets the g component (output)
  60091. */
  60092. get g(): NodeMaterialConnectionPoint;
  60093. /**
  60094. * Gets the b component (output)
  60095. */
  60096. get b(): NodeMaterialConnectionPoint;
  60097. /**
  60098. * Gets the a component (output)
  60099. */
  60100. get a(): NodeMaterialConnectionPoint;
  60101. protected _inputRename(name: string): string;
  60102. protected _outputRename(name: string): string;
  60103. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60104. }
  60105. }
  60106. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60107. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60108. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60109. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60110. /**
  60111. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60112. */
  60113. export class VectorSplitterBlock extends NodeMaterialBlock {
  60114. /**
  60115. * Create a new VectorSplitterBlock
  60116. * @param name defines the block name
  60117. */
  60118. constructor(name: string);
  60119. /**
  60120. * Gets the current class name
  60121. * @returns the class name
  60122. */
  60123. getClassName(): string;
  60124. /**
  60125. * Gets the xyzw component (input)
  60126. */
  60127. get xyzw(): NodeMaterialConnectionPoint;
  60128. /**
  60129. * Gets the xyz component (input)
  60130. */
  60131. get xyzIn(): NodeMaterialConnectionPoint;
  60132. /**
  60133. * Gets the xy component (input)
  60134. */
  60135. get xyIn(): NodeMaterialConnectionPoint;
  60136. /**
  60137. * Gets the xyz component (output)
  60138. */
  60139. get xyzOut(): NodeMaterialConnectionPoint;
  60140. /**
  60141. * Gets the xy component (output)
  60142. */
  60143. get xyOut(): NodeMaterialConnectionPoint;
  60144. /**
  60145. * Gets the x component (output)
  60146. */
  60147. get x(): NodeMaterialConnectionPoint;
  60148. /**
  60149. * Gets the y component (output)
  60150. */
  60151. get y(): NodeMaterialConnectionPoint;
  60152. /**
  60153. * Gets the z component (output)
  60154. */
  60155. get z(): NodeMaterialConnectionPoint;
  60156. /**
  60157. * Gets the w component (output)
  60158. */
  60159. get w(): NodeMaterialConnectionPoint;
  60160. protected _inputRename(name: string): string;
  60161. protected _outputRename(name: string): string;
  60162. protected _buildBlock(state: NodeMaterialBuildState): this;
  60163. }
  60164. }
  60165. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  60166. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60167. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60168. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60169. /**
  60170. * Block used to lerp between 2 values
  60171. */
  60172. export class LerpBlock extends NodeMaterialBlock {
  60173. /**
  60174. * Creates a new LerpBlock
  60175. * @param name defines the block name
  60176. */
  60177. constructor(name: string);
  60178. /**
  60179. * Gets the current class name
  60180. * @returns the class name
  60181. */
  60182. getClassName(): string;
  60183. /**
  60184. * Gets the left operand input component
  60185. */
  60186. get left(): NodeMaterialConnectionPoint;
  60187. /**
  60188. * Gets the right operand input component
  60189. */
  60190. get right(): NodeMaterialConnectionPoint;
  60191. /**
  60192. * Gets the gradient operand input component
  60193. */
  60194. get gradient(): NodeMaterialConnectionPoint;
  60195. /**
  60196. * Gets the output component
  60197. */
  60198. get output(): NodeMaterialConnectionPoint;
  60199. protected _buildBlock(state: NodeMaterialBuildState): this;
  60200. }
  60201. }
  60202. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  60203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60206. /**
  60207. * Block used to divide 2 vectors
  60208. */
  60209. export class DivideBlock extends NodeMaterialBlock {
  60210. /**
  60211. * Creates a new DivideBlock
  60212. * @param name defines the block name
  60213. */
  60214. constructor(name: string);
  60215. /**
  60216. * Gets the current class name
  60217. * @returns the class name
  60218. */
  60219. getClassName(): string;
  60220. /**
  60221. * Gets the left operand input component
  60222. */
  60223. get left(): NodeMaterialConnectionPoint;
  60224. /**
  60225. * Gets the right operand input component
  60226. */
  60227. get right(): NodeMaterialConnectionPoint;
  60228. /**
  60229. * Gets the output component
  60230. */
  60231. get output(): NodeMaterialConnectionPoint;
  60232. protected _buildBlock(state: NodeMaterialBuildState): this;
  60233. }
  60234. }
  60235. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  60236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60239. /**
  60240. * Block used to subtract 2 vectors
  60241. */
  60242. export class SubtractBlock extends NodeMaterialBlock {
  60243. /**
  60244. * Creates a new SubtractBlock
  60245. * @param name defines the block name
  60246. */
  60247. constructor(name: string);
  60248. /**
  60249. * Gets the current class name
  60250. * @returns the class name
  60251. */
  60252. getClassName(): string;
  60253. /**
  60254. * Gets the left operand input component
  60255. */
  60256. get left(): NodeMaterialConnectionPoint;
  60257. /**
  60258. * Gets the right operand input component
  60259. */
  60260. get right(): NodeMaterialConnectionPoint;
  60261. /**
  60262. * Gets the output component
  60263. */
  60264. get output(): NodeMaterialConnectionPoint;
  60265. protected _buildBlock(state: NodeMaterialBuildState): this;
  60266. }
  60267. }
  60268. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  60269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60270. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60271. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60272. /**
  60273. * Block used to step a value
  60274. */
  60275. export class StepBlock extends NodeMaterialBlock {
  60276. /**
  60277. * Creates a new StepBlock
  60278. * @param name defines the block name
  60279. */
  60280. constructor(name: string);
  60281. /**
  60282. * Gets the current class name
  60283. * @returns the class name
  60284. */
  60285. getClassName(): string;
  60286. /**
  60287. * Gets the value operand input component
  60288. */
  60289. get value(): NodeMaterialConnectionPoint;
  60290. /**
  60291. * Gets the edge operand input component
  60292. */
  60293. get edge(): NodeMaterialConnectionPoint;
  60294. /**
  60295. * Gets the output component
  60296. */
  60297. get output(): NodeMaterialConnectionPoint;
  60298. protected _buildBlock(state: NodeMaterialBuildState): this;
  60299. }
  60300. }
  60301. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  60302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60305. /**
  60306. * Block used to get the opposite (1 - x) of a value
  60307. */
  60308. export class OneMinusBlock extends NodeMaterialBlock {
  60309. /**
  60310. * Creates a new OneMinusBlock
  60311. * @param name defines the block name
  60312. */
  60313. constructor(name: string);
  60314. /**
  60315. * Gets the current class name
  60316. * @returns the class name
  60317. */
  60318. getClassName(): string;
  60319. /**
  60320. * Gets the input component
  60321. */
  60322. get input(): NodeMaterialConnectionPoint;
  60323. /**
  60324. * Gets the output component
  60325. */
  60326. get output(): NodeMaterialConnectionPoint;
  60327. protected _buildBlock(state: NodeMaterialBuildState): this;
  60328. }
  60329. }
  60330. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  60331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60334. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60335. /**
  60336. * Block used to get the view direction
  60337. */
  60338. export class ViewDirectionBlock extends NodeMaterialBlock {
  60339. /**
  60340. * Creates a new ViewDirectionBlock
  60341. * @param name defines the block name
  60342. */
  60343. constructor(name: string);
  60344. /**
  60345. * Gets the current class name
  60346. * @returns the class name
  60347. */
  60348. getClassName(): string;
  60349. /**
  60350. * Gets the world position component
  60351. */
  60352. get worldPosition(): NodeMaterialConnectionPoint;
  60353. /**
  60354. * Gets the camera position component
  60355. */
  60356. get cameraPosition(): NodeMaterialConnectionPoint;
  60357. /**
  60358. * Gets the output component
  60359. */
  60360. get output(): NodeMaterialConnectionPoint;
  60361. autoConfigure(material: NodeMaterial): void;
  60362. protected _buildBlock(state: NodeMaterialBuildState): this;
  60363. }
  60364. }
  60365. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  60366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60369. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60370. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  60371. /**
  60372. * Block used to compute fresnel value
  60373. */
  60374. export class FresnelBlock extends NodeMaterialBlock {
  60375. /**
  60376. * Create a new FresnelBlock
  60377. * @param name defines the block name
  60378. */
  60379. constructor(name: string);
  60380. /**
  60381. * Gets the current class name
  60382. * @returns the class name
  60383. */
  60384. getClassName(): string;
  60385. /**
  60386. * Gets the world normal input component
  60387. */
  60388. get worldNormal(): NodeMaterialConnectionPoint;
  60389. /**
  60390. * Gets the view direction input component
  60391. */
  60392. get viewDirection(): NodeMaterialConnectionPoint;
  60393. /**
  60394. * Gets the bias input component
  60395. */
  60396. get bias(): NodeMaterialConnectionPoint;
  60397. /**
  60398. * Gets the camera (or eye) position component
  60399. */
  60400. get power(): NodeMaterialConnectionPoint;
  60401. /**
  60402. * Gets the fresnel output component
  60403. */
  60404. get fresnel(): NodeMaterialConnectionPoint;
  60405. autoConfigure(material: NodeMaterial): void;
  60406. protected _buildBlock(state: NodeMaterialBuildState): this;
  60407. }
  60408. }
  60409. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  60410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60413. /**
  60414. * Block used to get the max of 2 values
  60415. */
  60416. export class MaxBlock extends NodeMaterialBlock {
  60417. /**
  60418. * Creates a new MaxBlock
  60419. * @param name defines the block name
  60420. */
  60421. constructor(name: string);
  60422. /**
  60423. * Gets the current class name
  60424. * @returns the class name
  60425. */
  60426. getClassName(): string;
  60427. /**
  60428. * Gets the left operand input component
  60429. */
  60430. get left(): NodeMaterialConnectionPoint;
  60431. /**
  60432. * Gets the right operand input component
  60433. */
  60434. get right(): NodeMaterialConnectionPoint;
  60435. /**
  60436. * Gets the output component
  60437. */
  60438. get output(): NodeMaterialConnectionPoint;
  60439. protected _buildBlock(state: NodeMaterialBuildState): this;
  60440. }
  60441. }
  60442. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  60443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60446. /**
  60447. * Block used to get the min of 2 values
  60448. */
  60449. export class MinBlock extends NodeMaterialBlock {
  60450. /**
  60451. * Creates a new MinBlock
  60452. * @param name defines the block name
  60453. */
  60454. constructor(name: string);
  60455. /**
  60456. * Gets the current class name
  60457. * @returns the class name
  60458. */
  60459. getClassName(): string;
  60460. /**
  60461. * Gets the left operand input component
  60462. */
  60463. get left(): NodeMaterialConnectionPoint;
  60464. /**
  60465. * Gets the right operand input component
  60466. */
  60467. get right(): NodeMaterialConnectionPoint;
  60468. /**
  60469. * Gets the output component
  60470. */
  60471. get output(): NodeMaterialConnectionPoint;
  60472. protected _buildBlock(state: NodeMaterialBuildState): this;
  60473. }
  60474. }
  60475. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  60476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60479. /**
  60480. * Block used to get the distance between 2 values
  60481. */
  60482. export class DistanceBlock extends NodeMaterialBlock {
  60483. /**
  60484. * Creates a new DistanceBlock
  60485. * @param name defines the block name
  60486. */
  60487. constructor(name: string);
  60488. /**
  60489. * Gets the current class name
  60490. * @returns the class name
  60491. */
  60492. getClassName(): string;
  60493. /**
  60494. * Gets the left operand input component
  60495. */
  60496. get left(): NodeMaterialConnectionPoint;
  60497. /**
  60498. * Gets the right operand input component
  60499. */
  60500. get right(): NodeMaterialConnectionPoint;
  60501. /**
  60502. * Gets the output component
  60503. */
  60504. get output(): NodeMaterialConnectionPoint;
  60505. protected _buildBlock(state: NodeMaterialBuildState): this;
  60506. }
  60507. }
  60508. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  60509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60510. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60512. /**
  60513. * Block used to get the length of a vector
  60514. */
  60515. export class LengthBlock extends NodeMaterialBlock {
  60516. /**
  60517. * Creates a new LengthBlock
  60518. * @param name defines the block name
  60519. */
  60520. constructor(name: string);
  60521. /**
  60522. * Gets the current class name
  60523. * @returns the class name
  60524. */
  60525. getClassName(): string;
  60526. /**
  60527. * Gets the value input component
  60528. */
  60529. get value(): NodeMaterialConnectionPoint;
  60530. /**
  60531. * Gets the output component
  60532. */
  60533. get output(): NodeMaterialConnectionPoint;
  60534. protected _buildBlock(state: NodeMaterialBuildState): this;
  60535. }
  60536. }
  60537. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  60538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60541. /**
  60542. * Block used to get negative version of a value (i.e. x * -1)
  60543. */
  60544. export class NegateBlock extends NodeMaterialBlock {
  60545. /**
  60546. * Creates a new NegateBlock
  60547. * @param name defines the block name
  60548. */
  60549. constructor(name: string);
  60550. /**
  60551. * Gets the current class name
  60552. * @returns the class name
  60553. */
  60554. getClassName(): string;
  60555. /**
  60556. * Gets the value input component
  60557. */
  60558. get value(): NodeMaterialConnectionPoint;
  60559. /**
  60560. * Gets the output component
  60561. */
  60562. get output(): NodeMaterialConnectionPoint;
  60563. protected _buildBlock(state: NodeMaterialBuildState): this;
  60564. }
  60565. }
  60566. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  60567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60569. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60570. /**
  60571. * Block used to get the value of the first parameter raised to the power of the second
  60572. */
  60573. export class PowBlock extends NodeMaterialBlock {
  60574. /**
  60575. * Creates a new PowBlock
  60576. * @param name defines the block name
  60577. */
  60578. constructor(name: string);
  60579. /**
  60580. * Gets the current class name
  60581. * @returns the class name
  60582. */
  60583. getClassName(): string;
  60584. /**
  60585. * Gets the value operand input component
  60586. */
  60587. get value(): NodeMaterialConnectionPoint;
  60588. /**
  60589. * Gets the power operand input component
  60590. */
  60591. get power(): NodeMaterialConnectionPoint;
  60592. /**
  60593. * Gets the output component
  60594. */
  60595. get output(): NodeMaterialConnectionPoint;
  60596. protected _buildBlock(state: NodeMaterialBuildState): this;
  60597. }
  60598. }
  60599. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  60600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60604. /**
  60605. * Block used to get a random number
  60606. */
  60607. export class RandomNumberBlock extends NodeMaterialBlock {
  60608. /**
  60609. * Creates a new RandomNumberBlock
  60610. * @param name defines the block name
  60611. */
  60612. constructor(name: string);
  60613. /**
  60614. * Gets the current class name
  60615. * @returns the class name
  60616. */
  60617. getClassName(): string;
  60618. /**
  60619. * Gets the seed input component
  60620. */
  60621. get seed(): NodeMaterialConnectionPoint;
  60622. /**
  60623. * Gets the output component
  60624. */
  60625. get output(): NodeMaterialConnectionPoint;
  60626. protected _buildBlock(state: NodeMaterialBuildState): this;
  60627. }
  60628. }
  60629. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  60630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60631. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60632. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60633. /**
  60634. * Block used to compute arc tangent of 2 values
  60635. */
  60636. export class ArcTan2Block extends NodeMaterialBlock {
  60637. /**
  60638. * Creates a new ArcTan2Block
  60639. * @param name defines the block name
  60640. */
  60641. constructor(name: string);
  60642. /**
  60643. * Gets the current class name
  60644. * @returns the class name
  60645. */
  60646. getClassName(): string;
  60647. /**
  60648. * Gets the x operand input component
  60649. */
  60650. get x(): NodeMaterialConnectionPoint;
  60651. /**
  60652. * Gets the y operand input component
  60653. */
  60654. get y(): NodeMaterialConnectionPoint;
  60655. /**
  60656. * Gets the output component
  60657. */
  60658. get output(): NodeMaterialConnectionPoint;
  60659. protected _buildBlock(state: NodeMaterialBuildState): this;
  60660. }
  60661. }
  60662. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  60663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60666. /**
  60667. * Block used to smooth step a value
  60668. */
  60669. export class SmoothStepBlock extends NodeMaterialBlock {
  60670. /**
  60671. * Creates a new SmoothStepBlock
  60672. * @param name defines the block name
  60673. */
  60674. constructor(name: string);
  60675. /**
  60676. * Gets the current class name
  60677. * @returns the class name
  60678. */
  60679. getClassName(): string;
  60680. /**
  60681. * Gets the value operand input component
  60682. */
  60683. get value(): NodeMaterialConnectionPoint;
  60684. /**
  60685. * Gets the first edge operand input component
  60686. */
  60687. get edge0(): NodeMaterialConnectionPoint;
  60688. /**
  60689. * Gets the second edge operand input component
  60690. */
  60691. get edge1(): NodeMaterialConnectionPoint;
  60692. /**
  60693. * Gets the output component
  60694. */
  60695. get output(): NodeMaterialConnectionPoint;
  60696. protected _buildBlock(state: NodeMaterialBuildState): this;
  60697. }
  60698. }
  60699. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  60700. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60701. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60702. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60703. /**
  60704. * Block used to get the reciprocal (1 / x) of a value
  60705. */
  60706. export class ReciprocalBlock extends NodeMaterialBlock {
  60707. /**
  60708. * Creates a new ReciprocalBlock
  60709. * @param name defines the block name
  60710. */
  60711. constructor(name: string);
  60712. /**
  60713. * Gets the current class name
  60714. * @returns the class name
  60715. */
  60716. getClassName(): string;
  60717. /**
  60718. * Gets the input component
  60719. */
  60720. get input(): NodeMaterialConnectionPoint;
  60721. /**
  60722. * Gets the output component
  60723. */
  60724. get output(): NodeMaterialConnectionPoint;
  60725. protected _buildBlock(state: NodeMaterialBuildState): this;
  60726. }
  60727. }
  60728. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  60729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60732. /**
  60733. * Block used to replace a color by another one
  60734. */
  60735. export class ReplaceColorBlock extends NodeMaterialBlock {
  60736. /**
  60737. * Creates a new ReplaceColorBlock
  60738. * @param name defines the block name
  60739. */
  60740. constructor(name: string);
  60741. /**
  60742. * Gets the current class name
  60743. * @returns the class name
  60744. */
  60745. getClassName(): string;
  60746. /**
  60747. * Gets the value input component
  60748. */
  60749. get value(): NodeMaterialConnectionPoint;
  60750. /**
  60751. * Gets the reference input component
  60752. */
  60753. get reference(): NodeMaterialConnectionPoint;
  60754. /**
  60755. * Gets the distance input component
  60756. */
  60757. get distance(): NodeMaterialConnectionPoint;
  60758. /**
  60759. * Gets the replacement input component
  60760. */
  60761. get replacement(): NodeMaterialConnectionPoint;
  60762. /**
  60763. * Gets the output component
  60764. */
  60765. get output(): NodeMaterialConnectionPoint;
  60766. protected _buildBlock(state: NodeMaterialBuildState): this;
  60767. }
  60768. }
  60769. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  60770. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60771. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60772. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60773. /**
  60774. * Block used to posterize a value
  60775. * @see https://en.wikipedia.org/wiki/Posterization
  60776. */
  60777. export class PosterizeBlock extends NodeMaterialBlock {
  60778. /**
  60779. * Creates a new PosterizeBlock
  60780. * @param name defines the block name
  60781. */
  60782. constructor(name: string);
  60783. /**
  60784. * Gets the current class name
  60785. * @returns the class name
  60786. */
  60787. getClassName(): string;
  60788. /**
  60789. * Gets the value input component
  60790. */
  60791. get value(): NodeMaterialConnectionPoint;
  60792. /**
  60793. * Gets the steps input component
  60794. */
  60795. get steps(): NodeMaterialConnectionPoint;
  60796. /**
  60797. * Gets the output component
  60798. */
  60799. get output(): NodeMaterialConnectionPoint;
  60800. protected _buildBlock(state: NodeMaterialBuildState): this;
  60801. }
  60802. }
  60803. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  60804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60806. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60807. import { Scene } from "babylonjs/scene";
  60808. /**
  60809. * Operations supported by the Wave block
  60810. */
  60811. export enum WaveBlockKind {
  60812. /** SawTooth */
  60813. SawTooth = 0,
  60814. /** Square */
  60815. Square = 1,
  60816. /** Triangle */
  60817. Triangle = 2
  60818. }
  60819. /**
  60820. * Block used to apply wave operation to floats
  60821. */
  60822. export class WaveBlock extends NodeMaterialBlock {
  60823. /**
  60824. * Gets or sets the kibnd of wave to be applied by the block
  60825. */
  60826. kind: WaveBlockKind;
  60827. /**
  60828. * Creates a new WaveBlock
  60829. * @param name defines the block name
  60830. */
  60831. constructor(name: string);
  60832. /**
  60833. * Gets the current class name
  60834. * @returns the class name
  60835. */
  60836. getClassName(): string;
  60837. /**
  60838. * Gets the input component
  60839. */
  60840. get input(): NodeMaterialConnectionPoint;
  60841. /**
  60842. * Gets the output component
  60843. */
  60844. get output(): NodeMaterialConnectionPoint;
  60845. protected _buildBlock(state: NodeMaterialBuildState): this;
  60846. serialize(): any;
  60847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60848. }
  60849. }
  60850. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  60851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60854. import { Color3 } from "babylonjs/Maths/math.color";
  60855. import { Scene } from "babylonjs/scene";
  60856. /**
  60857. * Class used to store a color step for the GradientBlock
  60858. */
  60859. export class GradientBlockColorStep {
  60860. /**
  60861. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60862. */
  60863. step: number;
  60864. /**
  60865. * Gets or sets the color associated with this step
  60866. */
  60867. color: Color3;
  60868. /**
  60869. * Creates a new GradientBlockColorStep
  60870. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60871. * @param color defines the color associated with this step
  60872. */
  60873. constructor(
  60874. /**
  60875. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60876. */
  60877. step: number,
  60878. /**
  60879. * Gets or sets the color associated with this step
  60880. */
  60881. color: Color3);
  60882. }
  60883. /**
  60884. * Block used to return a color from a gradient based on an input value between 0 and 1
  60885. */
  60886. export class GradientBlock extends NodeMaterialBlock {
  60887. /**
  60888. * Gets or sets the list of color steps
  60889. */
  60890. colorSteps: GradientBlockColorStep[];
  60891. /**
  60892. * Creates a new GradientBlock
  60893. * @param name defines the block name
  60894. */
  60895. constructor(name: string);
  60896. /**
  60897. * Gets the current class name
  60898. * @returns the class name
  60899. */
  60900. getClassName(): string;
  60901. /**
  60902. * Gets the gradient input component
  60903. */
  60904. get gradient(): NodeMaterialConnectionPoint;
  60905. /**
  60906. * Gets the output component
  60907. */
  60908. get output(): NodeMaterialConnectionPoint;
  60909. private _writeColorConstant;
  60910. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60911. serialize(): any;
  60912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60913. protected _dumpPropertiesCode(): string;
  60914. }
  60915. }
  60916. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  60917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60919. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60920. /**
  60921. * Block used to normalize lerp between 2 values
  60922. */
  60923. export class NLerpBlock extends NodeMaterialBlock {
  60924. /**
  60925. * Creates a new NLerpBlock
  60926. * @param name defines the block name
  60927. */
  60928. constructor(name: string);
  60929. /**
  60930. * Gets the current class name
  60931. * @returns the class name
  60932. */
  60933. getClassName(): string;
  60934. /**
  60935. * Gets the left operand input component
  60936. */
  60937. get left(): NodeMaterialConnectionPoint;
  60938. /**
  60939. * Gets the right operand input component
  60940. */
  60941. get right(): NodeMaterialConnectionPoint;
  60942. /**
  60943. * Gets the gradient operand input component
  60944. */
  60945. get gradient(): NodeMaterialConnectionPoint;
  60946. /**
  60947. * Gets the output component
  60948. */
  60949. get output(): NodeMaterialConnectionPoint;
  60950. protected _buildBlock(state: NodeMaterialBuildState): this;
  60951. }
  60952. }
  60953. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  60954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60957. import { Scene } from "babylonjs/scene";
  60958. /**
  60959. * block used to Generate a Worley Noise 3D Noise Pattern
  60960. */
  60961. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60962. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60963. manhattanDistance: boolean;
  60964. /**
  60965. * Creates a new WorleyNoise3DBlock
  60966. * @param name defines the block name
  60967. */
  60968. constructor(name: string);
  60969. /**
  60970. * Gets the current class name
  60971. * @returns the class name
  60972. */
  60973. getClassName(): string;
  60974. /**
  60975. * Gets the seed input component
  60976. */
  60977. get seed(): NodeMaterialConnectionPoint;
  60978. /**
  60979. * Gets the jitter input component
  60980. */
  60981. get jitter(): NodeMaterialConnectionPoint;
  60982. /**
  60983. * Gets the output component
  60984. */
  60985. get output(): NodeMaterialConnectionPoint;
  60986. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60987. /**
  60988. * Exposes the properties to the UI?
  60989. */
  60990. protected _dumpPropertiesCode(): string;
  60991. /**
  60992. * Exposes the properties to the Seralize?
  60993. */
  60994. serialize(): any;
  60995. /**
  60996. * Exposes the properties to the deseralize?
  60997. */
  60998. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60999. }
  61000. }
  61001. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61005. /**
  61006. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61007. */
  61008. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61009. /**
  61010. * Creates a new SimplexPerlin3DBlock
  61011. * @param name defines the block name
  61012. */
  61013. constructor(name: string);
  61014. /**
  61015. * Gets the current class name
  61016. * @returns the class name
  61017. */
  61018. getClassName(): string;
  61019. /**
  61020. * Gets the seed operand input component
  61021. */
  61022. get seed(): NodeMaterialConnectionPoint;
  61023. /**
  61024. * Gets the output component
  61025. */
  61026. get output(): NodeMaterialConnectionPoint;
  61027. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61028. }
  61029. }
  61030. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61031. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61032. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61033. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61034. /**
  61035. * Block used to blend normals
  61036. */
  61037. export class NormalBlendBlock extends NodeMaterialBlock {
  61038. /**
  61039. * Creates a new NormalBlendBlock
  61040. * @param name defines the block name
  61041. */
  61042. constructor(name: string);
  61043. /**
  61044. * Gets the current class name
  61045. * @returns the class name
  61046. */
  61047. getClassName(): string;
  61048. /**
  61049. * Gets the first input component
  61050. */
  61051. get normalMap0(): NodeMaterialConnectionPoint;
  61052. /**
  61053. * Gets the second input component
  61054. */
  61055. get normalMap1(): NodeMaterialConnectionPoint;
  61056. /**
  61057. * Gets the output component
  61058. */
  61059. get output(): NodeMaterialConnectionPoint;
  61060. protected _buildBlock(state: NodeMaterialBuildState): this;
  61061. }
  61062. }
  61063. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61067. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61068. /**
  61069. * Block used to rotate a 2d vector by a given angle
  61070. */
  61071. export class Rotate2dBlock extends NodeMaterialBlock {
  61072. /**
  61073. * Creates a new Rotate2dBlock
  61074. * @param name defines the block name
  61075. */
  61076. constructor(name: string);
  61077. /**
  61078. * Gets the current class name
  61079. * @returns the class name
  61080. */
  61081. getClassName(): string;
  61082. /**
  61083. * Gets the input vector
  61084. */
  61085. get input(): NodeMaterialConnectionPoint;
  61086. /**
  61087. * Gets the input angle
  61088. */
  61089. get angle(): NodeMaterialConnectionPoint;
  61090. /**
  61091. * Gets the output component
  61092. */
  61093. get output(): NodeMaterialConnectionPoint;
  61094. autoConfigure(material: NodeMaterial): void;
  61095. protected _buildBlock(state: NodeMaterialBuildState): this;
  61096. }
  61097. }
  61098. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  61099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61102. /**
  61103. * Block used to get the reflected vector from a direction and a normal
  61104. */
  61105. export class ReflectBlock extends NodeMaterialBlock {
  61106. /**
  61107. * Creates a new ReflectBlock
  61108. * @param name defines the block name
  61109. */
  61110. constructor(name: string);
  61111. /**
  61112. * Gets the current class name
  61113. * @returns the class name
  61114. */
  61115. getClassName(): string;
  61116. /**
  61117. * Gets the incident component
  61118. */
  61119. get incident(): NodeMaterialConnectionPoint;
  61120. /**
  61121. * Gets the normal component
  61122. */
  61123. get normal(): NodeMaterialConnectionPoint;
  61124. /**
  61125. * Gets the output component
  61126. */
  61127. get output(): NodeMaterialConnectionPoint;
  61128. protected _buildBlock(state: NodeMaterialBuildState): this;
  61129. }
  61130. }
  61131. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61133. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61134. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61135. /**
  61136. * Block used to get the refracted vector from a direction and a normal
  61137. */
  61138. export class RefractBlock extends NodeMaterialBlock {
  61139. /**
  61140. * Creates a new RefractBlock
  61141. * @param name defines the block name
  61142. */
  61143. constructor(name: string);
  61144. /**
  61145. * Gets the current class name
  61146. * @returns the class name
  61147. */
  61148. getClassName(): string;
  61149. /**
  61150. * Gets the incident component
  61151. */
  61152. get incident(): NodeMaterialConnectionPoint;
  61153. /**
  61154. * Gets the normal component
  61155. */
  61156. get normal(): NodeMaterialConnectionPoint;
  61157. /**
  61158. * Gets the index of refraction component
  61159. */
  61160. get ior(): NodeMaterialConnectionPoint;
  61161. /**
  61162. * Gets the output component
  61163. */
  61164. get output(): NodeMaterialConnectionPoint;
  61165. protected _buildBlock(state: NodeMaterialBuildState): this;
  61166. }
  61167. }
  61168. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  61169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61172. /**
  61173. * Block used to desaturate a color
  61174. */
  61175. export class DesaturateBlock extends NodeMaterialBlock {
  61176. /**
  61177. * Creates a new DesaturateBlock
  61178. * @param name defines the block name
  61179. */
  61180. constructor(name: string);
  61181. /**
  61182. * Gets the current class name
  61183. * @returns the class name
  61184. */
  61185. getClassName(): string;
  61186. /**
  61187. * Gets the color operand input component
  61188. */
  61189. get color(): NodeMaterialConnectionPoint;
  61190. /**
  61191. * Gets the level operand input component
  61192. */
  61193. get level(): NodeMaterialConnectionPoint;
  61194. /**
  61195. * Gets the output component
  61196. */
  61197. get output(): NodeMaterialConnectionPoint;
  61198. protected _buildBlock(state: NodeMaterialBuildState): this;
  61199. }
  61200. }
  61201. declare module "babylonjs/Materials/Node/Blocks/index" {
  61202. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  61203. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  61204. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  61205. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  61206. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  61207. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  61208. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  61209. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  61210. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  61211. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  61212. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  61213. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  61214. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  61215. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  61216. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  61217. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  61218. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  61219. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  61220. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  61221. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  61222. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  61223. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  61224. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  61225. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  61226. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  61227. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  61228. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  61229. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  61230. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  61231. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  61232. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  61233. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  61234. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  61235. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  61236. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  61237. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  61238. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  61239. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  61240. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  61241. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  61242. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  61243. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  61244. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  61245. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  61246. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  61247. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  61248. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  61249. }
  61250. declare module "babylonjs/Materials/Node/Optimizers/index" {
  61251. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61252. }
  61253. declare module "babylonjs/Materials/Node/index" {
  61254. export * from "babylonjs/Materials/Node/Enums/index";
  61255. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61256. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  61257. export * from "babylonjs/Materials/Node/nodeMaterial";
  61258. export * from "babylonjs/Materials/Node/Blocks/index";
  61259. export * from "babylonjs/Materials/Node/Optimizers/index";
  61260. }
  61261. declare module "babylonjs/Materials/effectRenderer" {
  61262. import { Nullable } from "babylonjs/types";
  61263. import { Texture } from "babylonjs/Materials/Textures/texture";
  61264. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61265. import { Viewport } from "babylonjs/Maths/math.viewport";
  61266. import { Observable } from "babylonjs/Misc/observable";
  61267. import { Effect } from "babylonjs/Materials/effect";
  61268. import "babylonjs/Engines/Extensions/engine.renderTarget";
  61269. import "babylonjs/Shaders/postprocess.vertex";
  61270. /**
  61271. * Effect Render Options
  61272. */
  61273. export interface IEffectRendererOptions {
  61274. /**
  61275. * Defines the vertices positions.
  61276. */
  61277. positions?: number[];
  61278. /**
  61279. * Defines the indices.
  61280. */
  61281. indices?: number[];
  61282. }
  61283. /**
  61284. * Helper class to render one or more effects
  61285. */
  61286. export class EffectRenderer {
  61287. private engine;
  61288. private static _DefaultOptions;
  61289. private _vertexBuffers;
  61290. private _indexBuffer;
  61291. private _ringBufferIndex;
  61292. private _ringScreenBuffer;
  61293. private _fullscreenViewport;
  61294. private _getNextFrameBuffer;
  61295. /**
  61296. * Creates an effect renderer
  61297. * @param engine the engine to use for rendering
  61298. * @param options defines the options of the effect renderer
  61299. */
  61300. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61301. /**
  61302. * Sets the current viewport in normalized coordinates 0-1
  61303. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61304. */
  61305. setViewport(viewport?: Viewport): void;
  61306. /**
  61307. * Binds the embedded attributes buffer to the effect.
  61308. * @param effect Defines the effect to bind the attributes for
  61309. */
  61310. bindBuffers(effect: Effect): void;
  61311. /**
  61312. * Sets the current effect wrapper to use during draw.
  61313. * The effect needs to be ready before calling this api.
  61314. * This also sets the default full screen position attribute.
  61315. * @param effectWrapper Defines the effect to draw with
  61316. */
  61317. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61318. /**
  61319. * Draws a full screen quad.
  61320. */
  61321. draw(): void;
  61322. /**
  61323. * renders one or more effects to a specified texture
  61324. * @param effectWrappers list of effects to renderer
  61325. * @param outputTexture texture to draw to, if null it will render to the screen
  61326. */
  61327. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  61328. /**
  61329. * Disposes of the effect renderer
  61330. */
  61331. dispose(): void;
  61332. }
  61333. /**
  61334. * Options to create an EffectWrapper
  61335. */
  61336. interface EffectWrapperCreationOptions {
  61337. /**
  61338. * Engine to use to create the effect
  61339. */
  61340. engine: ThinEngine;
  61341. /**
  61342. * Fragment shader for the effect
  61343. */
  61344. fragmentShader: string;
  61345. /**
  61346. * Vertex shader for the effect
  61347. */
  61348. vertexShader?: string;
  61349. /**
  61350. * Attributes to use in the shader
  61351. */
  61352. attributeNames?: Array<string>;
  61353. /**
  61354. * Uniforms to use in the shader
  61355. */
  61356. uniformNames?: Array<string>;
  61357. /**
  61358. * Texture sampler names to use in the shader
  61359. */
  61360. samplerNames?: Array<string>;
  61361. /**
  61362. * The friendly name of the effect displayed in Spector.
  61363. */
  61364. name?: string;
  61365. }
  61366. /**
  61367. * Wraps an effect to be used for rendering
  61368. */
  61369. export class EffectWrapper {
  61370. /**
  61371. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61372. */
  61373. onApplyObservable: Observable<{}>;
  61374. /**
  61375. * The underlying effect
  61376. */
  61377. effect: Effect;
  61378. /**
  61379. * Creates an effect to be renderer
  61380. * @param creationOptions options to create the effect
  61381. */
  61382. constructor(creationOptions: EffectWrapperCreationOptions);
  61383. /**
  61384. * Disposes of the effect wrapper
  61385. */
  61386. dispose(): void;
  61387. }
  61388. }
  61389. declare module "babylonjs/Materials/index" {
  61390. export * from "babylonjs/Materials/Background/index";
  61391. export * from "babylonjs/Materials/colorCurves";
  61392. export * from "babylonjs/Materials/iEffectFallbacks";
  61393. export * from "babylonjs/Materials/effectFallbacks";
  61394. export * from "babylonjs/Materials/effect";
  61395. export * from "babylonjs/Materials/fresnelParameters";
  61396. export * from "babylonjs/Materials/imageProcessingConfiguration";
  61397. export * from "babylonjs/Materials/material";
  61398. export * from "babylonjs/Materials/materialDefines";
  61399. export * from "babylonjs/Materials/materialHelper";
  61400. export * from "babylonjs/Materials/multiMaterial";
  61401. export * from "babylonjs/Materials/PBR/index";
  61402. export * from "babylonjs/Materials/pushMaterial";
  61403. export * from "babylonjs/Materials/shaderMaterial";
  61404. export * from "babylonjs/Materials/standardMaterial";
  61405. export * from "babylonjs/Materials/Textures/index";
  61406. export * from "babylonjs/Materials/uniformBuffer";
  61407. export * from "babylonjs/Materials/materialFlags";
  61408. export * from "babylonjs/Materials/Node/index";
  61409. export * from "babylonjs/Materials/effectRenderer";
  61410. }
  61411. declare module "babylonjs/Maths/index" {
  61412. export * from "babylonjs/Maths/math.scalar";
  61413. export * from "babylonjs/Maths/math";
  61414. export * from "babylonjs/Maths/sphericalPolynomial";
  61415. }
  61416. declare module "babylonjs/Misc/workerPool" {
  61417. import { IDisposable } from "babylonjs/scene";
  61418. /**
  61419. * Helper class to push actions to a pool of workers.
  61420. */
  61421. export class WorkerPool implements IDisposable {
  61422. private _workerInfos;
  61423. private _pendingActions;
  61424. /**
  61425. * Constructor
  61426. * @param workers Array of workers to use for actions
  61427. */
  61428. constructor(workers: Array<Worker>);
  61429. /**
  61430. * Terminates all workers and clears any pending actions.
  61431. */
  61432. dispose(): void;
  61433. /**
  61434. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61435. * pended until a worker has completed its action.
  61436. * @param action The action to perform. Call onComplete when the action is complete.
  61437. */
  61438. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61439. private _execute;
  61440. }
  61441. }
  61442. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  61443. import { IDisposable } from "babylonjs/scene";
  61444. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61445. /**
  61446. * Configuration for Draco compression
  61447. */
  61448. export interface IDracoCompressionConfiguration {
  61449. /**
  61450. * Configuration for the decoder.
  61451. */
  61452. decoder: {
  61453. /**
  61454. * The url to the WebAssembly module.
  61455. */
  61456. wasmUrl?: string;
  61457. /**
  61458. * The url to the WebAssembly binary.
  61459. */
  61460. wasmBinaryUrl?: string;
  61461. /**
  61462. * The url to the fallback JavaScript module.
  61463. */
  61464. fallbackUrl?: string;
  61465. };
  61466. }
  61467. /**
  61468. * Draco compression (https://google.github.io/draco/)
  61469. *
  61470. * This class wraps the Draco module.
  61471. *
  61472. * **Encoder**
  61473. *
  61474. * The encoder is not currently implemented.
  61475. *
  61476. * **Decoder**
  61477. *
  61478. * 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.
  61479. *
  61480. * To update the configuration, use the following code:
  61481. * ```javascript
  61482. * DracoCompression.Configuration = {
  61483. * decoder: {
  61484. * wasmUrl: "<url to the WebAssembly library>",
  61485. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61486. * fallbackUrl: "<url to the fallback JavaScript library>",
  61487. * }
  61488. * };
  61489. * ```
  61490. *
  61491. * 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.
  61492. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61493. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61494. *
  61495. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61496. * ```javascript
  61497. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61498. * ```
  61499. *
  61500. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61501. */
  61502. export class DracoCompression implements IDisposable {
  61503. private _workerPoolPromise?;
  61504. private _decoderModulePromise?;
  61505. /**
  61506. * The configuration. Defaults to the following urls:
  61507. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61508. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61509. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61510. */
  61511. static Configuration: IDracoCompressionConfiguration;
  61512. /**
  61513. * Returns true if the decoder configuration is available.
  61514. */
  61515. static get DecoderAvailable(): boolean;
  61516. /**
  61517. * Default number of workers to create when creating the draco compression object.
  61518. */
  61519. static DefaultNumWorkers: number;
  61520. private static GetDefaultNumWorkers;
  61521. private static _Default;
  61522. /**
  61523. * Default instance for the draco compression object.
  61524. */
  61525. static get Default(): DracoCompression;
  61526. /**
  61527. * Constructor
  61528. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61529. */
  61530. constructor(numWorkers?: number);
  61531. /**
  61532. * Stop all async operations and release resources.
  61533. */
  61534. dispose(): void;
  61535. /**
  61536. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61537. * @returns a promise that resolves when ready
  61538. */
  61539. whenReadyAsync(): Promise<void>;
  61540. /**
  61541. * Decode Draco compressed mesh data to vertex data.
  61542. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61543. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61544. * @returns A promise that resolves with the decoded vertex data
  61545. */
  61546. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61547. [kind: string]: number;
  61548. }): Promise<VertexData>;
  61549. }
  61550. }
  61551. declare module "babylonjs/Meshes/Compression/index" {
  61552. export * from "babylonjs/Meshes/Compression/dracoCompression";
  61553. }
  61554. declare module "babylonjs/Meshes/csg" {
  61555. import { Nullable } from "babylonjs/types";
  61556. import { Scene } from "babylonjs/scene";
  61557. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61558. import { Mesh } from "babylonjs/Meshes/mesh";
  61559. import { Material } from "babylonjs/Materials/material";
  61560. /**
  61561. * Class for building Constructive Solid Geometry
  61562. */
  61563. export class CSG {
  61564. private polygons;
  61565. /**
  61566. * The world matrix
  61567. */
  61568. matrix: Matrix;
  61569. /**
  61570. * Stores the position
  61571. */
  61572. position: Vector3;
  61573. /**
  61574. * Stores the rotation
  61575. */
  61576. rotation: Vector3;
  61577. /**
  61578. * Stores the rotation quaternion
  61579. */
  61580. rotationQuaternion: Nullable<Quaternion>;
  61581. /**
  61582. * Stores the scaling vector
  61583. */
  61584. scaling: Vector3;
  61585. /**
  61586. * Convert the Mesh to CSG
  61587. * @param mesh The Mesh to convert to CSG
  61588. * @returns A new CSG from the Mesh
  61589. */
  61590. static FromMesh(mesh: Mesh): CSG;
  61591. /**
  61592. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61593. * @param polygons Polygons used to construct a CSG solid
  61594. */
  61595. private static FromPolygons;
  61596. /**
  61597. * Clones, or makes a deep copy, of the CSG
  61598. * @returns A new CSG
  61599. */
  61600. clone(): CSG;
  61601. /**
  61602. * Unions this CSG with another CSG
  61603. * @param csg The CSG to union against this CSG
  61604. * @returns The unioned CSG
  61605. */
  61606. union(csg: CSG): CSG;
  61607. /**
  61608. * Unions this CSG with another CSG in place
  61609. * @param csg The CSG to union against this CSG
  61610. */
  61611. unionInPlace(csg: CSG): void;
  61612. /**
  61613. * Subtracts this CSG with another CSG
  61614. * @param csg The CSG to subtract against this CSG
  61615. * @returns A new CSG
  61616. */
  61617. subtract(csg: CSG): CSG;
  61618. /**
  61619. * Subtracts this CSG with another CSG in place
  61620. * @param csg The CSG to subtact against this CSG
  61621. */
  61622. subtractInPlace(csg: CSG): void;
  61623. /**
  61624. * Intersect this CSG with another CSG
  61625. * @param csg The CSG to intersect against this CSG
  61626. * @returns A new CSG
  61627. */
  61628. intersect(csg: CSG): CSG;
  61629. /**
  61630. * Intersects this CSG with another CSG in place
  61631. * @param csg The CSG to intersect against this CSG
  61632. */
  61633. intersectInPlace(csg: CSG): void;
  61634. /**
  61635. * Return a new CSG solid with solid and empty space switched. This solid is
  61636. * not modified.
  61637. * @returns A new CSG solid with solid and empty space switched
  61638. */
  61639. inverse(): CSG;
  61640. /**
  61641. * Inverses the CSG in place
  61642. */
  61643. inverseInPlace(): void;
  61644. /**
  61645. * This is used to keep meshes transformations so they can be restored
  61646. * when we build back a Babylon Mesh
  61647. * NB : All CSG operations are performed in world coordinates
  61648. * @param csg The CSG to copy the transform attributes from
  61649. * @returns This CSG
  61650. */
  61651. copyTransformAttributes(csg: CSG): CSG;
  61652. /**
  61653. * Build Raw mesh from CSG
  61654. * Coordinates here are in world space
  61655. * @param name The name of the mesh geometry
  61656. * @param scene The Scene
  61657. * @param keepSubMeshes Specifies if the submeshes should be kept
  61658. * @returns A new Mesh
  61659. */
  61660. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61661. /**
  61662. * Build Mesh from CSG taking material and transforms into account
  61663. * @param name The name of the Mesh
  61664. * @param material The material of the Mesh
  61665. * @param scene The Scene
  61666. * @param keepSubMeshes Specifies if submeshes should be kept
  61667. * @returns The new Mesh
  61668. */
  61669. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61670. }
  61671. }
  61672. declare module "babylonjs/Meshes/trailMesh" {
  61673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61674. import { Mesh } from "babylonjs/Meshes/mesh";
  61675. import { Scene } from "babylonjs/scene";
  61676. /**
  61677. * Class used to create a trail following a mesh
  61678. */
  61679. export class TrailMesh extends Mesh {
  61680. private _generator;
  61681. private _autoStart;
  61682. private _running;
  61683. private _diameter;
  61684. private _length;
  61685. private _sectionPolygonPointsCount;
  61686. private _sectionVectors;
  61687. private _sectionNormalVectors;
  61688. private _beforeRenderObserver;
  61689. /**
  61690. * @constructor
  61691. * @param name The value used by scene.getMeshByName() to do a lookup.
  61692. * @param generator The mesh to generate a trail.
  61693. * @param scene The scene to add this mesh to.
  61694. * @param diameter Diameter of trailing mesh. Default is 1.
  61695. * @param length Length of trailing mesh. Default is 60.
  61696. * @param autoStart Automatically start trailing mesh. Default true.
  61697. */
  61698. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61699. /**
  61700. * "TrailMesh"
  61701. * @returns "TrailMesh"
  61702. */
  61703. getClassName(): string;
  61704. private _createMesh;
  61705. /**
  61706. * Start trailing mesh.
  61707. */
  61708. start(): void;
  61709. /**
  61710. * Stop trailing mesh.
  61711. */
  61712. stop(): void;
  61713. /**
  61714. * Update trailing mesh geometry.
  61715. */
  61716. update(): void;
  61717. /**
  61718. * Returns a new TrailMesh object.
  61719. * @param name is a string, the name given to the new mesh
  61720. * @param newGenerator use new generator object for cloned trail mesh
  61721. * @returns a new mesh
  61722. */
  61723. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  61724. /**
  61725. * Serializes this trail mesh
  61726. * @param serializationObject object to write serialization to
  61727. */
  61728. serialize(serializationObject: any): void;
  61729. /**
  61730. * Parses a serialized trail mesh
  61731. * @param parsedMesh the serialized mesh
  61732. * @param scene the scene to create the trail mesh in
  61733. * @returns the created trail mesh
  61734. */
  61735. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61736. }
  61737. }
  61738. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  61739. import { Nullable } from "babylonjs/types";
  61740. import { Scene } from "babylonjs/scene";
  61741. import { Vector4 } from "babylonjs/Maths/math.vector";
  61742. import { Color4 } from "babylonjs/Maths/math.color";
  61743. import { Mesh } from "babylonjs/Meshes/mesh";
  61744. /**
  61745. * Class containing static functions to help procedurally build meshes
  61746. */
  61747. export class TiledBoxBuilder {
  61748. /**
  61749. * Creates a box mesh
  61750. * 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)
  61751. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61755. * @param name defines the name of the mesh
  61756. * @param options defines the options used to create the mesh
  61757. * @param scene defines the hosting scene
  61758. * @returns the box mesh
  61759. */
  61760. static CreateTiledBox(name: string, options: {
  61761. pattern?: number;
  61762. width?: number;
  61763. height?: number;
  61764. depth?: number;
  61765. tileSize?: number;
  61766. tileWidth?: number;
  61767. tileHeight?: number;
  61768. alignHorizontal?: number;
  61769. alignVertical?: number;
  61770. faceUV?: Vector4[];
  61771. faceColors?: Color4[];
  61772. sideOrientation?: number;
  61773. updatable?: boolean;
  61774. }, scene?: Nullable<Scene>): Mesh;
  61775. }
  61776. }
  61777. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  61778. import { Vector4 } from "babylonjs/Maths/math.vector";
  61779. import { Mesh } from "babylonjs/Meshes/mesh";
  61780. /**
  61781. * Class containing static functions to help procedurally build meshes
  61782. */
  61783. export class TorusKnotBuilder {
  61784. /**
  61785. * Creates a torus knot mesh
  61786. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61787. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61788. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61789. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61793. * @param name defines the name of the mesh
  61794. * @param options defines the options used to create the mesh
  61795. * @param scene defines the hosting scene
  61796. * @returns the torus knot mesh
  61797. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61798. */
  61799. static CreateTorusKnot(name: string, options: {
  61800. radius?: number;
  61801. tube?: number;
  61802. radialSegments?: number;
  61803. tubularSegments?: number;
  61804. p?: number;
  61805. q?: number;
  61806. updatable?: boolean;
  61807. sideOrientation?: number;
  61808. frontUVs?: Vector4;
  61809. backUVs?: Vector4;
  61810. }, scene: any): Mesh;
  61811. }
  61812. }
  61813. declare module "babylonjs/Meshes/polygonMesh" {
  61814. import { Scene } from "babylonjs/scene";
  61815. import { Vector2 } from "babylonjs/Maths/math.vector";
  61816. import { Mesh } from "babylonjs/Meshes/mesh";
  61817. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61818. import { Path2 } from "babylonjs/Maths/math.path";
  61819. /**
  61820. * Polygon
  61821. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61822. */
  61823. export class Polygon {
  61824. /**
  61825. * Creates a rectangle
  61826. * @param xmin bottom X coord
  61827. * @param ymin bottom Y coord
  61828. * @param xmax top X coord
  61829. * @param ymax top Y coord
  61830. * @returns points that make the resulting rectation
  61831. */
  61832. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61833. /**
  61834. * Creates a circle
  61835. * @param radius radius of circle
  61836. * @param cx scale in x
  61837. * @param cy scale in y
  61838. * @param numberOfSides number of sides that make up the circle
  61839. * @returns points that make the resulting circle
  61840. */
  61841. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61842. /**
  61843. * Creates a polygon from input string
  61844. * @param input Input polygon data
  61845. * @returns the parsed points
  61846. */
  61847. static Parse(input: string): Vector2[];
  61848. /**
  61849. * Starts building a polygon from x and y coordinates
  61850. * @param x x coordinate
  61851. * @param y y coordinate
  61852. * @returns the started path2
  61853. */
  61854. static StartingAt(x: number, y: number): Path2;
  61855. }
  61856. /**
  61857. * Builds a polygon
  61858. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61859. */
  61860. export class PolygonMeshBuilder {
  61861. private _points;
  61862. private _outlinepoints;
  61863. private _holes;
  61864. private _name;
  61865. private _scene;
  61866. private _epoints;
  61867. private _eholes;
  61868. private _addToepoint;
  61869. /**
  61870. * Babylon reference to the earcut plugin.
  61871. */
  61872. bjsEarcut: any;
  61873. /**
  61874. * Creates a PolygonMeshBuilder
  61875. * @param name name of the builder
  61876. * @param contours Path of the polygon
  61877. * @param scene scene to add to when creating the mesh
  61878. * @param earcutInjection can be used to inject your own earcut reference
  61879. */
  61880. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61881. /**
  61882. * Adds a whole within the polygon
  61883. * @param hole Array of points defining the hole
  61884. * @returns this
  61885. */
  61886. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61887. /**
  61888. * Creates the polygon
  61889. * @param updatable If the mesh should be updatable
  61890. * @param depth The depth of the mesh created
  61891. * @returns the created mesh
  61892. */
  61893. build(updatable?: boolean, depth?: number): Mesh;
  61894. /**
  61895. * Creates the polygon
  61896. * @param depth The depth of the mesh created
  61897. * @returns the created VertexData
  61898. */
  61899. buildVertexData(depth?: number): VertexData;
  61900. /**
  61901. * Adds a side to the polygon
  61902. * @param positions points that make the polygon
  61903. * @param normals normals of the polygon
  61904. * @param uvs uvs of the polygon
  61905. * @param indices indices of the polygon
  61906. * @param bounds bounds of the polygon
  61907. * @param points points of the polygon
  61908. * @param depth depth of the polygon
  61909. * @param flip flip of the polygon
  61910. */
  61911. private addSide;
  61912. }
  61913. }
  61914. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  61915. import { Scene } from "babylonjs/scene";
  61916. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61917. import { Color4 } from "babylonjs/Maths/math.color";
  61918. import { Mesh } from "babylonjs/Meshes/mesh";
  61919. import { Nullable } from "babylonjs/types";
  61920. /**
  61921. * Class containing static functions to help procedurally build meshes
  61922. */
  61923. export class PolygonBuilder {
  61924. /**
  61925. * Creates a polygon mesh
  61926. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61927. * * 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
  61928. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61931. * * Remember you can only change the shape positions, not their number when updating a polygon
  61932. * @param name defines the name of the mesh
  61933. * @param options defines the options used to create the mesh
  61934. * @param scene defines the hosting scene
  61935. * @param earcutInjection can be used to inject your own earcut reference
  61936. * @returns the polygon mesh
  61937. */
  61938. static CreatePolygon(name: string, options: {
  61939. shape: Vector3[];
  61940. holes?: Vector3[][];
  61941. depth?: number;
  61942. faceUV?: Vector4[];
  61943. faceColors?: Color4[];
  61944. updatable?: boolean;
  61945. sideOrientation?: number;
  61946. frontUVs?: Vector4;
  61947. backUVs?: Vector4;
  61948. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61949. /**
  61950. * Creates an extruded polygon mesh, with depth in the Y direction.
  61951. * * 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)
  61952. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61953. * @param name defines the name of the mesh
  61954. * @param options defines the options used to create the mesh
  61955. * @param scene defines the hosting scene
  61956. * @param earcutInjection can be used to inject your own earcut reference
  61957. * @returns the polygon mesh
  61958. */
  61959. static ExtrudePolygon(name: string, options: {
  61960. shape: Vector3[];
  61961. holes?: Vector3[][];
  61962. depth?: number;
  61963. faceUV?: Vector4[];
  61964. faceColors?: Color4[];
  61965. updatable?: boolean;
  61966. sideOrientation?: number;
  61967. frontUVs?: Vector4;
  61968. backUVs?: Vector4;
  61969. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61970. }
  61971. }
  61972. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  61973. import { Scene } from "babylonjs/scene";
  61974. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61975. import { Mesh } from "babylonjs/Meshes/mesh";
  61976. import { Nullable } from "babylonjs/types";
  61977. /**
  61978. * Class containing static functions to help procedurally build meshes
  61979. */
  61980. export class LatheBuilder {
  61981. /**
  61982. * Creates lathe mesh.
  61983. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61984. * * 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
  61985. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61986. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61987. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61988. * * 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
  61989. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61990. * * 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
  61991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61992. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61993. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61995. * @param name defines the name of the mesh
  61996. * @param options defines the options used to create the mesh
  61997. * @param scene defines the hosting scene
  61998. * @returns the lathe mesh
  61999. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62000. */
  62001. static CreateLathe(name: string, options: {
  62002. shape: Vector3[];
  62003. radius?: number;
  62004. tessellation?: number;
  62005. clip?: number;
  62006. arc?: number;
  62007. closed?: boolean;
  62008. updatable?: boolean;
  62009. sideOrientation?: number;
  62010. frontUVs?: Vector4;
  62011. backUVs?: Vector4;
  62012. cap?: number;
  62013. invertUV?: boolean;
  62014. }, scene?: Nullable<Scene>): Mesh;
  62015. }
  62016. }
  62017. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62018. import { Nullable } from "babylonjs/types";
  62019. import { Scene } from "babylonjs/scene";
  62020. import { Vector4 } from "babylonjs/Maths/math.vector";
  62021. import { Mesh } from "babylonjs/Meshes/mesh";
  62022. /**
  62023. * Class containing static functions to help procedurally build meshes
  62024. */
  62025. export class TiledPlaneBuilder {
  62026. /**
  62027. * Creates a tiled plane mesh
  62028. * * The parameter `pattern` will, depending on value, do nothing or
  62029. * * * flip (reflect about central vertical) alternate tiles across and up
  62030. * * * flip every tile on alternate rows
  62031. * * * rotate (180 degs) alternate tiles across and up
  62032. * * * rotate every tile on alternate rows
  62033. * * * flip and rotate alternate tiles across and up
  62034. * * * flip and rotate every tile on alternate rows
  62035. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62036. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62038. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62039. * * 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)
  62040. * * 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)
  62041. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62042. * @param name defines the name of the mesh
  62043. * @param options defines the options used to create the mesh
  62044. * @param scene defines the hosting scene
  62045. * @returns the box mesh
  62046. */
  62047. static CreateTiledPlane(name: string, options: {
  62048. pattern?: number;
  62049. tileSize?: number;
  62050. tileWidth?: number;
  62051. tileHeight?: number;
  62052. size?: number;
  62053. width?: number;
  62054. height?: number;
  62055. alignHorizontal?: number;
  62056. alignVertical?: number;
  62057. sideOrientation?: number;
  62058. frontUVs?: Vector4;
  62059. backUVs?: Vector4;
  62060. updatable?: boolean;
  62061. }, scene?: Nullable<Scene>): Mesh;
  62062. }
  62063. }
  62064. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62065. import { Nullable } from "babylonjs/types";
  62066. import { Scene } from "babylonjs/scene";
  62067. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62068. import { Mesh } from "babylonjs/Meshes/mesh";
  62069. /**
  62070. * Class containing static functions to help procedurally build meshes
  62071. */
  62072. export class TubeBuilder {
  62073. /**
  62074. * Creates a tube mesh.
  62075. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62076. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62077. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62078. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62079. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62080. * * 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)
  62081. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62082. * * 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
  62083. * * 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
  62084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62086. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62088. * @param name defines the name of the mesh
  62089. * @param options defines the options used to create the mesh
  62090. * @param scene defines the hosting scene
  62091. * @returns the tube mesh
  62092. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62093. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62094. */
  62095. static CreateTube(name: string, options: {
  62096. path: Vector3[];
  62097. radius?: number;
  62098. tessellation?: number;
  62099. radiusFunction?: {
  62100. (i: number, distance: number): number;
  62101. };
  62102. cap?: number;
  62103. arc?: number;
  62104. updatable?: boolean;
  62105. sideOrientation?: number;
  62106. frontUVs?: Vector4;
  62107. backUVs?: Vector4;
  62108. instance?: Mesh;
  62109. invertUV?: boolean;
  62110. }, scene?: Nullable<Scene>): Mesh;
  62111. }
  62112. }
  62113. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62114. import { Scene } from "babylonjs/scene";
  62115. import { Vector4 } from "babylonjs/Maths/math.vector";
  62116. import { Mesh } from "babylonjs/Meshes/mesh";
  62117. import { Nullable } from "babylonjs/types";
  62118. /**
  62119. * Class containing static functions to help procedurally build meshes
  62120. */
  62121. export class IcoSphereBuilder {
  62122. /**
  62123. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62124. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62125. * * 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`)
  62126. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62127. * * 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
  62128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62131. * @param name defines the name of the mesh
  62132. * @param options defines the options used to create the mesh
  62133. * @param scene defines the hosting scene
  62134. * @returns the icosahedron mesh
  62135. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62136. */
  62137. static CreateIcoSphere(name: string, options: {
  62138. radius?: number;
  62139. radiusX?: number;
  62140. radiusY?: number;
  62141. radiusZ?: number;
  62142. flat?: boolean;
  62143. subdivisions?: number;
  62144. sideOrientation?: number;
  62145. frontUVs?: Vector4;
  62146. backUVs?: Vector4;
  62147. updatable?: boolean;
  62148. }, scene?: Nullable<Scene>): Mesh;
  62149. }
  62150. }
  62151. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62152. import { Vector3 } from "babylonjs/Maths/math.vector";
  62153. import { Mesh } from "babylonjs/Meshes/mesh";
  62154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62155. /**
  62156. * Class containing static functions to help procedurally build meshes
  62157. */
  62158. export class DecalBuilder {
  62159. /**
  62160. * Creates a decal mesh.
  62161. * 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
  62162. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62163. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62164. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62165. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62166. * @param name defines the name of the mesh
  62167. * @param sourceMesh defines the mesh where the decal must be applied
  62168. * @param options defines the options used to create the mesh
  62169. * @param scene defines the hosting scene
  62170. * @returns the decal mesh
  62171. * @see https://doc.babylonjs.com/how_to/decals
  62172. */
  62173. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62174. position?: Vector3;
  62175. normal?: Vector3;
  62176. size?: Vector3;
  62177. angle?: number;
  62178. }): Mesh;
  62179. }
  62180. }
  62181. declare module "babylonjs/Meshes/meshBuilder" {
  62182. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  62183. import { Nullable } from "babylonjs/types";
  62184. import { Scene } from "babylonjs/scene";
  62185. import { Mesh } from "babylonjs/Meshes/mesh";
  62186. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  62187. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  62188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62189. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62190. import { Plane } from "babylonjs/Maths/math.plane";
  62191. /**
  62192. * Class containing static functions to help procedurally build meshes
  62193. */
  62194. export class MeshBuilder {
  62195. /**
  62196. * Creates a box mesh
  62197. * * The parameter `size` sets the size (float) of each box side (default 1)
  62198. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  62199. * * 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)
  62200. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62204. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62205. * @param name defines the name of the mesh
  62206. * @param options defines the options used to create the mesh
  62207. * @param scene defines the hosting scene
  62208. * @returns the box mesh
  62209. */
  62210. static CreateBox(name: string, options: {
  62211. size?: number;
  62212. width?: number;
  62213. height?: number;
  62214. depth?: number;
  62215. faceUV?: Vector4[];
  62216. faceColors?: Color4[];
  62217. sideOrientation?: number;
  62218. frontUVs?: Vector4;
  62219. backUVs?: Vector4;
  62220. updatable?: boolean;
  62221. }, scene?: Nullable<Scene>): Mesh;
  62222. /**
  62223. * Creates a tiled box mesh
  62224. * * faceTiles sets the pattern, tile size and number of tiles for a face
  62225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62226. * @param name defines the name of the mesh
  62227. * @param options defines the options used to create the mesh
  62228. * @param scene defines the hosting scene
  62229. * @returns the tiled box mesh
  62230. */
  62231. static CreateTiledBox(name: string, options: {
  62232. pattern?: number;
  62233. size?: number;
  62234. width?: number;
  62235. height?: number;
  62236. depth: number;
  62237. tileSize?: number;
  62238. tileWidth?: number;
  62239. tileHeight?: number;
  62240. faceUV?: Vector4[];
  62241. faceColors?: Color4[];
  62242. alignHorizontal?: number;
  62243. alignVertical?: number;
  62244. sideOrientation?: number;
  62245. updatable?: boolean;
  62246. }, scene?: Nullable<Scene>): Mesh;
  62247. /**
  62248. * Creates a sphere mesh
  62249. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  62250. * * 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`)
  62251. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  62252. * * 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
  62253. * * 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)
  62254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62257. * @param name defines the name of the mesh
  62258. * @param options defines the options used to create the mesh
  62259. * @param scene defines the hosting scene
  62260. * @returns the sphere mesh
  62261. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  62262. */
  62263. static CreateSphere(name: string, options: {
  62264. segments?: number;
  62265. diameter?: number;
  62266. diameterX?: number;
  62267. diameterY?: number;
  62268. diameterZ?: number;
  62269. arc?: number;
  62270. slice?: number;
  62271. sideOrientation?: number;
  62272. frontUVs?: Vector4;
  62273. backUVs?: Vector4;
  62274. updatable?: boolean;
  62275. }, scene?: Nullable<Scene>): Mesh;
  62276. /**
  62277. * Creates a plane polygonal mesh. By default, this is a disc
  62278. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  62279. * * 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
  62280. * * 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
  62281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62284. * @param name defines the name of the mesh
  62285. * @param options defines the options used to create the mesh
  62286. * @param scene defines the hosting scene
  62287. * @returns the plane polygonal mesh
  62288. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  62289. */
  62290. static CreateDisc(name: string, options: {
  62291. radius?: number;
  62292. tessellation?: number;
  62293. arc?: number;
  62294. updatable?: boolean;
  62295. sideOrientation?: number;
  62296. frontUVs?: Vector4;
  62297. backUVs?: Vector4;
  62298. }, scene?: Nullable<Scene>): Mesh;
  62299. /**
  62300. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62301. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62302. * * 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`)
  62303. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62304. * * 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
  62305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62308. * @param name defines the name of the mesh
  62309. * @param options defines the options used to create the mesh
  62310. * @param scene defines the hosting scene
  62311. * @returns the icosahedron mesh
  62312. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62313. */
  62314. static CreateIcoSphere(name: string, options: {
  62315. radius?: number;
  62316. radiusX?: number;
  62317. radiusY?: number;
  62318. radiusZ?: number;
  62319. flat?: boolean;
  62320. subdivisions?: number;
  62321. sideOrientation?: number;
  62322. frontUVs?: Vector4;
  62323. backUVs?: Vector4;
  62324. updatable?: boolean;
  62325. }, scene?: Nullable<Scene>): Mesh;
  62326. /**
  62327. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62328. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62329. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62330. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62331. * * 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
  62332. * * 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
  62333. * * 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
  62334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62336. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62337. * * 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
  62338. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62339. * * 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
  62340. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62342. * @param name defines the name of the mesh
  62343. * @param options defines the options used to create the mesh
  62344. * @param scene defines the hosting scene
  62345. * @returns the ribbon mesh
  62346. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62348. */
  62349. static CreateRibbon(name: string, options: {
  62350. pathArray: Vector3[][];
  62351. closeArray?: boolean;
  62352. closePath?: boolean;
  62353. offset?: number;
  62354. updatable?: boolean;
  62355. sideOrientation?: number;
  62356. frontUVs?: Vector4;
  62357. backUVs?: Vector4;
  62358. instance?: Mesh;
  62359. invertUV?: boolean;
  62360. uvs?: Vector2[];
  62361. colors?: Color4[];
  62362. }, scene?: Nullable<Scene>): Mesh;
  62363. /**
  62364. * Creates a cylinder or a cone mesh
  62365. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  62366. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  62367. * * 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.
  62368. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  62369. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  62370. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  62371. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  62372. * * 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).
  62373. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  62374. * * 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).
  62375. * * 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
  62376. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  62377. * * 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
  62378. * * 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.
  62379. * * If `enclose` is false, a ring surface is one element.
  62380. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  62381. * * 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
  62382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62385. * @param name defines the name of the mesh
  62386. * @param options defines the options used to create the mesh
  62387. * @param scene defines the hosting scene
  62388. * @returns the cylinder mesh
  62389. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  62390. */
  62391. static CreateCylinder(name: string, options: {
  62392. height?: number;
  62393. diameterTop?: number;
  62394. diameterBottom?: number;
  62395. diameter?: number;
  62396. tessellation?: number;
  62397. subdivisions?: number;
  62398. arc?: number;
  62399. faceColors?: Color4[];
  62400. faceUV?: Vector4[];
  62401. updatable?: boolean;
  62402. hasRings?: boolean;
  62403. enclose?: boolean;
  62404. cap?: number;
  62405. sideOrientation?: number;
  62406. frontUVs?: Vector4;
  62407. backUVs?: Vector4;
  62408. }, scene?: Nullable<Scene>): Mesh;
  62409. /**
  62410. * Creates a torus mesh
  62411. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  62412. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  62413. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  62414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62417. * @param name defines the name of the mesh
  62418. * @param options defines the options used to create the mesh
  62419. * @param scene defines the hosting scene
  62420. * @returns the torus mesh
  62421. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  62422. */
  62423. static CreateTorus(name: string, options: {
  62424. diameter?: number;
  62425. thickness?: number;
  62426. tessellation?: number;
  62427. updatable?: boolean;
  62428. sideOrientation?: number;
  62429. frontUVs?: Vector4;
  62430. backUVs?: Vector4;
  62431. }, scene?: Nullable<Scene>): Mesh;
  62432. /**
  62433. * Creates a torus knot mesh
  62434. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62435. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62436. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62437. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62441. * @param name defines the name of the mesh
  62442. * @param options defines the options used to create the mesh
  62443. * @param scene defines the hosting scene
  62444. * @returns the torus knot mesh
  62445. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62446. */
  62447. static CreateTorusKnot(name: string, options: {
  62448. radius?: number;
  62449. tube?: number;
  62450. radialSegments?: number;
  62451. tubularSegments?: number;
  62452. p?: number;
  62453. q?: number;
  62454. updatable?: boolean;
  62455. sideOrientation?: number;
  62456. frontUVs?: Vector4;
  62457. backUVs?: Vector4;
  62458. }, scene?: Nullable<Scene>): Mesh;
  62459. /**
  62460. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62461. * * 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
  62462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62463. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62464. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62465. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62466. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62467. * * 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
  62468. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62471. * @param name defines the name of the new line system
  62472. * @param options defines the options used to create the line system
  62473. * @param scene defines the hosting scene
  62474. * @returns a new line system mesh
  62475. */
  62476. static CreateLineSystem(name: string, options: {
  62477. lines: Vector3[][];
  62478. updatable?: boolean;
  62479. instance?: Nullable<LinesMesh>;
  62480. colors?: Nullable<Color4[][]>;
  62481. useVertexAlpha?: boolean;
  62482. }, scene: Nullable<Scene>): LinesMesh;
  62483. /**
  62484. * Creates a line mesh
  62485. * 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
  62486. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62487. * * The parameter `points` is an array successive Vector3
  62488. * * 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
  62489. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62490. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62491. * * When updating an instance, remember that only point positions can change, not the number of points
  62492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62494. * @param name defines the name of the new line system
  62495. * @param options defines the options used to create the line system
  62496. * @param scene defines the hosting scene
  62497. * @returns a new line mesh
  62498. */
  62499. static CreateLines(name: string, options: {
  62500. points: Vector3[];
  62501. updatable?: boolean;
  62502. instance?: Nullable<LinesMesh>;
  62503. colors?: Color4[];
  62504. useVertexAlpha?: boolean;
  62505. }, scene?: Nullable<Scene>): LinesMesh;
  62506. /**
  62507. * Creates a dashed line mesh
  62508. * * 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
  62509. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62510. * * The parameter `points` is an array successive Vector3
  62511. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62512. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62513. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62514. * * 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
  62515. * * When updating an instance, remember that only point positions can change, not the number of points
  62516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62517. * @param name defines the name of the mesh
  62518. * @param options defines the options used to create the mesh
  62519. * @param scene defines the hosting scene
  62520. * @returns the dashed line mesh
  62521. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62522. */
  62523. static CreateDashedLines(name: string, options: {
  62524. points: Vector3[];
  62525. dashSize?: number;
  62526. gapSize?: number;
  62527. dashNb?: number;
  62528. updatable?: boolean;
  62529. instance?: LinesMesh;
  62530. }, scene?: Nullable<Scene>): LinesMesh;
  62531. /**
  62532. * 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.
  62533. * * 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.
  62534. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62535. * * 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.
  62536. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62537. * * 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
  62538. * * 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
  62539. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62542. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62544. * @param name defines the name of the mesh
  62545. * @param options defines the options used to create the mesh
  62546. * @param scene defines the hosting scene
  62547. * @returns the extruded shape mesh
  62548. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62550. */
  62551. static ExtrudeShape(name: string, options: {
  62552. shape: Vector3[];
  62553. path: Vector3[];
  62554. scale?: number;
  62555. rotation?: number;
  62556. cap?: number;
  62557. updatable?: boolean;
  62558. sideOrientation?: number;
  62559. frontUVs?: Vector4;
  62560. backUVs?: Vector4;
  62561. instance?: Mesh;
  62562. invertUV?: boolean;
  62563. }, scene?: Nullable<Scene>): Mesh;
  62564. /**
  62565. * Creates an custom extruded shape mesh.
  62566. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62567. * * 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.
  62568. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62569. * * 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
  62570. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62571. * * 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
  62572. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62573. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62574. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62575. * * 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
  62576. * * 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
  62577. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62580. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62582. * @param name defines the name of the mesh
  62583. * @param options defines the options used to create the mesh
  62584. * @param scene defines the hosting scene
  62585. * @returns the custom extruded shape mesh
  62586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62589. */
  62590. static ExtrudeShapeCustom(name: string, options: {
  62591. shape: Vector3[];
  62592. path: Vector3[];
  62593. scaleFunction?: any;
  62594. rotationFunction?: any;
  62595. ribbonCloseArray?: boolean;
  62596. ribbonClosePath?: boolean;
  62597. cap?: number;
  62598. updatable?: boolean;
  62599. sideOrientation?: number;
  62600. frontUVs?: Vector4;
  62601. backUVs?: Vector4;
  62602. instance?: Mesh;
  62603. invertUV?: boolean;
  62604. }, scene?: Nullable<Scene>): Mesh;
  62605. /**
  62606. * Creates lathe mesh.
  62607. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62608. * * 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
  62609. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62610. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62611. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62612. * * 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
  62613. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62614. * * 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
  62615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62619. * @param name defines the name of the mesh
  62620. * @param options defines the options used to create the mesh
  62621. * @param scene defines the hosting scene
  62622. * @returns the lathe mesh
  62623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62624. */
  62625. static CreateLathe(name: string, options: {
  62626. shape: Vector3[];
  62627. radius?: number;
  62628. tessellation?: number;
  62629. clip?: number;
  62630. arc?: number;
  62631. closed?: boolean;
  62632. updatable?: boolean;
  62633. sideOrientation?: number;
  62634. frontUVs?: Vector4;
  62635. backUVs?: Vector4;
  62636. cap?: number;
  62637. invertUV?: boolean;
  62638. }, scene?: Nullable<Scene>): Mesh;
  62639. /**
  62640. * Creates a tiled plane mesh
  62641. * * You can set a limited pattern arrangement with the tiles
  62642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62645. * @param name defines the name of the mesh
  62646. * @param options defines the options used to create the mesh
  62647. * @param scene defines the hosting scene
  62648. * @returns the plane mesh
  62649. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62650. */
  62651. static CreateTiledPlane(name: string, options: {
  62652. pattern?: number;
  62653. tileSize?: number;
  62654. tileWidth?: number;
  62655. tileHeight?: number;
  62656. size?: number;
  62657. width?: number;
  62658. height?: number;
  62659. alignHorizontal?: number;
  62660. alignVertical?: number;
  62661. sideOrientation?: number;
  62662. frontUVs?: Vector4;
  62663. backUVs?: Vector4;
  62664. updatable?: boolean;
  62665. }, scene?: Nullable<Scene>): Mesh;
  62666. /**
  62667. * Creates a plane mesh
  62668. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62669. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62670. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62674. * @param name defines the name of the mesh
  62675. * @param options defines the options used to create the mesh
  62676. * @param scene defines the hosting scene
  62677. * @returns the plane mesh
  62678. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62679. */
  62680. static CreatePlane(name: string, options: {
  62681. size?: number;
  62682. width?: number;
  62683. height?: number;
  62684. sideOrientation?: number;
  62685. frontUVs?: Vector4;
  62686. backUVs?: Vector4;
  62687. updatable?: boolean;
  62688. sourcePlane?: Plane;
  62689. }, scene?: Nullable<Scene>): Mesh;
  62690. /**
  62691. * Creates a ground mesh
  62692. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62693. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62695. * @param name defines the name of the mesh
  62696. * @param options defines the options used to create the mesh
  62697. * @param scene defines the hosting scene
  62698. * @returns the ground mesh
  62699. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62700. */
  62701. static CreateGround(name: string, options: {
  62702. width?: number;
  62703. height?: number;
  62704. subdivisions?: number;
  62705. subdivisionsX?: number;
  62706. subdivisionsY?: number;
  62707. updatable?: boolean;
  62708. }, scene?: Nullable<Scene>): Mesh;
  62709. /**
  62710. * Creates a tiled ground mesh
  62711. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62712. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62713. * * 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
  62714. * * 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
  62715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62716. * @param name defines the name of the mesh
  62717. * @param options defines the options used to create the mesh
  62718. * @param scene defines the hosting scene
  62719. * @returns the tiled ground mesh
  62720. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62721. */
  62722. static CreateTiledGround(name: string, options: {
  62723. xmin: number;
  62724. zmin: number;
  62725. xmax: number;
  62726. zmax: number;
  62727. subdivisions?: {
  62728. w: number;
  62729. h: number;
  62730. };
  62731. precision?: {
  62732. w: number;
  62733. h: number;
  62734. };
  62735. updatable?: boolean;
  62736. }, scene?: Nullable<Scene>): Mesh;
  62737. /**
  62738. * Creates a ground mesh from a height map
  62739. * * The parameter `url` sets the URL of the height map image resource.
  62740. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62741. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62742. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62743. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62744. * * 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.
  62745. * * 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).
  62746. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62748. * @param name defines the name of the mesh
  62749. * @param url defines the url to the height map
  62750. * @param options defines the options used to create the mesh
  62751. * @param scene defines the hosting scene
  62752. * @returns the ground mesh
  62753. * @see https://doc.babylonjs.com/babylon101/height_map
  62754. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62755. */
  62756. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62757. width?: number;
  62758. height?: number;
  62759. subdivisions?: number;
  62760. minHeight?: number;
  62761. maxHeight?: number;
  62762. colorFilter?: Color3;
  62763. alphaFilter?: number;
  62764. updatable?: boolean;
  62765. onReady?: (mesh: GroundMesh) => void;
  62766. }, scene?: Nullable<Scene>): GroundMesh;
  62767. /**
  62768. * Creates a polygon mesh
  62769. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62770. * * 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
  62771. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62774. * * Remember you can only change the shape positions, not their number when updating a polygon
  62775. * @param name defines the name of the mesh
  62776. * @param options defines the options used to create the mesh
  62777. * @param scene defines the hosting scene
  62778. * @param earcutInjection can be used to inject your own earcut reference
  62779. * @returns the polygon mesh
  62780. */
  62781. static CreatePolygon(name: string, options: {
  62782. shape: Vector3[];
  62783. holes?: Vector3[][];
  62784. depth?: number;
  62785. faceUV?: Vector4[];
  62786. faceColors?: Color4[];
  62787. updatable?: boolean;
  62788. sideOrientation?: number;
  62789. frontUVs?: Vector4;
  62790. backUVs?: Vector4;
  62791. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62792. /**
  62793. * Creates an extruded polygon mesh, with depth in the Y direction.
  62794. * * 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)
  62795. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62796. * @param name defines the name of the mesh
  62797. * @param options defines the options used to create the mesh
  62798. * @param scene defines the hosting scene
  62799. * @param earcutInjection can be used to inject your own earcut reference
  62800. * @returns the polygon mesh
  62801. */
  62802. static ExtrudePolygon(name: string, options: {
  62803. shape: Vector3[];
  62804. holes?: Vector3[][];
  62805. depth?: number;
  62806. faceUV?: Vector4[];
  62807. faceColors?: Color4[];
  62808. updatable?: boolean;
  62809. sideOrientation?: number;
  62810. frontUVs?: Vector4;
  62811. backUVs?: Vector4;
  62812. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62813. /**
  62814. * Creates a tube mesh.
  62815. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62816. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62817. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62818. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62819. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62820. * * 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)
  62821. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62822. * * 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
  62823. * * 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
  62824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62826. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62828. * @param name defines the name of the mesh
  62829. * @param options defines the options used to create the mesh
  62830. * @param scene defines the hosting scene
  62831. * @returns the tube mesh
  62832. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62833. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62834. */
  62835. static CreateTube(name: string, options: {
  62836. path: Vector3[];
  62837. radius?: number;
  62838. tessellation?: number;
  62839. radiusFunction?: {
  62840. (i: number, distance: number): number;
  62841. };
  62842. cap?: number;
  62843. arc?: number;
  62844. updatable?: boolean;
  62845. sideOrientation?: number;
  62846. frontUVs?: Vector4;
  62847. backUVs?: Vector4;
  62848. instance?: Mesh;
  62849. invertUV?: boolean;
  62850. }, scene?: Nullable<Scene>): Mesh;
  62851. /**
  62852. * Creates a polyhedron mesh
  62853. * * 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
  62854. * * The parameter `size` (positive float, default 1) sets the polygon size
  62855. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62856. * * 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`
  62857. * * 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
  62858. * * 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)`)
  62859. * * 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
  62860. * * 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
  62861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62864. * @param name defines the name of the mesh
  62865. * @param options defines the options used to create the mesh
  62866. * @param scene defines the hosting scene
  62867. * @returns the polyhedron mesh
  62868. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62869. */
  62870. static CreatePolyhedron(name: string, options: {
  62871. type?: number;
  62872. size?: number;
  62873. sizeX?: number;
  62874. sizeY?: number;
  62875. sizeZ?: number;
  62876. custom?: any;
  62877. faceUV?: Vector4[];
  62878. faceColors?: Color4[];
  62879. flat?: boolean;
  62880. updatable?: boolean;
  62881. sideOrientation?: number;
  62882. frontUVs?: Vector4;
  62883. backUVs?: Vector4;
  62884. }, scene?: Nullable<Scene>): Mesh;
  62885. /**
  62886. * Creates a decal mesh.
  62887. * 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
  62888. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62889. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62890. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62891. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62892. * @param name defines the name of the mesh
  62893. * @param sourceMesh defines the mesh where the decal must be applied
  62894. * @param options defines the options used to create the mesh
  62895. * @param scene defines the hosting scene
  62896. * @returns the decal mesh
  62897. * @see https://doc.babylonjs.com/how_to/decals
  62898. */
  62899. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62900. position?: Vector3;
  62901. normal?: Vector3;
  62902. size?: Vector3;
  62903. angle?: number;
  62904. }): Mesh;
  62905. }
  62906. }
  62907. declare module "babylonjs/Meshes/meshSimplification" {
  62908. import { Mesh } from "babylonjs/Meshes/mesh";
  62909. /**
  62910. * A simplifier interface for future simplification implementations
  62911. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62912. */
  62913. export interface ISimplifier {
  62914. /**
  62915. * Simplification of a given mesh according to the given settings.
  62916. * Since this requires computation, it is assumed that the function runs async.
  62917. * @param settings The settings of the simplification, including quality and distance
  62918. * @param successCallback A callback that will be called after the mesh was simplified.
  62919. * @param errorCallback in case of an error, this callback will be called. optional.
  62920. */
  62921. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62922. }
  62923. /**
  62924. * Expected simplification settings.
  62925. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62926. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62927. */
  62928. export interface ISimplificationSettings {
  62929. /**
  62930. * Gets or sets the expected quality
  62931. */
  62932. quality: number;
  62933. /**
  62934. * Gets or sets the distance when this optimized version should be used
  62935. */
  62936. distance: number;
  62937. /**
  62938. * Gets an already optimized mesh
  62939. */
  62940. optimizeMesh?: boolean;
  62941. }
  62942. /**
  62943. * Class used to specify simplification options
  62944. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62945. */
  62946. export class SimplificationSettings implements ISimplificationSettings {
  62947. /** expected quality */
  62948. quality: number;
  62949. /** distance when this optimized version should be used */
  62950. distance: number;
  62951. /** already optimized mesh */
  62952. optimizeMesh?: boolean | undefined;
  62953. /**
  62954. * Creates a SimplificationSettings
  62955. * @param quality expected quality
  62956. * @param distance distance when this optimized version should be used
  62957. * @param optimizeMesh already optimized mesh
  62958. */
  62959. constructor(
  62960. /** expected quality */
  62961. quality: number,
  62962. /** distance when this optimized version should be used */
  62963. distance: number,
  62964. /** already optimized mesh */
  62965. optimizeMesh?: boolean | undefined);
  62966. }
  62967. /**
  62968. * Interface used to define a simplification task
  62969. */
  62970. export interface ISimplificationTask {
  62971. /**
  62972. * Array of settings
  62973. */
  62974. settings: Array<ISimplificationSettings>;
  62975. /**
  62976. * Simplification type
  62977. */
  62978. simplificationType: SimplificationType;
  62979. /**
  62980. * Mesh to simplify
  62981. */
  62982. mesh: Mesh;
  62983. /**
  62984. * Callback called on success
  62985. */
  62986. successCallback?: () => void;
  62987. /**
  62988. * Defines if parallel processing can be used
  62989. */
  62990. parallelProcessing: boolean;
  62991. }
  62992. /**
  62993. * Queue used to order the simplification tasks
  62994. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62995. */
  62996. export class SimplificationQueue {
  62997. private _simplificationArray;
  62998. /**
  62999. * Gets a boolean indicating that the process is still running
  63000. */
  63001. running: boolean;
  63002. /**
  63003. * Creates a new queue
  63004. */
  63005. constructor();
  63006. /**
  63007. * Adds a new simplification task
  63008. * @param task defines a task to add
  63009. */
  63010. addTask(task: ISimplificationTask): void;
  63011. /**
  63012. * Execute next task
  63013. */
  63014. executeNext(): void;
  63015. /**
  63016. * Execute a simplification task
  63017. * @param task defines the task to run
  63018. */
  63019. runSimplification(task: ISimplificationTask): void;
  63020. private getSimplifier;
  63021. }
  63022. /**
  63023. * The implemented types of simplification
  63024. * At the moment only Quadratic Error Decimation is implemented
  63025. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63026. */
  63027. export enum SimplificationType {
  63028. /** Quadratic error decimation */
  63029. QUADRATIC = 0
  63030. }
  63031. }
  63032. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63033. import { Scene } from "babylonjs/scene";
  63034. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63035. import { ISceneComponent } from "babylonjs/sceneComponent";
  63036. module "babylonjs/scene" {
  63037. interface Scene {
  63038. /** @hidden (Backing field) */
  63039. _simplificationQueue: SimplificationQueue;
  63040. /**
  63041. * Gets or sets the simplification queue attached to the scene
  63042. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63043. */
  63044. simplificationQueue: SimplificationQueue;
  63045. }
  63046. }
  63047. module "babylonjs/Meshes/mesh" {
  63048. interface Mesh {
  63049. /**
  63050. * Simplify the mesh according to the given array of settings.
  63051. * Function will return immediately and will simplify async
  63052. * @param settings a collection of simplification settings
  63053. * @param parallelProcessing should all levels calculate parallel or one after the other
  63054. * @param simplificationType the type of simplification to run
  63055. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63056. * @returns the current mesh
  63057. */
  63058. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63059. }
  63060. }
  63061. /**
  63062. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63063. * created in a scene
  63064. */
  63065. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63066. /**
  63067. * The component name helpfull to identify the component in the list of scene components.
  63068. */
  63069. readonly name: string;
  63070. /**
  63071. * The scene the component belongs to.
  63072. */
  63073. scene: Scene;
  63074. /**
  63075. * Creates a new instance of the component for the given scene
  63076. * @param scene Defines the scene to register the component in
  63077. */
  63078. constructor(scene: Scene);
  63079. /**
  63080. * Registers the component in a given scene
  63081. */
  63082. register(): void;
  63083. /**
  63084. * Rebuilds the elements related to this component in case of
  63085. * context lost for instance.
  63086. */
  63087. rebuild(): void;
  63088. /**
  63089. * Disposes the component and the associated ressources
  63090. */
  63091. dispose(): void;
  63092. private _beforeCameraUpdate;
  63093. }
  63094. }
  63095. declare module "babylonjs/Meshes/Builders/index" {
  63096. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63097. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63098. export * from "babylonjs/Meshes/Builders/discBuilder";
  63099. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63100. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63101. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63102. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63103. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63104. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63105. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63106. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63107. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63108. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63109. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63110. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63111. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63112. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63113. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63114. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63115. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63116. }
  63117. declare module "babylonjs/Meshes/index" {
  63118. export * from "babylonjs/Meshes/abstractMesh";
  63119. export * from "babylonjs/Meshes/buffer";
  63120. export * from "babylonjs/Meshes/Compression/index";
  63121. export * from "babylonjs/Meshes/csg";
  63122. export * from "babylonjs/Meshes/geometry";
  63123. export * from "babylonjs/Meshes/groundMesh";
  63124. export * from "babylonjs/Meshes/trailMesh";
  63125. export * from "babylonjs/Meshes/instancedMesh";
  63126. export * from "babylonjs/Meshes/linesMesh";
  63127. export * from "babylonjs/Meshes/mesh";
  63128. export * from "babylonjs/Meshes/mesh.vertexData";
  63129. export * from "babylonjs/Meshes/meshBuilder";
  63130. export * from "babylonjs/Meshes/meshSimplification";
  63131. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63132. export * from "babylonjs/Meshes/polygonMesh";
  63133. export * from "babylonjs/Meshes/subMesh";
  63134. export * from "babylonjs/Meshes/meshLODLevel";
  63135. export * from "babylonjs/Meshes/transformNode";
  63136. export * from "babylonjs/Meshes/Builders/index";
  63137. export * from "babylonjs/Meshes/dataBuffer";
  63138. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63139. }
  63140. declare module "babylonjs/Morph/index" {
  63141. export * from "babylonjs/Morph/morphTarget";
  63142. export * from "babylonjs/Morph/morphTargetManager";
  63143. }
  63144. declare module "babylonjs/Navigation/INavigationEngine" {
  63145. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63146. import { Vector3 } from "babylonjs/Maths/math";
  63147. import { Mesh } from "babylonjs/Meshes/mesh";
  63148. import { Scene } from "babylonjs/scene";
  63149. /**
  63150. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63151. */
  63152. export interface INavigationEnginePlugin {
  63153. /**
  63154. * plugin name
  63155. */
  63156. name: string;
  63157. /**
  63158. * Creates a navigation mesh
  63159. * @param meshes array of all the geometry used to compute the navigatio mesh
  63160. * @param parameters bunch of parameters used to filter geometry
  63161. */
  63162. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63163. /**
  63164. * Create a navigation mesh debug mesh
  63165. * @param scene is where the mesh will be added
  63166. * @returns debug display mesh
  63167. */
  63168. createDebugNavMesh(scene: Scene): Mesh;
  63169. /**
  63170. * Get a navigation mesh constrained position, closest to the parameter position
  63171. * @param position world position
  63172. * @returns the closest point to position constrained by the navigation mesh
  63173. */
  63174. getClosestPoint(position: Vector3): Vector3;
  63175. /**
  63176. * Get a navigation mesh constrained position, within a particular radius
  63177. * @param position world position
  63178. * @param maxRadius the maximum distance to the constrained world position
  63179. * @returns the closest point to position constrained by the navigation mesh
  63180. */
  63181. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63182. /**
  63183. * Compute the final position from a segment made of destination-position
  63184. * @param position world position
  63185. * @param destination world position
  63186. * @returns the resulting point along the navmesh
  63187. */
  63188. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63189. /**
  63190. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63191. * @param start world position
  63192. * @param end world position
  63193. * @returns array containing world position composing the path
  63194. */
  63195. computePath(start: Vector3, end: Vector3): Vector3[];
  63196. /**
  63197. * If this plugin is supported
  63198. * @returns true if plugin is supported
  63199. */
  63200. isSupported(): boolean;
  63201. /**
  63202. * Create a new Crowd so you can add agents
  63203. * @param maxAgents the maximum agent count in the crowd
  63204. * @param maxAgentRadius the maximum radius an agent can have
  63205. * @param scene to attach the crowd to
  63206. * @returns the crowd you can add agents to
  63207. */
  63208. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63209. /**
  63210. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63211. * The queries will try to find a solution within those bounds
  63212. * default is (1,1,1)
  63213. * @param extent x,y,z value that define the extent around the queries point of reference
  63214. */
  63215. setDefaultQueryExtent(extent: Vector3): void;
  63216. /**
  63217. * Get the Bounding box extent specified by setDefaultQueryExtent
  63218. * @returns the box extent values
  63219. */
  63220. getDefaultQueryExtent(): Vector3;
  63221. /**
  63222. * Release all resources
  63223. */
  63224. dispose(): void;
  63225. }
  63226. /**
  63227. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  63228. */
  63229. export interface ICrowd {
  63230. /**
  63231. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63232. * You can attach anything to that node. The node position is updated in the scene update tick.
  63233. * @param pos world position that will be constrained by the navigation mesh
  63234. * @param parameters agent parameters
  63235. * @param transform hooked to the agent that will be update by the scene
  63236. * @returns agent index
  63237. */
  63238. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63239. /**
  63240. * Returns the agent position in world space
  63241. * @param index agent index returned by addAgent
  63242. * @returns world space position
  63243. */
  63244. getAgentPosition(index: number): Vector3;
  63245. /**
  63246. * Gets the agent velocity in world space
  63247. * @param index agent index returned by addAgent
  63248. * @returns world space velocity
  63249. */
  63250. getAgentVelocity(index: number): Vector3;
  63251. /**
  63252. * remove a particular agent previously created
  63253. * @param index agent index returned by addAgent
  63254. */
  63255. removeAgent(index: number): void;
  63256. /**
  63257. * get the list of all agents attached to this crowd
  63258. * @returns list of agent indices
  63259. */
  63260. getAgents(): number[];
  63261. /**
  63262. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63263. * @param deltaTime in seconds
  63264. */
  63265. update(deltaTime: number): void;
  63266. /**
  63267. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63268. * @param index agent index returned by addAgent
  63269. * @param destination targeted world position
  63270. */
  63271. agentGoto(index: number, destination: Vector3): void;
  63272. /**
  63273. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63274. * The queries will try to find a solution within those bounds
  63275. * default is (1,1,1)
  63276. * @param extent x,y,z value that define the extent around the queries point of reference
  63277. */
  63278. setDefaultQueryExtent(extent: Vector3): void;
  63279. /**
  63280. * Get the Bounding box extent specified by setDefaultQueryExtent
  63281. * @returns the box extent values
  63282. */
  63283. getDefaultQueryExtent(): Vector3;
  63284. /**
  63285. * Release all resources
  63286. */
  63287. dispose(): void;
  63288. }
  63289. /**
  63290. * Configures an agent
  63291. */
  63292. export interface IAgentParameters {
  63293. /**
  63294. * Agent radius. [Limit: >= 0]
  63295. */
  63296. radius: number;
  63297. /**
  63298. * Agent height. [Limit: > 0]
  63299. */
  63300. height: number;
  63301. /**
  63302. * Maximum allowed acceleration. [Limit: >= 0]
  63303. */
  63304. maxAcceleration: number;
  63305. /**
  63306. * Maximum allowed speed. [Limit: >= 0]
  63307. */
  63308. maxSpeed: number;
  63309. /**
  63310. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  63311. */
  63312. collisionQueryRange: number;
  63313. /**
  63314. * The path visibility optimization range. [Limit: > 0]
  63315. */
  63316. pathOptimizationRange: number;
  63317. /**
  63318. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  63319. */
  63320. separationWeight: number;
  63321. }
  63322. /**
  63323. * Configures the navigation mesh creation
  63324. */
  63325. export interface INavMeshParameters {
  63326. /**
  63327. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  63328. */
  63329. cs: number;
  63330. /**
  63331. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  63332. */
  63333. ch: number;
  63334. /**
  63335. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  63336. */
  63337. walkableSlopeAngle: number;
  63338. /**
  63339. * Minimum floor to 'ceiling' height that will still allow the floor area to
  63340. * be considered walkable. [Limit: >= 3] [Units: vx]
  63341. */
  63342. walkableHeight: number;
  63343. /**
  63344. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  63345. */
  63346. walkableClimb: number;
  63347. /**
  63348. * The distance to erode/shrink the walkable area of the heightfield away from
  63349. * obstructions. [Limit: >=0] [Units: vx]
  63350. */
  63351. walkableRadius: number;
  63352. /**
  63353. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  63354. */
  63355. maxEdgeLen: number;
  63356. /**
  63357. * The maximum distance a simplfied contour's border edges should deviate
  63358. * the original raw contour. [Limit: >=0] [Units: vx]
  63359. */
  63360. maxSimplificationError: number;
  63361. /**
  63362. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  63363. */
  63364. minRegionArea: number;
  63365. /**
  63366. * Any regions with a span count smaller than this value will, if possible,
  63367. * be merged with larger regions. [Limit: >=0] [Units: vx]
  63368. */
  63369. mergeRegionArea: number;
  63370. /**
  63371. * The maximum number of vertices allowed for polygons generated during the
  63372. * contour to polygon conversion process. [Limit: >= 3]
  63373. */
  63374. maxVertsPerPoly: number;
  63375. /**
  63376. * Sets the sampling distance to use when generating the detail mesh.
  63377. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  63378. */
  63379. detailSampleDist: number;
  63380. /**
  63381. * The maximum distance the detail mesh surface should deviate from heightfield
  63382. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  63383. */
  63384. detailSampleMaxError: number;
  63385. }
  63386. }
  63387. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  63388. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  63389. import { Mesh } from "babylonjs/Meshes/mesh";
  63390. import { Scene } from "babylonjs/scene";
  63391. import { Vector3 } from "babylonjs/Maths/math";
  63392. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63393. /**
  63394. * RecastJS navigation plugin
  63395. */
  63396. export class RecastJSPlugin implements INavigationEnginePlugin {
  63397. /**
  63398. * Reference to the Recast library
  63399. */
  63400. bjsRECAST: any;
  63401. /**
  63402. * plugin name
  63403. */
  63404. name: string;
  63405. /**
  63406. * the first navmesh created. We might extend this to support multiple navmeshes
  63407. */
  63408. navMesh: any;
  63409. /**
  63410. * Initializes the recastJS plugin
  63411. * @param recastInjection can be used to inject your own recast reference
  63412. */
  63413. constructor(recastInjection?: any);
  63414. /**
  63415. * Creates a navigation mesh
  63416. * @param meshes array of all the geometry used to compute the navigatio mesh
  63417. * @param parameters bunch of parameters used to filter geometry
  63418. */
  63419. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63420. /**
  63421. * Create a navigation mesh debug mesh
  63422. * @param scene is where the mesh will be added
  63423. * @returns debug display mesh
  63424. */
  63425. createDebugNavMesh(scene: Scene): Mesh;
  63426. /**
  63427. * Get a navigation mesh constrained position, closest to the parameter position
  63428. * @param position world position
  63429. * @returns the closest point to position constrained by the navigation mesh
  63430. */
  63431. getClosestPoint(position: Vector3): Vector3;
  63432. /**
  63433. * Get a navigation mesh constrained position, within a particular radius
  63434. * @param position world position
  63435. * @param maxRadius the maximum distance to the constrained world position
  63436. * @returns the closest point to position constrained by the navigation mesh
  63437. */
  63438. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63439. /**
  63440. * Compute the final position from a segment made of destination-position
  63441. * @param position world position
  63442. * @param destination world position
  63443. * @returns the resulting point along the navmesh
  63444. */
  63445. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63446. /**
  63447. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63448. * @param start world position
  63449. * @param end world position
  63450. * @returns array containing world position composing the path
  63451. */
  63452. computePath(start: Vector3, end: Vector3): Vector3[];
  63453. /**
  63454. * Create a new Crowd so you can add agents
  63455. * @param maxAgents the maximum agent count in the crowd
  63456. * @param maxAgentRadius the maximum radius an agent can have
  63457. * @param scene to attach the crowd to
  63458. * @returns the crowd you can add agents to
  63459. */
  63460. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63461. /**
  63462. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63463. * The queries will try to find a solution within those bounds
  63464. * default is (1,1,1)
  63465. * @param extent x,y,z value that define the extent around the queries point of reference
  63466. */
  63467. setDefaultQueryExtent(extent: Vector3): void;
  63468. /**
  63469. * Get the Bounding box extent specified by setDefaultQueryExtent
  63470. * @returns the box extent values
  63471. */
  63472. getDefaultQueryExtent(): Vector3;
  63473. /**
  63474. * Disposes
  63475. */
  63476. dispose(): void;
  63477. /**
  63478. * If this plugin is supported
  63479. * @returns true if plugin is supported
  63480. */
  63481. isSupported(): boolean;
  63482. }
  63483. /**
  63484. * Recast detour crowd implementation
  63485. */
  63486. export class RecastJSCrowd implements ICrowd {
  63487. /**
  63488. * Recast/detour plugin
  63489. */
  63490. bjsRECASTPlugin: RecastJSPlugin;
  63491. /**
  63492. * Link to the detour crowd
  63493. */
  63494. recastCrowd: any;
  63495. /**
  63496. * One transform per agent
  63497. */
  63498. transforms: TransformNode[];
  63499. /**
  63500. * All agents created
  63501. */
  63502. agents: number[];
  63503. /**
  63504. * Link to the scene is kept to unregister the crowd from the scene
  63505. */
  63506. private _scene;
  63507. /**
  63508. * Observer for crowd updates
  63509. */
  63510. private _onBeforeAnimationsObserver;
  63511. /**
  63512. * Constructor
  63513. * @param plugin recastJS plugin
  63514. * @param maxAgents the maximum agent count in the crowd
  63515. * @param maxAgentRadius the maximum radius an agent can have
  63516. * @param scene to attach the crowd to
  63517. * @returns the crowd you can add agents to
  63518. */
  63519. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63520. /**
  63521. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63522. * You can attach anything to that node. The node position is updated in the scene update tick.
  63523. * @param pos world position that will be constrained by the navigation mesh
  63524. * @param parameters agent parameters
  63525. * @param transform hooked to the agent that will be update by the scene
  63526. * @returns agent index
  63527. */
  63528. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63529. /**
  63530. * Returns the agent position in world space
  63531. * @param index agent index returned by addAgent
  63532. * @returns world space position
  63533. */
  63534. getAgentPosition(index: number): Vector3;
  63535. /**
  63536. * Returns the agent velocity in world space
  63537. * @param index agent index returned by addAgent
  63538. * @returns world space velocity
  63539. */
  63540. getAgentVelocity(index: number): Vector3;
  63541. /**
  63542. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63543. * @param index agent index returned by addAgent
  63544. * @param destination targeted world position
  63545. */
  63546. agentGoto(index: number, destination: Vector3): void;
  63547. /**
  63548. * remove a particular agent previously created
  63549. * @param index agent index returned by addAgent
  63550. */
  63551. removeAgent(index: number): void;
  63552. /**
  63553. * get the list of all agents attached to this crowd
  63554. * @returns list of agent indices
  63555. */
  63556. getAgents(): number[];
  63557. /**
  63558. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63559. * @param deltaTime in seconds
  63560. */
  63561. update(deltaTime: number): void;
  63562. /**
  63563. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63564. * The queries will try to find a solution within those bounds
  63565. * default is (1,1,1)
  63566. * @param extent x,y,z value that define the extent around the queries point of reference
  63567. */
  63568. setDefaultQueryExtent(extent: Vector3): void;
  63569. /**
  63570. * Get the Bounding box extent specified by setDefaultQueryExtent
  63571. * @returns the box extent values
  63572. */
  63573. getDefaultQueryExtent(): Vector3;
  63574. /**
  63575. * Release all resources
  63576. */
  63577. dispose(): void;
  63578. }
  63579. }
  63580. declare module "babylonjs/Navigation/Plugins/index" {
  63581. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  63582. }
  63583. declare module "babylonjs/Navigation/index" {
  63584. export * from "babylonjs/Navigation/INavigationEngine";
  63585. export * from "babylonjs/Navigation/Plugins/index";
  63586. }
  63587. declare module "babylonjs/Offline/database" {
  63588. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  63589. /**
  63590. * Class used to enable access to IndexedDB
  63591. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63592. */
  63593. export class Database implements IOfflineProvider {
  63594. private _callbackManifestChecked;
  63595. private _currentSceneUrl;
  63596. private _db;
  63597. private _enableSceneOffline;
  63598. private _enableTexturesOffline;
  63599. private _manifestVersionFound;
  63600. private _mustUpdateRessources;
  63601. private _hasReachedQuota;
  63602. private _isSupported;
  63603. private _idbFactory;
  63604. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63605. private static IsUASupportingBlobStorage;
  63606. /**
  63607. * Gets a boolean indicating if Database storate is enabled (off by default)
  63608. */
  63609. static IDBStorageEnabled: boolean;
  63610. /**
  63611. * Gets a boolean indicating if scene must be saved in the database
  63612. */
  63613. get enableSceneOffline(): boolean;
  63614. /**
  63615. * Gets a boolean indicating if textures must be saved in the database
  63616. */
  63617. get enableTexturesOffline(): boolean;
  63618. /**
  63619. * Creates a new Database
  63620. * @param urlToScene defines the url to load the scene
  63621. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63622. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63623. */
  63624. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63625. private static _ParseURL;
  63626. private static _ReturnFullUrlLocation;
  63627. private _checkManifestFile;
  63628. /**
  63629. * Open the database and make it available
  63630. * @param successCallback defines the callback to call on success
  63631. * @param errorCallback defines the callback to call on error
  63632. */
  63633. open(successCallback: () => void, errorCallback: () => void): void;
  63634. /**
  63635. * Loads an image from the database
  63636. * @param url defines the url to load from
  63637. * @param image defines the target DOM image
  63638. */
  63639. loadImage(url: string, image: HTMLImageElement): void;
  63640. private _loadImageFromDBAsync;
  63641. private _saveImageIntoDBAsync;
  63642. private _checkVersionFromDB;
  63643. private _loadVersionFromDBAsync;
  63644. private _saveVersionIntoDBAsync;
  63645. /**
  63646. * Loads a file from database
  63647. * @param url defines the URL to load from
  63648. * @param sceneLoaded defines a callback to call on success
  63649. * @param progressCallBack defines a callback to call when progress changed
  63650. * @param errorCallback defines a callback to call on error
  63651. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63652. */
  63653. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63654. private _loadFileAsync;
  63655. private _saveFileAsync;
  63656. /**
  63657. * Validates if xhr data is correct
  63658. * @param xhr defines the request to validate
  63659. * @param dataType defines the expected data type
  63660. * @returns true if data is correct
  63661. */
  63662. private static _ValidateXHRData;
  63663. }
  63664. }
  63665. declare module "babylonjs/Offline/index" {
  63666. export * from "babylonjs/Offline/database";
  63667. export * from "babylonjs/Offline/IOfflineProvider";
  63668. }
  63669. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  63670. /** @hidden */
  63671. export var gpuUpdateParticlesPixelShader: {
  63672. name: string;
  63673. shader: string;
  63674. };
  63675. }
  63676. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  63677. /** @hidden */
  63678. export var gpuUpdateParticlesVertexShader: {
  63679. name: string;
  63680. shader: string;
  63681. };
  63682. }
  63683. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  63684. /** @hidden */
  63685. export var clipPlaneFragmentDeclaration2: {
  63686. name: string;
  63687. shader: string;
  63688. };
  63689. }
  63690. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  63691. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  63692. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63693. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63694. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63695. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63696. /** @hidden */
  63697. export var gpuRenderParticlesPixelShader: {
  63698. name: string;
  63699. shader: string;
  63700. };
  63701. }
  63702. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  63703. /** @hidden */
  63704. export var clipPlaneVertexDeclaration2: {
  63705. name: string;
  63706. shader: string;
  63707. };
  63708. }
  63709. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  63710. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  63711. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63712. /** @hidden */
  63713. export var gpuRenderParticlesVertexShader: {
  63714. name: string;
  63715. shader: string;
  63716. };
  63717. }
  63718. declare module "babylonjs/Particles/gpuParticleSystem" {
  63719. import { Nullable } from "babylonjs/types";
  63720. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  63721. import { Observable } from "babylonjs/Misc/observable";
  63722. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63723. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63724. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  63725. import { Scene, IDisposable } from "babylonjs/scene";
  63726. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  63727. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63728. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  63729. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  63730. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  63731. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  63732. /**
  63733. * This represents a GPU particle system in Babylon
  63734. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63735. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63736. */
  63737. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63738. /**
  63739. * The layer mask we are rendering the particles through.
  63740. */
  63741. layerMask: number;
  63742. private _capacity;
  63743. private _activeCount;
  63744. private _currentActiveCount;
  63745. private _accumulatedCount;
  63746. private _renderEffect;
  63747. private _updateEffect;
  63748. private _buffer0;
  63749. private _buffer1;
  63750. private _spriteBuffer;
  63751. private _updateVAO;
  63752. private _renderVAO;
  63753. private _targetIndex;
  63754. private _sourceBuffer;
  63755. private _targetBuffer;
  63756. private _engine;
  63757. private _currentRenderId;
  63758. private _started;
  63759. private _stopped;
  63760. private _timeDelta;
  63761. private _randomTexture;
  63762. private _randomTexture2;
  63763. private _attributesStrideSize;
  63764. private _updateEffectOptions;
  63765. private _randomTextureSize;
  63766. private _actualFrame;
  63767. private readonly _rawTextureWidth;
  63768. /**
  63769. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63770. */
  63771. static get IsSupported(): boolean;
  63772. /**
  63773. * An event triggered when the system is disposed.
  63774. */
  63775. onDisposeObservable: Observable<GPUParticleSystem>;
  63776. /**
  63777. * Gets the maximum number of particles active at the same time.
  63778. * @returns The max number of active particles.
  63779. */
  63780. getCapacity(): number;
  63781. /**
  63782. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63783. * to override the particles.
  63784. */
  63785. forceDepthWrite: boolean;
  63786. /**
  63787. * Gets or set the number of active particles
  63788. */
  63789. get activeParticleCount(): number;
  63790. set activeParticleCount(value: number);
  63791. private _preWarmDone;
  63792. /**
  63793. * Is this system ready to be used/rendered
  63794. * @return true if the system is ready
  63795. */
  63796. isReady(): boolean;
  63797. /**
  63798. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63799. * @returns True if it has been started, otherwise false.
  63800. */
  63801. isStarted(): boolean;
  63802. /**
  63803. * Starts the particle system and begins to emit
  63804. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63805. */
  63806. start(delay?: number): void;
  63807. /**
  63808. * Stops the particle system.
  63809. */
  63810. stop(): void;
  63811. /**
  63812. * Remove all active particles
  63813. */
  63814. reset(): void;
  63815. /**
  63816. * Returns the string "GPUParticleSystem"
  63817. * @returns a string containing the class name
  63818. */
  63819. getClassName(): string;
  63820. private _colorGradientsTexture;
  63821. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63822. /**
  63823. * Adds a new color gradient
  63824. * @param gradient defines the gradient to use (between 0 and 1)
  63825. * @param color1 defines the color to affect to the specified gradient
  63826. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63827. * @returns the current particle system
  63828. */
  63829. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63830. /**
  63831. * Remove a specific color gradient
  63832. * @param gradient defines the gradient to remove
  63833. * @returns the current particle system
  63834. */
  63835. removeColorGradient(gradient: number): GPUParticleSystem;
  63836. private _angularSpeedGradientsTexture;
  63837. private _sizeGradientsTexture;
  63838. private _velocityGradientsTexture;
  63839. private _limitVelocityGradientsTexture;
  63840. private _dragGradientsTexture;
  63841. private _addFactorGradient;
  63842. /**
  63843. * Adds a new size gradient
  63844. * @param gradient defines the gradient to use (between 0 and 1)
  63845. * @param factor defines the size factor to affect to the specified gradient
  63846. * @returns the current particle system
  63847. */
  63848. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63849. /**
  63850. * Remove a specific size gradient
  63851. * @param gradient defines the gradient to remove
  63852. * @returns the current particle system
  63853. */
  63854. removeSizeGradient(gradient: number): GPUParticleSystem;
  63855. /**
  63856. * Adds a new angular speed gradient
  63857. * @param gradient defines the gradient to use (between 0 and 1)
  63858. * @param factor defines the angular speed to affect to the specified gradient
  63859. * @returns the current particle system
  63860. */
  63861. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63862. /**
  63863. * Remove a specific angular speed gradient
  63864. * @param gradient defines the gradient to remove
  63865. * @returns the current particle system
  63866. */
  63867. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63868. /**
  63869. * Adds a new velocity gradient
  63870. * @param gradient defines the gradient to use (between 0 and 1)
  63871. * @param factor defines the velocity to affect to the specified gradient
  63872. * @returns the current particle system
  63873. */
  63874. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63875. /**
  63876. * Remove a specific velocity gradient
  63877. * @param gradient defines the gradient to remove
  63878. * @returns the current particle system
  63879. */
  63880. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63881. /**
  63882. * Adds a new limit velocity gradient
  63883. * @param gradient defines the gradient to use (between 0 and 1)
  63884. * @param factor defines the limit velocity value to affect to the specified gradient
  63885. * @returns the current particle system
  63886. */
  63887. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63888. /**
  63889. * Remove a specific limit velocity gradient
  63890. * @param gradient defines the gradient to remove
  63891. * @returns the current particle system
  63892. */
  63893. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63894. /**
  63895. * Adds a new drag gradient
  63896. * @param gradient defines the gradient to use (between 0 and 1)
  63897. * @param factor defines the drag value to affect to the specified gradient
  63898. * @returns the current particle system
  63899. */
  63900. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63901. /**
  63902. * Remove a specific drag gradient
  63903. * @param gradient defines the gradient to remove
  63904. * @returns the current particle system
  63905. */
  63906. removeDragGradient(gradient: number): GPUParticleSystem;
  63907. /**
  63908. * Not supported by GPUParticleSystem
  63909. * @param gradient defines the gradient to use (between 0 and 1)
  63910. * @param factor defines the emit rate value to affect to the specified gradient
  63911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63912. * @returns the current particle system
  63913. */
  63914. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63915. /**
  63916. * Not supported by GPUParticleSystem
  63917. * @param gradient defines the gradient to remove
  63918. * @returns the current particle system
  63919. */
  63920. removeEmitRateGradient(gradient: number): IParticleSystem;
  63921. /**
  63922. * Not supported by GPUParticleSystem
  63923. * @param gradient defines the gradient to use (between 0 and 1)
  63924. * @param factor defines the start size value to affect to the specified gradient
  63925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63926. * @returns the current particle system
  63927. */
  63928. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63929. /**
  63930. * Not supported by GPUParticleSystem
  63931. * @param gradient defines the gradient to remove
  63932. * @returns the current particle system
  63933. */
  63934. removeStartSizeGradient(gradient: number): IParticleSystem;
  63935. /**
  63936. * Not supported by GPUParticleSystem
  63937. * @param gradient defines the gradient to use (between 0 and 1)
  63938. * @param min defines the color remap minimal range
  63939. * @param max defines the color remap maximal range
  63940. * @returns the current particle system
  63941. */
  63942. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63943. /**
  63944. * Not supported by GPUParticleSystem
  63945. * @param gradient defines the gradient to remove
  63946. * @returns the current particle system
  63947. */
  63948. removeColorRemapGradient(): IParticleSystem;
  63949. /**
  63950. * Not supported by GPUParticleSystem
  63951. * @param gradient defines the gradient to use (between 0 and 1)
  63952. * @param min defines the alpha remap minimal range
  63953. * @param max defines the alpha remap maximal range
  63954. * @returns the current particle system
  63955. */
  63956. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63957. /**
  63958. * Not supported by GPUParticleSystem
  63959. * @param gradient defines the gradient to remove
  63960. * @returns the current particle system
  63961. */
  63962. removeAlphaRemapGradient(): IParticleSystem;
  63963. /**
  63964. * Not supported by GPUParticleSystem
  63965. * @param gradient defines the gradient to use (between 0 and 1)
  63966. * @param color defines the color to affect to the specified gradient
  63967. * @returns the current particle system
  63968. */
  63969. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63970. /**
  63971. * Not supported by GPUParticleSystem
  63972. * @param gradient defines the gradient to remove
  63973. * @returns the current particle system
  63974. */
  63975. removeRampGradient(): IParticleSystem;
  63976. /**
  63977. * Not supported by GPUParticleSystem
  63978. * @returns the list of ramp gradients
  63979. */
  63980. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63981. /**
  63982. * Not supported by GPUParticleSystem
  63983. * Gets or sets a boolean indicating that ramp gradients must be used
  63984. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63985. */
  63986. get useRampGradients(): boolean;
  63987. set useRampGradients(value: boolean);
  63988. /**
  63989. * Not supported by GPUParticleSystem
  63990. * @param gradient defines the gradient to use (between 0 and 1)
  63991. * @param factor defines the life time factor to affect to the specified gradient
  63992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63993. * @returns the current particle system
  63994. */
  63995. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63996. /**
  63997. * Not supported by GPUParticleSystem
  63998. * @param gradient defines the gradient to remove
  63999. * @returns the current particle system
  64000. */
  64001. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64002. /**
  64003. * Instantiates a GPU particle system.
  64004. * 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.
  64005. * @param name The name of the particle system
  64006. * @param options The options used to create the system
  64007. * @param scene The scene the particle system belongs to
  64008. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64009. */
  64010. constructor(name: string, options: Partial<{
  64011. capacity: number;
  64012. randomTextureSize: number;
  64013. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64014. protected _reset(): void;
  64015. private _createUpdateVAO;
  64016. private _createRenderVAO;
  64017. private _initialize;
  64018. /** @hidden */
  64019. _recreateUpdateEffect(): void;
  64020. /** @hidden */
  64021. _recreateRenderEffect(): void;
  64022. /**
  64023. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64024. * @param preWarm defines if we are in the pre-warmimg phase
  64025. */
  64026. animate(preWarm?: boolean): void;
  64027. private _createFactorGradientTexture;
  64028. private _createSizeGradientTexture;
  64029. private _createAngularSpeedGradientTexture;
  64030. private _createVelocityGradientTexture;
  64031. private _createLimitVelocityGradientTexture;
  64032. private _createDragGradientTexture;
  64033. private _createColorGradientTexture;
  64034. /**
  64035. * Renders the particle system in its current state
  64036. * @param preWarm defines if the system should only update the particles but not render them
  64037. * @returns the current number of particles
  64038. */
  64039. render(preWarm?: boolean): number;
  64040. /**
  64041. * Rebuilds the particle system
  64042. */
  64043. rebuild(): void;
  64044. private _releaseBuffers;
  64045. private _releaseVAOs;
  64046. /**
  64047. * Disposes the particle system and free the associated resources
  64048. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64049. */
  64050. dispose(disposeTexture?: boolean): void;
  64051. /**
  64052. * Clones the particle system.
  64053. * @param name The name of the cloned object
  64054. * @param newEmitter The new emitter to use
  64055. * @returns the cloned particle system
  64056. */
  64057. clone(name: string, newEmitter: any): GPUParticleSystem;
  64058. /**
  64059. * Serializes the particle system to a JSON object.
  64060. * @returns the JSON object
  64061. */
  64062. serialize(): any;
  64063. /**
  64064. * Parses a JSON object to create a GPU particle system.
  64065. * @param parsedParticleSystem The JSON object to parse
  64066. * @param scene The scene to create the particle system in
  64067. * @param rootUrl The root url to use to load external dependencies like texture
  64068. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64069. * @returns the parsed GPU particle system
  64070. */
  64071. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64072. }
  64073. }
  64074. declare module "babylonjs/Particles/particleSystemSet" {
  64075. import { Nullable } from "babylonjs/types";
  64076. import { Color3 } from "babylonjs/Maths/math.color";
  64077. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64079. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64080. import { Scene, IDisposable } from "babylonjs/scene";
  64081. /**
  64082. * Represents a set of particle systems working together to create a specific effect
  64083. */
  64084. export class ParticleSystemSet implements IDisposable {
  64085. /**
  64086. * Gets or sets base Assets URL
  64087. */
  64088. static BaseAssetsUrl: string;
  64089. private _emitterCreationOptions;
  64090. private _emitterNode;
  64091. /**
  64092. * Gets the particle system list
  64093. */
  64094. systems: IParticleSystem[];
  64095. /**
  64096. * Gets the emitter node used with this set
  64097. */
  64098. get emitterNode(): Nullable<TransformNode>;
  64099. /**
  64100. * Creates a new emitter mesh as a sphere
  64101. * @param options defines the options used to create the sphere
  64102. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64103. * @param scene defines the hosting scene
  64104. */
  64105. setEmitterAsSphere(options: {
  64106. diameter: number;
  64107. segments: number;
  64108. color: Color3;
  64109. }, renderingGroupId: number, scene: Scene): void;
  64110. /**
  64111. * Starts all particle systems of the set
  64112. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64113. */
  64114. start(emitter?: AbstractMesh): void;
  64115. /**
  64116. * Release all associated resources
  64117. */
  64118. dispose(): void;
  64119. /**
  64120. * Serialize the set into a JSON compatible object
  64121. * @returns a JSON compatible representation of the set
  64122. */
  64123. serialize(): any;
  64124. /**
  64125. * Parse a new ParticleSystemSet from a serialized source
  64126. * @param data defines a JSON compatible representation of the set
  64127. * @param scene defines the hosting scene
  64128. * @param gpu defines if we want GPU particles or CPU particles
  64129. * @returns a new ParticleSystemSet
  64130. */
  64131. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64132. }
  64133. }
  64134. declare module "babylonjs/Particles/particleHelper" {
  64135. import { Nullable } from "babylonjs/types";
  64136. import { Scene } from "babylonjs/scene";
  64137. import { Vector3 } from "babylonjs/Maths/math.vector";
  64138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64139. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64140. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64141. /**
  64142. * This class is made for on one-liner static method to help creating particle system set.
  64143. */
  64144. export class ParticleHelper {
  64145. /**
  64146. * Gets or sets base Assets URL
  64147. */
  64148. static BaseAssetsUrl: string;
  64149. /**
  64150. * Create a default particle system that you can tweak
  64151. * @param emitter defines the emitter to use
  64152. * @param capacity defines the system capacity (default is 500 particles)
  64153. * @param scene defines the hosting scene
  64154. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64155. * @returns the new Particle system
  64156. */
  64157. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64158. /**
  64159. * This is the main static method (one-liner) of this helper to create different particle systems
  64160. * @param type This string represents the type to the particle system to create
  64161. * @param scene The scene where the particle system should live
  64162. * @param gpu If the system will use gpu
  64163. * @returns the ParticleSystemSet created
  64164. */
  64165. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64166. /**
  64167. * Static function used to export a particle system to a ParticleSystemSet variable.
  64168. * Please note that the emitter shape is not exported
  64169. * @param systems defines the particle systems to export
  64170. * @returns the created particle system set
  64171. */
  64172. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64173. }
  64174. }
  64175. declare module "babylonjs/Particles/particleSystemComponent" {
  64176. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64177. import { Effect } from "babylonjs/Materials/effect";
  64178. import "babylonjs/Shaders/particles.vertex";
  64179. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64180. module "babylonjs/Engines/engine" {
  64181. interface Engine {
  64182. /**
  64183. * Create an effect to use with particle systems.
  64184. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  64185. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  64186. * @param uniformsNames defines a list of attribute names
  64187. * @param samplers defines an array of string used to represent textures
  64188. * @param defines defines the string containing the defines to use to compile the shaders
  64189. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  64190. * @param onCompiled defines a function to call when the effect creation is successful
  64191. * @param onError defines a function to call when the effect creation has failed
  64192. * @returns the new Effect
  64193. */
  64194. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  64195. }
  64196. }
  64197. module "babylonjs/Meshes/mesh" {
  64198. interface Mesh {
  64199. /**
  64200. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  64201. * @returns an array of IParticleSystem
  64202. */
  64203. getEmittedParticleSystems(): IParticleSystem[];
  64204. /**
  64205. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  64206. * @returns an array of IParticleSystem
  64207. */
  64208. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  64209. }
  64210. }
  64211. /**
  64212. * @hidden
  64213. */
  64214. export var _IDoNeedToBeInTheBuild: number;
  64215. }
  64216. declare module "babylonjs/Particles/pointsCloudSystem" {
  64217. import { Color4 } from "babylonjs/Maths/math";
  64218. import { Mesh } from "babylonjs/Meshes/mesh";
  64219. import { Scene, IDisposable } from "babylonjs/scene";
  64220. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  64221. /** Defines the 4 color options */
  64222. export enum PointColor {
  64223. /** color value */
  64224. Color = 2,
  64225. /** uv value */
  64226. UV = 1,
  64227. /** random value */
  64228. Random = 0,
  64229. /** stated value */
  64230. Stated = 3
  64231. }
  64232. /**
  64233. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  64234. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  64235. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  64236. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  64237. *
  64238. * Full documentation here : TO BE ENTERED
  64239. */
  64240. export class PointsCloudSystem implements IDisposable {
  64241. /**
  64242. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  64243. * Example : var p = SPS.particles[i];
  64244. */
  64245. particles: CloudPoint[];
  64246. /**
  64247. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  64248. */
  64249. nbParticles: number;
  64250. /**
  64251. * This a counter for your own usage. It's not set by any SPS functions.
  64252. */
  64253. counter: number;
  64254. /**
  64255. * The PCS name. This name is also given to the underlying mesh.
  64256. */
  64257. name: string;
  64258. /**
  64259. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  64260. */
  64261. mesh: Mesh;
  64262. /**
  64263. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  64264. * Please read :
  64265. */
  64266. vars: any;
  64267. /**
  64268. * @hidden
  64269. */
  64270. _size: number;
  64271. private _scene;
  64272. private _promises;
  64273. private _positions;
  64274. private _indices;
  64275. private _normals;
  64276. private _colors;
  64277. private _uvs;
  64278. private _indices32;
  64279. private _positions32;
  64280. private _colors32;
  64281. private _uvs32;
  64282. private _updatable;
  64283. private _isVisibilityBoxLocked;
  64284. private _alwaysVisible;
  64285. private _groups;
  64286. private _groupCounter;
  64287. private _computeParticleColor;
  64288. private _computeParticleTexture;
  64289. private _computeParticleRotation;
  64290. private _computeBoundingBox;
  64291. private _isReady;
  64292. /**
  64293. * Creates a PCS (Points Cloud System) object
  64294. * @param name (String) is the PCS name, this will be the underlying mesh name
  64295. * @param pointSize (number) is the size for each point
  64296. * @param scene (Scene) is the scene in which the PCS is added
  64297. * @param options defines the options of the PCS e.g.
  64298. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  64299. */
  64300. constructor(name: string, pointSize: number, scene: Scene, options?: {
  64301. updatable?: boolean;
  64302. });
  64303. /**
  64304. * Builds the PCS underlying mesh. Returns a standard Mesh.
  64305. * If no points were added to the PCS, the returned mesh is just a single point.
  64306. * @returns a promise for the created mesh
  64307. */
  64308. buildMeshAsync(): Promise<Mesh>;
  64309. /**
  64310. * @hidden
  64311. */
  64312. private _buildMesh;
  64313. private _addParticle;
  64314. private _randomUnitVector;
  64315. private _getColorIndicesForCoord;
  64316. private _setPointsColorOrUV;
  64317. private _colorFromTexture;
  64318. private _calculateDensity;
  64319. /**
  64320. * Adds points to the PCS in random positions within a unit sphere
  64321. * @param nb (positive integer) the number of particles to be created from this model
  64322. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  64323. * @returns the number of groups in the system
  64324. */
  64325. addPoints(nb: number, pointFunction?: any): number;
  64326. /**
  64327. * Adds points to the PCS from the surface of the model shape
  64328. * @param mesh is any Mesh object that will be used as a surface model for the points
  64329. * @param nb (positive integer) the number of particles to be created from this model
  64330. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64331. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64332. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64333. * @returns the number of groups in the system
  64334. */
  64335. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64336. /**
  64337. * Adds points to the PCS inside the model shape
  64338. * @param mesh is any Mesh object that will be used as a surface model for the points
  64339. * @param nb (positive integer) the number of particles to be created from this model
  64340. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64341. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64342. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64343. * @returns the number of groups in the system
  64344. */
  64345. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64346. /**
  64347. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  64348. * This method calls `updateParticle()` for each particle of the SPS.
  64349. * For an animated SPS, it is usually called within the render loop.
  64350. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  64351. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  64352. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  64353. * @returns the PCS.
  64354. */
  64355. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  64356. /**
  64357. * Disposes the PCS.
  64358. */
  64359. dispose(): void;
  64360. /**
  64361. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  64362. * doc :
  64363. * @returns the PCS.
  64364. */
  64365. refreshVisibleSize(): PointsCloudSystem;
  64366. /**
  64367. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64368. * @param size the size (float) of the visibility box
  64369. * note : this doesn't lock the PCS mesh bounding box.
  64370. * doc :
  64371. */
  64372. setVisibilityBox(size: number): void;
  64373. /**
  64374. * Gets whether the PCS is always visible or not
  64375. * doc :
  64376. */
  64377. get isAlwaysVisible(): boolean;
  64378. /**
  64379. * Sets the PCS as always visible or not
  64380. * doc :
  64381. */
  64382. set isAlwaysVisible(val: boolean);
  64383. /**
  64384. * Tells to `setParticles()` to compute the particle rotations or not
  64385. * Default value : false. The PCS is faster when it's set to false
  64386. * Note : particle rotations are only applied to parent particles
  64387. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64388. */
  64389. set computeParticleRotation(val: boolean);
  64390. /**
  64391. * Tells to `setParticles()` to compute the particle colors or not.
  64392. * Default value : true. The PCS is faster when it's set to false.
  64393. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64394. */
  64395. set computeParticleColor(val: boolean);
  64396. set computeParticleTexture(val: boolean);
  64397. /**
  64398. * Gets if `setParticles()` computes the particle colors or not.
  64399. * Default value : false. The PCS is faster when it's set to false.
  64400. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64401. */
  64402. get computeParticleColor(): boolean;
  64403. /**
  64404. * Gets if `setParticles()` computes the particle textures or not.
  64405. * Default value : false. The PCS is faster when it's set to false.
  64406. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64407. */
  64408. get computeParticleTexture(): boolean;
  64409. /**
  64410. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64411. */
  64412. set computeBoundingBox(val: boolean);
  64413. /**
  64414. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64415. */
  64416. get computeBoundingBox(): boolean;
  64417. /**
  64418. * This function does nothing. It may be overwritten to set all the particle first values.
  64419. * The PCS doesn't call this function, you may have to call it by your own.
  64420. * doc :
  64421. */
  64422. initParticles(): void;
  64423. /**
  64424. * This function does nothing. It may be overwritten to recycle a particle
  64425. * The PCS doesn't call this function, you can to call it
  64426. * doc :
  64427. * @param particle The particle to recycle
  64428. * @returns the recycled particle
  64429. */
  64430. recycleParticle(particle: CloudPoint): CloudPoint;
  64431. /**
  64432. * Updates a particle : this function should be overwritten by the user.
  64433. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64434. * doc :
  64435. * @example : just set a particle position or velocity and recycle conditions
  64436. * @param particle The particle to update
  64437. * @returns the updated particle
  64438. */
  64439. updateParticle(particle: CloudPoint): CloudPoint;
  64440. /**
  64441. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64442. * This does nothing and may be overwritten by the user.
  64443. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64444. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64445. * @param update the boolean update value actually passed to setParticles()
  64446. */
  64447. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64448. /**
  64449. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64450. * This will be passed three parameters.
  64451. * This does nothing and may be overwritten by the user.
  64452. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64453. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64454. * @param update the boolean update value actually passed to setParticles()
  64455. */
  64456. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64457. }
  64458. }
  64459. declare module "babylonjs/Particles/cloudPoint" {
  64460. import { Nullable } from "babylonjs/types";
  64461. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  64462. import { Mesh } from "babylonjs/Meshes/mesh";
  64463. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64464. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  64465. /**
  64466. * Represents one particle of a points cloud system.
  64467. */
  64468. export class CloudPoint {
  64469. /**
  64470. * particle global index
  64471. */
  64472. idx: number;
  64473. /**
  64474. * The color of the particle
  64475. */
  64476. color: Nullable<Color4>;
  64477. /**
  64478. * The world space position of the particle.
  64479. */
  64480. position: Vector3;
  64481. /**
  64482. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64483. */
  64484. rotation: Vector3;
  64485. /**
  64486. * The world space rotation quaternion of the particle.
  64487. */
  64488. rotationQuaternion: Nullable<Quaternion>;
  64489. /**
  64490. * The uv of the particle.
  64491. */
  64492. uv: Nullable<Vector2>;
  64493. /**
  64494. * The current speed of the particle.
  64495. */
  64496. velocity: Vector3;
  64497. /**
  64498. * The pivot point in the particle local space.
  64499. */
  64500. pivot: Vector3;
  64501. /**
  64502. * Must the particle be translated from its pivot point in its local space ?
  64503. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64504. * Default : false
  64505. */
  64506. translateFromPivot: boolean;
  64507. /**
  64508. * Index of this particle in the global "positions" array (Internal use)
  64509. * @hidden
  64510. */
  64511. _pos: number;
  64512. /**
  64513. * @hidden Index of this particle in the global "indices" array (Internal use)
  64514. */
  64515. _ind: number;
  64516. /**
  64517. * Group this particle belongs to
  64518. */
  64519. _group: PointsGroup;
  64520. /**
  64521. * Group id of this particle
  64522. */
  64523. groupId: number;
  64524. /**
  64525. * Index of the particle in its group id (Internal use)
  64526. */
  64527. idxInGroup: number;
  64528. /**
  64529. * @hidden Particle BoundingInfo object (Internal use)
  64530. */
  64531. _boundingInfo: BoundingInfo;
  64532. /**
  64533. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64534. */
  64535. _pcs: PointsCloudSystem;
  64536. /**
  64537. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64538. */
  64539. _stillInvisible: boolean;
  64540. /**
  64541. * @hidden Last computed particle rotation matrix
  64542. */
  64543. _rotationMatrix: number[];
  64544. /**
  64545. * Parent particle Id, if any.
  64546. * Default null.
  64547. */
  64548. parentId: Nullable<number>;
  64549. /**
  64550. * @hidden Internal global position in the PCS.
  64551. */
  64552. _globalPosition: Vector3;
  64553. /**
  64554. * Creates a Point Cloud object.
  64555. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64556. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64557. * @param group (PointsGroup) is the group the particle belongs to
  64558. * @param groupId (integer) is the group identifier in the PCS.
  64559. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64560. * @param pcs defines the PCS it is associated to
  64561. */
  64562. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64563. /**
  64564. * get point size
  64565. */
  64566. get size(): Vector3;
  64567. /**
  64568. * Set point size
  64569. */
  64570. set size(scale: Vector3);
  64571. /**
  64572. * Legacy support, changed quaternion to rotationQuaternion
  64573. */
  64574. get quaternion(): Nullable<Quaternion>;
  64575. /**
  64576. * Legacy support, changed quaternion to rotationQuaternion
  64577. */
  64578. set quaternion(q: Nullable<Quaternion>);
  64579. /**
  64580. * Returns a boolean. True if the particle intersects a mesh, else false
  64581. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64582. * @param target is the object (point or mesh) what the intersection is computed against
  64583. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64584. * @returns true if it intersects
  64585. */
  64586. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64587. /**
  64588. * get the rotation matrix of the particle
  64589. * @hidden
  64590. */
  64591. getRotationMatrix(m: Matrix): void;
  64592. }
  64593. /**
  64594. * Represents a group of points in a points cloud system
  64595. * * PCS internal tool, don't use it manually.
  64596. */
  64597. export class PointsGroup {
  64598. /**
  64599. * The group id
  64600. * @hidden
  64601. */
  64602. groupID: number;
  64603. /**
  64604. * image data for group (internal use)
  64605. * @hidden
  64606. */
  64607. _groupImageData: Nullable<ArrayBufferView>;
  64608. /**
  64609. * Image Width (internal use)
  64610. * @hidden
  64611. */
  64612. _groupImgWidth: number;
  64613. /**
  64614. * Image Height (internal use)
  64615. * @hidden
  64616. */
  64617. _groupImgHeight: number;
  64618. /**
  64619. * Custom position function (internal use)
  64620. * @hidden
  64621. */
  64622. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64623. /**
  64624. * density per facet for surface points
  64625. * @hidden
  64626. */
  64627. _groupDensity: number[];
  64628. /**
  64629. * Only when points are colored by texture carries pointer to texture list array
  64630. * @hidden
  64631. */
  64632. _textureNb: number;
  64633. /**
  64634. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64635. * PCS internal tool, don't use it manually.
  64636. * @hidden
  64637. */
  64638. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64639. }
  64640. }
  64641. declare module "babylonjs/Particles/index" {
  64642. export * from "babylonjs/Particles/baseParticleSystem";
  64643. export * from "babylonjs/Particles/EmitterTypes/index";
  64644. export * from "babylonjs/Particles/gpuParticleSystem";
  64645. export * from "babylonjs/Particles/IParticleSystem";
  64646. export * from "babylonjs/Particles/particle";
  64647. export * from "babylonjs/Particles/particleHelper";
  64648. export * from "babylonjs/Particles/particleSystem";
  64649. export * from "babylonjs/Particles/particleSystemComponent";
  64650. export * from "babylonjs/Particles/particleSystemSet";
  64651. export * from "babylonjs/Particles/solidParticle";
  64652. export * from "babylonjs/Particles/solidParticleSystem";
  64653. export * from "babylonjs/Particles/cloudPoint";
  64654. export * from "babylonjs/Particles/pointsCloudSystem";
  64655. export * from "babylonjs/Particles/subEmitter";
  64656. }
  64657. declare module "babylonjs/Physics/physicsEngineComponent" {
  64658. import { Nullable } from "babylonjs/types";
  64659. import { Observable, Observer } from "babylonjs/Misc/observable";
  64660. import { Vector3 } from "babylonjs/Maths/math.vector";
  64661. import { Mesh } from "babylonjs/Meshes/mesh";
  64662. import { ISceneComponent } from "babylonjs/sceneComponent";
  64663. import { Scene } from "babylonjs/scene";
  64664. import { Node } from "babylonjs/node";
  64665. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64666. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64667. module "babylonjs/scene" {
  64668. interface Scene {
  64669. /** @hidden (Backing field) */
  64670. _physicsEngine: Nullable<IPhysicsEngine>;
  64671. /** @hidden */
  64672. _physicsTimeAccumulator: number;
  64673. /**
  64674. * Gets the current physics engine
  64675. * @returns a IPhysicsEngine or null if none attached
  64676. */
  64677. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64678. /**
  64679. * Enables physics to the current scene
  64680. * @param gravity defines the scene's gravity for the physics engine
  64681. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64682. * @return a boolean indicating if the physics engine was initialized
  64683. */
  64684. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64685. /**
  64686. * Disables and disposes the physics engine associated with the scene
  64687. */
  64688. disablePhysicsEngine(): void;
  64689. /**
  64690. * Gets a boolean indicating if there is an active physics engine
  64691. * @returns a boolean indicating if there is an active physics engine
  64692. */
  64693. isPhysicsEnabled(): boolean;
  64694. /**
  64695. * Deletes a physics compound impostor
  64696. * @param compound defines the compound to delete
  64697. */
  64698. deleteCompoundImpostor(compound: any): void;
  64699. /**
  64700. * An event triggered when physic simulation is about to be run
  64701. */
  64702. onBeforePhysicsObservable: Observable<Scene>;
  64703. /**
  64704. * An event triggered when physic simulation has been done
  64705. */
  64706. onAfterPhysicsObservable: Observable<Scene>;
  64707. }
  64708. }
  64709. module "babylonjs/Meshes/abstractMesh" {
  64710. interface AbstractMesh {
  64711. /** @hidden */
  64712. _physicsImpostor: Nullable<PhysicsImpostor>;
  64713. /**
  64714. * Gets or sets impostor used for physic simulation
  64715. * @see http://doc.babylonjs.com/features/physics_engine
  64716. */
  64717. physicsImpostor: Nullable<PhysicsImpostor>;
  64718. /**
  64719. * Gets the current physics impostor
  64720. * @see http://doc.babylonjs.com/features/physics_engine
  64721. * @returns a physics impostor or null
  64722. */
  64723. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64724. /** Apply a physic impulse to the mesh
  64725. * @param force defines the force to apply
  64726. * @param contactPoint defines where to apply the force
  64727. * @returns the current mesh
  64728. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64729. */
  64730. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64731. /**
  64732. * Creates a physic joint between two meshes
  64733. * @param otherMesh defines the other mesh to use
  64734. * @param pivot1 defines the pivot to use on this mesh
  64735. * @param pivot2 defines the pivot to use on the other mesh
  64736. * @param options defines additional options (can be plugin dependent)
  64737. * @returns the current mesh
  64738. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64739. */
  64740. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64741. /** @hidden */
  64742. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64743. }
  64744. }
  64745. /**
  64746. * Defines the physics engine scene component responsible to manage a physics engine
  64747. */
  64748. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64749. /**
  64750. * The component name helpful to identify the component in the list of scene components.
  64751. */
  64752. readonly name: string;
  64753. /**
  64754. * The scene the component belongs to.
  64755. */
  64756. scene: Scene;
  64757. /**
  64758. * Creates a new instance of the component for the given scene
  64759. * @param scene Defines the scene to register the component in
  64760. */
  64761. constructor(scene: Scene);
  64762. /**
  64763. * Registers the component in a given scene
  64764. */
  64765. register(): void;
  64766. /**
  64767. * Rebuilds the elements related to this component in case of
  64768. * context lost for instance.
  64769. */
  64770. rebuild(): void;
  64771. /**
  64772. * Disposes the component and the associated ressources
  64773. */
  64774. dispose(): void;
  64775. }
  64776. }
  64777. declare module "babylonjs/Physics/physicsHelper" {
  64778. import { Nullable } from "babylonjs/types";
  64779. import { Vector3 } from "babylonjs/Maths/math.vector";
  64780. import { Mesh } from "babylonjs/Meshes/mesh";
  64781. import { Scene } from "babylonjs/scene";
  64782. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64783. /**
  64784. * A helper for physics simulations
  64785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64786. */
  64787. export class PhysicsHelper {
  64788. private _scene;
  64789. private _physicsEngine;
  64790. /**
  64791. * Initializes the Physics helper
  64792. * @param scene Babylon.js scene
  64793. */
  64794. constructor(scene: Scene);
  64795. /**
  64796. * Applies a radial explosion impulse
  64797. * @param origin the origin of the explosion
  64798. * @param radiusOrEventOptions the radius or the options of radial explosion
  64799. * @param strength the explosion strength
  64800. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64801. * @returns A physics radial explosion event, or null
  64802. */
  64803. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64804. /**
  64805. * Applies a radial explosion force
  64806. * @param origin the origin of the explosion
  64807. * @param radiusOrEventOptions the radius or the options of radial explosion
  64808. * @param strength the explosion strength
  64809. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64810. * @returns A physics radial explosion event, or null
  64811. */
  64812. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64813. /**
  64814. * Creates a gravitational field
  64815. * @param origin the origin of the explosion
  64816. * @param radiusOrEventOptions the radius or the options of radial explosion
  64817. * @param strength the explosion strength
  64818. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64819. * @returns A physics gravitational field event, or null
  64820. */
  64821. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64822. /**
  64823. * Creates a physics updraft event
  64824. * @param origin the origin of the updraft
  64825. * @param radiusOrEventOptions the radius or the options of the updraft
  64826. * @param strength the strength of the updraft
  64827. * @param height the height of the updraft
  64828. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64829. * @returns A physics updraft event, or null
  64830. */
  64831. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64832. /**
  64833. * Creates a physics vortex event
  64834. * @param origin the of the vortex
  64835. * @param radiusOrEventOptions the radius or the options of the vortex
  64836. * @param strength the strength of the vortex
  64837. * @param height the height of the vortex
  64838. * @returns a Physics vortex event, or null
  64839. * A physics vortex event or null
  64840. */
  64841. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64842. }
  64843. /**
  64844. * Represents a physics radial explosion event
  64845. */
  64846. class PhysicsRadialExplosionEvent {
  64847. private _scene;
  64848. private _options;
  64849. private _sphere;
  64850. private _dataFetched;
  64851. /**
  64852. * Initializes a radial explosioin event
  64853. * @param _scene BabylonJS scene
  64854. * @param _options The options for the vortex event
  64855. */
  64856. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64857. /**
  64858. * Returns the data related to the radial explosion event (sphere).
  64859. * @returns The radial explosion event data
  64860. */
  64861. getData(): PhysicsRadialExplosionEventData;
  64862. /**
  64863. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64864. * @param impostor A physics imposter
  64865. * @param origin the origin of the explosion
  64866. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64867. */
  64868. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64869. /**
  64870. * Triggers affecterd impostors callbacks
  64871. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64872. */
  64873. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64874. /**
  64875. * Disposes the sphere.
  64876. * @param force Specifies if the sphere should be disposed by force
  64877. */
  64878. dispose(force?: boolean): void;
  64879. /*** Helpers ***/
  64880. private _prepareSphere;
  64881. private _intersectsWithSphere;
  64882. }
  64883. /**
  64884. * Represents a gravitational field event
  64885. */
  64886. class PhysicsGravitationalFieldEvent {
  64887. private _physicsHelper;
  64888. private _scene;
  64889. private _origin;
  64890. private _options;
  64891. private _tickCallback;
  64892. private _sphere;
  64893. private _dataFetched;
  64894. /**
  64895. * Initializes the physics gravitational field event
  64896. * @param _physicsHelper A physics helper
  64897. * @param _scene BabylonJS scene
  64898. * @param _origin The origin position of the gravitational field event
  64899. * @param _options The options for the vortex event
  64900. */
  64901. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64902. /**
  64903. * Returns the data related to the gravitational field event (sphere).
  64904. * @returns A gravitational field event
  64905. */
  64906. getData(): PhysicsGravitationalFieldEventData;
  64907. /**
  64908. * Enables the gravitational field.
  64909. */
  64910. enable(): void;
  64911. /**
  64912. * Disables the gravitational field.
  64913. */
  64914. disable(): void;
  64915. /**
  64916. * Disposes the sphere.
  64917. * @param force The force to dispose from the gravitational field event
  64918. */
  64919. dispose(force?: boolean): void;
  64920. private _tick;
  64921. }
  64922. /**
  64923. * Represents a physics updraft event
  64924. */
  64925. class PhysicsUpdraftEvent {
  64926. private _scene;
  64927. private _origin;
  64928. private _options;
  64929. private _physicsEngine;
  64930. private _originTop;
  64931. private _originDirection;
  64932. private _tickCallback;
  64933. private _cylinder;
  64934. private _cylinderPosition;
  64935. private _dataFetched;
  64936. /**
  64937. * Initializes the physics updraft event
  64938. * @param _scene BabylonJS scene
  64939. * @param _origin The origin position of the updraft
  64940. * @param _options The options for the updraft event
  64941. */
  64942. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64943. /**
  64944. * Returns the data related to the updraft event (cylinder).
  64945. * @returns A physics updraft event
  64946. */
  64947. getData(): PhysicsUpdraftEventData;
  64948. /**
  64949. * Enables the updraft.
  64950. */
  64951. enable(): void;
  64952. /**
  64953. * Disables the updraft.
  64954. */
  64955. disable(): void;
  64956. /**
  64957. * Disposes the cylinder.
  64958. * @param force Specifies if the updraft should be disposed by force
  64959. */
  64960. dispose(force?: boolean): void;
  64961. private getImpostorHitData;
  64962. private _tick;
  64963. /*** Helpers ***/
  64964. private _prepareCylinder;
  64965. private _intersectsWithCylinder;
  64966. }
  64967. /**
  64968. * Represents a physics vortex event
  64969. */
  64970. class PhysicsVortexEvent {
  64971. private _scene;
  64972. private _origin;
  64973. private _options;
  64974. private _physicsEngine;
  64975. private _originTop;
  64976. private _tickCallback;
  64977. private _cylinder;
  64978. private _cylinderPosition;
  64979. private _dataFetched;
  64980. /**
  64981. * Initializes the physics vortex event
  64982. * @param _scene The BabylonJS scene
  64983. * @param _origin The origin position of the vortex
  64984. * @param _options The options for the vortex event
  64985. */
  64986. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64987. /**
  64988. * Returns the data related to the vortex event (cylinder).
  64989. * @returns The physics vortex event data
  64990. */
  64991. getData(): PhysicsVortexEventData;
  64992. /**
  64993. * Enables the vortex.
  64994. */
  64995. enable(): void;
  64996. /**
  64997. * Disables the cortex.
  64998. */
  64999. disable(): void;
  65000. /**
  65001. * Disposes the sphere.
  65002. * @param force
  65003. */
  65004. dispose(force?: boolean): void;
  65005. private getImpostorHitData;
  65006. private _tick;
  65007. /*** Helpers ***/
  65008. private _prepareCylinder;
  65009. private _intersectsWithCylinder;
  65010. }
  65011. /**
  65012. * Options fot the radial explosion event
  65013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65014. */
  65015. export class PhysicsRadialExplosionEventOptions {
  65016. /**
  65017. * The radius of the sphere for the radial explosion.
  65018. */
  65019. radius: number;
  65020. /**
  65021. * The strenth of the explosion.
  65022. */
  65023. strength: number;
  65024. /**
  65025. * The strenght of the force in correspondence to the distance of the affected object
  65026. */
  65027. falloff: PhysicsRadialImpulseFalloff;
  65028. /**
  65029. * Sphere options for the radial explosion.
  65030. */
  65031. sphere: {
  65032. segments: number;
  65033. diameter: number;
  65034. };
  65035. /**
  65036. * Sphere options for the radial explosion.
  65037. */
  65038. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65039. }
  65040. /**
  65041. * Options fot the updraft event
  65042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65043. */
  65044. export class PhysicsUpdraftEventOptions {
  65045. /**
  65046. * The radius of the cylinder for the vortex
  65047. */
  65048. radius: number;
  65049. /**
  65050. * The strenth of the updraft.
  65051. */
  65052. strength: number;
  65053. /**
  65054. * The height of the cylinder for the updraft.
  65055. */
  65056. height: number;
  65057. /**
  65058. * The mode for the the updraft.
  65059. */
  65060. updraftMode: PhysicsUpdraftMode;
  65061. }
  65062. /**
  65063. * Options fot the vortex event
  65064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65065. */
  65066. export class PhysicsVortexEventOptions {
  65067. /**
  65068. * The radius of the cylinder for the vortex
  65069. */
  65070. radius: number;
  65071. /**
  65072. * The strenth of the vortex.
  65073. */
  65074. strength: number;
  65075. /**
  65076. * The height of the cylinder for the vortex.
  65077. */
  65078. height: number;
  65079. /**
  65080. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65081. */
  65082. centripetalForceThreshold: number;
  65083. /**
  65084. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65085. */
  65086. centripetalForceMultiplier: number;
  65087. /**
  65088. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65089. */
  65090. centrifugalForceMultiplier: number;
  65091. /**
  65092. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65093. */
  65094. updraftForceMultiplier: number;
  65095. }
  65096. /**
  65097. * The strenght of the force in correspondence to the distance of the affected object
  65098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65099. */
  65100. export enum PhysicsRadialImpulseFalloff {
  65101. /** Defines that impulse is constant in strength across it's whole radius */
  65102. Constant = 0,
  65103. /** Defines that impulse gets weaker if it's further from the origin */
  65104. Linear = 1
  65105. }
  65106. /**
  65107. * The strength of the force in correspondence to the distance of the affected object
  65108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65109. */
  65110. export enum PhysicsUpdraftMode {
  65111. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65112. Center = 0,
  65113. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65114. Perpendicular = 1
  65115. }
  65116. /**
  65117. * Interface for a physics hit data
  65118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65119. */
  65120. export interface PhysicsHitData {
  65121. /**
  65122. * The force applied at the contact point
  65123. */
  65124. force: Vector3;
  65125. /**
  65126. * The contact point
  65127. */
  65128. contactPoint: Vector3;
  65129. /**
  65130. * The distance from the origin to the contact point
  65131. */
  65132. distanceFromOrigin: number;
  65133. }
  65134. /**
  65135. * Interface for radial explosion event data
  65136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65137. */
  65138. export interface PhysicsRadialExplosionEventData {
  65139. /**
  65140. * A sphere used for the radial explosion event
  65141. */
  65142. sphere: Mesh;
  65143. }
  65144. /**
  65145. * Interface for gravitational field event data
  65146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65147. */
  65148. export interface PhysicsGravitationalFieldEventData {
  65149. /**
  65150. * A sphere mesh used for the gravitational field event
  65151. */
  65152. sphere: Mesh;
  65153. }
  65154. /**
  65155. * Interface for updraft event data
  65156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65157. */
  65158. export interface PhysicsUpdraftEventData {
  65159. /**
  65160. * A cylinder used for the updraft event
  65161. */
  65162. cylinder: Mesh;
  65163. }
  65164. /**
  65165. * Interface for vortex event data
  65166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65167. */
  65168. export interface PhysicsVortexEventData {
  65169. /**
  65170. * A cylinder used for the vortex event
  65171. */
  65172. cylinder: Mesh;
  65173. }
  65174. /**
  65175. * Interface for an affected physics impostor
  65176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65177. */
  65178. export interface PhysicsAffectedImpostorWithData {
  65179. /**
  65180. * The impostor affected by the effect
  65181. */
  65182. impostor: PhysicsImpostor;
  65183. /**
  65184. * The data about the hit/horce from the explosion
  65185. */
  65186. hitData: PhysicsHitData;
  65187. }
  65188. }
  65189. declare module "babylonjs/Physics/Plugins/index" {
  65190. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  65191. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  65192. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  65193. }
  65194. declare module "babylonjs/Physics/index" {
  65195. export * from "babylonjs/Physics/IPhysicsEngine";
  65196. export * from "babylonjs/Physics/physicsEngine";
  65197. export * from "babylonjs/Physics/physicsEngineComponent";
  65198. export * from "babylonjs/Physics/physicsHelper";
  65199. export * from "babylonjs/Physics/physicsImpostor";
  65200. export * from "babylonjs/Physics/physicsJoint";
  65201. export * from "babylonjs/Physics/Plugins/index";
  65202. }
  65203. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  65204. /** @hidden */
  65205. export var blackAndWhitePixelShader: {
  65206. name: string;
  65207. shader: string;
  65208. };
  65209. }
  65210. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  65211. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65212. import { Camera } from "babylonjs/Cameras/camera";
  65213. import { Engine } from "babylonjs/Engines/engine";
  65214. import "babylonjs/Shaders/blackAndWhite.fragment";
  65215. /**
  65216. * Post process used to render in black and white
  65217. */
  65218. export class BlackAndWhitePostProcess extends PostProcess {
  65219. /**
  65220. * Linear about to convert he result to black and white (default: 1)
  65221. */
  65222. degree: number;
  65223. /**
  65224. * Creates a black and white post process
  65225. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  65226. * @param name The name of the effect.
  65227. * @param options The required width/height ratio to downsize to before computing the render pass.
  65228. * @param camera The camera to apply the render pass to.
  65229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65230. * @param engine The engine which the post process will be applied. (default: current engine)
  65231. * @param reusable If the post process can be reused on the same frame. (default: false)
  65232. */
  65233. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65234. }
  65235. }
  65236. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  65237. import { Nullable } from "babylonjs/types";
  65238. import { Camera } from "babylonjs/Cameras/camera";
  65239. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65240. import { Engine } from "babylonjs/Engines/engine";
  65241. /**
  65242. * This represents a set of one or more post processes in Babylon.
  65243. * A post process can be used to apply a shader to a texture after it is rendered.
  65244. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65245. */
  65246. export class PostProcessRenderEffect {
  65247. private _postProcesses;
  65248. private _getPostProcesses;
  65249. private _singleInstance;
  65250. private _cameras;
  65251. private _indicesForCamera;
  65252. /**
  65253. * Name of the effect
  65254. * @hidden
  65255. */
  65256. _name: string;
  65257. /**
  65258. * Instantiates a post process render effect.
  65259. * A post process can be used to apply a shader to a texture after it is rendered.
  65260. * @param engine The engine the effect is tied to
  65261. * @param name The name of the effect
  65262. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  65263. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  65264. */
  65265. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  65266. /**
  65267. * Checks if all the post processes in the effect are supported.
  65268. */
  65269. get isSupported(): boolean;
  65270. /**
  65271. * Updates the current state of the effect
  65272. * @hidden
  65273. */
  65274. _update(): void;
  65275. /**
  65276. * Attaches the effect on cameras
  65277. * @param cameras The camera to attach to.
  65278. * @hidden
  65279. */
  65280. _attachCameras(cameras: Camera): void;
  65281. /**
  65282. * Attaches the effect on cameras
  65283. * @param cameras The camera to attach to.
  65284. * @hidden
  65285. */
  65286. _attachCameras(cameras: Camera[]): void;
  65287. /**
  65288. * Detaches the effect on cameras
  65289. * @param cameras The camera to detatch from.
  65290. * @hidden
  65291. */
  65292. _detachCameras(cameras: Camera): void;
  65293. /**
  65294. * Detatches the effect on cameras
  65295. * @param cameras The camera to detatch from.
  65296. * @hidden
  65297. */
  65298. _detachCameras(cameras: Camera[]): void;
  65299. /**
  65300. * Enables the effect on given cameras
  65301. * @param cameras The camera to enable.
  65302. * @hidden
  65303. */
  65304. _enable(cameras: Camera): void;
  65305. /**
  65306. * Enables the effect on given cameras
  65307. * @param cameras The camera to enable.
  65308. * @hidden
  65309. */
  65310. _enable(cameras: Nullable<Camera[]>): void;
  65311. /**
  65312. * Disables the effect on the given cameras
  65313. * @param cameras The camera to disable.
  65314. * @hidden
  65315. */
  65316. _disable(cameras: Camera): void;
  65317. /**
  65318. * Disables the effect on the given cameras
  65319. * @param cameras The camera to disable.
  65320. * @hidden
  65321. */
  65322. _disable(cameras: Nullable<Camera[]>): void;
  65323. /**
  65324. * Gets a list of the post processes contained in the effect.
  65325. * @param camera The camera to get the post processes on.
  65326. * @returns The list of the post processes in the effect.
  65327. */
  65328. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  65329. }
  65330. }
  65331. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  65332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65333. /** @hidden */
  65334. export var extractHighlightsPixelShader: {
  65335. name: string;
  65336. shader: string;
  65337. };
  65338. }
  65339. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  65340. import { Nullable } from "babylonjs/types";
  65341. import { Camera } from "babylonjs/Cameras/camera";
  65342. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65343. import { Engine } from "babylonjs/Engines/engine";
  65344. import "babylonjs/Shaders/extractHighlights.fragment";
  65345. /**
  65346. * 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.
  65347. */
  65348. export class ExtractHighlightsPostProcess extends PostProcess {
  65349. /**
  65350. * The luminance threshold, pixels below this value will be set to black.
  65351. */
  65352. threshold: number;
  65353. /** @hidden */
  65354. _exposure: number;
  65355. /**
  65356. * Post process which has the input texture to be used when performing highlight extraction
  65357. * @hidden
  65358. */
  65359. _inputPostProcess: Nullable<PostProcess>;
  65360. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65361. }
  65362. }
  65363. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  65364. /** @hidden */
  65365. export var bloomMergePixelShader: {
  65366. name: string;
  65367. shader: string;
  65368. };
  65369. }
  65370. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  65371. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65372. import { Nullable } from "babylonjs/types";
  65373. import { Engine } from "babylonjs/Engines/engine";
  65374. import { Camera } from "babylonjs/Cameras/camera";
  65375. import "babylonjs/Shaders/bloomMerge.fragment";
  65376. /**
  65377. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65378. */
  65379. export class BloomMergePostProcess extends PostProcess {
  65380. /** Weight of the bloom to be added to the original input. */
  65381. weight: number;
  65382. /**
  65383. * Creates a new instance of @see BloomMergePostProcess
  65384. * @param name The name of the effect.
  65385. * @param originalFromInput Post process which's input will be used for the merge.
  65386. * @param blurred Blurred highlights post process which's output will be used.
  65387. * @param weight Weight of the bloom to be added to the original input.
  65388. * @param options The required width/height ratio to downsize to before computing the render pass.
  65389. * @param camera The camera to apply the render pass to.
  65390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65391. * @param engine The engine which the post process will be applied. (default: current engine)
  65392. * @param reusable If the post process can be reused on the same frame. (default: false)
  65393. * @param textureType Type of textures used when performing the post process. (default: 0)
  65394. * @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)
  65395. */
  65396. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  65397. /** Weight of the bloom to be added to the original input. */
  65398. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65399. }
  65400. }
  65401. declare module "babylonjs/PostProcesses/bloomEffect" {
  65402. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65403. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65404. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65405. import { Camera } from "babylonjs/Cameras/camera";
  65406. import { Scene } from "babylonjs/scene";
  65407. /**
  65408. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  65409. */
  65410. export class BloomEffect extends PostProcessRenderEffect {
  65411. private bloomScale;
  65412. /**
  65413. * @hidden Internal
  65414. */
  65415. _effects: Array<PostProcess>;
  65416. /**
  65417. * @hidden Internal
  65418. */
  65419. _downscale: ExtractHighlightsPostProcess;
  65420. private _blurX;
  65421. private _blurY;
  65422. private _merge;
  65423. /**
  65424. * The luminance threshold to find bright areas of the image to bloom.
  65425. */
  65426. get threshold(): number;
  65427. set threshold(value: number);
  65428. /**
  65429. * The strength of the bloom.
  65430. */
  65431. get weight(): number;
  65432. set weight(value: number);
  65433. /**
  65434. * Specifies the size of the bloom blur kernel, relative to the final output size
  65435. */
  65436. get kernel(): number;
  65437. set kernel(value: number);
  65438. /**
  65439. * Creates a new instance of @see BloomEffect
  65440. * @param scene The scene the effect belongs to.
  65441. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65442. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65443. * @param bloomWeight The the strength of bloom.
  65444. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65445. * @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)
  65446. */
  65447. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65448. /**
  65449. * Disposes each of the internal effects for a given camera.
  65450. * @param camera The camera to dispose the effect on.
  65451. */
  65452. disposeEffects(camera: Camera): void;
  65453. /**
  65454. * @hidden Internal
  65455. */
  65456. _updateEffects(): void;
  65457. /**
  65458. * Internal
  65459. * @returns if all the contained post processes are ready.
  65460. * @hidden
  65461. */
  65462. _isReady(): boolean;
  65463. }
  65464. }
  65465. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  65466. /** @hidden */
  65467. export var chromaticAberrationPixelShader: {
  65468. name: string;
  65469. shader: string;
  65470. };
  65471. }
  65472. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  65473. import { Vector2 } from "babylonjs/Maths/math.vector";
  65474. import { Nullable } from "babylonjs/types";
  65475. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65476. import { Camera } from "babylonjs/Cameras/camera";
  65477. import { Engine } from "babylonjs/Engines/engine";
  65478. import "babylonjs/Shaders/chromaticAberration.fragment";
  65479. /**
  65480. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65481. */
  65482. export class ChromaticAberrationPostProcess extends PostProcess {
  65483. /**
  65484. * The amount of seperation of rgb channels (default: 30)
  65485. */
  65486. aberrationAmount: number;
  65487. /**
  65488. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65489. */
  65490. radialIntensity: number;
  65491. /**
  65492. * 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))
  65493. */
  65494. direction: Vector2;
  65495. /**
  65496. * 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))
  65497. */
  65498. centerPosition: Vector2;
  65499. /**
  65500. * Creates a new instance ChromaticAberrationPostProcess
  65501. * @param name The name of the effect.
  65502. * @param screenWidth The width of the screen to apply the effect on.
  65503. * @param screenHeight The height of the screen to apply the effect on.
  65504. * @param options The required width/height ratio to downsize to before computing the render pass.
  65505. * @param camera The camera to apply the render pass to.
  65506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65507. * @param engine The engine which the post process will be applied. (default: current engine)
  65508. * @param reusable If the post process can be reused on the same frame. (default: false)
  65509. * @param textureType Type of textures used when performing the post process. (default: 0)
  65510. * @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)
  65511. */
  65512. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65513. }
  65514. }
  65515. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  65516. /** @hidden */
  65517. export var circleOfConfusionPixelShader: {
  65518. name: string;
  65519. shader: string;
  65520. };
  65521. }
  65522. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  65523. import { Nullable } from "babylonjs/types";
  65524. import { Engine } from "babylonjs/Engines/engine";
  65525. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65526. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65527. import { Camera } from "babylonjs/Cameras/camera";
  65528. import "babylonjs/Shaders/circleOfConfusion.fragment";
  65529. /**
  65530. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65531. */
  65532. export class CircleOfConfusionPostProcess extends PostProcess {
  65533. /**
  65534. * 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.
  65535. */
  65536. lensSize: number;
  65537. /**
  65538. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65539. */
  65540. fStop: number;
  65541. /**
  65542. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65543. */
  65544. focusDistance: number;
  65545. /**
  65546. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65547. */
  65548. focalLength: number;
  65549. private _depthTexture;
  65550. /**
  65551. * Creates a new instance CircleOfConfusionPostProcess
  65552. * @param name The name of the effect.
  65553. * @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.
  65554. * @param options The required width/height ratio to downsize to before computing the render pass.
  65555. * @param camera The camera to apply the render pass to.
  65556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65557. * @param engine The engine which the post process will be applied. (default: current engine)
  65558. * @param reusable If the post process can be reused on the same frame. (default: false)
  65559. * @param textureType Type of textures used when performing the post process. (default: 0)
  65560. * @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)
  65561. */
  65562. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65563. /**
  65564. * 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.
  65565. */
  65566. set depthTexture(value: RenderTargetTexture);
  65567. }
  65568. }
  65569. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  65570. /** @hidden */
  65571. export var colorCorrectionPixelShader: {
  65572. name: string;
  65573. shader: string;
  65574. };
  65575. }
  65576. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  65577. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65578. import { Engine } from "babylonjs/Engines/engine";
  65579. import { Camera } from "babylonjs/Cameras/camera";
  65580. import "babylonjs/Shaders/colorCorrection.fragment";
  65581. /**
  65582. *
  65583. * This post-process allows the modification of rendered colors by using
  65584. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65585. *
  65586. * The object needs to be provided an url to a texture containing the color
  65587. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65588. * Use an image editing software to tweak the LUT to match your needs.
  65589. *
  65590. * For an example of a color LUT, see here:
  65591. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65592. * For explanations on color grading, see here:
  65593. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65594. *
  65595. */
  65596. export class ColorCorrectionPostProcess extends PostProcess {
  65597. private _colorTableTexture;
  65598. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65599. }
  65600. }
  65601. declare module "babylonjs/Shaders/convolution.fragment" {
  65602. /** @hidden */
  65603. export var convolutionPixelShader: {
  65604. name: string;
  65605. shader: string;
  65606. };
  65607. }
  65608. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  65609. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65610. import { Nullable } from "babylonjs/types";
  65611. import { Camera } from "babylonjs/Cameras/camera";
  65612. import { Engine } from "babylonjs/Engines/engine";
  65613. import "babylonjs/Shaders/convolution.fragment";
  65614. /**
  65615. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65616. * input texture to perform effects such as edge detection or sharpening
  65617. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65618. */
  65619. export class ConvolutionPostProcess extends PostProcess {
  65620. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65621. kernel: number[];
  65622. /**
  65623. * Creates a new instance ConvolutionPostProcess
  65624. * @param name The name of the effect.
  65625. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65626. * @param options The required width/height ratio to downsize to before computing the render pass.
  65627. * @param camera The camera to apply the render pass to.
  65628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65629. * @param engine The engine which the post process will be applied. (default: current engine)
  65630. * @param reusable If the post process can be reused on the same frame. (default: false)
  65631. * @param textureType Type of textures used when performing the post process. (default: 0)
  65632. */
  65633. constructor(name: string,
  65634. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65635. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65636. /**
  65637. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65638. */
  65639. static EdgeDetect0Kernel: number[];
  65640. /**
  65641. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65642. */
  65643. static EdgeDetect1Kernel: number[];
  65644. /**
  65645. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65646. */
  65647. static EdgeDetect2Kernel: number[];
  65648. /**
  65649. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65650. */
  65651. static SharpenKernel: number[];
  65652. /**
  65653. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65654. */
  65655. static EmbossKernel: number[];
  65656. /**
  65657. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65658. */
  65659. static GaussianKernel: number[];
  65660. }
  65661. }
  65662. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  65663. import { Nullable } from "babylonjs/types";
  65664. import { Vector2 } from "babylonjs/Maths/math.vector";
  65665. import { Camera } from "babylonjs/Cameras/camera";
  65666. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65667. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65668. import { Engine } from "babylonjs/Engines/engine";
  65669. import { Scene } from "babylonjs/scene";
  65670. /**
  65671. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65672. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65673. * based on samples that have a large difference in distance than the center pixel.
  65674. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65675. */
  65676. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65677. direction: Vector2;
  65678. /**
  65679. * Creates a new instance CircleOfConfusionPostProcess
  65680. * @param name The name of the effect.
  65681. * @param scene The scene the effect belongs to.
  65682. * @param direction The direction the blur should be applied.
  65683. * @param kernel The size of the kernel used to blur.
  65684. * @param options The required width/height ratio to downsize to before computing the render pass.
  65685. * @param camera The camera to apply the render pass to.
  65686. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65687. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65689. * @param engine The engine which the post process will be applied. (default: current engine)
  65690. * @param reusable If the post process can be reused on the same frame. (default: false)
  65691. * @param textureType Type of textures used when performing the post process. (default: 0)
  65692. * @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)
  65693. */
  65694. 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);
  65695. }
  65696. }
  65697. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  65698. /** @hidden */
  65699. export var depthOfFieldMergePixelShader: {
  65700. name: string;
  65701. shader: string;
  65702. };
  65703. }
  65704. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  65705. import { Nullable } from "babylonjs/types";
  65706. import { Camera } from "babylonjs/Cameras/camera";
  65707. import { Effect } from "babylonjs/Materials/effect";
  65708. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65709. import { Engine } from "babylonjs/Engines/engine";
  65710. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  65711. /**
  65712. * Options to be set when merging outputs from the default pipeline.
  65713. */
  65714. export class DepthOfFieldMergePostProcessOptions {
  65715. /**
  65716. * The original image to merge on top of
  65717. */
  65718. originalFromInput: PostProcess;
  65719. /**
  65720. * Parameters to perform the merge of the depth of field effect
  65721. */
  65722. depthOfField?: {
  65723. circleOfConfusion: PostProcess;
  65724. blurSteps: Array<PostProcess>;
  65725. };
  65726. /**
  65727. * Parameters to perform the merge of bloom effect
  65728. */
  65729. bloom?: {
  65730. blurred: PostProcess;
  65731. weight: number;
  65732. };
  65733. }
  65734. /**
  65735. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65736. */
  65737. export class DepthOfFieldMergePostProcess extends PostProcess {
  65738. private blurSteps;
  65739. /**
  65740. * Creates a new instance of DepthOfFieldMergePostProcess
  65741. * @param name The name of the effect.
  65742. * @param originalFromInput Post process which's input will be used for the merge.
  65743. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65744. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65745. * @param options The required width/height ratio to downsize to before computing the render pass.
  65746. * @param camera The camera to apply the render pass to.
  65747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65748. * @param engine The engine which the post process will be applied. (default: current engine)
  65749. * @param reusable If the post process can be reused on the same frame. (default: false)
  65750. * @param textureType Type of textures used when performing the post process. (default: 0)
  65751. * @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)
  65752. */
  65753. 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);
  65754. /**
  65755. * Updates the effect with the current post process compile time values and recompiles the shader.
  65756. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65757. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65758. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65759. * @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
  65760. * @param onCompiled Called when the shader has been compiled.
  65761. * @param onError Called if there is an error when compiling a shader.
  65762. */
  65763. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65764. }
  65765. }
  65766. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  65767. import { Nullable } from "babylonjs/types";
  65768. import { Camera } from "babylonjs/Cameras/camera";
  65769. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65770. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65771. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65772. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65773. import { Scene } from "babylonjs/scene";
  65774. /**
  65775. * Specifies the level of max blur that should be applied when using the depth of field effect
  65776. */
  65777. export enum DepthOfFieldEffectBlurLevel {
  65778. /**
  65779. * Subtle blur
  65780. */
  65781. Low = 0,
  65782. /**
  65783. * Medium blur
  65784. */
  65785. Medium = 1,
  65786. /**
  65787. * Large blur
  65788. */
  65789. High = 2
  65790. }
  65791. /**
  65792. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65793. */
  65794. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65795. private _circleOfConfusion;
  65796. /**
  65797. * @hidden Internal, blurs from high to low
  65798. */
  65799. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65800. private _depthOfFieldBlurY;
  65801. private _dofMerge;
  65802. /**
  65803. * @hidden Internal post processes in depth of field effect
  65804. */
  65805. _effects: Array<PostProcess>;
  65806. /**
  65807. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65808. */
  65809. set focalLength(value: number);
  65810. get focalLength(): number;
  65811. /**
  65812. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65813. */
  65814. set fStop(value: number);
  65815. get fStop(): number;
  65816. /**
  65817. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65818. */
  65819. set focusDistance(value: number);
  65820. get focusDistance(): number;
  65821. /**
  65822. * 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.
  65823. */
  65824. set lensSize(value: number);
  65825. get lensSize(): number;
  65826. /**
  65827. * Creates a new instance DepthOfFieldEffect
  65828. * @param scene The scene the effect belongs to.
  65829. * @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.
  65830. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65831. * @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)
  65832. */
  65833. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65834. /**
  65835. * Get the current class name of the current effet
  65836. * @returns "DepthOfFieldEffect"
  65837. */
  65838. getClassName(): string;
  65839. /**
  65840. * 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.
  65841. */
  65842. set depthTexture(value: RenderTargetTexture);
  65843. /**
  65844. * Disposes each of the internal effects for a given camera.
  65845. * @param camera The camera to dispose the effect on.
  65846. */
  65847. disposeEffects(camera: Camera): void;
  65848. /**
  65849. * @hidden Internal
  65850. */
  65851. _updateEffects(): void;
  65852. /**
  65853. * Internal
  65854. * @returns if all the contained post processes are ready.
  65855. * @hidden
  65856. */
  65857. _isReady(): boolean;
  65858. }
  65859. }
  65860. declare module "babylonjs/Shaders/displayPass.fragment" {
  65861. /** @hidden */
  65862. export var displayPassPixelShader: {
  65863. name: string;
  65864. shader: string;
  65865. };
  65866. }
  65867. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  65868. import { Nullable } from "babylonjs/types";
  65869. import { Camera } from "babylonjs/Cameras/camera";
  65870. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65871. import { Engine } from "babylonjs/Engines/engine";
  65872. import "babylonjs/Shaders/displayPass.fragment";
  65873. /**
  65874. * DisplayPassPostProcess which produces an output the same as it's input
  65875. */
  65876. export class DisplayPassPostProcess extends PostProcess {
  65877. /**
  65878. * Creates the DisplayPassPostProcess
  65879. * @param name The name of the effect.
  65880. * @param options The required width/height ratio to downsize to before computing the render pass.
  65881. * @param camera The camera to apply the render pass to.
  65882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65883. * @param engine The engine which the post process will be applied. (default: current engine)
  65884. * @param reusable If the post process can be reused on the same frame. (default: false)
  65885. */
  65886. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65887. }
  65888. }
  65889. declare module "babylonjs/Shaders/filter.fragment" {
  65890. /** @hidden */
  65891. export var filterPixelShader: {
  65892. name: string;
  65893. shader: string;
  65894. };
  65895. }
  65896. declare module "babylonjs/PostProcesses/filterPostProcess" {
  65897. import { Nullable } from "babylonjs/types";
  65898. import { Matrix } from "babylonjs/Maths/math.vector";
  65899. import { Camera } from "babylonjs/Cameras/camera";
  65900. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65901. import { Engine } from "babylonjs/Engines/engine";
  65902. import "babylonjs/Shaders/filter.fragment";
  65903. /**
  65904. * Applies a kernel filter to the image
  65905. */
  65906. export class FilterPostProcess extends PostProcess {
  65907. /** The matrix to be applied to the image */
  65908. kernelMatrix: Matrix;
  65909. /**
  65910. *
  65911. * @param name The name of the effect.
  65912. * @param kernelMatrix The matrix to be applied to the image
  65913. * @param options The required width/height ratio to downsize to before computing the render pass.
  65914. * @param camera The camera to apply the render pass to.
  65915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65916. * @param engine The engine which the post process will be applied. (default: current engine)
  65917. * @param reusable If the post process can be reused on the same frame. (default: false)
  65918. */
  65919. constructor(name: string,
  65920. /** The matrix to be applied to the image */
  65921. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65922. }
  65923. }
  65924. declare module "babylonjs/Shaders/fxaa.fragment" {
  65925. /** @hidden */
  65926. export var fxaaPixelShader: {
  65927. name: string;
  65928. shader: string;
  65929. };
  65930. }
  65931. declare module "babylonjs/Shaders/fxaa.vertex" {
  65932. /** @hidden */
  65933. export var fxaaVertexShader: {
  65934. name: string;
  65935. shader: string;
  65936. };
  65937. }
  65938. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  65939. import { Nullable } from "babylonjs/types";
  65940. import { Camera } from "babylonjs/Cameras/camera";
  65941. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65942. import { Engine } from "babylonjs/Engines/engine";
  65943. import "babylonjs/Shaders/fxaa.fragment";
  65944. import "babylonjs/Shaders/fxaa.vertex";
  65945. /**
  65946. * Fxaa post process
  65947. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65948. */
  65949. export class FxaaPostProcess extends PostProcess {
  65950. /** @hidden */
  65951. texelWidth: number;
  65952. /** @hidden */
  65953. texelHeight: number;
  65954. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65955. private _getDefines;
  65956. }
  65957. }
  65958. declare module "babylonjs/Shaders/grain.fragment" {
  65959. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65960. /** @hidden */
  65961. export var grainPixelShader: {
  65962. name: string;
  65963. shader: string;
  65964. };
  65965. }
  65966. declare module "babylonjs/PostProcesses/grainPostProcess" {
  65967. import { Nullable } from "babylonjs/types";
  65968. import { Camera } from "babylonjs/Cameras/camera";
  65969. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65970. import { Engine } from "babylonjs/Engines/engine";
  65971. import "babylonjs/Shaders/grain.fragment";
  65972. /**
  65973. * The GrainPostProcess adds noise to the image at mid luminance levels
  65974. */
  65975. export class GrainPostProcess extends PostProcess {
  65976. /**
  65977. * The intensity of the grain added (default: 30)
  65978. */
  65979. intensity: number;
  65980. /**
  65981. * If the grain should be randomized on every frame
  65982. */
  65983. animated: boolean;
  65984. /**
  65985. * Creates a new instance of @see GrainPostProcess
  65986. * @param name The name of the effect.
  65987. * @param options The required width/height ratio to downsize to before computing the render pass.
  65988. * @param camera The camera to apply the render pass to.
  65989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65990. * @param engine The engine which the post process will be applied. (default: current engine)
  65991. * @param reusable If the post process can be reused on the same frame. (default: false)
  65992. * @param textureType Type of textures used when performing the post process. (default: 0)
  65993. * @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)
  65994. */
  65995. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65996. }
  65997. }
  65998. declare module "babylonjs/Shaders/highlights.fragment" {
  65999. /** @hidden */
  66000. export var highlightsPixelShader: {
  66001. name: string;
  66002. shader: string;
  66003. };
  66004. }
  66005. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66006. import { Nullable } from "babylonjs/types";
  66007. import { Camera } from "babylonjs/Cameras/camera";
  66008. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66009. import { Engine } from "babylonjs/Engines/engine";
  66010. import "babylonjs/Shaders/highlights.fragment";
  66011. /**
  66012. * Extracts highlights from the image
  66013. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66014. */
  66015. export class HighlightsPostProcess extends PostProcess {
  66016. /**
  66017. * Extracts highlights from the image
  66018. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66019. * @param name The name of the effect.
  66020. * @param options The required width/height ratio to downsize to before computing the render pass.
  66021. * @param camera The camera to apply the render pass to.
  66022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66023. * @param engine The engine which the post process will be applied. (default: current engine)
  66024. * @param reusable If the post process can be reused on the same frame. (default: false)
  66025. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66026. */
  66027. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66028. }
  66029. }
  66030. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66031. /** @hidden */
  66032. export var mrtFragmentDeclaration: {
  66033. name: string;
  66034. shader: string;
  66035. };
  66036. }
  66037. declare module "babylonjs/Shaders/geometry.fragment" {
  66038. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66039. /** @hidden */
  66040. export var geometryPixelShader: {
  66041. name: string;
  66042. shader: string;
  66043. };
  66044. }
  66045. declare module "babylonjs/Shaders/geometry.vertex" {
  66046. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66047. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66048. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66049. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66050. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66051. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66052. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66053. /** @hidden */
  66054. export var geometryVertexShader: {
  66055. name: string;
  66056. shader: string;
  66057. };
  66058. }
  66059. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66060. import { Matrix } from "babylonjs/Maths/math.vector";
  66061. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66062. import { Mesh } from "babylonjs/Meshes/mesh";
  66063. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66064. import { Effect } from "babylonjs/Materials/effect";
  66065. import { Scene } from "babylonjs/scene";
  66066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66067. import "babylonjs/Shaders/geometry.fragment";
  66068. import "babylonjs/Shaders/geometry.vertex";
  66069. /** @hidden */
  66070. interface ISavedTransformationMatrix {
  66071. world: Matrix;
  66072. viewProjection: Matrix;
  66073. }
  66074. /**
  66075. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66076. */
  66077. export class GeometryBufferRenderer {
  66078. /**
  66079. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66080. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66081. */
  66082. static readonly POSITION_TEXTURE_TYPE: number;
  66083. /**
  66084. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66085. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66086. */
  66087. static readonly VELOCITY_TEXTURE_TYPE: number;
  66088. /**
  66089. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66090. * in order to compute objects velocities when enableVelocity is set to "true"
  66091. * @hidden
  66092. */
  66093. _previousTransformationMatrices: {
  66094. [index: number]: ISavedTransformationMatrix;
  66095. };
  66096. /**
  66097. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66098. * in order to compute objects velocities when enableVelocity is set to "true"
  66099. * @hidden
  66100. */
  66101. _previousBonesTransformationMatrices: {
  66102. [index: number]: Float32Array;
  66103. };
  66104. /**
  66105. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66106. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66107. */
  66108. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66109. private _scene;
  66110. private _multiRenderTarget;
  66111. private _ratio;
  66112. private _enablePosition;
  66113. private _enableVelocity;
  66114. private _positionIndex;
  66115. private _velocityIndex;
  66116. protected _effect: Effect;
  66117. protected _cachedDefines: string;
  66118. /**
  66119. * Set the render list (meshes to be rendered) used in the G buffer.
  66120. */
  66121. set renderList(meshes: Mesh[]);
  66122. /**
  66123. * Gets wether or not G buffer are supported by the running hardware.
  66124. * This requires draw buffer supports
  66125. */
  66126. get isSupported(): boolean;
  66127. /**
  66128. * Returns the index of the given texture type in the G-Buffer textures array
  66129. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66130. * @returns the index of the given texture type in the G-Buffer textures array
  66131. */
  66132. getTextureIndex(textureType: number): number;
  66133. /**
  66134. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66135. */
  66136. get enablePosition(): boolean;
  66137. /**
  66138. * Sets whether or not objects positions are enabled for the G buffer.
  66139. */
  66140. set enablePosition(enable: boolean);
  66141. /**
  66142. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66143. */
  66144. get enableVelocity(): boolean;
  66145. /**
  66146. * Sets wether or not objects velocities are enabled for the G buffer.
  66147. */
  66148. set enableVelocity(enable: boolean);
  66149. /**
  66150. * Gets the scene associated with the buffer.
  66151. */
  66152. get scene(): Scene;
  66153. /**
  66154. * Gets the ratio used by the buffer during its creation.
  66155. * How big is the buffer related to the main canvas.
  66156. */
  66157. get ratio(): number;
  66158. /** @hidden */
  66159. static _SceneComponentInitialization: (scene: Scene) => void;
  66160. /**
  66161. * Creates a new G Buffer for the scene
  66162. * @param scene The scene the buffer belongs to
  66163. * @param ratio How big is the buffer related to the main canvas.
  66164. */
  66165. constructor(scene: Scene, ratio?: number);
  66166. /**
  66167. * Checks wether everything is ready to render a submesh to the G buffer.
  66168. * @param subMesh the submesh to check readiness for
  66169. * @param useInstances is the mesh drawn using instance or not
  66170. * @returns true if ready otherwise false
  66171. */
  66172. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66173. /**
  66174. * Gets the current underlying G Buffer.
  66175. * @returns the buffer
  66176. */
  66177. getGBuffer(): MultiRenderTarget;
  66178. /**
  66179. * Gets the number of samples used to render the buffer (anti aliasing).
  66180. */
  66181. get samples(): number;
  66182. /**
  66183. * Sets the number of samples used to render the buffer (anti aliasing).
  66184. */
  66185. set samples(value: number);
  66186. /**
  66187. * Disposes the renderer and frees up associated resources.
  66188. */
  66189. dispose(): void;
  66190. protected _createRenderTargets(): void;
  66191. private _copyBonesTransformationMatrices;
  66192. }
  66193. }
  66194. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  66195. import { Nullable } from "babylonjs/types";
  66196. import { Scene } from "babylonjs/scene";
  66197. import { ISceneComponent } from "babylonjs/sceneComponent";
  66198. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  66199. module "babylonjs/scene" {
  66200. interface Scene {
  66201. /** @hidden (Backing field) */
  66202. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66203. /**
  66204. * Gets or Sets the current geometry buffer associated to the scene.
  66205. */
  66206. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66207. /**
  66208. * Enables a GeometryBufferRender and associates it with the scene
  66209. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66210. * @returns the GeometryBufferRenderer
  66211. */
  66212. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66213. /**
  66214. * Disables the GeometryBufferRender associated with the scene
  66215. */
  66216. disableGeometryBufferRenderer(): void;
  66217. }
  66218. }
  66219. /**
  66220. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66221. * in several rendering techniques.
  66222. */
  66223. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  66224. /**
  66225. * The component name helpful to identify the component in the list of scene components.
  66226. */
  66227. readonly name: string;
  66228. /**
  66229. * The scene the component belongs to.
  66230. */
  66231. scene: Scene;
  66232. /**
  66233. * Creates a new instance of the component for the given scene
  66234. * @param scene Defines the scene to register the component in
  66235. */
  66236. constructor(scene: Scene);
  66237. /**
  66238. * Registers the component in a given scene
  66239. */
  66240. register(): void;
  66241. /**
  66242. * Rebuilds the elements related to this component in case of
  66243. * context lost for instance.
  66244. */
  66245. rebuild(): void;
  66246. /**
  66247. * Disposes the component and the associated ressources
  66248. */
  66249. dispose(): void;
  66250. private _gatherRenderTargets;
  66251. }
  66252. }
  66253. declare module "babylonjs/Shaders/motionBlur.fragment" {
  66254. /** @hidden */
  66255. export var motionBlurPixelShader: {
  66256. name: string;
  66257. shader: string;
  66258. };
  66259. }
  66260. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  66261. import { Nullable } from "babylonjs/types";
  66262. import { Camera } from "babylonjs/Cameras/camera";
  66263. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66264. import { Scene } from "babylonjs/scene";
  66265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66266. import "babylonjs/Animations/animatable";
  66267. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66268. import "babylonjs/Shaders/motionBlur.fragment";
  66269. import { Engine } from "babylonjs/Engines/engine";
  66270. /**
  66271. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  66272. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  66273. * As an example, all you have to do is to create the post-process:
  66274. * var mb = new BABYLON.MotionBlurPostProcess(
  66275. * 'mb', // The name of the effect.
  66276. * scene, // The scene containing the objects to blur according to their velocity.
  66277. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  66278. * camera // The camera to apply the render pass to.
  66279. * );
  66280. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  66281. */
  66282. export class MotionBlurPostProcess extends PostProcess {
  66283. /**
  66284. * Defines how much the image is blurred by the movement. Default value is equal to 1
  66285. */
  66286. motionStrength: number;
  66287. /**
  66288. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  66289. */
  66290. get motionBlurSamples(): number;
  66291. /**
  66292. * Sets the number of iterations to be used for motion blur quality
  66293. */
  66294. set motionBlurSamples(samples: number);
  66295. private _motionBlurSamples;
  66296. private _geometryBufferRenderer;
  66297. /**
  66298. * Creates a new instance MotionBlurPostProcess
  66299. * @param name The name of the effect.
  66300. * @param scene The scene containing the objects to blur according to their velocity.
  66301. * @param options The required width/height ratio to downsize to before computing the render pass.
  66302. * @param camera The camera to apply the render pass to.
  66303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66304. * @param engine The engine which the post process will be applied. (default: current engine)
  66305. * @param reusable If the post process can be reused on the same frame. (default: false)
  66306. * @param textureType Type of textures used when performing the post process. (default: 0)
  66307. * @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)
  66308. */
  66309. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66310. /**
  66311. * Excludes the given skinned mesh from computing bones velocities.
  66312. * 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.
  66313. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  66314. */
  66315. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66316. /**
  66317. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  66318. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  66319. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  66320. */
  66321. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66322. /**
  66323. * Disposes the post process.
  66324. * @param camera The camera to dispose the post process on.
  66325. */
  66326. dispose(camera?: Camera): void;
  66327. }
  66328. }
  66329. declare module "babylonjs/Shaders/refraction.fragment" {
  66330. /** @hidden */
  66331. export var refractionPixelShader: {
  66332. name: string;
  66333. shader: string;
  66334. };
  66335. }
  66336. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  66337. import { Color3 } from "babylonjs/Maths/math.color";
  66338. import { Camera } from "babylonjs/Cameras/camera";
  66339. import { Texture } from "babylonjs/Materials/Textures/texture";
  66340. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66341. import { Engine } from "babylonjs/Engines/engine";
  66342. import "babylonjs/Shaders/refraction.fragment";
  66343. /**
  66344. * Post process which applies a refractin texture
  66345. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66346. */
  66347. export class RefractionPostProcess extends PostProcess {
  66348. /** the base color of the refraction (used to taint the rendering) */
  66349. color: Color3;
  66350. /** simulated refraction depth */
  66351. depth: number;
  66352. /** the coefficient of the base color (0 to remove base color tainting) */
  66353. colorLevel: number;
  66354. private _refTexture;
  66355. private _ownRefractionTexture;
  66356. /**
  66357. * Gets or sets the refraction texture
  66358. * Please note that you are responsible for disposing the texture if you set it manually
  66359. */
  66360. get refractionTexture(): Texture;
  66361. set refractionTexture(value: Texture);
  66362. /**
  66363. * Initializes the RefractionPostProcess
  66364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66365. * @param name The name of the effect.
  66366. * @param refractionTextureUrl Url of the refraction texture to use
  66367. * @param color the base color of the refraction (used to taint the rendering)
  66368. * @param depth simulated refraction depth
  66369. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  66370. * @param camera The camera to apply the render pass to.
  66371. * @param options The required width/height ratio to downsize to before computing the render pass.
  66372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66373. * @param engine The engine which the post process will be applied. (default: current engine)
  66374. * @param reusable If the post process can be reused on the same frame. (default: false)
  66375. */
  66376. constructor(name: string, refractionTextureUrl: string,
  66377. /** the base color of the refraction (used to taint the rendering) */
  66378. color: Color3,
  66379. /** simulated refraction depth */
  66380. depth: number,
  66381. /** the coefficient of the base color (0 to remove base color tainting) */
  66382. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66383. /**
  66384. * Disposes of the post process
  66385. * @param camera Camera to dispose post process on
  66386. */
  66387. dispose(camera: Camera): void;
  66388. }
  66389. }
  66390. declare module "babylonjs/Shaders/sharpen.fragment" {
  66391. /** @hidden */
  66392. export var sharpenPixelShader: {
  66393. name: string;
  66394. shader: string;
  66395. };
  66396. }
  66397. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  66398. import { Nullable } from "babylonjs/types";
  66399. import { Camera } from "babylonjs/Cameras/camera";
  66400. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66401. import "babylonjs/Shaders/sharpen.fragment";
  66402. import { Engine } from "babylonjs/Engines/engine";
  66403. /**
  66404. * The SharpenPostProcess applies a sharpen kernel to every pixel
  66405. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66406. */
  66407. export class SharpenPostProcess extends PostProcess {
  66408. /**
  66409. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  66410. */
  66411. colorAmount: number;
  66412. /**
  66413. * How much sharpness should be applied (default: 0.3)
  66414. */
  66415. edgeAmount: number;
  66416. /**
  66417. * Creates a new instance ConvolutionPostProcess
  66418. * @param name The name of the effect.
  66419. * @param options The required width/height ratio to downsize to before computing the render pass.
  66420. * @param camera The camera to apply the render pass to.
  66421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66422. * @param engine The engine which the post process will be applied. (default: current engine)
  66423. * @param reusable If the post process can be reused on the same frame. (default: false)
  66424. * @param textureType Type of textures used when performing the post process. (default: 0)
  66425. * @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)
  66426. */
  66427. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66428. }
  66429. }
  66430. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  66431. import { Nullable } from "babylonjs/types";
  66432. import { Camera } from "babylonjs/Cameras/camera";
  66433. import { Engine } from "babylonjs/Engines/engine";
  66434. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66435. import { IInspectable } from "babylonjs/Misc/iInspectable";
  66436. /**
  66437. * PostProcessRenderPipeline
  66438. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66439. */
  66440. export class PostProcessRenderPipeline {
  66441. private engine;
  66442. private _renderEffects;
  66443. private _renderEffectsForIsolatedPass;
  66444. /**
  66445. * List of inspectable custom properties (used by the Inspector)
  66446. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66447. */
  66448. inspectableCustomProperties: IInspectable[];
  66449. /**
  66450. * @hidden
  66451. */
  66452. protected _cameras: Camera[];
  66453. /** @hidden */
  66454. _name: string;
  66455. /**
  66456. * Gets pipeline name
  66457. */
  66458. get name(): string;
  66459. /** Gets the list of attached cameras */
  66460. get cameras(): Camera[];
  66461. /**
  66462. * Initializes a PostProcessRenderPipeline
  66463. * @param engine engine to add the pipeline to
  66464. * @param name name of the pipeline
  66465. */
  66466. constructor(engine: Engine, name: string);
  66467. /**
  66468. * Gets the class name
  66469. * @returns "PostProcessRenderPipeline"
  66470. */
  66471. getClassName(): string;
  66472. /**
  66473. * If all the render effects in the pipeline are supported
  66474. */
  66475. get isSupported(): boolean;
  66476. /**
  66477. * Adds an effect to the pipeline
  66478. * @param renderEffect the effect to add
  66479. */
  66480. addEffect(renderEffect: PostProcessRenderEffect): void;
  66481. /** @hidden */
  66482. _rebuild(): void;
  66483. /** @hidden */
  66484. _enableEffect(renderEffectName: string, cameras: Camera): void;
  66485. /** @hidden */
  66486. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  66487. /** @hidden */
  66488. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66489. /** @hidden */
  66490. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66491. /** @hidden */
  66492. _attachCameras(cameras: Camera, unique: boolean): void;
  66493. /** @hidden */
  66494. _attachCameras(cameras: Camera[], unique: boolean): void;
  66495. /** @hidden */
  66496. _detachCameras(cameras: Camera): void;
  66497. /** @hidden */
  66498. _detachCameras(cameras: Nullable<Camera[]>): void;
  66499. /** @hidden */
  66500. _update(): void;
  66501. /** @hidden */
  66502. _reset(): void;
  66503. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  66504. /**
  66505. * Disposes of the pipeline
  66506. */
  66507. dispose(): void;
  66508. }
  66509. }
  66510. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  66511. import { Camera } from "babylonjs/Cameras/camera";
  66512. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66513. /**
  66514. * PostProcessRenderPipelineManager class
  66515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66516. */
  66517. export class PostProcessRenderPipelineManager {
  66518. private _renderPipelines;
  66519. /**
  66520. * Initializes a PostProcessRenderPipelineManager
  66521. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66522. */
  66523. constructor();
  66524. /**
  66525. * Gets the list of supported render pipelines
  66526. */
  66527. get supportedPipelines(): PostProcessRenderPipeline[];
  66528. /**
  66529. * Adds a pipeline to the manager
  66530. * @param renderPipeline The pipeline to add
  66531. */
  66532. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  66533. /**
  66534. * Attaches a camera to the pipeline
  66535. * @param renderPipelineName The name of the pipeline to attach to
  66536. * @param cameras the camera to attach
  66537. * @param unique if the camera can be attached multiple times to the pipeline
  66538. */
  66539. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  66540. /**
  66541. * Detaches a camera from the pipeline
  66542. * @param renderPipelineName The name of the pipeline to detach from
  66543. * @param cameras the camera to detach
  66544. */
  66545. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66546. /**
  66547. * Enables an effect by name on a pipeline
  66548. * @param renderPipelineName the name of the pipeline to enable the effect in
  66549. * @param renderEffectName the name of the effect to enable
  66550. * @param cameras the cameras that the effect should be enabled on
  66551. */
  66552. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66553. /**
  66554. * Disables an effect by name on a pipeline
  66555. * @param renderPipelineName the name of the pipeline to disable the effect in
  66556. * @param renderEffectName the name of the effect to disable
  66557. * @param cameras the cameras that the effect should be disabled on
  66558. */
  66559. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66560. /**
  66561. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66562. */
  66563. update(): void;
  66564. /** @hidden */
  66565. _rebuild(): void;
  66566. /**
  66567. * Disposes of the manager and pipelines
  66568. */
  66569. dispose(): void;
  66570. }
  66571. }
  66572. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  66573. import { ISceneComponent } from "babylonjs/sceneComponent";
  66574. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66575. import { Scene } from "babylonjs/scene";
  66576. module "babylonjs/scene" {
  66577. interface Scene {
  66578. /** @hidden (Backing field) */
  66579. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66580. /**
  66581. * Gets the postprocess render pipeline manager
  66582. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66583. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66584. */
  66585. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66586. }
  66587. }
  66588. /**
  66589. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66590. */
  66591. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66592. /**
  66593. * The component name helpfull to identify the component in the list of scene components.
  66594. */
  66595. readonly name: string;
  66596. /**
  66597. * The scene the component belongs to.
  66598. */
  66599. scene: Scene;
  66600. /**
  66601. * Creates a new instance of the component for the given scene
  66602. * @param scene Defines the scene to register the component in
  66603. */
  66604. constructor(scene: Scene);
  66605. /**
  66606. * Registers the component in a given scene
  66607. */
  66608. register(): void;
  66609. /**
  66610. * Rebuilds the elements related to this component in case of
  66611. * context lost for instance.
  66612. */
  66613. rebuild(): void;
  66614. /**
  66615. * Disposes the component and the associated ressources
  66616. */
  66617. dispose(): void;
  66618. private _gatherRenderTargets;
  66619. }
  66620. }
  66621. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  66622. import { Nullable } from "babylonjs/types";
  66623. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66624. import { Camera } from "babylonjs/Cameras/camera";
  66625. import { IDisposable } from "babylonjs/scene";
  66626. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  66627. import { Scene } from "babylonjs/scene";
  66628. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  66629. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66630. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66631. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  66632. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66633. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66634. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  66635. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66636. import { Animation } from "babylonjs/Animations/animation";
  66637. /**
  66638. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66639. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66640. */
  66641. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66642. private _scene;
  66643. private _camerasToBeAttached;
  66644. /**
  66645. * ID of the sharpen post process,
  66646. */
  66647. private readonly SharpenPostProcessId;
  66648. /**
  66649. * @ignore
  66650. * ID of the image processing post process;
  66651. */
  66652. readonly ImageProcessingPostProcessId: string;
  66653. /**
  66654. * @ignore
  66655. * ID of the Fast Approximate Anti-Aliasing post process;
  66656. */
  66657. readonly FxaaPostProcessId: string;
  66658. /**
  66659. * ID of the chromatic aberration post process,
  66660. */
  66661. private readonly ChromaticAberrationPostProcessId;
  66662. /**
  66663. * ID of the grain post process
  66664. */
  66665. private readonly GrainPostProcessId;
  66666. /**
  66667. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66668. */
  66669. sharpen: SharpenPostProcess;
  66670. private _sharpenEffect;
  66671. private bloom;
  66672. /**
  66673. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66674. */
  66675. depthOfField: DepthOfFieldEffect;
  66676. /**
  66677. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66678. */
  66679. fxaa: FxaaPostProcess;
  66680. /**
  66681. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66682. */
  66683. imageProcessing: ImageProcessingPostProcess;
  66684. /**
  66685. * Chromatic aberration post process which will shift rgb colors in the image
  66686. */
  66687. chromaticAberration: ChromaticAberrationPostProcess;
  66688. private _chromaticAberrationEffect;
  66689. /**
  66690. * Grain post process which add noise to the image
  66691. */
  66692. grain: GrainPostProcess;
  66693. private _grainEffect;
  66694. /**
  66695. * Glow post process which adds a glow to emissive areas of the image
  66696. */
  66697. private _glowLayer;
  66698. /**
  66699. * Animations which can be used to tweak settings over a period of time
  66700. */
  66701. animations: Animation[];
  66702. private _imageProcessingConfigurationObserver;
  66703. private _sharpenEnabled;
  66704. private _bloomEnabled;
  66705. private _depthOfFieldEnabled;
  66706. private _depthOfFieldBlurLevel;
  66707. private _fxaaEnabled;
  66708. private _imageProcessingEnabled;
  66709. private _defaultPipelineTextureType;
  66710. private _bloomScale;
  66711. private _chromaticAberrationEnabled;
  66712. private _grainEnabled;
  66713. private _buildAllowed;
  66714. /**
  66715. * Gets active scene
  66716. */
  66717. get scene(): Scene;
  66718. /**
  66719. * Enable or disable the sharpen process from the pipeline
  66720. */
  66721. set sharpenEnabled(enabled: boolean);
  66722. get sharpenEnabled(): boolean;
  66723. private _resizeObserver;
  66724. private _hardwareScaleLevel;
  66725. private _bloomKernel;
  66726. /**
  66727. * Specifies the size of the bloom blur kernel, relative to the final output size
  66728. */
  66729. get bloomKernel(): number;
  66730. set bloomKernel(value: number);
  66731. /**
  66732. * Specifies the weight of the bloom in the final rendering
  66733. */
  66734. private _bloomWeight;
  66735. /**
  66736. * Specifies the luma threshold for the area that will be blurred by the bloom
  66737. */
  66738. private _bloomThreshold;
  66739. private _hdr;
  66740. /**
  66741. * The strength of the bloom.
  66742. */
  66743. set bloomWeight(value: number);
  66744. get bloomWeight(): number;
  66745. /**
  66746. * The strength of the bloom.
  66747. */
  66748. set bloomThreshold(value: number);
  66749. get bloomThreshold(): number;
  66750. /**
  66751. * The scale of the bloom, lower value will provide better performance.
  66752. */
  66753. set bloomScale(value: number);
  66754. get bloomScale(): number;
  66755. /**
  66756. * Enable or disable the bloom from the pipeline
  66757. */
  66758. set bloomEnabled(enabled: boolean);
  66759. get bloomEnabled(): boolean;
  66760. private _rebuildBloom;
  66761. /**
  66762. * If the depth of field is enabled.
  66763. */
  66764. get depthOfFieldEnabled(): boolean;
  66765. set depthOfFieldEnabled(enabled: boolean);
  66766. /**
  66767. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66768. */
  66769. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66770. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66771. /**
  66772. * If the anti aliasing is enabled.
  66773. */
  66774. set fxaaEnabled(enabled: boolean);
  66775. get fxaaEnabled(): boolean;
  66776. private _samples;
  66777. /**
  66778. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66779. */
  66780. set samples(sampleCount: number);
  66781. get samples(): number;
  66782. /**
  66783. * If image processing is enabled.
  66784. */
  66785. set imageProcessingEnabled(enabled: boolean);
  66786. get imageProcessingEnabled(): boolean;
  66787. /**
  66788. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66789. */
  66790. set glowLayerEnabled(enabled: boolean);
  66791. get glowLayerEnabled(): boolean;
  66792. /**
  66793. * Gets the glow layer (or null if not defined)
  66794. */
  66795. get glowLayer(): Nullable<GlowLayer>;
  66796. /**
  66797. * Enable or disable the chromaticAberration process from the pipeline
  66798. */
  66799. set chromaticAberrationEnabled(enabled: boolean);
  66800. get chromaticAberrationEnabled(): boolean;
  66801. /**
  66802. * Enable or disable the grain process from the pipeline
  66803. */
  66804. set grainEnabled(enabled: boolean);
  66805. get grainEnabled(): boolean;
  66806. /**
  66807. * @constructor
  66808. * @param name - The rendering pipeline name (default: "")
  66809. * @param hdr - If high dynamic range textures should be used (default: true)
  66810. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66811. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66812. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66813. */
  66814. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66815. /**
  66816. * Get the class name
  66817. * @returns "DefaultRenderingPipeline"
  66818. */
  66819. getClassName(): string;
  66820. /**
  66821. * Force the compilation of the entire pipeline.
  66822. */
  66823. prepare(): void;
  66824. private _hasCleared;
  66825. private _prevPostProcess;
  66826. private _prevPrevPostProcess;
  66827. private _setAutoClearAndTextureSharing;
  66828. private _depthOfFieldSceneObserver;
  66829. private _buildPipeline;
  66830. private _disposePostProcesses;
  66831. /**
  66832. * Adds a camera to the pipeline
  66833. * @param camera the camera to be added
  66834. */
  66835. addCamera(camera: Camera): void;
  66836. /**
  66837. * Removes a camera from the pipeline
  66838. * @param camera the camera to remove
  66839. */
  66840. removeCamera(camera: Camera): void;
  66841. /**
  66842. * Dispose of the pipeline and stop all post processes
  66843. */
  66844. dispose(): void;
  66845. /**
  66846. * Serialize the rendering pipeline (Used when exporting)
  66847. * @returns the serialized object
  66848. */
  66849. serialize(): any;
  66850. /**
  66851. * Parse the serialized pipeline
  66852. * @param source Source pipeline.
  66853. * @param scene The scene to load the pipeline to.
  66854. * @param rootUrl The URL of the serialized pipeline.
  66855. * @returns An instantiated pipeline from the serialized object.
  66856. */
  66857. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66858. }
  66859. }
  66860. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  66861. /** @hidden */
  66862. export var lensHighlightsPixelShader: {
  66863. name: string;
  66864. shader: string;
  66865. };
  66866. }
  66867. declare module "babylonjs/Shaders/depthOfField.fragment" {
  66868. /** @hidden */
  66869. export var depthOfFieldPixelShader: {
  66870. name: string;
  66871. shader: string;
  66872. };
  66873. }
  66874. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  66875. import { Camera } from "babylonjs/Cameras/camera";
  66876. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66877. import { Scene } from "babylonjs/scene";
  66878. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66879. import "babylonjs/Shaders/chromaticAberration.fragment";
  66880. import "babylonjs/Shaders/lensHighlights.fragment";
  66881. import "babylonjs/Shaders/depthOfField.fragment";
  66882. /**
  66883. * BABYLON.JS Chromatic Aberration GLSL Shader
  66884. * Author: Olivier Guyot
  66885. * Separates very slightly R, G and B colors on the edges of the screen
  66886. * Inspired by Francois Tarlier & Martins Upitis
  66887. */
  66888. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66889. /**
  66890. * @ignore
  66891. * The chromatic aberration PostProcess id in the pipeline
  66892. */
  66893. LensChromaticAberrationEffect: string;
  66894. /**
  66895. * @ignore
  66896. * The highlights enhancing PostProcess id in the pipeline
  66897. */
  66898. HighlightsEnhancingEffect: string;
  66899. /**
  66900. * @ignore
  66901. * The depth-of-field PostProcess id in the pipeline
  66902. */
  66903. LensDepthOfFieldEffect: string;
  66904. private _scene;
  66905. private _depthTexture;
  66906. private _grainTexture;
  66907. private _chromaticAberrationPostProcess;
  66908. private _highlightsPostProcess;
  66909. private _depthOfFieldPostProcess;
  66910. private _edgeBlur;
  66911. private _grainAmount;
  66912. private _chromaticAberration;
  66913. private _distortion;
  66914. private _highlightsGain;
  66915. private _highlightsThreshold;
  66916. private _dofDistance;
  66917. private _dofAperture;
  66918. private _dofDarken;
  66919. private _dofPentagon;
  66920. private _blurNoise;
  66921. /**
  66922. * @constructor
  66923. *
  66924. * Effect parameters are as follow:
  66925. * {
  66926. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66927. * edge_blur: number; // from 0 to x (1 for realism)
  66928. * distortion: number; // from 0 to x (1 for realism)
  66929. * grain_amount: number; // from 0 to 1
  66930. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66931. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66932. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66933. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66934. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66935. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66936. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66937. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66938. * }
  66939. * Note: if an effect parameter is unset, effect is disabled
  66940. *
  66941. * @param name The rendering pipeline name
  66942. * @param parameters - An object containing all parameters (see above)
  66943. * @param scene The scene linked to this pipeline
  66944. * @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)
  66945. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66946. */
  66947. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66948. /**
  66949. * Get the class name
  66950. * @returns "LensRenderingPipeline"
  66951. */
  66952. getClassName(): string;
  66953. /**
  66954. * Gets associated scene
  66955. */
  66956. get scene(): Scene;
  66957. /**
  66958. * Gets or sets the edge blur
  66959. */
  66960. get edgeBlur(): number;
  66961. set edgeBlur(value: number);
  66962. /**
  66963. * Gets or sets the grain amount
  66964. */
  66965. get grainAmount(): number;
  66966. set grainAmount(value: number);
  66967. /**
  66968. * Gets or sets the chromatic aberration amount
  66969. */
  66970. get chromaticAberration(): number;
  66971. set chromaticAberration(value: number);
  66972. /**
  66973. * Gets or sets the depth of field aperture
  66974. */
  66975. get dofAperture(): number;
  66976. set dofAperture(value: number);
  66977. /**
  66978. * Gets or sets the edge distortion
  66979. */
  66980. get edgeDistortion(): number;
  66981. set edgeDistortion(value: number);
  66982. /**
  66983. * Gets or sets the depth of field distortion
  66984. */
  66985. get dofDistortion(): number;
  66986. set dofDistortion(value: number);
  66987. /**
  66988. * Gets or sets the darken out of focus amount
  66989. */
  66990. get darkenOutOfFocus(): number;
  66991. set darkenOutOfFocus(value: number);
  66992. /**
  66993. * Gets or sets a boolean indicating if blur noise is enabled
  66994. */
  66995. get blurNoise(): boolean;
  66996. set blurNoise(value: boolean);
  66997. /**
  66998. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66999. */
  67000. get pentagonBokeh(): boolean;
  67001. set pentagonBokeh(value: boolean);
  67002. /**
  67003. * Gets or sets the highlight grain amount
  67004. */
  67005. get highlightsGain(): number;
  67006. set highlightsGain(value: number);
  67007. /**
  67008. * Gets or sets the highlight threshold
  67009. */
  67010. get highlightsThreshold(): number;
  67011. set highlightsThreshold(value: number);
  67012. /**
  67013. * Sets the amount of blur at the edges
  67014. * @param amount blur amount
  67015. */
  67016. setEdgeBlur(amount: number): void;
  67017. /**
  67018. * Sets edge blur to 0
  67019. */
  67020. disableEdgeBlur(): void;
  67021. /**
  67022. * Sets the amout of grain
  67023. * @param amount Amount of grain
  67024. */
  67025. setGrainAmount(amount: number): void;
  67026. /**
  67027. * Set grain amount to 0
  67028. */
  67029. disableGrain(): void;
  67030. /**
  67031. * Sets the chromatic aberration amount
  67032. * @param amount amount of chromatic aberration
  67033. */
  67034. setChromaticAberration(amount: number): void;
  67035. /**
  67036. * Sets chromatic aberration amount to 0
  67037. */
  67038. disableChromaticAberration(): void;
  67039. /**
  67040. * Sets the EdgeDistortion amount
  67041. * @param amount amount of EdgeDistortion
  67042. */
  67043. setEdgeDistortion(amount: number): void;
  67044. /**
  67045. * Sets edge distortion to 0
  67046. */
  67047. disableEdgeDistortion(): void;
  67048. /**
  67049. * Sets the FocusDistance amount
  67050. * @param amount amount of FocusDistance
  67051. */
  67052. setFocusDistance(amount: number): void;
  67053. /**
  67054. * Disables depth of field
  67055. */
  67056. disableDepthOfField(): void;
  67057. /**
  67058. * Sets the Aperture amount
  67059. * @param amount amount of Aperture
  67060. */
  67061. setAperture(amount: number): void;
  67062. /**
  67063. * Sets the DarkenOutOfFocus amount
  67064. * @param amount amount of DarkenOutOfFocus
  67065. */
  67066. setDarkenOutOfFocus(amount: number): void;
  67067. private _pentagonBokehIsEnabled;
  67068. /**
  67069. * Creates a pentagon bokeh effect
  67070. */
  67071. enablePentagonBokeh(): void;
  67072. /**
  67073. * Disables the pentagon bokeh effect
  67074. */
  67075. disablePentagonBokeh(): void;
  67076. /**
  67077. * Enables noise blur
  67078. */
  67079. enableNoiseBlur(): void;
  67080. /**
  67081. * Disables noise blur
  67082. */
  67083. disableNoiseBlur(): void;
  67084. /**
  67085. * Sets the HighlightsGain amount
  67086. * @param amount amount of HighlightsGain
  67087. */
  67088. setHighlightsGain(amount: number): void;
  67089. /**
  67090. * Sets the HighlightsThreshold amount
  67091. * @param amount amount of HighlightsThreshold
  67092. */
  67093. setHighlightsThreshold(amount: number): void;
  67094. /**
  67095. * Disables highlights
  67096. */
  67097. disableHighlights(): void;
  67098. /**
  67099. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67100. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67101. */
  67102. dispose(disableDepthRender?: boolean): void;
  67103. private _createChromaticAberrationPostProcess;
  67104. private _createHighlightsPostProcess;
  67105. private _createDepthOfFieldPostProcess;
  67106. private _createGrainTexture;
  67107. }
  67108. }
  67109. declare module "babylonjs/Shaders/ssao2.fragment" {
  67110. /** @hidden */
  67111. export var ssao2PixelShader: {
  67112. name: string;
  67113. shader: string;
  67114. };
  67115. }
  67116. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67117. /** @hidden */
  67118. export var ssaoCombinePixelShader: {
  67119. name: string;
  67120. shader: string;
  67121. };
  67122. }
  67123. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67124. import { Camera } from "babylonjs/Cameras/camera";
  67125. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67126. import { Scene } from "babylonjs/scene";
  67127. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67128. import "babylonjs/Shaders/ssao2.fragment";
  67129. import "babylonjs/Shaders/ssaoCombine.fragment";
  67130. /**
  67131. * Render pipeline to produce ssao effect
  67132. */
  67133. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67134. /**
  67135. * @ignore
  67136. * The PassPostProcess id in the pipeline that contains the original scene color
  67137. */
  67138. SSAOOriginalSceneColorEffect: string;
  67139. /**
  67140. * @ignore
  67141. * The SSAO PostProcess id in the pipeline
  67142. */
  67143. SSAORenderEffect: string;
  67144. /**
  67145. * @ignore
  67146. * The horizontal blur PostProcess id in the pipeline
  67147. */
  67148. SSAOBlurHRenderEffect: string;
  67149. /**
  67150. * @ignore
  67151. * The vertical blur PostProcess id in the pipeline
  67152. */
  67153. SSAOBlurVRenderEffect: string;
  67154. /**
  67155. * @ignore
  67156. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67157. */
  67158. SSAOCombineRenderEffect: string;
  67159. /**
  67160. * The output strength of the SSAO post-process. Default value is 1.0.
  67161. */
  67162. totalStrength: number;
  67163. /**
  67164. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67165. */
  67166. maxZ: number;
  67167. /**
  67168. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67169. */
  67170. minZAspect: number;
  67171. private _samples;
  67172. /**
  67173. * Number of samples used for the SSAO calculations. Default value is 8
  67174. */
  67175. set samples(n: number);
  67176. get samples(): number;
  67177. private _textureSamples;
  67178. /**
  67179. * Number of samples to use for antialiasing
  67180. */
  67181. set textureSamples(n: number);
  67182. get textureSamples(): number;
  67183. /**
  67184. * Ratio object used for SSAO ratio and blur ratio
  67185. */
  67186. private _ratio;
  67187. /**
  67188. * Dynamically generated sphere sampler.
  67189. */
  67190. private _sampleSphere;
  67191. /**
  67192. * Blur filter offsets
  67193. */
  67194. private _samplerOffsets;
  67195. private _expensiveBlur;
  67196. /**
  67197. * If bilateral blur should be used
  67198. */
  67199. set expensiveBlur(b: boolean);
  67200. get expensiveBlur(): boolean;
  67201. /**
  67202. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67203. */
  67204. radius: number;
  67205. /**
  67206. * The base color of the SSAO post-process
  67207. * The final result is "base + ssao" between [0, 1]
  67208. */
  67209. base: number;
  67210. /**
  67211. * Support test.
  67212. */
  67213. static get IsSupported(): boolean;
  67214. private _scene;
  67215. private _depthTexture;
  67216. private _normalTexture;
  67217. private _randomTexture;
  67218. private _originalColorPostProcess;
  67219. private _ssaoPostProcess;
  67220. private _blurHPostProcess;
  67221. private _blurVPostProcess;
  67222. private _ssaoCombinePostProcess;
  67223. /**
  67224. * Gets active scene
  67225. */
  67226. get scene(): Scene;
  67227. /**
  67228. * @constructor
  67229. * @param name The rendering pipeline name
  67230. * @param scene The scene linked to this pipeline
  67231. * @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 }
  67232. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67233. */
  67234. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67235. /**
  67236. * Get the class name
  67237. * @returns "SSAO2RenderingPipeline"
  67238. */
  67239. getClassName(): string;
  67240. /**
  67241. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67242. */
  67243. dispose(disableGeometryBufferRenderer?: boolean): void;
  67244. private _createBlurPostProcess;
  67245. /** @hidden */
  67246. _rebuild(): void;
  67247. private _bits;
  67248. private _radicalInverse_VdC;
  67249. private _hammersley;
  67250. private _hemisphereSample_uniform;
  67251. private _generateHemisphere;
  67252. private _createSSAOPostProcess;
  67253. private _createSSAOCombinePostProcess;
  67254. private _createRandomTexture;
  67255. /**
  67256. * Serialize the rendering pipeline (Used when exporting)
  67257. * @returns the serialized object
  67258. */
  67259. serialize(): any;
  67260. /**
  67261. * Parse the serialized pipeline
  67262. * @param source Source pipeline.
  67263. * @param scene The scene to load the pipeline to.
  67264. * @param rootUrl The URL of the serialized pipeline.
  67265. * @returns An instantiated pipeline from the serialized object.
  67266. */
  67267. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67268. }
  67269. }
  67270. declare module "babylonjs/Shaders/ssao.fragment" {
  67271. /** @hidden */
  67272. export var ssaoPixelShader: {
  67273. name: string;
  67274. shader: string;
  67275. };
  67276. }
  67277. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  67278. import { Camera } from "babylonjs/Cameras/camera";
  67279. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67280. import { Scene } from "babylonjs/scene";
  67281. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67282. import "babylonjs/Shaders/ssao.fragment";
  67283. import "babylonjs/Shaders/ssaoCombine.fragment";
  67284. /**
  67285. * Render pipeline to produce ssao effect
  67286. */
  67287. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67288. /**
  67289. * @ignore
  67290. * The PassPostProcess id in the pipeline that contains the original scene color
  67291. */
  67292. SSAOOriginalSceneColorEffect: string;
  67293. /**
  67294. * @ignore
  67295. * The SSAO PostProcess id in the pipeline
  67296. */
  67297. SSAORenderEffect: string;
  67298. /**
  67299. * @ignore
  67300. * The horizontal blur PostProcess id in the pipeline
  67301. */
  67302. SSAOBlurHRenderEffect: string;
  67303. /**
  67304. * @ignore
  67305. * The vertical blur PostProcess id in the pipeline
  67306. */
  67307. SSAOBlurVRenderEffect: string;
  67308. /**
  67309. * @ignore
  67310. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67311. */
  67312. SSAOCombineRenderEffect: string;
  67313. /**
  67314. * The output strength of the SSAO post-process. Default value is 1.0.
  67315. */
  67316. totalStrength: number;
  67317. /**
  67318. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  67319. */
  67320. radius: number;
  67321. /**
  67322. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  67323. * Must not be equal to fallOff and superior to fallOff.
  67324. * Default value is 0.0075
  67325. */
  67326. area: number;
  67327. /**
  67328. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  67329. * Must not be equal to area and inferior to area.
  67330. * Default value is 0.000001
  67331. */
  67332. fallOff: number;
  67333. /**
  67334. * The base color of the SSAO post-process
  67335. * The final result is "base + ssao" between [0, 1]
  67336. */
  67337. base: number;
  67338. private _scene;
  67339. private _depthTexture;
  67340. private _randomTexture;
  67341. private _originalColorPostProcess;
  67342. private _ssaoPostProcess;
  67343. private _blurHPostProcess;
  67344. private _blurVPostProcess;
  67345. private _ssaoCombinePostProcess;
  67346. private _firstUpdate;
  67347. /**
  67348. * Gets active scene
  67349. */
  67350. get scene(): Scene;
  67351. /**
  67352. * @constructor
  67353. * @param name - The rendering pipeline name
  67354. * @param scene - The scene linked to this pipeline
  67355. * @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 }
  67356. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  67357. */
  67358. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67359. /**
  67360. * Get the class name
  67361. * @returns "SSAORenderingPipeline"
  67362. */
  67363. getClassName(): string;
  67364. /**
  67365. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67366. */
  67367. dispose(disableDepthRender?: boolean): void;
  67368. private _createBlurPostProcess;
  67369. /** @hidden */
  67370. _rebuild(): void;
  67371. private _createSSAOPostProcess;
  67372. private _createSSAOCombinePostProcess;
  67373. private _createRandomTexture;
  67374. }
  67375. }
  67376. declare module "babylonjs/Shaders/standard.fragment" {
  67377. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  67378. /** @hidden */
  67379. export var standardPixelShader: {
  67380. name: string;
  67381. shader: string;
  67382. };
  67383. }
  67384. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  67385. import { Nullable } from "babylonjs/types";
  67386. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67387. import { Camera } from "babylonjs/Cameras/camera";
  67388. import { Texture } from "babylonjs/Materials/Textures/texture";
  67389. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67390. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67391. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67392. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67393. import { IDisposable } from "babylonjs/scene";
  67394. import { SpotLight } from "babylonjs/Lights/spotLight";
  67395. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67396. import { Scene } from "babylonjs/scene";
  67397. import { Animation } from "babylonjs/Animations/animation";
  67398. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67399. import "babylonjs/Shaders/standard.fragment";
  67400. /**
  67401. * Standard rendering pipeline
  67402. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67403. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  67404. */
  67405. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67406. /**
  67407. * Public members
  67408. */
  67409. /**
  67410. * Post-process which contains the original scene color before the pipeline applies all the effects
  67411. */
  67412. originalPostProcess: Nullable<PostProcess>;
  67413. /**
  67414. * Post-process used to down scale an image x4
  67415. */
  67416. downSampleX4PostProcess: Nullable<PostProcess>;
  67417. /**
  67418. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  67419. */
  67420. brightPassPostProcess: Nullable<PostProcess>;
  67421. /**
  67422. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  67423. */
  67424. blurHPostProcesses: PostProcess[];
  67425. /**
  67426. * Post-process array storing all the vertical blur post-processes used by the pipeline
  67427. */
  67428. blurVPostProcesses: PostProcess[];
  67429. /**
  67430. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  67431. */
  67432. textureAdderPostProcess: Nullable<PostProcess>;
  67433. /**
  67434. * Post-process used to create volumetric lighting effect
  67435. */
  67436. volumetricLightPostProcess: Nullable<PostProcess>;
  67437. /**
  67438. * Post-process used to smooth the previous volumetric light post-process on the X axis
  67439. */
  67440. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  67441. /**
  67442. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  67443. */
  67444. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  67445. /**
  67446. * Post-process used to merge the volumetric light effect and the real scene color
  67447. */
  67448. volumetricLightMergePostProces: Nullable<PostProcess>;
  67449. /**
  67450. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  67451. */
  67452. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  67453. /**
  67454. * Base post-process used to calculate the average luminance of the final image for HDR
  67455. */
  67456. luminancePostProcess: Nullable<PostProcess>;
  67457. /**
  67458. * Post-processes used to create down sample post-processes in order to get
  67459. * the average luminance of the final image for HDR
  67460. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  67461. */
  67462. luminanceDownSamplePostProcesses: PostProcess[];
  67463. /**
  67464. * Post-process used to create a HDR effect (light adaptation)
  67465. */
  67466. hdrPostProcess: Nullable<PostProcess>;
  67467. /**
  67468. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  67469. */
  67470. textureAdderFinalPostProcess: Nullable<PostProcess>;
  67471. /**
  67472. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  67473. */
  67474. lensFlareFinalPostProcess: Nullable<PostProcess>;
  67475. /**
  67476. * Post-process used to merge the final HDR post-process and the real scene color
  67477. */
  67478. hdrFinalPostProcess: Nullable<PostProcess>;
  67479. /**
  67480. * Post-process used to create a lens flare effect
  67481. */
  67482. lensFlarePostProcess: Nullable<PostProcess>;
  67483. /**
  67484. * Post-process that merges the result of the lens flare post-process and the real scene color
  67485. */
  67486. lensFlareComposePostProcess: Nullable<PostProcess>;
  67487. /**
  67488. * Post-process used to create a motion blur effect
  67489. */
  67490. motionBlurPostProcess: Nullable<PostProcess>;
  67491. /**
  67492. * Post-process used to create a depth of field effect
  67493. */
  67494. depthOfFieldPostProcess: Nullable<PostProcess>;
  67495. /**
  67496. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67497. */
  67498. fxaaPostProcess: Nullable<FxaaPostProcess>;
  67499. /**
  67500. * Represents the brightness threshold in order to configure the illuminated surfaces
  67501. */
  67502. brightThreshold: number;
  67503. /**
  67504. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  67505. */
  67506. blurWidth: number;
  67507. /**
  67508. * Sets if the blur for highlighted surfaces must be only horizontal
  67509. */
  67510. horizontalBlur: boolean;
  67511. /**
  67512. * Gets the overall exposure used by the pipeline
  67513. */
  67514. get exposure(): number;
  67515. /**
  67516. * Sets the overall exposure used by the pipeline
  67517. */
  67518. set exposure(value: number);
  67519. /**
  67520. * Texture used typically to simulate "dirty" on camera lens
  67521. */
  67522. lensTexture: Nullable<Texture>;
  67523. /**
  67524. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67525. */
  67526. volumetricLightCoefficient: number;
  67527. /**
  67528. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67529. */
  67530. volumetricLightPower: number;
  67531. /**
  67532. * Used the set the blur intensity to smooth the volumetric lights
  67533. */
  67534. volumetricLightBlurScale: number;
  67535. /**
  67536. * Light (spot or directional) used to generate the volumetric lights rays
  67537. * The source light must have a shadow generate so the pipeline can get its
  67538. * depth map
  67539. */
  67540. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67541. /**
  67542. * For eye adaptation, represents the minimum luminance the eye can see
  67543. */
  67544. hdrMinimumLuminance: number;
  67545. /**
  67546. * For eye adaptation, represents the decrease luminance speed
  67547. */
  67548. hdrDecreaseRate: number;
  67549. /**
  67550. * For eye adaptation, represents the increase luminance speed
  67551. */
  67552. hdrIncreaseRate: number;
  67553. /**
  67554. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67555. */
  67556. get hdrAutoExposure(): boolean;
  67557. /**
  67558. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67559. */
  67560. set hdrAutoExposure(value: boolean);
  67561. /**
  67562. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67563. */
  67564. lensColorTexture: Nullable<Texture>;
  67565. /**
  67566. * The overall strengh for the lens flare effect
  67567. */
  67568. lensFlareStrength: number;
  67569. /**
  67570. * Dispersion coefficient for lens flare ghosts
  67571. */
  67572. lensFlareGhostDispersal: number;
  67573. /**
  67574. * Main lens flare halo width
  67575. */
  67576. lensFlareHaloWidth: number;
  67577. /**
  67578. * Based on the lens distortion effect, defines how much the lens flare result
  67579. * is distorted
  67580. */
  67581. lensFlareDistortionStrength: number;
  67582. /**
  67583. * Configures the blur intensity used for for lens flare (halo)
  67584. */
  67585. lensFlareBlurWidth: number;
  67586. /**
  67587. * Lens star texture must be used to simulate rays on the flares and is available
  67588. * in the documentation
  67589. */
  67590. lensStarTexture: Nullable<Texture>;
  67591. /**
  67592. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67593. * flare effect by taking account of the dirt texture
  67594. */
  67595. lensFlareDirtTexture: Nullable<Texture>;
  67596. /**
  67597. * Represents the focal length for the depth of field effect
  67598. */
  67599. depthOfFieldDistance: number;
  67600. /**
  67601. * Represents the blur intensity for the blurred part of the depth of field effect
  67602. */
  67603. depthOfFieldBlurWidth: number;
  67604. /**
  67605. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67606. */
  67607. get motionStrength(): number;
  67608. /**
  67609. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67610. */
  67611. set motionStrength(strength: number);
  67612. /**
  67613. * Gets wether or not the motion blur post-process is object based or screen based.
  67614. */
  67615. get objectBasedMotionBlur(): boolean;
  67616. /**
  67617. * Sets wether or not the motion blur post-process should be object based or screen based
  67618. */
  67619. set objectBasedMotionBlur(value: boolean);
  67620. /**
  67621. * List of animations for the pipeline (IAnimatable implementation)
  67622. */
  67623. animations: Animation[];
  67624. /**
  67625. * Private members
  67626. */
  67627. private _scene;
  67628. private _currentDepthOfFieldSource;
  67629. private _basePostProcess;
  67630. private _fixedExposure;
  67631. private _currentExposure;
  67632. private _hdrAutoExposure;
  67633. private _hdrCurrentLuminance;
  67634. private _motionStrength;
  67635. private _isObjectBasedMotionBlur;
  67636. private _floatTextureType;
  67637. private _camerasToBeAttached;
  67638. private _ratio;
  67639. private _bloomEnabled;
  67640. private _depthOfFieldEnabled;
  67641. private _vlsEnabled;
  67642. private _lensFlareEnabled;
  67643. private _hdrEnabled;
  67644. private _motionBlurEnabled;
  67645. private _fxaaEnabled;
  67646. private _motionBlurSamples;
  67647. private _volumetricLightStepsCount;
  67648. private _samples;
  67649. /**
  67650. * @ignore
  67651. * Specifies if the bloom pipeline is enabled
  67652. */
  67653. get BloomEnabled(): boolean;
  67654. set BloomEnabled(enabled: boolean);
  67655. /**
  67656. * @ignore
  67657. * Specifies if the depth of field pipeline is enabed
  67658. */
  67659. get DepthOfFieldEnabled(): boolean;
  67660. set DepthOfFieldEnabled(enabled: boolean);
  67661. /**
  67662. * @ignore
  67663. * Specifies if the lens flare pipeline is enabed
  67664. */
  67665. get LensFlareEnabled(): boolean;
  67666. set LensFlareEnabled(enabled: boolean);
  67667. /**
  67668. * @ignore
  67669. * Specifies if the HDR pipeline is enabled
  67670. */
  67671. get HDREnabled(): boolean;
  67672. set HDREnabled(enabled: boolean);
  67673. /**
  67674. * @ignore
  67675. * Specifies if the volumetric lights scattering effect is enabled
  67676. */
  67677. get VLSEnabled(): boolean;
  67678. set VLSEnabled(enabled: boolean);
  67679. /**
  67680. * @ignore
  67681. * Specifies if the motion blur effect is enabled
  67682. */
  67683. get MotionBlurEnabled(): boolean;
  67684. set MotionBlurEnabled(enabled: boolean);
  67685. /**
  67686. * Specifies if anti-aliasing is enabled
  67687. */
  67688. get fxaaEnabled(): boolean;
  67689. set fxaaEnabled(enabled: boolean);
  67690. /**
  67691. * Specifies the number of steps used to calculate the volumetric lights
  67692. * Typically in interval [50, 200]
  67693. */
  67694. get volumetricLightStepsCount(): number;
  67695. set volumetricLightStepsCount(count: number);
  67696. /**
  67697. * Specifies the number of samples used for the motion blur effect
  67698. * Typically in interval [16, 64]
  67699. */
  67700. get motionBlurSamples(): number;
  67701. set motionBlurSamples(samples: number);
  67702. /**
  67703. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67704. */
  67705. get samples(): number;
  67706. set samples(sampleCount: number);
  67707. /**
  67708. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67709. * @constructor
  67710. * @param name The rendering pipeline name
  67711. * @param scene The scene linked to this pipeline
  67712. * @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)
  67713. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67714. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67715. */
  67716. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67717. private _buildPipeline;
  67718. private _createDownSampleX4PostProcess;
  67719. private _createBrightPassPostProcess;
  67720. private _createBlurPostProcesses;
  67721. private _createTextureAdderPostProcess;
  67722. private _createVolumetricLightPostProcess;
  67723. private _createLuminancePostProcesses;
  67724. private _createHdrPostProcess;
  67725. private _createLensFlarePostProcess;
  67726. private _createDepthOfFieldPostProcess;
  67727. private _createMotionBlurPostProcess;
  67728. private _getDepthTexture;
  67729. private _disposePostProcesses;
  67730. /**
  67731. * Dispose of the pipeline and stop all post processes
  67732. */
  67733. dispose(): void;
  67734. /**
  67735. * Serialize the rendering pipeline (Used when exporting)
  67736. * @returns the serialized object
  67737. */
  67738. serialize(): any;
  67739. /**
  67740. * Parse the serialized pipeline
  67741. * @param source Source pipeline.
  67742. * @param scene The scene to load the pipeline to.
  67743. * @param rootUrl The URL of the serialized pipeline.
  67744. * @returns An instantiated pipeline from the serialized object.
  67745. */
  67746. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67747. /**
  67748. * Luminance steps
  67749. */
  67750. static LuminanceSteps: number;
  67751. }
  67752. }
  67753. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  67754. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  67755. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  67756. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  67757. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  67758. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  67759. }
  67760. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  67761. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  67762. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67763. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67764. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67765. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67766. }
  67767. declare module "babylonjs/Shaders/tonemap.fragment" {
  67768. /** @hidden */
  67769. export var tonemapPixelShader: {
  67770. name: string;
  67771. shader: string;
  67772. };
  67773. }
  67774. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  67775. import { Camera } from "babylonjs/Cameras/camera";
  67776. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67777. import "babylonjs/Shaders/tonemap.fragment";
  67778. import { Engine } from "babylonjs/Engines/engine";
  67779. /** Defines operator used for tonemapping */
  67780. export enum TonemappingOperator {
  67781. /** Hable */
  67782. Hable = 0,
  67783. /** Reinhard */
  67784. Reinhard = 1,
  67785. /** HejiDawson */
  67786. HejiDawson = 2,
  67787. /** Photographic */
  67788. Photographic = 3
  67789. }
  67790. /**
  67791. * Defines a post process to apply tone mapping
  67792. */
  67793. export class TonemapPostProcess extends PostProcess {
  67794. private _operator;
  67795. /** Defines the required exposure adjustement */
  67796. exposureAdjustment: number;
  67797. /**
  67798. * Creates a new TonemapPostProcess
  67799. * @param name defines the name of the postprocess
  67800. * @param _operator defines the operator to use
  67801. * @param exposureAdjustment defines the required exposure adjustement
  67802. * @param camera defines the camera to use (can be null)
  67803. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67804. * @param engine defines the hosting engine (can be ignore if camera is set)
  67805. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67806. */
  67807. constructor(name: string, _operator: TonemappingOperator,
  67808. /** Defines the required exposure adjustement */
  67809. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67810. }
  67811. }
  67812. declare module "babylonjs/Shaders/depth.vertex" {
  67813. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67814. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67815. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67816. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67818. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67819. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67820. /** @hidden */
  67821. export var depthVertexShader: {
  67822. name: string;
  67823. shader: string;
  67824. };
  67825. }
  67826. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  67827. /** @hidden */
  67828. export var volumetricLightScatteringPixelShader: {
  67829. name: string;
  67830. shader: string;
  67831. };
  67832. }
  67833. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  67834. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67835. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67836. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67837. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67838. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67839. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67840. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67841. /** @hidden */
  67842. export var volumetricLightScatteringPassVertexShader: {
  67843. name: string;
  67844. shader: string;
  67845. };
  67846. }
  67847. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  67848. /** @hidden */
  67849. export var volumetricLightScatteringPassPixelShader: {
  67850. name: string;
  67851. shader: string;
  67852. };
  67853. }
  67854. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  67855. import { Vector3 } from "babylonjs/Maths/math.vector";
  67856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67857. import { Mesh } from "babylonjs/Meshes/mesh";
  67858. import { Camera } from "babylonjs/Cameras/camera";
  67859. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67860. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67861. import { Scene } from "babylonjs/scene";
  67862. import "babylonjs/Meshes/Builders/planeBuilder";
  67863. import "babylonjs/Shaders/depth.vertex";
  67864. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  67865. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  67866. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  67867. import { Engine } from "babylonjs/Engines/engine";
  67868. /**
  67869. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67870. */
  67871. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67872. private _volumetricLightScatteringPass;
  67873. private _volumetricLightScatteringRTT;
  67874. private _viewPort;
  67875. private _screenCoordinates;
  67876. private _cachedDefines;
  67877. /**
  67878. * If not undefined, the mesh position is computed from the attached node position
  67879. */
  67880. attachedNode: {
  67881. position: Vector3;
  67882. };
  67883. /**
  67884. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67885. */
  67886. customMeshPosition: Vector3;
  67887. /**
  67888. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67889. */
  67890. useCustomMeshPosition: boolean;
  67891. /**
  67892. * If the post-process should inverse the light scattering direction
  67893. */
  67894. invert: boolean;
  67895. /**
  67896. * The internal mesh used by the post-process
  67897. */
  67898. mesh: Mesh;
  67899. /**
  67900. * @hidden
  67901. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67902. */
  67903. get useDiffuseColor(): boolean;
  67904. set useDiffuseColor(useDiffuseColor: boolean);
  67905. /**
  67906. * Array containing the excluded meshes not rendered in the internal pass
  67907. */
  67908. excludedMeshes: AbstractMesh[];
  67909. /**
  67910. * Controls the overall intensity of the post-process
  67911. */
  67912. exposure: number;
  67913. /**
  67914. * Dissipates each sample's contribution in range [0, 1]
  67915. */
  67916. decay: number;
  67917. /**
  67918. * Controls the overall intensity of each sample
  67919. */
  67920. weight: number;
  67921. /**
  67922. * Controls the density of each sample
  67923. */
  67924. density: number;
  67925. /**
  67926. * @constructor
  67927. * @param name The post-process name
  67928. * @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)
  67929. * @param camera The camera that the post-process will be attached to
  67930. * @param mesh The mesh used to create the light scattering
  67931. * @param samples The post-process quality, default 100
  67932. * @param samplingModeThe post-process filtering mode
  67933. * @param engine The babylon engine
  67934. * @param reusable If the post-process is reusable
  67935. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67936. */
  67937. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67938. /**
  67939. * Returns the string "VolumetricLightScatteringPostProcess"
  67940. * @returns "VolumetricLightScatteringPostProcess"
  67941. */
  67942. getClassName(): string;
  67943. private _isReady;
  67944. /**
  67945. * Sets the new light position for light scattering effect
  67946. * @param position The new custom light position
  67947. */
  67948. setCustomMeshPosition(position: Vector3): void;
  67949. /**
  67950. * Returns the light position for light scattering effect
  67951. * @return Vector3 The custom light position
  67952. */
  67953. getCustomMeshPosition(): Vector3;
  67954. /**
  67955. * Disposes the internal assets and detaches the post-process from the camera
  67956. */
  67957. dispose(camera: Camera): void;
  67958. /**
  67959. * Returns the render target texture used by the post-process
  67960. * @return the render target texture used by the post-process
  67961. */
  67962. getPass(): RenderTargetTexture;
  67963. private _meshExcluded;
  67964. private _createPass;
  67965. private _updateMeshScreenCoordinates;
  67966. /**
  67967. * Creates a default mesh for the Volumeric Light Scattering post-process
  67968. * @param name The mesh name
  67969. * @param scene The scene where to create the mesh
  67970. * @return the default mesh
  67971. */
  67972. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67973. }
  67974. }
  67975. declare module "babylonjs/PostProcesses/index" {
  67976. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  67977. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  67978. export * from "babylonjs/PostProcesses/bloomEffect";
  67979. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  67980. export * from "babylonjs/PostProcesses/blurPostProcess";
  67981. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  67982. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  67983. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  67984. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  67985. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67986. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  67987. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  67988. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  67989. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67990. export * from "babylonjs/PostProcesses/filterPostProcess";
  67991. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  67992. export * from "babylonjs/PostProcesses/grainPostProcess";
  67993. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  67994. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  67995. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  67996. export * from "babylonjs/PostProcesses/passPostProcess";
  67997. export * from "babylonjs/PostProcesses/postProcess";
  67998. export * from "babylonjs/PostProcesses/postProcessManager";
  67999. export * from "babylonjs/PostProcesses/refractionPostProcess";
  68000. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68001. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68002. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68003. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68004. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68005. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68006. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68007. }
  68008. declare module "babylonjs/Probes/index" {
  68009. export * from "babylonjs/Probes/reflectionProbe";
  68010. }
  68011. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68012. import { Scene } from "babylonjs/scene";
  68013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68014. import { SmartArray } from "babylonjs/Misc/smartArray";
  68015. import { ISceneComponent } from "babylonjs/sceneComponent";
  68016. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68017. import "babylonjs/Meshes/Builders/boxBuilder";
  68018. import "babylonjs/Shaders/color.fragment";
  68019. import "babylonjs/Shaders/color.vertex";
  68020. import { Color3 } from "babylonjs/Maths/math.color";
  68021. module "babylonjs/scene" {
  68022. interface Scene {
  68023. /** @hidden (Backing field) */
  68024. _boundingBoxRenderer: BoundingBoxRenderer;
  68025. /** @hidden (Backing field) */
  68026. _forceShowBoundingBoxes: boolean;
  68027. /**
  68028. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68029. */
  68030. forceShowBoundingBoxes: boolean;
  68031. /**
  68032. * Gets the bounding box renderer associated with the scene
  68033. * @returns a BoundingBoxRenderer
  68034. */
  68035. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68036. }
  68037. }
  68038. module "babylonjs/Meshes/abstractMesh" {
  68039. interface AbstractMesh {
  68040. /** @hidden (Backing field) */
  68041. _showBoundingBox: boolean;
  68042. /**
  68043. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68044. */
  68045. showBoundingBox: boolean;
  68046. }
  68047. }
  68048. /**
  68049. * Component responsible of rendering the bounding box of the meshes in a scene.
  68050. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68051. */
  68052. export class BoundingBoxRenderer implements ISceneComponent {
  68053. /**
  68054. * The component name helpfull to identify the component in the list of scene components.
  68055. */
  68056. readonly name: string;
  68057. /**
  68058. * The scene the component belongs to.
  68059. */
  68060. scene: Scene;
  68061. /**
  68062. * Color of the bounding box lines placed in front of an object
  68063. */
  68064. frontColor: Color3;
  68065. /**
  68066. * Color of the bounding box lines placed behind an object
  68067. */
  68068. backColor: Color3;
  68069. /**
  68070. * Defines if the renderer should show the back lines or not
  68071. */
  68072. showBackLines: boolean;
  68073. /**
  68074. * @hidden
  68075. */
  68076. renderList: SmartArray<BoundingBox>;
  68077. private _colorShader;
  68078. private _vertexBuffers;
  68079. private _indexBuffer;
  68080. private _fillIndexBuffer;
  68081. private _fillIndexData;
  68082. /**
  68083. * Instantiates a new bounding box renderer in a scene.
  68084. * @param scene the scene the renderer renders in
  68085. */
  68086. constructor(scene: Scene);
  68087. /**
  68088. * Registers the component in a given scene
  68089. */
  68090. register(): void;
  68091. private _evaluateSubMesh;
  68092. private _activeMesh;
  68093. private _prepareRessources;
  68094. private _createIndexBuffer;
  68095. /**
  68096. * Rebuilds the elements related to this component in case of
  68097. * context lost for instance.
  68098. */
  68099. rebuild(): void;
  68100. /**
  68101. * @hidden
  68102. */
  68103. reset(): void;
  68104. /**
  68105. * Render the bounding boxes of a specific rendering group
  68106. * @param renderingGroupId defines the rendering group to render
  68107. */
  68108. render(renderingGroupId: number): void;
  68109. /**
  68110. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68111. * @param mesh Define the mesh to render the occlusion bounding box for
  68112. */
  68113. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68114. /**
  68115. * Dispose and release the resources attached to this renderer.
  68116. */
  68117. dispose(): void;
  68118. }
  68119. }
  68120. declare module "babylonjs/Shaders/depth.fragment" {
  68121. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68122. /** @hidden */
  68123. export var depthPixelShader: {
  68124. name: string;
  68125. shader: string;
  68126. };
  68127. }
  68128. declare module "babylonjs/Rendering/depthRenderer" {
  68129. import { Nullable } from "babylonjs/types";
  68130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68131. import { Scene } from "babylonjs/scene";
  68132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68133. import { Camera } from "babylonjs/Cameras/camera";
  68134. import "babylonjs/Shaders/depth.fragment";
  68135. import "babylonjs/Shaders/depth.vertex";
  68136. /**
  68137. * This represents a depth renderer in Babylon.
  68138. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68139. */
  68140. export class DepthRenderer {
  68141. private _scene;
  68142. private _depthMap;
  68143. private _effect;
  68144. private readonly _storeNonLinearDepth;
  68145. private readonly _clearColor;
  68146. /** Get if the depth renderer is using packed depth or not */
  68147. readonly isPacked: boolean;
  68148. private _cachedDefines;
  68149. private _camera;
  68150. /**
  68151. * Specifiess that the depth renderer will only be used within
  68152. * the camera it is created for.
  68153. * This can help forcing its rendering during the camera processing.
  68154. */
  68155. useOnlyInActiveCamera: boolean;
  68156. /** @hidden */
  68157. static _SceneComponentInitialization: (scene: Scene) => void;
  68158. /**
  68159. * Instantiates a depth renderer
  68160. * @param scene The scene the renderer belongs to
  68161. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  68162. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  68163. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68164. */
  68165. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  68166. /**
  68167. * Creates the depth rendering effect and checks if the effect is ready.
  68168. * @param subMesh The submesh to be used to render the depth map of
  68169. * @param useInstances If multiple world instances should be used
  68170. * @returns if the depth renderer is ready to render the depth map
  68171. */
  68172. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68173. /**
  68174. * Gets the texture which the depth map will be written to.
  68175. * @returns The depth map texture
  68176. */
  68177. getDepthMap(): RenderTargetTexture;
  68178. /**
  68179. * Disposes of the depth renderer.
  68180. */
  68181. dispose(): void;
  68182. }
  68183. }
  68184. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  68185. import { Nullable } from "babylonjs/types";
  68186. import { Scene } from "babylonjs/scene";
  68187. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  68188. import { Camera } from "babylonjs/Cameras/camera";
  68189. import { ISceneComponent } from "babylonjs/sceneComponent";
  68190. module "babylonjs/scene" {
  68191. interface Scene {
  68192. /** @hidden (Backing field) */
  68193. _depthRenderer: {
  68194. [id: string]: DepthRenderer;
  68195. };
  68196. /**
  68197. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68198. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68199. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68200. * @returns the created depth renderer
  68201. */
  68202. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68203. /**
  68204. * Disables a depth renderer for a given camera
  68205. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68206. */
  68207. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68208. }
  68209. }
  68210. /**
  68211. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68212. * in several rendering techniques.
  68213. */
  68214. export class DepthRendererSceneComponent implements ISceneComponent {
  68215. /**
  68216. * The component name helpfull to identify the component in the list of scene components.
  68217. */
  68218. readonly name: string;
  68219. /**
  68220. * The scene the component belongs to.
  68221. */
  68222. scene: Scene;
  68223. /**
  68224. * Creates a new instance of the component for the given scene
  68225. * @param scene Defines the scene to register the component in
  68226. */
  68227. constructor(scene: Scene);
  68228. /**
  68229. * Registers the component in a given scene
  68230. */
  68231. register(): void;
  68232. /**
  68233. * Rebuilds the elements related to this component in case of
  68234. * context lost for instance.
  68235. */
  68236. rebuild(): void;
  68237. /**
  68238. * Disposes the component and the associated ressources
  68239. */
  68240. dispose(): void;
  68241. private _gatherRenderTargets;
  68242. private _gatherActiveCameraRenderTargets;
  68243. }
  68244. }
  68245. declare module "babylonjs/Shaders/outline.fragment" {
  68246. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68247. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  68248. /** @hidden */
  68249. export var outlinePixelShader: {
  68250. name: string;
  68251. shader: string;
  68252. };
  68253. }
  68254. declare module "babylonjs/Shaders/outline.vertex" {
  68255. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68256. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68257. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68258. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68259. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68260. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68261. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68262. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68263. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  68264. /** @hidden */
  68265. export var outlineVertexShader: {
  68266. name: string;
  68267. shader: string;
  68268. };
  68269. }
  68270. declare module "babylonjs/Rendering/outlineRenderer" {
  68271. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68272. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  68273. import { Scene } from "babylonjs/scene";
  68274. import { ISceneComponent } from "babylonjs/sceneComponent";
  68275. import "babylonjs/Shaders/outline.fragment";
  68276. import "babylonjs/Shaders/outline.vertex";
  68277. module "babylonjs/scene" {
  68278. interface Scene {
  68279. /** @hidden */
  68280. _outlineRenderer: OutlineRenderer;
  68281. /**
  68282. * Gets the outline renderer associated with the scene
  68283. * @returns a OutlineRenderer
  68284. */
  68285. getOutlineRenderer(): OutlineRenderer;
  68286. }
  68287. }
  68288. module "babylonjs/Meshes/abstractMesh" {
  68289. interface AbstractMesh {
  68290. /** @hidden (Backing field) */
  68291. _renderOutline: boolean;
  68292. /**
  68293. * Gets or sets a boolean indicating if the outline must be rendered as well
  68294. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68295. */
  68296. renderOutline: boolean;
  68297. /** @hidden (Backing field) */
  68298. _renderOverlay: boolean;
  68299. /**
  68300. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68301. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68302. */
  68303. renderOverlay: boolean;
  68304. }
  68305. }
  68306. /**
  68307. * This class is responsible to draw bothe outline/overlay of meshes.
  68308. * It should not be used directly but through the available method on mesh.
  68309. */
  68310. export class OutlineRenderer implements ISceneComponent {
  68311. /**
  68312. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68313. */
  68314. private static _StencilReference;
  68315. /**
  68316. * The name of the component. Each component must have a unique name.
  68317. */
  68318. name: string;
  68319. /**
  68320. * The scene the component belongs to.
  68321. */
  68322. scene: Scene;
  68323. /**
  68324. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68325. */
  68326. zOffset: number;
  68327. private _engine;
  68328. private _effect;
  68329. private _cachedDefines;
  68330. private _savedDepthWrite;
  68331. /**
  68332. * Instantiates a new outline renderer. (There could be only one per scene).
  68333. * @param scene Defines the scene it belongs to
  68334. */
  68335. constructor(scene: Scene);
  68336. /**
  68337. * Register the component to one instance of a scene.
  68338. */
  68339. register(): void;
  68340. /**
  68341. * Rebuilds the elements related to this component in case of
  68342. * context lost for instance.
  68343. */
  68344. rebuild(): void;
  68345. /**
  68346. * Disposes the component and the associated ressources.
  68347. */
  68348. dispose(): void;
  68349. /**
  68350. * Renders the outline in the canvas.
  68351. * @param subMesh Defines the sumesh to render
  68352. * @param batch Defines the batch of meshes in case of instances
  68353. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68354. */
  68355. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68356. /**
  68357. * Returns whether or not the outline renderer is ready for a given submesh.
  68358. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68359. * @param subMesh Defines the submesh to check readyness for
  68360. * @param useInstances Defines wheter wee are trying to render instances or not
  68361. * @returns true if ready otherwise false
  68362. */
  68363. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68364. private _beforeRenderingMesh;
  68365. private _afterRenderingMesh;
  68366. }
  68367. }
  68368. declare module "babylonjs/Rendering/index" {
  68369. export * from "babylonjs/Rendering/boundingBoxRenderer";
  68370. export * from "babylonjs/Rendering/depthRenderer";
  68371. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  68372. export * from "babylonjs/Rendering/edgesRenderer";
  68373. export * from "babylonjs/Rendering/geometryBufferRenderer";
  68374. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68375. export * from "babylonjs/Rendering/outlineRenderer";
  68376. export * from "babylonjs/Rendering/renderingGroup";
  68377. export * from "babylonjs/Rendering/renderingManager";
  68378. export * from "babylonjs/Rendering/utilityLayerRenderer";
  68379. }
  68380. declare module "babylonjs/Sprites/ISprites" {
  68381. /**
  68382. * Defines the basic options interface of a Sprite Frame Source Size.
  68383. */
  68384. export interface ISpriteJSONSpriteSourceSize {
  68385. /**
  68386. * number of the original width of the Frame
  68387. */
  68388. w: number;
  68389. /**
  68390. * number of the original height of the Frame
  68391. */
  68392. h: number;
  68393. }
  68394. /**
  68395. * Defines the basic options interface of a Sprite Frame Data.
  68396. */
  68397. export interface ISpriteJSONSpriteFrameData {
  68398. /**
  68399. * number of the x offset of the Frame
  68400. */
  68401. x: number;
  68402. /**
  68403. * number of the y offset of the Frame
  68404. */
  68405. y: number;
  68406. /**
  68407. * number of the width of the Frame
  68408. */
  68409. w: number;
  68410. /**
  68411. * number of the height of the Frame
  68412. */
  68413. h: number;
  68414. }
  68415. /**
  68416. * Defines the basic options interface of a JSON Sprite.
  68417. */
  68418. export interface ISpriteJSONSprite {
  68419. /**
  68420. * string name of the Frame
  68421. */
  68422. filename: string;
  68423. /**
  68424. * ISpriteJSONSpriteFrame basic object of the frame data
  68425. */
  68426. frame: ISpriteJSONSpriteFrameData;
  68427. /**
  68428. * boolean to flag is the frame was rotated.
  68429. */
  68430. rotated: boolean;
  68431. /**
  68432. * boolean to flag is the frame was trimmed.
  68433. */
  68434. trimmed: boolean;
  68435. /**
  68436. * ISpriteJSONSpriteFrame basic object of the source data
  68437. */
  68438. spriteSourceSize: ISpriteJSONSpriteFrameData;
  68439. /**
  68440. * ISpriteJSONSpriteFrame basic object of the source data
  68441. */
  68442. sourceSize: ISpriteJSONSpriteSourceSize;
  68443. }
  68444. /**
  68445. * Defines the basic options interface of a JSON atlas.
  68446. */
  68447. export interface ISpriteJSONAtlas {
  68448. /**
  68449. * Array of objects that contain the frame data.
  68450. */
  68451. frames: Array<ISpriteJSONSprite>;
  68452. /**
  68453. * object basic object containing the sprite meta data.
  68454. */
  68455. meta?: object;
  68456. }
  68457. }
  68458. declare module "babylonjs/Shaders/spriteMap.fragment" {
  68459. /** @hidden */
  68460. export var spriteMapPixelShader: {
  68461. name: string;
  68462. shader: string;
  68463. };
  68464. }
  68465. declare module "babylonjs/Shaders/spriteMap.vertex" {
  68466. /** @hidden */
  68467. export var spriteMapVertexShader: {
  68468. name: string;
  68469. shader: string;
  68470. };
  68471. }
  68472. declare module "babylonjs/Sprites/spriteMap" {
  68473. import { IDisposable, Scene } from "babylonjs/scene";
  68474. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  68475. import { Texture } from "babylonjs/Materials/Textures/texture";
  68476. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68477. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  68478. import "babylonjs/Meshes/Builders/planeBuilder";
  68479. import "babylonjs/Shaders/spriteMap.fragment";
  68480. import "babylonjs/Shaders/spriteMap.vertex";
  68481. /**
  68482. * Defines the basic options interface of a SpriteMap
  68483. */
  68484. export interface ISpriteMapOptions {
  68485. /**
  68486. * Vector2 of the number of cells in the grid.
  68487. */
  68488. stageSize?: Vector2;
  68489. /**
  68490. * Vector2 of the size of the output plane in World Units.
  68491. */
  68492. outputSize?: Vector2;
  68493. /**
  68494. * Vector3 of the position of the output plane in World Units.
  68495. */
  68496. outputPosition?: Vector3;
  68497. /**
  68498. * Vector3 of the rotation of the output plane.
  68499. */
  68500. outputRotation?: Vector3;
  68501. /**
  68502. * number of layers that the system will reserve in resources.
  68503. */
  68504. layerCount?: number;
  68505. /**
  68506. * number of max animation frames a single cell will reserve in resources.
  68507. */
  68508. maxAnimationFrames?: number;
  68509. /**
  68510. * number cell index of the base tile when the system compiles.
  68511. */
  68512. baseTile?: number;
  68513. /**
  68514. * boolean flip the sprite after its been repositioned by the framing data.
  68515. */
  68516. flipU?: boolean;
  68517. /**
  68518. * Vector3 scalar of the global RGB values of the SpriteMap.
  68519. */
  68520. colorMultiply?: Vector3;
  68521. }
  68522. /**
  68523. * Defines the IDisposable interface in order to be cleanable from resources.
  68524. */
  68525. export interface ISpriteMap extends IDisposable {
  68526. /**
  68527. * String name of the SpriteMap.
  68528. */
  68529. name: string;
  68530. /**
  68531. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  68532. */
  68533. atlasJSON: ISpriteJSONAtlas;
  68534. /**
  68535. * Texture of the SpriteMap.
  68536. */
  68537. spriteSheet: Texture;
  68538. /**
  68539. * The parameters to initialize the SpriteMap with.
  68540. */
  68541. options: ISpriteMapOptions;
  68542. }
  68543. /**
  68544. * Class used to manage a grid restricted sprite deployment on an Output plane.
  68545. */
  68546. export class SpriteMap implements ISpriteMap {
  68547. /** The Name of the spriteMap */
  68548. name: string;
  68549. /** The JSON file with the frame and meta data */
  68550. atlasJSON: ISpriteJSONAtlas;
  68551. /** The systems Sprite Sheet Texture */
  68552. spriteSheet: Texture;
  68553. /** Arguments passed with the Constructor */
  68554. options: ISpriteMapOptions;
  68555. /** Public Sprite Storage array, parsed from atlasJSON */
  68556. sprites: Array<ISpriteJSONSprite>;
  68557. /** Returns the Number of Sprites in the System */
  68558. get spriteCount(): number;
  68559. /** Returns the Position of Output Plane*/
  68560. get position(): Vector3;
  68561. /** Returns the Position of Output Plane*/
  68562. set position(v: Vector3);
  68563. /** Returns the Rotation of Output Plane*/
  68564. get rotation(): Vector3;
  68565. /** Returns the Rotation of Output Plane*/
  68566. set rotation(v: Vector3);
  68567. /** Sets the AnimationMap*/
  68568. get animationMap(): RawTexture;
  68569. /** Sets the AnimationMap*/
  68570. set animationMap(v: RawTexture);
  68571. /** Scene that the SpriteMap was created in */
  68572. private _scene;
  68573. /** Texture Buffer of Float32 that holds tile frame data*/
  68574. private _frameMap;
  68575. /** Texture Buffers of Float32 that holds tileMap data*/
  68576. private _tileMaps;
  68577. /** Texture Buffer of Float32 that holds Animation Data*/
  68578. private _animationMap;
  68579. /** Custom ShaderMaterial Central to the System*/
  68580. private _material;
  68581. /** Custom ShaderMaterial Central to the System*/
  68582. private _output;
  68583. /** Systems Time Ticker*/
  68584. private _time;
  68585. /**
  68586. * Creates a new SpriteMap
  68587. * @param name defines the SpriteMaps Name
  68588. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  68589. * @param spriteSheet is the Texture that the Sprites are on.
  68590. * @param options a basic deployment configuration
  68591. * @param scene The Scene that the map is deployed on
  68592. */
  68593. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  68594. /**
  68595. * Returns tileID location
  68596. * @returns Vector2 the cell position ID
  68597. */
  68598. getTileID(): Vector2;
  68599. /**
  68600. * Gets the UV location of the mouse over the SpriteMap.
  68601. * @returns Vector2 the UV position of the mouse interaction
  68602. */
  68603. getMousePosition(): Vector2;
  68604. /**
  68605. * Creates the "frame" texture Buffer
  68606. * -------------------------------------
  68607. * Structure of frames
  68608. * "filename": "Falling-Water-2.png",
  68609. * "frame": {"x":69,"y":103,"w":24,"h":32},
  68610. * "rotated": true,
  68611. * "trimmed": true,
  68612. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  68613. * "sourceSize": {"w":32,"h":32}
  68614. * @returns RawTexture of the frameMap
  68615. */
  68616. private _createFrameBuffer;
  68617. /**
  68618. * Creates the tileMap texture Buffer
  68619. * @param buffer normally and array of numbers, or a false to generate from scratch
  68620. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  68621. * @returns RawTexture of the tileMap
  68622. */
  68623. private _createTileBuffer;
  68624. /**
  68625. * Modifies the data of the tileMaps
  68626. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  68627. * @param pos is the iVector2 Coordinates of the Tile
  68628. * @param tile The SpriteIndex of the new Tile
  68629. */
  68630. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  68631. /**
  68632. * Creates the animationMap texture Buffer
  68633. * @param buffer normally and array of numbers, or a false to generate from scratch
  68634. * @returns RawTexture of the animationMap
  68635. */
  68636. private _createTileAnimationBuffer;
  68637. /**
  68638. * Modifies the data of the animationMap
  68639. * @param cellID is the Index of the Sprite
  68640. * @param _frame is the target Animation frame
  68641. * @param toCell is the Target Index of the next frame of the animation
  68642. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  68643. * @param speed is a global scalar of the time variable on the map.
  68644. */
  68645. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  68646. /**
  68647. * Exports the .tilemaps file
  68648. */
  68649. saveTileMaps(): void;
  68650. /**
  68651. * Imports the .tilemaps file
  68652. * @param url of the .tilemaps file
  68653. */
  68654. loadTileMaps(url: string): void;
  68655. /**
  68656. * Release associated resources
  68657. */
  68658. dispose(): void;
  68659. }
  68660. }
  68661. declare module "babylonjs/Sprites/spritePackedManager" {
  68662. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  68663. import { Scene } from "babylonjs/scene";
  68664. /**
  68665. * Class used to manage multiple sprites of different sizes on the same spritesheet
  68666. * @see http://doc.babylonjs.com/babylon101/sprites
  68667. */
  68668. export class SpritePackedManager extends SpriteManager {
  68669. /** defines the packed manager's name */
  68670. name: string;
  68671. /**
  68672. * Creates a new sprite manager from a packed sprite sheet
  68673. * @param name defines the manager's name
  68674. * @param imgUrl defines the sprite sheet url
  68675. * @param capacity defines the maximum allowed number of sprites
  68676. * @param scene defines the hosting scene
  68677. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68678. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68679. * @param samplingMode defines the smapling mode to use with spritesheet
  68680. * @param fromPacked set to true; do not alter
  68681. */
  68682. constructor(
  68683. /** defines the packed manager's name */
  68684. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68685. }
  68686. }
  68687. declare module "babylonjs/Sprites/index" {
  68688. export * from "babylonjs/Sprites/sprite";
  68689. export * from "babylonjs/Sprites/ISprites";
  68690. export * from "babylonjs/Sprites/spriteManager";
  68691. export * from "babylonjs/Sprites/spriteMap";
  68692. export * from "babylonjs/Sprites/spritePackedManager";
  68693. export * from "babylonjs/Sprites/spriteSceneComponent";
  68694. }
  68695. declare module "babylonjs/States/index" {
  68696. export * from "babylonjs/States/alphaCullingState";
  68697. export * from "babylonjs/States/depthCullingState";
  68698. export * from "babylonjs/States/stencilState";
  68699. }
  68700. declare module "babylonjs/Misc/assetsManager" {
  68701. import { Scene } from "babylonjs/scene";
  68702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68703. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68704. import { Skeleton } from "babylonjs/Bones/skeleton";
  68705. import { Observable } from "babylonjs/Misc/observable";
  68706. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68707. import { Texture } from "babylonjs/Materials/Textures/texture";
  68708. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  68709. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  68710. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  68711. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  68712. /**
  68713. * Defines the list of states available for a task inside a AssetsManager
  68714. */
  68715. export enum AssetTaskState {
  68716. /**
  68717. * Initialization
  68718. */
  68719. INIT = 0,
  68720. /**
  68721. * Running
  68722. */
  68723. RUNNING = 1,
  68724. /**
  68725. * Done
  68726. */
  68727. DONE = 2,
  68728. /**
  68729. * Error
  68730. */
  68731. ERROR = 3
  68732. }
  68733. /**
  68734. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68735. */
  68736. export abstract class AbstractAssetTask {
  68737. /**
  68738. * Task name
  68739. */ name: string;
  68740. /**
  68741. * Callback called when the task is successful
  68742. */
  68743. onSuccess: (task: any) => void;
  68744. /**
  68745. * Callback called when the task is not successful
  68746. */
  68747. onError: (task: any, message?: string, exception?: any) => void;
  68748. /**
  68749. * Creates a new AssetsManager
  68750. * @param name defines the name of the task
  68751. */
  68752. constructor(
  68753. /**
  68754. * Task name
  68755. */ name: string);
  68756. private _isCompleted;
  68757. private _taskState;
  68758. private _errorObject;
  68759. /**
  68760. * Get if the task is completed
  68761. */
  68762. get isCompleted(): boolean;
  68763. /**
  68764. * Gets the current state of the task
  68765. */
  68766. get taskState(): AssetTaskState;
  68767. /**
  68768. * Gets the current error object (if task is in error)
  68769. */
  68770. get errorObject(): {
  68771. message?: string;
  68772. exception?: any;
  68773. };
  68774. /**
  68775. * Internal only
  68776. * @hidden
  68777. */
  68778. _setErrorObject(message?: string, exception?: any): void;
  68779. /**
  68780. * Execute the current task
  68781. * @param scene defines the scene where you want your assets to be loaded
  68782. * @param onSuccess is a callback called when the task is successfully executed
  68783. * @param onError is a callback called if an error occurs
  68784. */
  68785. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68786. /**
  68787. * Execute the current task
  68788. * @param scene defines the scene where you want your assets to be loaded
  68789. * @param onSuccess is a callback called when the task is successfully executed
  68790. * @param onError is a callback called if an error occurs
  68791. */
  68792. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68793. /**
  68794. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68795. * This can be used with failed tasks that have the reason for failure fixed.
  68796. */
  68797. reset(): void;
  68798. private onErrorCallback;
  68799. private onDoneCallback;
  68800. }
  68801. /**
  68802. * Define the interface used by progress events raised during assets loading
  68803. */
  68804. export interface IAssetsProgressEvent {
  68805. /**
  68806. * Defines the number of remaining tasks to process
  68807. */
  68808. remainingCount: number;
  68809. /**
  68810. * Defines the total number of tasks
  68811. */
  68812. totalCount: number;
  68813. /**
  68814. * Defines the task that was just processed
  68815. */
  68816. task: AbstractAssetTask;
  68817. }
  68818. /**
  68819. * Class used to share progress information about assets loading
  68820. */
  68821. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68822. /**
  68823. * Defines the number of remaining tasks to process
  68824. */
  68825. remainingCount: number;
  68826. /**
  68827. * Defines the total number of tasks
  68828. */
  68829. totalCount: number;
  68830. /**
  68831. * Defines the task that was just processed
  68832. */
  68833. task: AbstractAssetTask;
  68834. /**
  68835. * Creates a AssetsProgressEvent
  68836. * @param remainingCount defines the number of remaining tasks to process
  68837. * @param totalCount defines the total number of tasks
  68838. * @param task defines the task that was just processed
  68839. */
  68840. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68841. }
  68842. /**
  68843. * Define a task used by AssetsManager to load meshes
  68844. */
  68845. export class MeshAssetTask extends AbstractAssetTask {
  68846. /**
  68847. * Defines the name of the task
  68848. */
  68849. name: string;
  68850. /**
  68851. * Defines the list of mesh's names you want to load
  68852. */
  68853. meshesNames: any;
  68854. /**
  68855. * Defines the root url to use as a base to load your meshes and associated resources
  68856. */
  68857. rootUrl: string;
  68858. /**
  68859. * Defines the filename of the scene to load from
  68860. */
  68861. sceneFilename: string;
  68862. /**
  68863. * Gets the list of loaded meshes
  68864. */
  68865. loadedMeshes: Array<AbstractMesh>;
  68866. /**
  68867. * Gets the list of loaded particle systems
  68868. */
  68869. loadedParticleSystems: Array<IParticleSystem>;
  68870. /**
  68871. * Gets the list of loaded skeletons
  68872. */
  68873. loadedSkeletons: Array<Skeleton>;
  68874. /**
  68875. * Gets the list of loaded animation groups
  68876. */
  68877. loadedAnimationGroups: Array<AnimationGroup>;
  68878. /**
  68879. * Callback called when the task is successful
  68880. */
  68881. onSuccess: (task: MeshAssetTask) => void;
  68882. /**
  68883. * Callback called when the task is successful
  68884. */
  68885. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68886. /**
  68887. * Creates a new MeshAssetTask
  68888. * @param name defines the name of the task
  68889. * @param meshesNames defines the list of mesh's names you want to load
  68890. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68891. * @param sceneFilename defines the filename of the scene to load from
  68892. */
  68893. constructor(
  68894. /**
  68895. * Defines the name of the task
  68896. */
  68897. name: string,
  68898. /**
  68899. * Defines the list of mesh's names you want to load
  68900. */
  68901. meshesNames: any,
  68902. /**
  68903. * Defines the root url to use as a base to load your meshes and associated resources
  68904. */
  68905. rootUrl: string,
  68906. /**
  68907. * Defines the filename of the scene to load from
  68908. */
  68909. sceneFilename: string);
  68910. /**
  68911. * Execute the current task
  68912. * @param scene defines the scene where you want your assets to be loaded
  68913. * @param onSuccess is a callback called when the task is successfully executed
  68914. * @param onError is a callback called if an error occurs
  68915. */
  68916. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68917. }
  68918. /**
  68919. * Define a task used by AssetsManager to load text content
  68920. */
  68921. export class TextFileAssetTask extends AbstractAssetTask {
  68922. /**
  68923. * Defines the name of the task
  68924. */
  68925. name: string;
  68926. /**
  68927. * Defines the location of the file to load
  68928. */
  68929. url: string;
  68930. /**
  68931. * Gets the loaded text string
  68932. */
  68933. text: string;
  68934. /**
  68935. * Callback called when the task is successful
  68936. */
  68937. onSuccess: (task: TextFileAssetTask) => void;
  68938. /**
  68939. * Callback called when the task is successful
  68940. */
  68941. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68942. /**
  68943. * Creates a new TextFileAssetTask object
  68944. * @param name defines the name of the task
  68945. * @param url defines the location of the file to load
  68946. */
  68947. constructor(
  68948. /**
  68949. * Defines the name of the task
  68950. */
  68951. name: string,
  68952. /**
  68953. * Defines the location of the file to load
  68954. */
  68955. url: string);
  68956. /**
  68957. * Execute the current task
  68958. * @param scene defines the scene where you want your assets to be loaded
  68959. * @param onSuccess is a callback called when the task is successfully executed
  68960. * @param onError is a callback called if an error occurs
  68961. */
  68962. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68963. }
  68964. /**
  68965. * Define a task used by AssetsManager to load binary data
  68966. */
  68967. export class BinaryFileAssetTask extends AbstractAssetTask {
  68968. /**
  68969. * Defines the name of the task
  68970. */
  68971. name: string;
  68972. /**
  68973. * Defines the location of the file to load
  68974. */
  68975. url: string;
  68976. /**
  68977. * Gets the lodaded data (as an array buffer)
  68978. */
  68979. data: ArrayBuffer;
  68980. /**
  68981. * Callback called when the task is successful
  68982. */
  68983. onSuccess: (task: BinaryFileAssetTask) => void;
  68984. /**
  68985. * Callback called when the task is successful
  68986. */
  68987. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68988. /**
  68989. * Creates a new BinaryFileAssetTask object
  68990. * @param name defines the name of the new task
  68991. * @param url defines the location of the file to load
  68992. */
  68993. constructor(
  68994. /**
  68995. * Defines the name of the task
  68996. */
  68997. name: string,
  68998. /**
  68999. * Defines the location of the file to load
  69000. */
  69001. url: string);
  69002. /**
  69003. * Execute the current task
  69004. * @param scene defines the scene where you want your assets to be loaded
  69005. * @param onSuccess is a callback called when the task is successfully executed
  69006. * @param onError is a callback called if an error occurs
  69007. */
  69008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69009. }
  69010. /**
  69011. * Define a task used by AssetsManager to load images
  69012. */
  69013. export class ImageAssetTask extends AbstractAssetTask {
  69014. /**
  69015. * Defines the name of the task
  69016. */
  69017. name: string;
  69018. /**
  69019. * Defines the location of the image to load
  69020. */
  69021. url: string;
  69022. /**
  69023. * Gets the loaded images
  69024. */
  69025. image: HTMLImageElement;
  69026. /**
  69027. * Callback called when the task is successful
  69028. */
  69029. onSuccess: (task: ImageAssetTask) => void;
  69030. /**
  69031. * Callback called when the task is successful
  69032. */
  69033. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69034. /**
  69035. * Creates a new ImageAssetTask
  69036. * @param name defines the name of the task
  69037. * @param url defines the location of the image to load
  69038. */
  69039. constructor(
  69040. /**
  69041. * Defines the name of the task
  69042. */
  69043. name: string,
  69044. /**
  69045. * Defines the location of the image to load
  69046. */
  69047. url: string);
  69048. /**
  69049. * Execute the current task
  69050. * @param scene defines the scene where you want your assets to be loaded
  69051. * @param onSuccess is a callback called when the task is successfully executed
  69052. * @param onError is a callback called if an error occurs
  69053. */
  69054. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69055. }
  69056. /**
  69057. * Defines the interface used by texture loading tasks
  69058. */
  69059. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69060. /**
  69061. * Gets the loaded texture
  69062. */
  69063. texture: TEX;
  69064. }
  69065. /**
  69066. * Define a task used by AssetsManager to load 2D textures
  69067. */
  69068. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69069. /**
  69070. * Defines the name of the task
  69071. */
  69072. name: string;
  69073. /**
  69074. * Defines the location of the file to load
  69075. */
  69076. url: string;
  69077. /**
  69078. * Defines if mipmap should not be generated (default is false)
  69079. */
  69080. noMipmap?: boolean | undefined;
  69081. /**
  69082. * Defines if texture must be inverted on Y axis (default is false)
  69083. */
  69084. invertY?: boolean | undefined;
  69085. /**
  69086. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69087. */
  69088. samplingMode: number;
  69089. /**
  69090. * Gets the loaded texture
  69091. */
  69092. texture: Texture;
  69093. /**
  69094. * Callback called when the task is successful
  69095. */
  69096. onSuccess: (task: TextureAssetTask) => void;
  69097. /**
  69098. * Callback called when the task is successful
  69099. */
  69100. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69101. /**
  69102. * Creates a new TextureAssetTask object
  69103. * @param name defines the name of the task
  69104. * @param url defines the location of the file to load
  69105. * @param noMipmap defines if mipmap should not be generated (default is false)
  69106. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69107. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69108. */
  69109. constructor(
  69110. /**
  69111. * Defines the name of the task
  69112. */
  69113. name: string,
  69114. /**
  69115. * Defines the location of the file to load
  69116. */
  69117. url: string,
  69118. /**
  69119. * Defines if mipmap should not be generated (default is false)
  69120. */
  69121. noMipmap?: boolean | undefined,
  69122. /**
  69123. * Defines if texture must be inverted on Y axis (default is false)
  69124. */
  69125. invertY?: boolean | undefined,
  69126. /**
  69127. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69128. */
  69129. samplingMode?: number);
  69130. /**
  69131. * Execute the current task
  69132. * @param scene defines the scene where you want your assets to be loaded
  69133. * @param onSuccess is a callback called when the task is successfully executed
  69134. * @param onError is a callback called if an error occurs
  69135. */
  69136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69137. }
  69138. /**
  69139. * Define a task used by AssetsManager to load cube textures
  69140. */
  69141. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69142. /**
  69143. * Defines the name of the task
  69144. */
  69145. name: string;
  69146. /**
  69147. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69148. */
  69149. url: string;
  69150. /**
  69151. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69152. */
  69153. extensions?: string[] | undefined;
  69154. /**
  69155. * Defines if mipmaps should not be generated (default is false)
  69156. */
  69157. noMipmap?: boolean | undefined;
  69158. /**
  69159. * Defines the explicit list of files (undefined by default)
  69160. */
  69161. files?: string[] | undefined;
  69162. /**
  69163. * Gets the loaded texture
  69164. */
  69165. texture: CubeTexture;
  69166. /**
  69167. * Callback called when the task is successful
  69168. */
  69169. onSuccess: (task: CubeTextureAssetTask) => void;
  69170. /**
  69171. * Callback called when the task is successful
  69172. */
  69173. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69174. /**
  69175. * Creates a new CubeTextureAssetTask
  69176. * @param name defines the name of the task
  69177. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69178. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69179. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69180. * @param files defines the explicit list of files (undefined by default)
  69181. */
  69182. constructor(
  69183. /**
  69184. * Defines the name of the task
  69185. */
  69186. name: string,
  69187. /**
  69188. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69189. */
  69190. url: string,
  69191. /**
  69192. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69193. */
  69194. extensions?: string[] | undefined,
  69195. /**
  69196. * Defines if mipmaps should not be generated (default is false)
  69197. */
  69198. noMipmap?: boolean | undefined,
  69199. /**
  69200. * Defines the explicit list of files (undefined by default)
  69201. */
  69202. files?: string[] | undefined);
  69203. /**
  69204. * Execute the current task
  69205. * @param scene defines the scene where you want your assets to be loaded
  69206. * @param onSuccess is a callback called when the task is successfully executed
  69207. * @param onError is a callback called if an error occurs
  69208. */
  69209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69210. }
  69211. /**
  69212. * Define a task used by AssetsManager to load HDR cube textures
  69213. */
  69214. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69215. /**
  69216. * Defines the name of the task
  69217. */
  69218. name: string;
  69219. /**
  69220. * Defines the location of the file to load
  69221. */
  69222. url: string;
  69223. /**
  69224. * Defines the desired size (the more it increases the longer the generation will be)
  69225. */
  69226. size: number;
  69227. /**
  69228. * Defines if mipmaps should not be generated (default is false)
  69229. */
  69230. noMipmap: boolean;
  69231. /**
  69232. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69233. */
  69234. generateHarmonics: boolean;
  69235. /**
  69236. * 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)
  69237. */
  69238. gammaSpace: boolean;
  69239. /**
  69240. * Internal Use Only
  69241. */
  69242. reserved: boolean;
  69243. /**
  69244. * Gets the loaded texture
  69245. */
  69246. texture: HDRCubeTexture;
  69247. /**
  69248. * Callback called when the task is successful
  69249. */
  69250. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69251. /**
  69252. * Callback called when the task is successful
  69253. */
  69254. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69255. /**
  69256. * Creates a new HDRCubeTextureAssetTask object
  69257. * @param name defines the name of the task
  69258. * @param url defines the location of the file to load
  69259. * @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.
  69260. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69261. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69262. * @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)
  69263. * @param reserved Internal use only
  69264. */
  69265. constructor(
  69266. /**
  69267. * Defines the name of the task
  69268. */
  69269. name: string,
  69270. /**
  69271. * Defines the location of the file to load
  69272. */
  69273. url: string,
  69274. /**
  69275. * Defines the desired size (the more it increases the longer the generation will be)
  69276. */
  69277. size: number,
  69278. /**
  69279. * Defines if mipmaps should not be generated (default is false)
  69280. */
  69281. noMipmap?: boolean,
  69282. /**
  69283. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69284. */
  69285. generateHarmonics?: boolean,
  69286. /**
  69287. * 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)
  69288. */
  69289. gammaSpace?: boolean,
  69290. /**
  69291. * Internal Use Only
  69292. */
  69293. reserved?: boolean);
  69294. /**
  69295. * Execute the current task
  69296. * @param scene defines the scene where you want your assets to be loaded
  69297. * @param onSuccess is a callback called when the task is successfully executed
  69298. * @param onError is a callback called if an error occurs
  69299. */
  69300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69301. }
  69302. /**
  69303. * Define a task used by AssetsManager to load Equirectangular cube textures
  69304. */
  69305. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69306. /**
  69307. * Defines the name of the task
  69308. */
  69309. name: string;
  69310. /**
  69311. * Defines the location of the file to load
  69312. */
  69313. url: string;
  69314. /**
  69315. * Defines the desired size (the more it increases the longer the generation will be)
  69316. */
  69317. size: number;
  69318. /**
  69319. * Defines if mipmaps should not be generated (default is false)
  69320. */
  69321. noMipmap: boolean;
  69322. /**
  69323. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69324. * but the standard material would require them in Gamma space) (default is true)
  69325. */
  69326. gammaSpace: boolean;
  69327. /**
  69328. * Gets the loaded texture
  69329. */
  69330. texture: EquiRectangularCubeTexture;
  69331. /**
  69332. * Callback called when the task is successful
  69333. */
  69334. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69335. /**
  69336. * Callback called when the task is successful
  69337. */
  69338. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69339. /**
  69340. * Creates a new EquiRectangularCubeTextureAssetTask object
  69341. * @param name defines the name of the task
  69342. * @param url defines the location of the file to load
  69343. * @param size defines the desired size (the more it increases the longer the generation will be)
  69344. * If the size is omitted this implies you are using a preprocessed cubemap.
  69345. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69346. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69347. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69348. * (default is true)
  69349. */
  69350. constructor(
  69351. /**
  69352. * Defines the name of the task
  69353. */
  69354. name: string,
  69355. /**
  69356. * Defines the location of the file to load
  69357. */
  69358. url: string,
  69359. /**
  69360. * Defines the desired size (the more it increases the longer the generation will be)
  69361. */
  69362. size: number,
  69363. /**
  69364. * Defines if mipmaps should not be generated (default is false)
  69365. */
  69366. noMipmap?: boolean,
  69367. /**
  69368. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69369. * but the standard material would require them in Gamma space) (default is true)
  69370. */
  69371. gammaSpace?: boolean);
  69372. /**
  69373. * Execute the current task
  69374. * @param scene defines the scene where you want your assets to be loaded
  69375. * @param onSuccess is a callback called when the task is successfully executed
  69376. * @param onError is a callback called if an error occurs
  69377. */
  69378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69379. }
  69380. /**
  69381. * This class can be used to easily import assets into a scene
  69382. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69383. */
  69384. export class AssetsManager {
  69385. private _scene;
  69386. private _isLoading;
  69387. protected _tasks: AbstractAssetTask[];
  69388. protected _waitingTasksCount: number;
  69389. protected _totalTasksCount: number;
  69390. /**
  69391. * Callback called when all tasks are processed
  69392. */
  69393. onFinish: (tasks: AbstractAssetTask[]) => void;
  69394. /**
  69395. * Callback called when a task is successful
  69396. */
  69397. onTaskSuccess: (task: AbstractAssetTask) => void;
  69398. /**
  69399. * Callback called when a task had an error
  69400. */
  69401. onTaskError: (task: AbstractAssetTask) => void;
  69402. /**
  69403. * Callback called when a task is done (whatever the result is)
  69404. */
  69405. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69406. /**
  69407. * Observable called when all tasks are processed
  69408. */
  69409. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  69410. /**
  69411. * Observable called when a task had an error
  69412. */
  69413. onTaskErrorObservable: Observable<AbstractAssetTask>;
  69414. /**
  69415. * Observable called when all tasks were executed
  69416. */
  69417. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  69418. /**
  69419. * Observable called when a task is done (whatever the result is)
  69420. */
  69421. onProgressObservable: Observable<IAssetsProgressEvent>;
  69422. /**
  69423. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  69424. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  69425. */
  69426. useDefaultLoadingScreen: boolean;
  69427. /**
  69428. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  69429. * when all assets have been downloaded.
  69430. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  69431. */
  69432. autoHideLoadingUI: boolean;
  69433. /**
  69434. * Creates a new AssetsManager
  69435. * @param scene defines the scene to work on
  69436. */
  69437. constructor(scene: Scene);
  69438. /**
  69439. * Add a MeshAssetTask to the list of active tasks
  69440. * @param taskName defines the name of the new task
  69441. * @param meshesNames defines the name of meshes to load
  69442. * @param rootUrl defines the root url to use to locate files
  69443. * @param sceneFilename defines the filename of the scene file
  69444. * @returns a new MeshAssetTask object
  69445. */
  69446. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  69447. /**
  69448. * Add a TextFileAssetTask to the list of active tasks
  69449. * @param taskName defines the name of the new task
  69450. * @param url defines the url of the file to load
  69451. * @returns a new TextFileAssetTask object
  69452. */
  69453. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  69454. /**
  69455. * Add a BinaryFileAssetTask to the list of active tasks
  69456. * @param taskName defines the name of the new task
  69457. * @param url defines the url of the file to load
  69458. * @returns a new BinaryFileAssetTask object
  69459. */
  69460. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  69461. /**
  69462. * Add a ImageAssetTask to the list of active tasks
  69463. * @param taskName defines the name of the new task
  69464. * @param url defines the url of the file to load
  69465. * @returns a new ImageAssetTask object
  69466. */
  69467. addImageTask(taskName: string, url: string): ImageAssetTask;
  69468. /**
  69469. * Add a TextureAssetTask to the list of active tasks
  69470. * @param taskName defines the name of the new task
  69471. * @param url defines the url of the file to load
  69472. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69473. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  69474. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69475. * @returns a new TextureAssetTask object
  69476. */
  69477. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  69478. /**
  69479. * Add a CubeTextureAssetTask to the list of active tasks
  69480. * @param taskName defines the name of the new task
  69481. * @param url defines the url of the file to load
  69482. * @param extensions defines the extension to use to load the cube map (can be null)
  69483. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69484. * @param files defines the list of files to load (can be null)
  69485. * @returns a new CubeTextureAssetTask object
  69486. */
  69487. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  69488. /**
  69489. *
  69490. * Add a HDRCubeTextureAssetTask to the list of active tasks
  69491. * @param taskName defines the name of the new task
  69492. * @param url defines the url of the file to load
  69493. * @param size defines the size you want for the cubemap (can be null)
  69494. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69495. * @param generateHarmonics defines if you want to automatically generate (true by default)
  69496. * @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)
  69497. * @param reserved Internal use only
  69498. * @returns a new HDRCubeTextureAssetTask object
  69499. */
  69500. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  69501. /**
  69502. *
  69503. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  69504. * @param taskName defines the name of the new task
  69505. * @param url defines the url of the file to load
  69506. * @param size defines the size you want for the cubemap (can be null)
  69507. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69508. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69509. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69510. * @returns a new EquiRectangularCubeTextureAssetTask object
  69511. */
  69512. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  69513. /**
  69514. * Remove a task from the assets manager.
  69515. * @param task the task to remove
  69516. */
  69517. removeTask(task: AbstractAssetTask): void;
  69518. private _decreaseWaitingTasksCount;
  69519. private _runTask;
  69520. /**
  69521. * Reset the AssetsManager and remove all tasks
  69522. * @return the current instance of the AssetsManager
  69523. */
  69524. reset(): AssetsManager;
  69525. /**
  69526. * Start the loading process
  69527. * @return the current instance of the AssetsManager
  69528. */
  69529. load(): AssetsManager;
  69530. /**
  69531. * Start the loading process as an async operation
  69532. * @return a promise returning the list of failed tasks
  69533. */
  69534. loadAsync(): Promise<void>;
  69535. }
  69536. }
  69537. declare module "babylonjs/Misc/deferred" {
  69538. /**
  69539. * Wrapper class for promise with external resolve and reject.
  69540. */
  69541. export class Deferred<T> {
  69542. /**
  69543. * The promise associated with this deferred object.
  69544. */
  69545. readonly promise: Promise<T>;
  69546. private _resolve;
  69547. private _reject;
  69548. /**
  69549. * The resolve method of the promise associated with this deferred object.
  69550. */
  69551. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  69552. /**
  69553. * The reject method of the promise associated with this deferred object.
  69554. */
  69555. get reject(): (reason?: any) => void;
  69556. /**
  69557. * Constructor for this deferred object.
  69558. */
  69559. constructor();
  69560. }
  69561. }
  69562. declare module "babylonjs/Misc/meshExploder" {
  69563. import { Mesh } from "babylonjs/Meshes/mesh";
  69564. /**
  69565. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  69566. */
  69567. export class MeshExploder {
  69568. private _centerMesh;
  69569. private _meshes;
  69570. private _meshesOrigins;
  69571. private _toCenterVectors;
  69572. private _scaledDirection;
  69573. private _newPosition;
  69574. private _centerPosition;
  69575. /**
  69576. * Explodes meshes from a center mesh.
  69577. * @param meshes The meshes to explode.
  69578. * @param centerMesh The mesh to be center of explosion.
  69579. */
  69580. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  69581. private _setCenterMesh;
  69582. /**
  69583. * Get class name
  69584. * @returns "MeshExploder"
  69585. */
  69586. getClassName(): string;
  69587. /**
  69588. * "Exploded meshes"
  69589. * @returns Array of meshes with the centerMesh at index 0.
  69590. */
  69591. getMeshes(): Array<Mesh>;
  69592. /**
  69593. * Explodes meshes giving a specific direction
  69594. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  69595. */
  69596. explode(direction?: number): void;
  69597. }
  69598. }
  69599. declare module "babylonjs/Misc/filesInput" {
  69600. import { Engine } from "babylonjs/Engines/engine";
  69601. import { Scene } from "babylonjs/scene";
  69602. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  69603. /**
  69604. * Class used to help managing file picking and drag'n'drop
  69605. */
  69606. export class FilesInput {
  69607. /**
  69608. * List of files ready to be loaded
  69609. */
  69610. static get FilesToLoad(): {
  69611. [key: string]: File;
  69612. };
  69613. /**
  69614. * Callback called when a file is processed
  69615. */
  69616. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  69617. private _engine;
  69618. private _currentScene;
  69619. private _sceneLoadedCallback;
  69620. private _progressCallback;
  69621. private _additionalRenderLoopLogicCallback;
  69622. private _textureLoadingCallback;
  69623. private _startingProcessingFilesCallback;
  69624. private _onReloadCallback;
  69625. private _errorCallback;
  69626. private _elementToMonitor;
  69627. private _sceneFileToLoad;
  69628. private _filesToLoad;
  69629. /**
  69630. * Creates a new FilesInput
  69631. * @param engine defines the rendering engine
  69632. * @param scene defines the hosting scene
  69633. * @param sceneLoadedCallback callback called when scene is loaded
  69634. * @param progressCallback callback called to track progress
  69635. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  69636. * @param textureLoadingCallback callback called when a texture is loading
  69637. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  69638. * @param onReloadCallback callback called when a reload is requested
  69639. * @param errorCallback callback call if an error occurs
  69640. */
  69641. 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);
  69642. private _dragEnterHandler;
  69643. private _dragOverHandler;
  69644. private _dropHandler;
  69645. /**
  69646. * Calls this function to listen to drag'n'drop events on a specific DOM element
  69647. * @param elementToMonitor defines the DOM element to track
  69648. */
  69649. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  69650. /**
  69651. * Release all associated resources
  69652. */
  69653. dispose(): void;
  69654. private renderFunction;
  69655. private drag;
  69656. private drop;
  69657. private _traverseFolder;
  69658. private _processFiles;
  69659. /**
  69660. * Load files from a drop event
  69661. * @param event defines the drop event to use as source
  69662. */
  69663. loadFiles(event: any): void;
  69664. private _processReload;
  69665. /**
  69666. * Reload the current scene from the loaded files
  69667. */
  69668. reload(): void;
  69669. }
  69670. }
  69671. declare module "babylonjs/Misc/HighDynamicRange/index" {
  69672. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  69673. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  69674. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  69675. }
  69676. declare module "babylonjs/Misc/sceneOptimizer" {
  69677. import { Scene, IDisposable } from "babylonjs/scene";
  69678. import { Observable } from "babylonjs/Misc/observable";
  69679. /**
  69680. * Defines the root class used to create scene optimization to use with SceneOptimizer
  69681. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69682. */
  69683. export class SceneOptimization {
  69684. /**
  69685. * Defines the priority of this optimization (0 by default which means first in the list)
  69686. */
  69687. priority: number;
  69688. /**
  69689. * Gets a string describing the action executed by the current optimization
  69690. * @returns description string
  69691. */
  69692. getDescription(): string;
  69693. /**
  69694. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69695. * @param scene defines the current scene where to apply this optimization
  69696. * @param optimizer defines the current optimizer
  69697. * @returns true if everything that can be done was applied
  69698. */
  69699. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69700. /**
  69701. * Creates the SceneOptimization object
  69702. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69703. * @param desc defines the description associated with the optimization
  69704. */
  69705. constructor(
  69706. /**
  69707. * Defines the priority of this optimization (0 by default which means first in the list)
  69708. */
  69709. priority?: number);
  69710. }
  69711. /**
  69712. * Defines an optimization used to reduce the size of render target textures
  69713. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69714. */
  69715. export class TextureOptimization extends SceneOptimization {
  69716. /**
  69717. * Defines the priority of this optimization (0 by default which means first in the list)
  69718. */
  69719. priority: number;
  69720. /**
  69721. * 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
  69722. */
  69723. maximumSize: number;
  69724. /**
  69725. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69726. */
  69727. step: number;
  69728. /**
  69729. * Gets a string describing the action executed by the current optimization
  69730. * @returns description string
  69731. */
  69732. getDescription(): string;
  69733. /**
  69734. * Creates the TextureOptimization object
  69735. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69736. * @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
  69737. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69738. */
  69739. constructor(
  69740. /**
  69741. * Defines the priority of this optimization (0 by default which means first in the list)
  69742. */
  69743. priority?: number,
  69744. /**
  69745. * 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
  69746. */
  69747. maximumSize?: number,
  69748. /**
  69749. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69750. */
  69751. step?: number);
  69752. /**
  69753. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69754. * @param scene defines the current scene where to apply this optimization
  69755. * @param optimizer defines the current optimizer
  69756. * @returns true if everything that can be done was applied
  69757. */
  69758. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69759. }
  69760. /**
  69761. * Defines an optimization used to increase or decrease the rendering resolution
  69762. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69763. */
  69764. export class HardwareScalingOptimization extends SceneOptimization {
  69765. /**
  69766. * Defines the priority of this optimization (0 by default which means first in the list)
  69767. */
  69768. priority: number;
  69769. /**
  69770. * Defines the maximum scale to use (2 by default)
  69771. */
  69772. maximumScale: number;
  69773. /**
  69774. * Defines the step to use between two passes (0.5 by default)
  69775. */
  69776. step: number;
  69777. private _currentScale;
  69778. private _directionOffset;
  69779. /**
  69780. * Gets a string describing the action executed by the current optimization
  69781. * @return description string
  69782. */
  69783. getDescription(): string;
  69784. /**
  69785. * Creates the HardwareScalingOptimization object
  69786. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69787. * @param maximumScale defines the maximum scale to use (2 by default)
  69788. * @param step defines the step to use between two passes (0.5 by default)
  69789. */
  69790. constructor(
  69791. /**
  69792. * Defines the priority of this optimization (0 by default which means first in the list)
  69793. */
  69794. priority?: number,
  69795. /**
  69796. * Defines the maximum scale to use (2 by default)
  69797. */
  69798. maximumScale?: number,
  69799. /**
  69800. * Defines the step to use between two passes (0.5 by default)
  69801. */
  69802. step?: number);
  69803. /**
  69804. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69805. * @param scene defines the current scene where to apply this optimization
  69806. * @param optimizer defines the current optimizer
  69807. * @returns true if everything that can be done was applied
  69808. */
  69809. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69810. }
  69811. /**
  69812. * Defines an optimization used to remove shadows
  69813. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69814. */
  69815. export class ShadowsOptimization extends SceneOptimization {
  69816. /**
  69817. * Gets a string describing the action executed by the current optimization
  69818. * @return description string
  69819. */
  69820. getDescription(): string;
  69821. /**
  69822. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69823. * @param scene defines the current scene where to apply this optimization
  69824. * @param optimizer defines the current optimizer
  69825. * @returns true if everything that can be done was applied
  69826. */
  69827. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69828. }
  69829. /**
  69830. * Defines an optimization used to turn post-processes off
  69831. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69832. */
  69833. export class PostProcessesOptimization extends SceneOptimization {
  69834. /**
  69835. * Gets a string describing the action executed by the current optimization
  69836. * @return description string
  69837. */
  69838. getDescription(): string;
  69839. /**
  69840. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69841. * @param scene defines the current scene where to apply this optimization
  69842. * @param optimizer defines the current optimizer
  69843. * @returns true if everything that can be done was applied
  69844. */
  69845. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69846. }
  69847. /**
  69848. * Defines an optimization used to turn lens flares off
  69849. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69850. */
  69851. export class LensFlaresOptimization extends SceneOptimization {
  69852. /**
  69853. * Gets a string describing the action executed by the current optimization
  69854. * @return description string
  69855. */
  69856. getDescription(): string;
  69857. /**
  69858. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69859. * @param scene defines the current scene where to apply this optimization
  69860. * @param optimizer defines the current optimizer
  69861. * @returns true if everything that can be done was applied
  69862. */
  69863. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69864. }
  69865. /**
  69866. * Defines an optimization based on user defined callback.
  69867. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69868. */
  69869. export class CustomOptimization extends SceneOptimization {
  69870. /**
  69871. * Callback called to apply the custom optimization.
  69872. */
  69873. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69874. /**
  69875. * Callback called to get custom description
  69876. */
  69877. onGetDescription: () => string;
  69878. /**
  69879. * Gets a string describing the action executed by the current optimization
  69880. * @returns description string
  69881. */
  69882. getDescription(): string;
  69883. /**
  69884. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69885. * @param scene defines the current scene where to apply this optimization
  69886. * @param optimizer defines the current optimizer
  69887. * @returns true if everything that can be done was applied
  69888. */
  69889. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69890. }
  69891. /**
  69892. * Defines an optimization used to turn particles off
  69893. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69894. */
  69895. export class ParticlesOptimization extends SceneOptimization {
  69896. /**
  69897. * Gets a string describing the action executed by the current optimization
  69898. * @return description string
  69899. */
  69900. getDescription(): string;
  69901. /**
  69902. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69903. * @param scene defines the current scene where to apply this optimization
  69904. * @param optimizer defines the current optimizer
  69905. * @returns true if everything that can be done was applied
  69906. */
  69907. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69908. }
  69909. /**
  69910. * Defines an optimization used to turn render targets off
  69911. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69912. */
  69913. export class RenderTargetsOptimization extends SceneOptimization {
  69914. /**
  69915. * Gets a string describing the action executed by the current optimization
  69916. * @return description string
  69917. */
  69918. getDescription(): string;
  69919. /**
  69920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69921. * @param scene defines the current scene where to apply this optimization
  69922. * @param optimizer defines the current optimizer
  69923. * @returns true if everything that can be done was applied
  69924. */
  69925. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69926. }
  69927. /**
  69928. * Defines an optimization used to merge meshes with compatible materials
  69929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69930. */
  69931. export class MergeMeshesOptimization extends SceneOptimization {
  69932. private static _UpdateSelectionTree;
  69933. /**
  69934. * Gets or sets a boolean which defines if optimization octree has to be updated
  69935. */
  69936. static get UpdateSelectionTree(): boolean;
  69937. /**
  69938. * Gets or sets a boolean which defines if optimization octree has to be updated
  69939. */
  69940. static set UpdateSelectionTree(value: boolean);
  69941. /**
  69942. * Gets a string describing the action executed by the current optimization
  69943. * @return description string
  69944. */
  69945. getDescription(): string;
  69946. private _canBeMerged;
  69947. /**
  69948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69949. * @param scene defines the current scene where to apply this optimization
  69950. * @param optimizer defines the current optimizer
  69951. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69952. * @returns true if everything that can be done was applied
  69953. */
  69954. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69955. }
  69956. /**
  69957. * Defines a list of options used by SceneOptimizer
  69958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69959. */
  69960. export class SceneOptimizerOptions {
  69961. /**
  69962. * Defines the target frame rate to reach (60 by default)
  69963. */
  69964. targetFrameRate: number;
  69965. /**
  69966. * Defines the interval between two checkes (2000ms by default)
  69967. */
  69968. trackerDuration: number;
  69969. /**
  69970. * Gets the list of optimizations to apply
  69971. */
  69972. optimizations: SceneOptimization[];
  69973. /**
  69974. * Creates a new list of options used by SceneOptimizer
  69975. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69976. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69977. */
  69978. constructor(
  69979. /**
  69980. * Defines the target frame rate to reach (60 by default)
  69981. */
  69982. targetFrameRate?: number,
  69983. /**
  69984. * Defines the interval between two checkes (2000ms by default)
  69985. */
  69986. trackerDuration?: number);
  69987. /**
  69988. * Add a new optimization
  69989. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69990. * @returns the current SceneOptimizerOptions
  69991. */
  69992. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69993. /**
  69994. * Add a new custom optimization
  69995. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69996. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69997. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69998. * @returns the current SceneOptimizerOptions
  69999. */
  70000. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70001. /**
  70002. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70003. * @param targetFrameRate defines the target frame rate (60 by default)
  70004. * @returns a SceneOptimizerOptions object
  70005. */
  70006. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70007. /**
  70008. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70009. * @param targetFrameRate defines the target frame rate (60 by default)
  70010. * @returns a SceneOptimizerOptions object
  70011. */
  70012. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70013. /**
  70014. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70015. * @param targetFrameRate defines the target frame rate (60 by default)
  70016. * @returns a SceneOptimizerOptions object
  70017. */
  70018. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70019. }
  70020. /**
  70021. * Class used to run optimizations in order to reach a target frame rate
  70022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70023. */
  70024. export class SceneOptimizer implements IDisposable {
  70025. private _isRunning;
  70026. private _options;
  70027. private _scene;
  70028. private _currentPriorityLevel;
  70029. private _targetFrameRate;
  70030. private _trackerDuration;
  70031. private _currentFrameRate;
  70032. private _sceneDisposeObserver;
  70033. private _improvementMode;
  70034. /**
  70035. * Defines an observable called when the optimizer reaches the target frame rate
  70036. */
  70037. onSuccessObservable: Observable<SceneOptimizer>;
  70038. /**
  70039. * Defines an observable called when the optimizer enables an optimization
  70040. */
  70041. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70042. /**
  70043. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70044. */
  70045. onFailureObservable: Observable<SceneOptimizer>;
  70046. /**
  70047. * Gets a boolean indicating if the optimizer is in improvement mode
  70048. */
  70049. get isInImprovementMode(): boolean;
  70050. /**
  70051. * Gets the current priority level (0 at start)
  70052. */
  70053. get currentPriorityLevel(): number;
  70054. /**
  70055. * Gets the current frame rate checked by the SceneOptimizer
  70056. */
  70057. get currentFrameRate(): number;
  70058. /**
  70059. * Gets or sets the current target frame rate (60 by default)
  70060. */
  70061. get targetFrameRate(): number;
  70062. /**
  70063. * Gets or sets the current target frame rate (60 by default)
  70064. */
  70065. set targetFrameRate(value: number);
  70066. /**
  70067. * Gets or sets the current interval between two checks (every 2000ms by default)
  70068. */
  70069. get trackerDuration(): number;
  70070. /**
  70071. * Gets or sets the current interval between two checks (every 2000ms by default)
  70072. */
  70073. set trackerDuration(value: number);
  70074. /**
  70075. * Gets the list of active optimizations
  70076. */
  70077. get optimizations(): SceneOptimization[];
  70078. /**
  70079. * Creates a new SceneOptimizer
  70080. * @param scene defines the scene to work on
  70081. * @param options defines the options to use with the SceneOptimizer
  70082. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70083. * @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)
  70084. */
  70085. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70086. /**
  70087. * Stops the current optimizer
  70088. */
  70089. stop(): void;
  70090. /**
  70091. * Reset the optimizer to initial step (current priority level = 0)
  70092. */
  70093. reset(): void;
  70094. /**
  70095. * Start the optimizer. By default it will try to reach a specific framerate
  70096. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70097. */
  70098. start(): void;
  70099. private _checkCurrentState;
  70100. /**
  70101. * Release all resources
  70102. */
  70103. dispose(): void;
  70104. /**
  70105. * Helper function to create a SceneOptimizer with one single line of code
  70106. * @param scene defines the scene to work on
  70107. * @param options defines the options to use with the SceneOptimizer
  70108. * @param onSuccess defines a callback to call on success
  70109. * @param onFailure defines a callback to call on failure
  70110. * @returns the new SceneOptimizer object
  70111. */
  70112. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70113. }
  70114. }
  70115. declare module "babylonjs/Misc/sceneSerializer" {
  70116. import { Scene } from "babylonjs/scene";
  70117. /**
  70118. * Class used to serialize a scene into a string
  70119. */
  70120. export class SceneSerializer {
  70121. /**
  70122. * Clear cache used by a previous serialization
  70123. */
  70124. static ClearCache(): void;
  70125. /**
  70126. * Serialize a scene into a JSON compatible object
  70127. * @param scene defines the scene to serialize
  70128. * @returns a JSON compatible object
  70129. */
  70130. static Serialize(scene: Scene): any;
  70131. /**
  70132. * Serialize a mesh into a JSON compatible object
  70133. * @param toSerialize defines the mesh to serialize
  70134. * @param withParents defines if parents must be serialized as well
  70135. * @param withChildren defines if children must be serialized as well
  70136. * @returns a JSON compatible object
  70137. */
  70138. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70139. }
  70140. }
  70141. declare module "babylonjs/Misc/textureTools" {
  70142. import { Texture } from "babylonjs/Materials/Textures/texture";
  70143. /**
  70144. * Class used to host texture specific utilities
  70145. */
  70146. export class TextureTools {
  70147. /**
  70148. * Uses the GPU to create a copy texture rescaled at a given size
  70149. * @param texture Texture to copy from
  70150. * @param width defines the desired width
  70151. * @param height defines the desired height
  70152. * @param useBilinearMode defines if bilinear mode has to be used
  70153. * @return the generated texture
  70154. */
  70155. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70156. }
  70157. }
  70158. declare module "babylonjs/Misc/videoRecorder" {
  70159. import { Nullable } from "babylonjs/types";
  70160. import { Engine } from "babylonjs/Engines/engine";
  70161. /**
  70162. * This represents the different options available for the video capture.
  70163. */
  70164. export interface VideoRecorderOptions {
  70165. /** Defines the mime type of the video. */
  70166. mimeType: string;
  70167. /** Defines the FPS the video should be recorded at. */
  70168. fps: number;
  70169. /** Defines the chunk size for the recording data. */
  70170. recordChunckSize: number;
  70171. /** The audio tracks to attach to the recording. */
  70172. audioTracks?: MediaStreamTrack[];
  70173. }
  70174. /**
  70175. * This can help with recording videos from BabylonJS.
  70176. * This is based on the available WebRTC functionalities of the browser.
  70177. *
  70178. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70179. */
  70180. export class VideoRecorder {
  70181. private static readonly _defaultOptions;
  70182. /**
  70183. * Returns whether or not the VideoRecorder is available in your browser.
  70184. * @param engine Defines the Babylon Engine.
  70185. * @returns true if supported otherwise false.
  70186. */
  70187. static IsSupported(engine: Engine): boolean;
  70188. private readonly _options;
  70189. private _canvas;
  70190. private _mediaRecorder;
  70191. private _recordedChunks;
  70192. private _fileName;
  70193. private _resolve;
  70194. private _reject;
  70195. /**
  70196. * True when a recording is already in progress.
  70197. */
  70198. get isRecording(): boolean;
  70199. /**
  70200. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70201. * @param engine Defines the BabylonJS Engine you wish to record.
  70202. * @param options Defines options that can be used to customize the capture.
  70203. */
  70204. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70205. /**
  70206. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70207. */
  70208. stopRecording(): void;
  70209. /**
  70210. * Starts recording the canvas for a max duration specified in parameters.
  70211. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70212. * If null no automatic download will start and you can rely on the promise to get the data back.
  70213. * @param maxDuration Defines the maximum recording time in seconds.
  70214. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70215. * @return A promise callback at the end of the recording with the video data in Blob.
  70216. */
  70217. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70218. /**
  70219. * Releases internal resources used during the recording.
  70220. */
  70221. dispose(): void;
  70222. private _handleDataAvailable;
  70223. private _handleError;
  70224. private _handleStop;
  70225. }
  70226. }
  70227. declare module "babylonjs/Misc/screenshotTools" {
  70228. import { Camera } from "babylonjs/Cameras/camera";
  70229. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  70230. import { Engine } from "babylonjs/Engines/engine";
  70231. /**
  70232. * Class containing a set of static utilities functions for screenshots
  70233. */
  70234. export class ScreenshotTools {
  70235. /**
  70236. * Captures a screenshot of the current rendering
  70237. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70238. * @param engine defines the rendering engine
  70239. * @param camera defines the source camera
  70240. * @param size This parameter can be set to a single number or to an object with the
  70241. * following (optional) properties: precision, width, height. If a single number is passed,
  70242. * it will be used for both width and height. If an object is passed, the screenshot size
  70243. * will be derived from the parameters. The precision property is a multiplier allowing
  70244. * rendering at a higher or lower resolution
  70245. * @param successCallback defines the callback receives a single parameter which contains the
  70246. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70247. * src parameter of an <img> to display it
  70248. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70249. * Check your browser for supported MIME types
  70250. */
  70251. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70252. /**
  70253. * Captures a screenshot of the current rendering
  70254. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70255. * @param engine defines the rendering engine
  70256. * @param camera defines the source camera
  70257. * @param size This parameter can be set to a single number or to an object with the
  70258. * following (optional) properties: precision, width, height. If a single number is passed,
  70259. * it will be used for both width and height. If an object is passed, the screenshot size
  70260. * will be derived from the parameters. The precision property is a multiplier allowing
  70261. * rendering at a higher or lower resolution
  70262. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70263. * Check your browser for supported MIME types
  70264. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70265. * to the src parameter of an <img> to display it
  70266. */
  70267. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70268. /**
  70269. * Generates an image screenshot from the specified camera.
  70270. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70271. * @param engine The engine to use for rendering
  70272. * @param camera The camera to use for rendering
  70273. * @param size This parameter can be set to a single number or to an object with the
  70274. * following (optional) properties: precision, width, height. If a single number is passed,
  70275. * it will be used for both width and height. If an object is passed, the screenshot size
  70276. * will be derived from the parameters. The precision property is a multiplier allowing
  70277. * rendering at a higher or lower resolution
  70278. * @param successCallback The callback receives a single parameter which contains the
  70279. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70280. * src parameter of an <img> to display it
  70281. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70282. * Check your browser for supported MIME types
  70283. * @param samples Texture samples (default: 1)
  70284. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70285. * @param fileName A name for for the downloaded file.
  70286. */
  70287. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  70288. /**
  70289. * Generates an image screenshot from the specified camera.
  70290. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70291. * @param engine The engine to use for rendering
  70292. * @param camera The camera to use for rendering
  70293. * @param size This parameter can be set to a single number or to an object with the
  70294. * following (optional) properties: precision, width, height. If a single number is passed,
  70295. * it will be used for both width and height. If an object is passed, the screenshot size
  70296. * will be derived from the parameters. The precision property is a multiplier allowing
  70297. * rendering at a higher or lower resolution
  70298. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70299. * Check your browser for supported MIME types
  70300. * @param samples Texture samples (default: 1)
  70301. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70302. * @param fileName A name for for the downloaded file.
  70303. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70304. * to the src parameter of an <img> to display it
  70305. */
  70306. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  70307. /**
  70308. * Gets height and width for screenshot size
  70309. * @private
  70310. */
  70311. private static _getScreenshotSize;
  70312. }
  70313. }
  70314. declare module "babylonjs/Misc/dataReader" {
  70315. /**
  70316. * Interface for a data buffer
  70317. */
  70318. export interface IDataBuffer {
  70319. /**
  70320. * Reads bytes from the data buffer.
  70321. * @param byteOffset The byte offset to read
  70322. * @param byteLength The byte length to read
  70323. * @returns A promise that resolves when the bytes are read
  70324. */
  70325. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70326. /**
  70327. * The byte length of the buffer.
  70328. */
  70329. readonly byteLength: number;
  70330. }
  70331. /**
  70332. * Utility class for reading from a data buffer
  70333. */
  70334. export class DataReader {
  70335. /**
  70336. * The data buffer associated with this data reader.
  70337. */
  70338. readonly buffer: IDataBuffer;
  70339. /**
  70340. * The current byte offset from the beginning of the data buffer.
  70341. */
  70342. byteOffset: number;
  70343. private _dataView;
  70344. private _dataByteOffset;
  70345. /**
  70346. * Constructor
  70347. * @param buffer The buffer to read
  70348. */
  70349. constructor(buffer: IDataBuffer);
  70350. /**
  70351. * Loads the given byte length.
  70352. * @param byteLength The byte length to load
  70353. * @returns A promise that resolves when the load is complete
  70354. */
  70355. loadAsync(byteLength: number): Promise<void>;
  70356. /**
  70357. * Read a unsigned 32-bit integer from the currently loaded data range.
  70358. * @returns The 32-bit integer read
  70359. */
  70360. readUint32(): number;
  70361. /**
  70362. * Read a byte array from the currently loaded data range.
  70363. * @param byteLength The byte length to read
  70364. * @returns The byte array read
  70365. */
  70366. readUint8Array(byteLength: number): Uint8Array;
  70367. /**
  70368. * Read a string from the currently loaded data range.
  70369. * @param byteLength The byte length to read
  70370. * @returns The string read
  70371. */
  70372. readString(byteLength: number): string;
  70373. /**
  70374. * Skips the given byte length the currently loaded data range.
  70375. * @param byteLength The byte length to skip
  70376. */
  70377. skipBytes(byteLength: number): void;
  70378. }
  70379. }
  70380. declare module "babylonjs/Misc/index" {
  70381. export * from "babylonjs/Misc/andOrNotEvaluator";
  70382. export * from "babylonjs/Misc/assetsManager";
  70383. export * from "babylonjs/Misc/basis";
  70384. export * from "babylonjs/Misc/dds";
  70385. export * from "babylonjs/Misc/decorators";
  70386. export * from "babylonjs/Misc/deferred";
  70387. export * from "babylonjs/Misc/environmentTextureTools";
  70388. export * from "babylonjs/Misc/meshExploder";
  70389. export * from "babylonjs/Misc/filesInput";
  70390. export * from "babylonjs/Misc/HighDynamicRange/index";
  70391. export * from "babylonjs/Misc/khronosTextureContainer";
  70392. export * from "babylonjs/Misc/observable";
  70393. export * from "babylonjs/Misc/performanceMonitor";
  70394. export * from "babylonjs/Misc/promise";
  70395. export * from "babylonjs/Misc/sceneOptimizer";
  70396. export * from "babylonjs/Misc/sceneSerializer";
  70397. export * from "babylonjs/Misc/smartArray";
  70398. export * from "babylonjs/Misc/stringDictionary";
  70399. export * from "babylonjs/Misc/tags";
  70400. export * from "babylonjs/Misc/textureTools";
  70401. export * from "babylonjs/Misc/tga";
  70402. export * from "babylonjs/Misc/tools";
  70403. export * from "babylonjs/Misc/videoRecorder";
  70404. export * from "babylonjs/Misc/virtualJoystick";
  70405. export * from "babylonjs/Misc/workerPool";
  70406. export * from "babylonjs/Misc/logger";
  70407. export * from "babylonjs/Misc/typeStore";
  70408. export * from "babylonjs/Misc/filesInputStore";
  70409. export * from "babylonjs/Misc/deepCopier";
  70410. export * from "babylonjs/Misc/pivotTools";
  70411. export * from "babylonjs/Misc/precisionDate";
  70412. export * from "babylonjs/Misc/screenshotTools";
  70413. export * from "babylonjs/Misc/typeStore";
  70414. export * from "babylonjs/Misc/webRequest";
  70415. export * from "babylonjs/Misc/iInspectable";
  70416. export * from "babylonjs/Misc/brdfTextureTools";
  70417. export * from "babylonjs/Misc/rgbdTextureTools";
  70418. export * from "babylonjs/Misc/gradients";
  70419. export * from "babylonjs/Misc/perfCounter";
  70420. export * from "babylonjs/Misc/fileRequest";
  70421. export * from "babylonjs/Misc/customAnimationFrameRequester";
  70422. export * from "babylonjs/Misc/retryStrategy";
  70423. export * from "babylonjs/Misc/interfaces/screenshotSize";
  70424. export * from "babylonjs/Misc/canvasGenerator";
  70425. export * from "babylonjs/Misc/fileTools";
  70426. export * from "babylonjs/Misc/stringTools";
  70427. export * from "babylonjs/Misc/dataReader";
  70428. }
  70429. declare module "babylonjs/index" {
  70430. export * from "babylonjs/abstractScene";
  70431. export * from "babylonjs/Actions/index";
  70432. export * from "babylonjs/Animations/index";
  70433. export * from "babylonjs/assetContainer";
  70434. export * from "babylonjs/Audio/index";
  70435. export * from "babylonjs/Behaviors/index";
  70436. export * from "babylonjs/Bones/index";
  70437. export * from "babylonjs/Cameras/index";
  70438. export * from "babylonjs/Collisions/index";
  70439. export * from "babylonjs/Culling/index";
  70440. export * from "babylonjs/Debug/index";
  70441. export * from "babylonjs/Engines/index";
  70442. export * from "babylonjs/Events/index";
  70443. export * from "babylonjs/Gamepads/index";
  70444. export * from "babylonjs/Gizmos/index";
  70445. export * from "babylonjs/Helpers/index";
  70446. export * from "babylonjs/Instrumentation/index";
  70447. export * from "babylonjs/Layers/index";
  70448. export * from "babylonjs/LensFlares/index";
  70449. export * from "babylonjs/Lights/index";
  70450. export * from "babylonjs/Loading/index";
  70451. export * from "babylonjs/Materials/index";
  70452. export * from "babylonjs/Maths/index";
  70453. export * from "babylonjs/Meshes/index";
  70454. export * from "babylonjs/Morph/index";
  70455. export * from "babylonjs/Navigation/index";
  70456. export * from "babylonjs/node";
  70457. export * from "babylonjs/Offline/index";
  70458. export * from "babylonjs/Particles/index";
  70459. export * from "babylonjs/Physics/index";
  70460. export * from "babylonjs/PostProcesses/index";
  70461. export * from "babylonjs/Probes/index";
  70462. export * from "babylonjs/Rendering/index";
  70463. export * from "babylonjs/scene";
  70464. export * from "babylonjs/sceneComponent";
  70465. export * from "babylonjs/Sprites/index";
  70466. export * from "babylonjs/States/index";
  70467. export * from "babylonjs/Misc/index";
  70468. export * from "babylonjs/types";
  70469. }
  70470. declare module "babylonjs/Animations/pathCursor" {
  70471. import { Vector3 } from "babylonjs/Maths/math.vector";
  70472. import { Path2 } from "babylonjs/Maths/math.path";
  70473. /**
  70474. * A cursor which tracks a point on a path
  70475. */
  70476. export class PathCursor {
  70477. private path;
  70478. /**
  70479. * Stores path cursor callbacks for when an onchange event is triggered
  70480. */
  70481. private _onchange;
  70482. /**
  70483. * The value of the path cursor
  70484. */
  70485. value: number;
  70486. /**
  70487. * The animation array of the path cursor
  70488. */
  70489. animations: Animation[];
  70490. /**
  70491. * Initializes the path cursor
  70492. * @param path The path to track
  70493. */
  70494. constructor(path: Path2);
  70495. /**
  70496. * Gets the cursor point on the path
  70497. * @returns A point on the path cursor at the cursor location
  70498. */
  70499. getPoint(): Vector3;
  70500. /**
  70501. * Moves the cursor ahead by the step amount
  70502. * @param step The amount to move the cursor forward
  70503. * @returns This path cursor
  70504. */
  70505. moveAhead(step?: number): PathCursor;
  70506. /**
  70507. * Moves the cursor behind by the step amount
  70508. * @param step The amount to move the cursor back
  70509. * @returns This path cursor
  70510. */
  70511. moveBack(step?: number): PathCursor;
  70512. /**
  70513. * Moves the cursor by the step amount
  70514. * If the step amount is greater than one, an exception is thrown
  70515. * @param step The amount to move the cursor
  70516. * @returns This path cursor
  70517. */
  70518. move(step: number): PathCursor;
  70519. /**
  70520. * Ensures that the value is limited between zero and one
  70521. * @returns This path cursor
  70522. */
  70523. private ensureLimits;
  70524. /**
  70525. * Runs onchange callbacks on change (used by the animation engine)
  70526. * @returns This path cursor
  70527. */
  70528. private raiseOnChange;
  70529. /**
  70530. * Executes a function on change
  70531. * @param f A path cursor onchange callback
  70532. * @returns This path cursor
  70533. */
  70534. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70535. }
  70536. }
  70537. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  70538. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  70539. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  70540. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  70541. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  70542. }
  70543. declare module "babylonjs/Engines/Processors/Expressions/index" {
  70544. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  70545. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  70546. }
  70547. declare module "babylonjs/Engines/Processors/index" {
  70548. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  70549. export * from "babylonjs/Engines/Processors/Expressions/index";
  70550. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  70551. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  70552. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  70553. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  70554. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  70555. export * from "babylonjs/Engines/Processors/shaderProcessor";
  70556. }
  70557. declare module "babylonjs/Legacy/legacy" {
  70558. import * as Babylon from "babylonjs/index";
  70559. export * from "babylonjs/index";
  70560. }
  70561. declare module "babylonjs/Shaders/blur.fragment" {
  70562. /** @hidden */
  70563. export var blurPixelShader: {
  70564. name: string;
  70565. shader: string;
  70566. };
  70567. }
  70568. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  70569. /** @hidden */
  70570. export var pointCloudVertexDeclaration: {
  70571. name: string;
  70572. shader: string;
  70573. };
  70574. }
  70575. declare module "babylonjs" {
  70576. export * from "babylonjs/Legacy/legacy";
  70577. }
  70578. declare module BABYLON {
  70579. /** Alias type for value that can be null */
  70580. export type Nullable<T> = T | null;
  70581. /**
  70582. * Alias type for number that are floats
  70583. * @ignorenaming
  70584. */
  70585. export type float = number;
  70586. /**
  70587. * Alias type for number that are doubles.
  70588. * @ignorenaming
  70589. */
  70590. export type double = number;
  70591. /**
  70592. * Alias type for number that are integer
  70593. * @ignorenaming
  70594. */
  70595. export type int = number;
  70596. /** Alias type for number array or Float32Array */
  70597. export type FloatArray = number[] | Float32Array;
  70598. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  70599. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  70600. /**
  70601. * Alias for types that can be used by a Buffer or VertexBuffer.
  70602. */
  70603. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  70604. /**
  70605. * Alias type for primitive types
  70606. * @ignorenaming
  70607. */
  70608. type Primitive = undefined | null | boolean | string | number | Function;
  70609. /**
  70610. * Type modifier to make all the properties of an object Readonly
  70611. */
  70612. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  70613. /**
  70614. * Type modifier to make all the properties of an object Readonly recursively
  70615. */
  70616. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  70617. /**
  70618. * Type modifier to make object properties readonly.
  70619. */
  70620. export type DeepImmutableObject<T> = {
  70621. readonly [K in keyof T]: DeepImmutable<T[K]>;
  70622. };
  70623. /** @hidden */
  70624. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  70625. }
  70626. }
  70627. declare module BABYLON {
  70628. /**
  70629. * A class serves as a medium between the observable and its observers
  70630. */
  70631. export class EventState {
  70632. /**
  70633. * Create a new EventState
  70634. * @param mask defines the mask associated with this state
  70635. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70636. * @param target defines the original target of the state
  70637. * @param currentTarget defines the current target of the state
  70638. */
  70639. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  70640. /**
  70641. * Initialize the current event state
  70642. * @param mask defines the mask associated with this state
  70643. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70644. * @param target defines the original target of the state
  70645. * @param currentTarget defines the current target of the state
  70646. * @returns the current event state
  70647. */
  70648. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  70649. /**
  70650. * An Observer can set this property to true to prevent subsequent observers of being notified
  70651. */
  70652. skipNextObservers: boolean;
  70653. /**
  70654. * Get the mask value that were used to trigger the event corresponding to this EventState object
  70655. */
  70656. mask: number;
  70657. /**
  70658. * The object that originally notified the event
  70659. */
  70660. target?: any;
  70661. /**
  70662. * The current object in the bubbling phase
  70663. */
  70664. currentTarget?: any;
  70665. /**
  70666. * This will be populated with the return value of the last function that was executed.
  70667. * If it is the first function in the callback chain it will be the event data.
  70668. */
  70669. lastReturnValue?: any;
  70670. }
  70671. /**
  70672. * Represent an Observer registered to a given Observable object.
  70673. */
  70674. export class Observer<T> {
  70675. /**
  70676. * Defines the callback to call when the observer is notified
  70677. */
  70678. callback: (eventData: T, eventState: EventState) => void;
  70679. /**
  70680. * Defines the mask of the observer (used to filter notifications)
  70681. */
  70682. mask: number;
  70683. /**
  70684. * Defines the current scope used to restore the JS context
  70685. */
  70686. scope: any;
  70687. /** @hidden */
  70688. _willBeUnregistered: boolean;
  70689. /**
  70690. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  70691. */
  70692. unregisterOnNextCall: boolean;
  70693. /**
  70694. * Creates a new observer
  70695. * @param callback defines the callback to call when the observer is notified
  70696. * @param mask defines the mask of the observer (used to filter notifications)
  70697. * @param scope defines the current scope used to restore the JS context
  70698. */
  70699. constructor(
  70700. /**
  70701. * Defines the callback to call when the observer is notified
  70702. */
  70703. callback: (eventData: T, eventState: EventState) => void,
  70704. /**
  70705. * Defines the mask of the observer (used to filter notifications)
  70706. */
  70707. mask: number,
  70708. /**
  70709. * Defines the current scope used to restore the JS context
  70710. */
  70711. scope?: any);
  70712. }
  70713. /**
  70714. * Represent a list of observers registered to multiple Observables object.
  70715. */
  70716. export class MultiObserver<T> {
  70717. private _observers;
  70718. private _observables;
  70719. /**
  70720. * Release associated resources
  70721. */
  70722. dispose(): void;
  70723. /**
  70724. * Raise a callback when one of the observable will notify
  70725. * @param observables defines a list of observables to watch
  70726. * @param callback defines the callback to call on notification
  70727. * @param mask defines the mask used to filter notifications
  70728. * @param scope defines the current scope used to restore the JS context
  70729. * @returns the new MultiObserver
  70730. */
  70731. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  70732. }
  70733. /**
  70734. * The Observable class is a simple implementation of the Observable pattern.
  70735. *
  70736. * 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.
  70737. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  70738. * 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).
  70739. * 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.
  70740. */
  70741. export class Observable<T> {
  70742. private _observers;
  70743. private _eventState;
  70744. private _onObserverAdded;
  70745. /**
  70746. * Gets the list of observers
  70747. */
  70748. get observers(): Array<Observer<T>>;
  70749. /**
  70750. * Creates a new observable
  70751. * @param onObserverAdded defines a callback to call when a new observer is added
  70752. */
  70753. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  70754. /**
  70755. * Create a new Observer with the specified callback
  70756. * @param callback the callback that will be executed for that Observer
  70757. * @param mask the mask used to filter observers
  70758. * @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.
  70759. * @param scope optional scope for the callback to be called from
  70760. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  70761. * @returns the new observer created for the callback
  70762. */
  70763. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  70764. /**
  70765. * Create a new Observer with the specified callback and unregisters after the next notification
  70766. * @param callback the callback that will be executed for that Observer
  70767. * @returns the new observer created for the callback
  70768. */
  70769. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  70770. /**
  70771. * Remove an Observer from the Observable object
  70772. * @param observer the instance of the Observer to remove
  70773. * @returns false if it doesn't belong to this Observable
  70774. */
  70775. remove(observer: Nullable<Observer<T>>): boolean;
  70776. /**
  70777. * Remove a callback from the Observable object
  70778. * @param callback the callback to remove
  70779. * @param scope optional scope. If used only the callbacks with this scope will be removed
  70780. * @returns false if it doesn't belong to this Observable
  70781. */
  70782. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  70783. private _deferUnregister;
  70784. private _remove;
  70785. /**
  70786. * Moves the observable to the top of the observer list making it get called first when notified
  70787. * @param observer the observer to move
  70788. */
  70789. makeObserverTopPriority(observer: Observer<T>): void;
  70790. /**
  70791. * Moves the observable to the bottom of the observer list making it get called last when notified
  70792. * @param observer the observer to move
  70793. */
  70794. makeObserverBottomPriority(observer: Observer<T>): void;
  70795. /**
  70796. * Notify all Observers by calling their respective callback with the given data
  70797. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  70798. * @param eventData defines the data to send to all observers
  70799. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  70800. * @param target defines the original target of the state
  70801. * @param currentTarget defines the current target of the state
  70802. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  70803. */
  70804. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  70805. /**
  70806. * Calling this will execute each callback, expecting it to be a promise or return a value.
  70807. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  70808. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  70809. * and it is crucial that all callbacks will be executed.
  70810. * The order of the callbacks is kept, callbacks are not executed parallel.
  70811. *
  70812. * @param eventData The data to be sent to each callback
  70813. * @param mask is used to filter observers defaults to -1
  70814. * @param target defines the callback target (see EventState)
  70815. * @param currentTarget defines he current object in the bubbling phase
  70816. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  70817. */
  70818. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  70819. /**
  70820. * Notify a specific observer
  70821. * @param observer defines the observer to notify
  70822. * @param eventData defines the data to be sent to each callback
  70823. * @param mask is used to filter observers defaults to -1
  70824. */
  70825. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  70826. /**
  70827. * Gets a boolean indicating if the observable has at least one observer
  70828. * @returns true is the Observable has at least one Observer registered
  70829. */
  70830. hasObservers(): boolean;
  70831. /**
  70832. * Clear the list of observers
  70833. */
  70834. clear(): void;
  70835. /**
  70836. * Clone the current observable
  70837. * @returns a new observable
  70838. */
  70839. clone(): Observable<T>;
  70840. /**
  70841. * Does this observable handles observer registered with a given mask
  70842. * @param mask defines the mask to be tested
  70843. * @return whether or not one observer registered with the given mask is handeled
  70844. **/
  70845. hasSpecificMask(mask?: number): boolean;
  70846. }
  70847. }
  70848. declare module BABYLON {
  70849. /**
  70850. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  70851. * Babylon.js
  70852. */
  70853. export class DomManagement {
  70854. /**
  70855. * Checks if the window object exists
  70856. * @returns true if the window object exists
  70857. */
  70858. static IsWindowObjectExist(): boolean;
  70859. /**
  70860. * Checks if the navigator object exists
  70861. * @returns true if the navigator object exists
  70862. */
  70863. static IsNavigatorAvailable(): boolean;
  70864. /**
  70865. * Extracts text content from a DOM element hierarchy
  70866. * @param element defines the root element
  70867. * @returns a string
  70868. */
  70869. static GetDOMTextContent(element: HTMLElement): string;
  70870. }
  70871. }
  70872. declare module BABYLON {
  70873. /**
  70874. * Logger used througouht the application to allow configuration of
  70875. * the log level required for the messages.
  70876. */
  70877. export class Logger {
  70878. /**
  70879. * No log
  70880. */
  70881. static readonly NoneLogLevel: number;
  70882. /**
  70883. * Only message logs
  70884. */
  70885. static readonly MessageLogLevel: number;
  70886. /**
  70887. * Only warning logs
  70888. */
  70889. static readonly WarningLogLevel: number;
  70890. /**
  70891. * Only error logs
  70892. */
  70893. static readonly ErrorLogLevel: number;
  70894. /**
  70895. * All logs
  70896. */
  70897. static readonly AllLogLevel: number;
  70898. private static _LogCache;
  70899. /**
  70900. * Gets a value indicating the number of loading errors
  70901. * @ignorenaming
  70902. */
  70903. static errorsCount: number;
  70904. /**
  70905. * Callback called when a new log is added
  70906. */
  70907. static OnNewCacheEntry: (entry: string) => void;
  70908. private static _AddLogEntry;
  70909. private static _FormatMessage;
  70910. private static _LogDisabled;
  70911. private static _LogEnabled;
  70912. private static _WarnDisabled;
  70913. private static _WarnEnabled;
  70914. private static _ErrorDisabled;
  70915. private static _ErrorEnabled;
  70916. /**
  70917. * Log a message to the console
  70918. */
  70919. static Log: (message: string) => void;
  70920. /**
  70921. * Write a warning message to the console
  70922. */
  70923. static Warn: (message: string) => void;
  70924. /**
  70925. * Write an error message to the console
  70926. */
  70927. static Error: (message: string) => void;
  70928. /**
  70929. * Gets current log cache (list of logs)
  70930. */
  70931. static get LogCache(): string;
  70932. /**
  70933. * Clears the log cache
  70934. */
  70935. static ClearLogCache(): void;
  70936. /**
  70937. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  70938. */
  70939. static set LogLevels(level: number);
  70940. }
  70941. }
  70942. declare module BABYLON {
  70943. /** @hidden */
  70944. export class _TypeStore {
  70945. /** @hidden */
  70946. static RegisteredTypes: {
  70947. [key: string]: Object;
  70948. };
  70949. /** @hidden */
  70950. static GetClass(fqdn: string): any;
  70951. }
  70952. }
  70953. declare module BABYLON {
  70954. /**
  70955. * Helper to manipulate strings
  70956. */
  70957. export class StringTools {
  70958. /**
  70959. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70960. * @param str Source string
  70961. * @param suffix Suffix to search for in the source string
  70962. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70963. */
  70964. static EndsWith(str: string, suffix: string): boolean;
  70965. /**
  70966. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70967. * @param str Source string
  70968. * @param suffix Suffix to search for in the source string
  70969. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70970. */
  70971. static StartsWith(str: string, suffix: string): boolean;
  70972. /**
  70973. * Decodes a buffer into a string
  70974. * @param buffer The buffer to decode
  70975. * @returns The decoded string
  70976. */
  70977. static Decode(buffer: Uint8Array | Uint16Array): string;
  70978. /**
  70979. * Encode a buffer to a base64 string
  70980. * @param buffer defines the buffer to encode
  70981. * @returns the encoded string
  70982. */
  70983. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  70984. }
  70985. }
  70986. declare module BABYLON {
  70987. /**
  70988. * Class containing a set of static utilities functions for deep copy.
  70989. */
  70990. export class DeepCopier {
  70991. /**
  70992. * Tries to copy an object by duplicating every property
  70993. * @param source defines the source object
  70994. * @param destination defines the target object
  70995. * @param doNotCopyList defines a list of properties to avoid
  70996. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  70997. */
  70998. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  70999. }
  71000. }
  71001. declare module BABYLON {
  71002. /**
  71003. * Class containing a set of static utilities functions for precision date
  71004. */
  71005. export class PrecisionDate {
  71006. /**
  71007. * Gets either window.performance.now() if supported or Date.now() else
  71008. */
  71009. static get Now(): number;
  71010. }
  71011. }
  71012. declare module BABYLON {
  71013. /** @hidden */
  71014. export class _DevTools {
  71015. static WarnImport(name: string): string;
  71016. }
  71017. }
  71018. declare module BABYLON {
  71019. /**
  71020. * Interface used to define the mechanism to get data from the network
  71021. */
  71022. export interface IWebRequest {
  71023. /**
  71024. * Returns client's response url
  71025. */
  71026. responseURL: string;
  71027. /**
  71028. * Returns client's status
  71029. */
  71030. status: number;
  71031. /**
  71032. * Returns client's status as a text
  71033. */
  71034. statusText: string;
  71035. }
  71036. }
  71037. declare module BABYLON {
  71038. /**
  71039. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71040. */
  71041. export class WebRequest implements IWebRequest {
  71042. private _xhr;
  71043. /**
  71044. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71045. * i.e. when loading files, where the server/service expects an Authorization header
  71046. */
  71047. static CustomRequestHeaders: {
  71048. [key: string]: string;
  71049. };
  71050. /**
  71051. * Add callback functions in this array to update all the requests before they get sent to the network
  71052. */
  71053. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71054. private _injectCustomRequestHeaders;
  71055. /**
  71056. * Gets or sets a function to be called when loading progress changes
  71057. */
  71058. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71059. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71060. /**
  71061. * Returns client's state
  71062. */
  71063. get readyState(): number;
  71064. /**
  71065. * Returns client's status
  71066. */
  71067. get status(): number;
  71068. /**
  71069. * Returns client's status as a text
  71070. */
  71071. get statusText(): string;
  71072. /**
  71073. * Returns client's response
  71074. */
  71075. get response(): any;
  71076. /**
  71077. * Returns client's response url
  71078. */
  71079. get responseURL(): string;
  71080. /**
  71081. * Returns client's response as text
  71082. */
  71083. get responseText(): string;
  71084. /**
  71085. * Gets or sets the expected response type
  71086. */
  71087. get responseType(): XMLHttpRequestResponseType;
  71088. set responseType(value: XMLHttpRequestResponseType);
  71089. /** @hidden */
  71090. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71091. /** @hidden */
  71092. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71093. /**
  71094. * Cancels any network activity
  71095. */
  71096. abort(): void;
  71097. /**
  71098. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71099. * @param body defines an optional request body
  71100. */
  71101. send(body?: Document | BodyInit | null): void;
  71102. /**
  71103. * Sets the request method, request URL
  71104. * @param method defines the method to use (GET, POST, etc..)
  71105. * @param url defines the url to connect with
  71106. */
  71107. open(method: string, url: string): void;
  71108. /**
  71109. * Sets the value of a request header.
  71110. * @param name The name of the header whose value is to be set
  71111. * @param value The value to set as the body of the header
  71112. */
  71113. setRequestHeader(name: string, value: string): void;
  71114. /**
  71115. * Get the string containing the text of a particular header's value.
  71116. * @param name The name of the header
  71117. * @returns The string containing the text of the given header name
  71118. */
  71119. getResponseHeader(name: string): Nullable<string>;
  71120. }
  71121. }
  71122. declare module BABYLON {
  71123. /**
  71124. * File request interface
  71125. */
  71126. export interface IFileRequest {
  71127. /**
  71128. * Raised when the request is complete (success or error).
  71129. */
  71130. onCompleteObservable: Observable<IFileRequest>;
  71131. /**
  71132. * Aborts the request for a file.
  71133. */
  71134. abort: () => void;
  71135. }
  71136. }
  71137. declare module BABYLON {
  71138. /**
  71139. * Define options used to create a render target texture
  71140. */
  71141. export class RenderTargetCreationOptions {
  71142. /**
  71143. * Specifies is mipmaps must be generated
  71144. */
  71145. generateMipMaps?: boolean;
  71146. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71147. generateDepthBuffer?: boolean;
  71148. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71149. generateStencilBuffer?: boolean;
  71150. /** Defines texture type (int by default) */
  71151. type?: number;
  71152. /** Defines sampling mode (trilinear by default) */
  71153. samplingMode?: number;
  71154. /** Defines format (RGBA by default) */
  71155. format?: number;
  71156. }
  71157. }
  71158. declare module BABYLON {
  71159. /**
  71160. * @hidden
  71161. **/
  71162. export class _TimeToken {
  71163. _startTimeQuery: Nullable<WebGLQuery>;
  71164. _endTimeQuery: Nullable<WebGLQuery>;
  71165. _timeElapsedQuery: Nullable<WebGLQuery>;
  71166. _timeElapsedQueryEnded: boolean;
  71167. }
  71168. }
  71169. declare module BABYLON {
  71170. /** Defines the cross module used constants to avoid circular dependncies */
  71171. export class Constants {
  71172. /** Defines that alpha blending is disabled */
  71173. static readonly ALPHA_DISABLE: number;
  71174. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  71175. static readonly ALPHA_ADD: number;
  71176. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71177. static readonly ALPHA_COMBINE: number;
  71178. /** Defines that alpha blending is DEST - SRC * DEST */
  71179. static readonly ALPHA_SUBTRACT: number;
  71180. /** Defines that alpha blending is SRC * DEST */
  71181. static readonly ALPHA_MULTIPLY: number;
  71182. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  71183. static readonly ALPHA_MAXIMIZED: number;
  71184. /** Defines that alpha blending is SRC + DEST */
  71185. static readonly ALPHA_ONEONE: number;
  71186. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  71187. static readonly ALPHA_PREMULTIPLIED: number;
  71188. /**
  71189. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  71190. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71191. */
  71192. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71193. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  71194. static readonly ALPHA_INTERPOLATE: number;
  71195. /**
  71196. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  71197. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71198. */
  71199. static readonly ALPHA_SCREENMODE: number;
  71200. /**
  71201. * Defines that alpha blending is SRC + DST
  71202. * Alpha will be set to SRC ALPHA + DST ALPHA
  71203. */
  71204. static readonly ALPHA_ONEONE_ONEONE: number;
  71205. /**
  71206. * Defines that alpha blending is SRC * DST ALPHA + DST
  71207. * Alpha will be set to 0
  71208. */
  71209. static readonly ALPHA_ALPHATOCOLOR: number;
  71210. /**
  71211. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71212. */
  71213. static readonly ALPHA_REVERSEONEMINUS: number;
  71214. /**
  71215. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  71216. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71217. */
  71218. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71219. /**
  71220. * Defines that alpha blending is SRC + DST
  71221. * Alpha will be set to SRC ALPHA
  71222. */
  71223. static readonly ALPHA_ONEONE_ONEZERO: number;
  71224. /**
  71225. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71226. * Alpha will be set to DST ALPHA
  71227. */
  71228. static readonly ALPHA_EXCLUSION: number;
  71229. /** Defines that alpha blending equation a SUM */
  71230. static readonly ALPHA_EQUATION_ADD: number;
  71231. /** Defines that alpha blending equation a SUBSTRACTION */
  71232. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71233. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71234. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71235. /** Defines that alpha blending equation a MAX operation */
  71236. static readonly ALPHA_EQUATION_MAX: number;
  71237. /** Defines that alpha blending equation a MIN operation */
  71238. static readonly ALPHA_EQUATION_MIN: number;
  71239. /**
  71240. * Defines that alpha blending equation a DARKEN operation:
  71241. * It takes the min of the src and sums the alpha channels.
  71242. */
  71243. static readonly ALPHA_EQUATION_DARKEN: number;
  71244. /** Defines that the ressource is not delayed*/
  71245. static readonly DELAYLOADSTATE_NONE: number;
  71246. /** Defines that the ressource was successfully delay loaded */
  71247. static readonly DELAYLOADSTATE_LOADED: number;
  71248. /** Defines that the ressource is currently delay loading */
  71249. static readonly DELAYLOADSTATE_LOADING: number;
  71250. /** Defines that the ressource is delayed and has not started loading */
  71251. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71252. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71253. static readonly NEVER: number;
  71254. /** 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 */
  71255. static readonly ALWAYS: number;
  71256. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71257. static readonly LESS: number;
  71258. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71259. static readonly EQUAL: number;
  71260. /** 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 */
  71261. static readonly LEQUAL: number;
  71262. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71263. static readonly GREATER: number;
  71264. /** 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 */
  71265. static readonly GEQUAL: number;
  71266. /** 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 */
  71267. static readonly NOTEQUAL: number;
  71268. /** Passed to stencilOperation to specify that stencil value must be kept */
  71269. static readonly KEEP: number;
  71270. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71271. static readonly REPLACE: number;
  71272. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71273. static readonly INCR: number;
  71274. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71275. static readonly DECR: number;
  71276. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71277. static readonly INVERT: number;
  71278. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71279. static readonly INCR_WRAP: number;
  71280. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71281. static readonly DECR_WRAP: number;
  71282. /** Texture is not repeating outside of 0..1 UVs */
  71283. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71284. /** Texture is repeating outside of 0..1 UVs */
  71285. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71286. /** Texture is repeating and mirrored */
  71287. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71288. /** ALPHA */
  71289. static readonly TEXTUREFORMAT_ALPHA: number;
  71290. /** LUMINANCE */
  71291. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71292. /** LUMINANCE_ALPHA */
  71293. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71294. /** RGB */
  71295. static readonly TEXTUREFORMAT_RGB: number;
  71296. /** RGBA */
  71297. static readonly TEXTUREFORMAT_RGBA: number;
  71298. /** RED */
  71299. static readonly TEXTUREFORMAT_RED: number;
  71300. /** RED (2nd reference) */
  71301. static readonly TEXTUREFORMAT_R: number;
  71302. /** RG */
  71303. static readonly TEXTUREFORMAT_RG: number;
  71304. /** RED_INTEGER */
  71305. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71306. /** RED_INTEGER (2nd reference) */
  71307. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71308. /** RG_INTEGER */
  71309. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71310. /** RGB_INTEGER */
  71311. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71312. /** RGBA_INTEGER */
  71313. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71314. /** UNSIGNED_BYTE */
  71315. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71316. /** UNSIGNED_BYTE (2nd reference) */
  71317. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71318. /** FLOAT */
  71319. static readonly TEXTURETYPE_FLOAT: number;
  71320. /** HALF_FLOAT */
  71321. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71322. /** BYTE */
  71323. static readonly TEXTURETYPE_BYTE: number;
  71324. /** SHORT */
  71325. static readonly TEXTURETYPE_SHORT: number;
  71326. /** UNSIGNED_SHORT */
  71327. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71328. /** INT */
  71329. static readonly TEXTURETYPE_INT: number;
  71330. /** UNSIGNED_INT */
  71331. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71332. /** UNSIGNED_SHORT_4_4_4_4 */
  71333. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71334. /** UNSIGNED_SHORT_5_5_5_1 */
  71335. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71336. /** UNSIGNED_SHORT_5_6_5 */
  71337. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71338. /** UNSIGNED_INT_2_10_10_10_REV */
  71339. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71340. /** UNSIGNED_INT_24_8 */
  71341. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71342. /** UNSIGNED_INT_10F_11F_11F_REV */
  71343. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71344. /** UNSIGNED_INT_5_9_9_9_REV */
  71345. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71346. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71347. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71348. /** nearest is mag = nearest and min = nearest and mip = nearest */
  71349. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71350. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71351. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71352. /** Trilinear is mag = linear and min = linear and mip = linear */
  71353. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71354. /** nearest is mag = nearest and min = nearest and mip = linear */
  71355. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71356. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71357. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71358. /** Trilinear is mag = linear and min = linear and mip = linear */
  71359. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71360. /** mag = nearest and min = nearest and mip = nearest */
  71361. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71362. /** mag = nearest and min = linear and mip = nearest */
  71363. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71364. /** mag = nearest and min = linear and mip = linear */
  71365. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71366. /** mag = nearest and min = linear and mip = none */
  71367. static readonly TEXTURE_NEAREST_LINEAR: number;
  71368. /** mag = nearest and min = nearest and mip = none */
  71369. static readonly TEXTURE_NEAREST_NEAREST: number;
  71370. /** mag = linear and min = nearest and mip = nearest */
  71371. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71372. /** mag = linear and min = nearest and mip = linear */
  71373. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71374. /** mag = linear and min = linear and mip = none */
  71375. static readonly TEXTURE_LINEAR_LINEAR: number;
  71376. /** mag = linear and min = nearest and mip = none */
  71377. static readonly TEXTURE_LINEAR_NEAREST: number;
  71378. /** Explicit coordinates mode */
  71379. static readonly TEXTURE_EXPLICIT_MODE: number;
  71380. /** Spherical coordinates mode */
  71381. static readonly TEXTURE_SPHERICAL_MODE: number;
  71382. /** Planar coordinates mode */
  71383. static readonly TEXTURE_PLANAR_MODE: number;
  71384. /** Cubic coordinates mode */
  71385. static readonly TEXTURE_CUBIC_MODE: number;
  71386. /** Projection coordinates mode */
  71387. static readonly TEXTURE_PROJECTION_MODE: number;
  71388. /** Skybox coordinates mode */
  71389. static readonly TEXTURE_SKYBOX_MODE: number;
  71390. /** Inverse Cubic coordinates mode */
  71391. static readonly TEXTURE_INVCUBIC_MODE: number;
  71392. /** Equirectangular coordinates mode */
  71393. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71394. /** Equirectangular Fixed coordinates mode */
  71395. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71396. /** Equirectangular Fixed Mirrored coordinates mode */
  71397. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71398. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71399. static readonly SCALEMODE_FLOOR: number;
  71400. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71401. static readonly SCALEMODE_NEAREST: number;
  71402. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71403. static readonly SCALEMODE_CEILING: number;
  71404. /**
  71405. * The dirty texture flag value
  71406. */
  71407. static readonly MATERIAL_TextureDirtyFlag: number;
  71408. /**
  71409. * The dirty light flag value
  71410. */
  71411. static readonly MATERIAL_LightDirtyFlag: number;
  71412. /**
  71413. * The dirty fresnel flag value
  71414. */
  71415. static readonly MATERIAL_FresnelDirtyFlag: number;
  71416. /**
  71417. * The dirty attribute flag value
  71418. */
  71419. static readonly MATERIAL_AttributesDirtyFlag: number;
  71420. /**
  71421. * The dirty misc flag value
  71422. */
  71423. static readonly MATERIAL_MiscDirtyFlag: number;
  71424. /**
  71425. * The all dirty flag value
  71426. */
  71427. static readonly MATERIAL_AllDirtyFlag: number;
  71428. /**
  71429. * Returns the triangle fill mode
  71430. */
  71431. static readonly MATERIAL_TriangleFillMode: number;
  71432. /**
  71433. * Returns the wireframe mode
  71434. */
  71435. static readonly MATERIAL_WireFrameFillMode: number;
  71436. /**
  71437. * Returns the point fill mode
  71438. */
  71439. static readonly MATERIAL_PointFillMode: number;
  71440. /**
  71441. * Returns the point list draw mode
  71442. */
  71443. static readonly MATERIAL_PointListDrawMode: number;
  71444. /**
  71445. * Returns the line list draw mode
  71446. */
  71447. static readonly MATERIAL_LineListDrawMode: number;
  71448. /**
  71449. * Returns the line loop draw mode
  71450. */
  71451. static readonly MATERIAL_LineLoopDrawMode: number;
  71452. /**
  71453. * Returns the line strip draw mode
  71454. */
  71455. static readonly MATERIAL_LineStripDrawMode: number;
  71456. /**
  71457. * Returns the triangle strip draw mode
  71458. */
  71459. static readonly MATERIAL_TriangleStripDrawMode: number;
  71460. /**
  71461. * Returns the triangle fan draw mode
  71462. */
  71463. static readonly MATERIAL_TriangleFanDrawMode: number;
  71464. /**
  71465. * Stores the clock-wise side orientation
  71466. */
  71467. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71468. /**
  71469. * Stores the counter clock-wise side orientation
  71470. */
  71471. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71472. /**
  71473. * Nothing
  71474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71475. */
  71476. static readonly ACTION_NothingTrigger: number;
  71477. /**
  71478. * On pick
  71479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71480. */
  71481. static readonly ACTION_OnPickTrigger: number;
  71482. /**
  71483. * On left pick
  71484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71485. */
  71486. static readonly ACTION_OnLeftPickTrigger: number;
  71487. /**
  71488. * On right pick
  71489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71490. */
  71491. static readonly ACTION_OnRightPickTrigger: number;
  71492. /**
  71493. * On center pick
  71494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71495. */
  71496. static readonly ACTION_OnCenterPickTrigger: number;
  71497. /**
  71498. * On pick down
  71499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71500. */
  71501. static readonly ACTION_OnPickDownTrigger: number;
  71502. /**
  71503. * On double pick
  71504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71505. */
  71506. static readonly ACTION_OnDoublePickTrigger: number;
  71507. /**
  71508. * On pick up
  71509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71510. */
  71511. static readonly ACTION_OnPickUpTrigger: number;
  71512. /**
  71513. * On pick out.
  71514. * This trigger will only be raised if you also declared a OnPickDown
  71515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71516. */
  71517. static readonly ACTION_OnPickOutTrigger: number;
  71518. /**
  71519. * On long press
  71520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71521. */
  71522. static readonly ACTION_OnLongPressTrigger: number;
  71523. /**
  71524. * On pointer over
  71525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71526. */
  71527. static readonly ACTION_OnPointerOverTrigger: number;
  71528. /**
  71529. * On pointer out
  71530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71531. */
  71532. static readonly ACTION_OnPointerOutTrigger: number;
  71533. /**
  71534. * On every frame
  71535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71536. */
  71537. static readonly ACTION_OnEveryFrameTrigger: number;
  71538. /**
  71539. * On intersection enter
  71540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71541. */
  71542. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71543. /**
  71544. * On intersection exit
  71545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71546. */
  71547. static readonly ACTION_OnIntersectionExitTrigger: number;
  71548. /**
  71549. * On key down
  71550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71551. */
  71552. static readonly ACTION_OnKeyDownTrigger: number;
  71553. /**
  71554. * On key up
  71555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71556. */
  71557. static readonly ACTION_OnKeyUpTrigger: number;
  71558. /**
  71559. * Billboard mode will only apply to Y axis
  71560. */
  71561. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71562. /**
  71563. * Billboard mode will apply to all axes
  71564. */
  71565. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71566. /**
  71567. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71568. */
  71569. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71570. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71571. * Test order :
  71572. * Is the bounding sphere outside the frustum ?
  71573. * If not, are the bounding box vertices outside the frustum ?
  71574. * It not, then the cullable object is in the frustum.
  71575. */
  71576. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71577. /** Culling strategy : Bounding Sphere Only.
  71578. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71579. * It's also less accurate than the standard because some not visible objects can still be selected.
  71580. * Test : is the bounding sphere outside the frustum ?
  71581. * If not, then the cullable object is in the frustum.
  71582. */
  71583. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71584. /** Culling strategy : Optimistic Inclusion.
  71585. * This in an inclusion test first, then the standard exclusion test.
  71586. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71587. * 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.
  71588. * Anyway, it's as accurate as the standard strategy.
  71589. * Test :
  71590. * Is the cullable object bounding sphere center in the frustum ?
  71591. * If not, apply the default culling strategy.
  71592. */
  71593. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71594. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71595. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71596. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71597. * 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.
  71598. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71599. * Test :
  71600. * Is the cullable object bounding sphere center in the frustum ?
  71601. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71602. */
  71603. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71604. /**
  71605. * No logging while loading
  71606. */
  71607. static readonly SCENELOADER_NO_LOGGING: number;
  71608. /**
  71609. * Minimal logging while loading
  71610. */
  71611. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71612. /**
  71613. * Summary logging while loading
  71614. */
  71615. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71616. /**
  71617. * Detailled logging while loading
  71618. */
  71619. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71620. }
  71621. }
  71622. declare module BABYLON {
  71623. /**
  71624. * This represents the required contract to create a new type of texture loader.
  71625. */
  71626. export interface IInternalTextureLoader {
  71627. /**
  71628. * Defines wether the loader supports cascade loading the different faces.
  71629. */
  71630. supportCascades: boolean;
  71631. /**
  71632. * This returns if the loader support the current file information.
  71633. * @param extension defines the file extension of the file being loaded
  71634. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71635. * @param fallback defines the fallback internal texture if any
  71636. * @param isBase64 defines whether the texture is encoded as a base64
  71637. * @param isBuffer defines whether the texture data are stored as a buffer
  71638. * @returns true if the loader can load the specified file
  71639. */
  71640. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71641. /**
  71642. * Transform the url before loading if required.
  71643. * @param rootUrl the url of the texture
  71644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71645. * @returns the transformed texture
  71646. */
  71647. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71648. /**
  71649. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71650. * @param rootUrl the url of the texture
  71651. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71652. * @returns the fallback texture
  71653. */
  71654. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71655. /**
  71656. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71657. * @param data contains the texture data
  71658. * @param texture defines the BabylonJS internal texture
  71659. * @param createPolynomials will be true if polynomials have been requested
  71660. * @param onLoad defines the callback to trigger once the texture is ready
  71661. * @param onError defines the callback to trigger in case of error
  71662. */
  71663. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71664. /**
  71665. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71666. * @param data contains the texture data
  71667. * @param texture defines the BabylonJS internal texture
  71668. * @param callback defines the method to call once ready to upload
  71669. */
  71670. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71671. }
  71672. }
  71673. declare module BABYLON {
  71674. /**
  71675. * Class used to store and describe the pipeline context associated with an effect
  71676. */
  71677. export interface IPipelineContext {
  71678. /**
  71679. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71680. */
  71681. isAsync: boolean;
  71682. /**
  71683. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71684. */
  71685. isReady: boolean;
  71686. /** @hidden */
  71687. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71688. }
  71689. }
  71690. declare module BABYLON {
  71691. /**
  71692. * Class used to store gfx data (like WebGLBuffer)
  71693. */
  71694. export class DataBuffer {
  71695. /**
  71696. * Gets or sets the number of objects referencing this buffer
  71697. */
  71698. references: number;
  71699. /** Gets or sets the size of the underlying buffer */
  71700. capacity: number;
  71701. /**
  71702. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71703. */
  71704. is32Bits: boolean;
  71705. /**
  71706. * Gets the underlying buffer
  71707. */
  71708. get underlyingResource(): any;
  71709. }
  71710. }
  71711. declare module BABYLON {
  71712. /** @hidden */
  71713. export interface IShaderProcessor {
  71714. attributeProcessor?: (attribute: string) => string;
  71715. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71716. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71717. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71718. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71719. lineProcessor?: (line: string, isFragment: boolean) => string;
  71720. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71721. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71722. }
  71723. }
  71724. declare module BABYLON {
  71725. /** @hidden */
  71726. export interface ProcessingOptions {
  71727. defines: string[];
  71728. indexParameters: any;
  71729. isFragment: boolean;
  71730. shouldUseHighPrecisionShader: boolean;
  71731. supportsUniformBuffers: boolean;
  71732. shadersRepository: string;
  71733. includesShadersStore: {
  71734. [key: string]: string;
  71735. };
  71736. processor?: IShaderProcessor;
  71737. version: string;
  71738. platformName: string;
  71739. lookForClosingBracketForUniformBuffer?: boolean;
  71740. }
  71741. }
  71742. declare module BABYLON {
  71743. /** @hidden */
  71744. export class ShaderCodeNode {
  71745. line: string;
  71746. children: ShaderCodeNode[];
  71747. additionalDefineKey?: string;
  71748. additionalDefineValue?: string;
  71749. isValid(preprocessors: {
  71750. [key: string]: string;
  71751. }): boolean;
  71752. process(preprocessors: {
  71753. [key: string]: string;
  71754. }, options: ProcessingOptions): string;
  71755. }
  71756. }
  71757. declare module BABYLON {
  71758. /** @hidden */
  71759. export class ShaderCodeCursor {
  71760. private _lines;
  71761. lineIndex: number;
  71762. get currentLine(): string;
  71763. get canRead(): boolean;
  71764. set lines(value: string[]);
  71765. }
  71766. }
  71767. declare module BABYLON {
  71768. /** @hidden */
  71769. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71770. process(preprocessors: {
  71771. [key: string]: string;
  71772. }, options: ProcessingOptions): string;
  71773. }
  71774. }
  71775. declare module BABYLON {
  71776. /** @hidden */
  71777. export class ShaderDefineExpression {
  71778. isTrue(preprocessors: {
  71779. [key: string]: string;
  71780. }): boolean;
  71781. }
  71782. }
  71783. declare module BABYLON {
  71784. /** @hidden */
  71785. export class ShaderCodeTestNode extends ShaderCodeNode {
  71786. testExpression: ShaderDefineExpression;
  71787. isValid(preprocessors: {
  71788. [key: string]: string;
  71789. }): boolean;
  71790. }
  71791. }
  71792. declare module BABYLON {
  71793. /** @hidden */
  71794. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71795. define: string;
  71796. not: boolean;
  71797. constructor(define: string, not?: boolean);
  71798. isTrue(preprocessors: {
  71799. [key: string]: string;
  71800. }): boolean;
  71801. }
  71802. }
  71803. declare module BABYLON {
  71804. /** @hidden */
  71805. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71806. leftOperand: ShaderDefineExpression;
  71807. rightOperand: ShaderDefineExpression;
  71808. isTrue(preprocessors: {
  71809. [key: string]: string;
  71810. }): boolean;
  71811. }
  71812. }
  71813. declare module BABYLON {
  71814. /** @hidden */
  71815. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71816. leftOperand: ShaderDefineExpression;
  71817. rightOperand: ShaderDefineExpression;
  71818. isTrue(preprocessors: {
  71819. [key: string]: string;
  71820. }): boolean;
  71821. }
  71822. }
  71823. declare module BABYLON {
  71824. /** @hidden */
  71825. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71826. define: string;
  71827. operand: string;
  71828. testValue: string;
  71829. constructor(define: string, operand: string, testValue: string);
  71830. isTrue(preprocessors: {
  71831. [key: string]: string;
  71832. }): boolean;
  71833. }
  71834. }
  71835. declare module BABYLON {
  71836. /**
  71837. * Class used to enable access to offline support
  71838. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71839. */
  71840. export interface IOfflineProvider {
  71841. /**
  71842. * Gets a boolean indicating if scene must be saved in the database
  71843. */
  71844. enableSceneOffline: boolean;
  71845. /**
  71846. * Gets a boolean indicating if textures must be saved in the database
  71847. */
  71848. enableTexturesOffline: boolean;
  71849. /**
  71850. * Open the offline support and make it available
  71851. * @param successCallback defines the callback to call on success
  71852. * @param errorCallback defines the callback to call on error
  71853. */
  71854. open(successCallback: () => void, errorCallback: () => void): void;
  71855. /**
  71856. * Loads an image from the offline support
  71857. * @param url defines the url to load from
  71858. * @param image defines the target DOM image
  71859. */
  71860. loadImage(url: string, image: HTMLImageElement): void;
  71861. /**
  71862. * Loads a file from offline support
  71863. * @param url defines the URL to load from
  71864. * @param sceneLoaded defines a callback to call on success
  71865. * @param progressCallBack defines a callback to call when progress changed
  71866. * @param errorCallback defines a callback to call on error
  71867. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71868. */
  71869. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71870. }
  71871. }
  71872. declare module BABYLON {
  71873. /**
  71874. * Class used to help managing file picking and drag'n'drop
  71875. * File Storage
  71876. */
  71877. export class FilesInputStore {
  71878. /**
  71879. * List of files ready to be loaded
  71880. */
  71881. static FilesToLoad: {
  71882. [key: string]: File;
  71883. };
  71884. }
  71885. }
  71886. declare module BABYLON {
  71887. /**
  71888. * Class used to define a retry strategy when error happens while loading assets
  71889. */
  71890. export class RetryStrategy {
  71891. /**
  71892. * Function used to defines an exponential back off strategy
  71893. * @param maxRetries defines the maximum number of retries (3 by default)
  71894. * @param baseInterval defines the interval between retries
  71895. * @returns the strategy function to use
  71896. */
  71897. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71898. }
  71899. }
  71900. declare module BABYLON {
  71901. /**
  71902. * @ignore
  71903. * Application error to support additional information when loading a file
  71904. */
  71905. export abstract class BaseError extends Error {
  71906. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  71907. }
  71908. }
  71909. declare module BABYLON {
  71910. /** @ignore */
  71911. export class LoadFileError extends BaseError {
  71912. request?: WebRequest;
  71913. file?: File;
  71914. /**
  71915. * Creates a new LoadFileError
  71916. * @param message defines the message of the error
  71917. * @param request defines the optional web request
  71918. * @param file defines the optional file
  71919. */
  71920. constructor(message: string, object?: WebRequest | File);
  71921. }
  71922. /** @ignore */
  71923. export class RequestFileError extends BaseError {
  71924. request: WebRequest;
  71925. /**
  71926. * Creates a new LoadFileError
  71927. * @param message defines the message of the error
  71928. * @param request defines the optional web request
  71929. */
  71930. constructor(message: string, request: WebRequest);
  71931. }
  71932. /** @ignore */
  71933. export class ReadFileError extends BaseError {
  71934. file: File;
  71935. /**
  71936. * Creates a new ReadFileError
  71937. * @param message defines the message of the error
  71938. * @param file defines the optional file
  71939. */
  71940. constructor(message: string, file: File);
  71941. }
  71942. /**
  71943. * @hidden
  71944. */
  71945. export class FileTools {
  71946. /**
  71947. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71948. */
  71949. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71950. /**
  71951. * Gets or sets the base URL to use to load assets
  71952. */
  71953. static BaseUrl: string;
  71954. /**
  71955. * Default behaviour for cors in the application.
  71956. * It can be a string if the expected behavior is identical in the entire app.
  71957. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71958. */
  71959. static CorsBehavior: string | ((url: string | string[]) => string);
  71960. /**
  71961. * Gets or sets a function used to pre-process url before using them to load assets
  71962. */
  71963. static PreprocessUrl: (url: string) => string;
  71964. /**
  71965. * Removes unwanted characters from an url
  71966. * @param url defines the url to clean
  71967. * @returns the cleaned url
  71968. */
  71969. private static _CleanUrl;
  71970. /**
  71971. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71972. * @param url define the url we are trying
  71973. * @param element define the dom element where to configure the cors policy
  71974. */
  71975. static SetCorsBehavior(url: string | string[], element: {
  71976. crossOrigin: string | null;
  71977. }): void;
  71978. /**
  71979. * Loads an image as an HTMLImageElement.
  71980. * @param input url string, ArrayBuffer, or Blob to load
  71981. * @param onLoad callback called when the image successfully loads
  71982. * @param onError callback called when the image fails to load
  71983. * @param offlineProvider offline provider for caching
  71984. * @param mimeType optional mime type
  71985. * @returns the HTMLImageElement of the loaded image
  71986. */
  71987. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  71988. /**
  71989. * Reads a file from a File object
  71990. * @param file defines the file to load
  71991. * @param onSuccess defines the callback to call when data is loaded
  71992. * @param onProgress defines the callback to call during loading process
  71993. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71994. * @param onError defines the callback to call when an error occurs
  71995. * @returns a file request object
  71996. */
  71997. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  71998. /**
  71999. * Loads a file from a url
  72000. * @param url url to load
  72001. * @param onSuccess callback called when the file successfully loads
  72002. * @param onProgress callback called while file is loading (if the server supports this mode)
  72003. * @param offlineProvider defines the offline provider for caching
  72004. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72005. * @param onError callback called when the file fails to load
  72006. * @returns a file request object
  72007. */
  72008. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  72009. /**
  72010. * Loads a file
  72011. * @param url url to load
  72012. * @param onSuccess callback called when the file successfully loads
  72013. * @param onProgress callback called while file is loading (if the server supports this mode)
  72014. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72015. * @param onError callback called when the file fails to load
  72016. * @param onOpened callback called when the web request is opened
  72017. * @returns a file request object
  72018. */
  72019. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  72020. /**
  72021. * Checks if the loaded document was accessed via `file:`-Protocol.
  72022. * @returns boolean
  72023. */
  72024. static IsFileURL(): boolean;
  72025. }
  72026. }
  72027. declare module BABYLON {
  72028. /** @hidden */
  72029. export class ShaderProcessor {
  72030. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72031. private static _ProcessPrecision;
  72032. private static _ExtractOperation;
  72033. private static _BuildSubExpression;
  72034. private static _BuildExpression;
  72035. private static _MoveCursorWithinIf;
  72036. private static _MoveCursor;
  72037. private static _EvaluatePreProcessors;
  72038. private static _PreparePreProcessors;
  72039. private static _ProcessShaderConversion;
  72040. private static _ProcessIncludes;
  72041. }
  72042. }
  72043. declare module BABYLON {
  72044. /**
  72045. * @hidden
  72046. */
  72047. export interface IColor4Like {
  72048. r: float;
  72049. g: float;
  72050. b: float;
  72051. a: float;
  72052. }
  72053. /**
  72054. * @hidden
  72055. */
  72056. export interface IColor3Like {
  72057. r: float;
  72058. g: float;
  72059. b: float;
  72060. }
  72061. /**
  72062. * @hidden
  72063. */
  72064. export interface IVector4Like {
  72065. x: float;
  72066. y: float;
  72067. z: float;
  72068. w: float;
  72069. }
  72070. /**
  72071. * @hidden
  72072. */
  72073. export interface IVector3Like {
  72074. x: float;
  72075. y: float;
  72076. z: float;
  72077. }
  72078. /**
  72079. * @hidden
  72080. */
  72081. export interface IVector2Like {
  72082. x: float;
  72083. y: float;
  72084. }
  72085. /**
  72086. * @hidden
  72087. */
  72088. export interface IMatrixLike {
  72089. toArray(): DeepImmutable<Float32Array>;
  72090. updateFlag: int;
  72091. }
  72092. /**
  72093. * @hidden
  72094. */
  72095. export interface IViewportLike {
  72096. x: float;
  72097. y: float;
  72098. width: float;
  72099. height: float;
  72100. }
  72101. /**
  72102. * @hidden
  72103. */
  72104. export interface IPlaneLike {
  72105. normal: IVector3Like;
  72106. d: float;
  72107. normalize(): void;
  72108. }
  72109. }
  72110. declare module BABYLON {
  72111. /**
  72112. * Interface used to define common properties for effect fallbacks
  72113. */
  72114. export interface IEffectFallbacks {
  72115. /**
  72116. * Removes the defines that should be removed when falling back.
  72117. * @param currentDefines defines the current define statements for the shader.
  72118. * @param effect defines the current effect we try to compile
  72119. * @returns The resulting defines with defines of the current rank removed.
  72120. */
  72121. reduce(currentDefines: string, effect: Effect): string;
  72122. /**
  72123. * Removes the fallback from the bound mesh.
  72124. */
  72125. unBindMesh(): void;
  72126. /**
  72127. * Checks to see if more fallbacks are still availible.
  72128. */
  72129. hasMoreFallbacks: boolean;
  72130. }
  72131. }
  72132. declare module BABYLON {
  72133. /**
  72134. * Class used to evalaute queries containing `and` and `or` operators
  72135. */
  72136. export class AndOrNotEvaluator {
  72137. /**
  72138. * Evaluate a query
  72139. * @param query defines the query to evaluate
  72140. * @param evaluateCallback defines the callback used to filter result
  72141. * @returns true if the query matches
  72142. */
  72143. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  72144. private static _HandleParenthesisContent;
  72145. private static _SimplifyNegation;
  72146. }
  72147. }
  72148. declare module BABYLON {
  72149. /**
  72150. * Class used to store custom tags
  72151. */
  72152. export class Tags {
  72153. /**
  72154. * Adds support for tags on the given object
  72155. * @param obj defines the object to use
  72156. */
  72157. static EnableFor(obj: any): void;
  72158. /**
  72159. * Removes tags support
  72160. * @param obj defines the object to use
  72161. */
  72162. static DisableFor(obj: any): void;
  72163. /**
  72164. * Gets a boolean indicating if the given object has tags
  72165. * @param obj defines the object to use
  72166. * @returns a boolean
  72167. */
  72168. static HasTags(obj: any): boolean;
  72169. /**
  72170. * Gets the tags available on a given object
  72171. * @param obj defines the object to use
  72172. * @param asString defines if the tags must be returned as a string instead of an array of strings
  72173. * @returns the tags
  72174. */
  72175. static GetTags(obj: any, asString?: boolean): any;
  72176. /**
  72177. * Adds tags to an object
  72178. * @param obj defines the object to use
  72179. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  72180. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  72181. */
  72182. static AddTagsTo(obj: any, tagsString: string): void;
  72183. /**
  72184. * @hidden
  72185. */
  72186. static _AddTagTo(obj: any, tag: string): void;
  72187. /**
  72188. * Removes specific tags from a specific object
  72189. * @param obj defines the object to use
  72190. * @param tagsString defines the tags to remove
  72191. */
  72192. static RemoveTagsFrom(obj: any, tagsString: string): void;
  72193. /**
  72194. * @hidden
  72195. */
  72196. static _RemoveTagFrom(obj: any, tag: string): void;
  72197. /**
  72198. * Defines if tags hosted on an object match a given query
  72199. * @param obj defines the object to use
  72200. * @param tagsQuery defines the tag query
  72201. * @returns a boolean
  72202. */
  72203. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  72204. }
  72205. }
  72206. declare module BABYLON {
  72207. /**
  72208. * Scalar computation library
  72209. */
  72210. export class Scalar {
  72211. /**
  72212. * Two pi constants convenient for computation.
  72213. */
  72214. static TwoPi: number;
  72215. /**
  72216. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72217. * @param a number
  72218. * @param b number
  72219. * @param epsilon (default = 1.401298E-45)
  72220. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72221. */
  72222. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  72223. /**
  72224. * Returns a string : the upper case translation of the number i to hexadecimal.
  72225. * @param i number
  72226. * @returns the upper case translation of the number i to hexadecimal.
  72227. */
  72228. static ToHex(i: number): string;
  72229. /**
  72230. * Returns -1 if value is negative and +1 is value is positive.
  72231. * @param value the value
  72232. * @returns the value itself if it's equal to zero.
  72233. */
  72234. static Sign(value: number): number;
  72235. /**
  72236. * Returns the value itself if it's between min and max.
  72237. * Returns min if the value is lower than min.
  72238. * Returns max if the value is greater than max.
  72239. * @param value the value to clmap
  72240. * @param min the min value to clamp to (default: 0)
  72241. * @param max the max value to clamp to (default: 1)
  72242. * @returns the clamped value
  72243. */
  72244. static Clamp(value: number, min?: number, max?: number): number;
  72245. /**
  72246. * the log2 of value.
  72247. * @param value the value to compute log2 of
  72248. * @returns the log2 of value.
  72249. */
  72250. static Log2(value: number): number;
  72251. /**
  72252. * Loops the value, so that it is never larger than length and never smaller than 0.
  72253. *
  72254. * This is similar to the modulo operator but it works with floating point numbers.
  72255. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  72256. * With t = 5 and length = 2.5, the result would be 0.0.
  72257. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  72258. * @param value the value
  72259. * @param length the length
  72260. * @returns the looped value
  72261. */
  72262. static Repeat(value: number, length: number): number;
  72263. /**
  72264. * Normalize the value between 0.0 and 1.0 using min and max values
  72265. * @param value value to normalize
  72266. * @param min max to normalize between
  72267. * @param max min to normalize between
  72268. * @returns the normalized value
  72269. */
  72270. static Normalize(value: number, min: number, max: number): number;
  72271. /**
  72272. * Denormalize the value from 0.0 and 1.0 using min and max values
  72273. * @param normalized value to denormalize
  72274. * @param min max to denormalize between
  72275. * @param max min to denormalize between
  72276. * @returns the denormalized value
  72277. */
  72278. static Denormalize(normalized: number, min: number, max: number): number;
  72279. /**
  72280. * Calculates the shortest difference between two given angles given in degrees.
  72281. * @param current current angle in degrees
  72282. * @param target target angle in degrees
  72283. * @returns the delta
  72284. */
  72285. static DeltaAngle(current: number, target: number): number;
  72286. /**
  72287. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  72288. * @param tx value
  72289. * @param length length
  72290. * @returns The returned value will move back and forth between 0 and length
  72291. */
  72292. static PingPong(tx: number, length: number): number;
  72293. /**
  72294. * Interpolates between min and max with smoothing at the limits.
  72295. *
  72296. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  72297. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  72298. * @param from from
  72299. * @param to to
  72300. * @param tx value
  72301. * @returns the smooth stepped value
  72302. */
  72303. static SmoothStep(from: number, to: number, tx: number): number;
  72304. /**
  72305. * Moves a value current towards target.
  72306. *
  72307. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  72308. * Negative values of maxDelta pushes the value away from target.
  72309. * @param current current value
  72310. * @param target target value
  72311. * @param maxDelta max distance to move
  72312. * @returns resulting value
  72313. */
  72314. static MoveTowards(current: number, target: number, maxDelta: number): number;
  72315. /**
  72316. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72317. *
  72318. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  72319. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  72320. * @param current current value
  72321. * @param target target value
  72322. * @param maxDelta max distance to move
  72323. * @returns resulting angle
  72324. */
  72325. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  72326. /**
  72327. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  72328. * @param start start value
  72329. * @param end target value
  72330. * @param amount amount to lerp between
  72331. * @returns the lerped value
  72332. */
  72333. static Lerp(start: number, end: number, amount: number): number;
  72334. /**
  72335. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72336. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  72337. * @param start start value
  72338. * @param end target value
  72339. * @param amount amount to lerp between
  72340. * @returns the lerped value
  72341. */
  72342. static LerpAngle(start: number, end: number, amount: number): number;
  72343. /**
  72344. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  72345. * @param a start value
  72346. * @param b target value
  72347. * @param value value between a and b
  72348. * @returns the inverseLerp value
  72349. */
  72350. static InverseLerp(a: number, b: number, value: number): number;
  72351. /**
  72352. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  72353. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  72354. * @param value1 spline value
  72355. * @param tangent1 spline value
  72356. * @param value2 spline value
  72357. * @param tangent2 spline value
  72358. * @param amount input value
  72359. * @returns hermite result
  72360. */
  72361. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  72362. /**
  72363. * Returns a random float number between and min and max values
  72364. * @param min min value of random
  72365. * @param max max value of random
  72366. * @returns random value
  72367. */
  72368. static RandomRange(min: number, max: number): number;
  72369. /**
  72370. * This function returns percentage of a number in a given range.
  72371. *
  72372. * RangeToPercent(40,20,60) will return 0.5 (50%)
  72373. * RangeToPercent(34,0,100) will return 0.34 (34%)
  72374. * @param number to convert to percentage
  72375. * @param min min range
  72376. * @param max max range
  72377. * @returns the percentage
  72378. */
  72379. static RangeToPercent(number: number, min: number, max: number): number;
  72380. /**
  72381. * This function returns number that corresponds to the percentage in a given range.
  72382. *
  72383. * PercentToRange(0.34,0,100) will return 34.
  72384. * @param percent to convert to number
  72385. * @param min min range
  72386. * @param max max range
  72387. * @returns the number
  72388. */
  72389. static PercentToRange(percent: number, min: number, max: number): number;
  72390. /**
  72391. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  72392. * @param angle The angle to normalize in radian.
  72393. * @return The converted angle.
  72394. */
  72395. static NormalizeRadians(angle: number): number;
  72396. }
  72397. }
  72398. declare module BABYLON {
  72399. /**
  72400. * Constant used to convert a value to gamma space
  72401. * @ignorenaming
  72402. */
  72403. export const ToGammaSpace: number;
  72404. /**
  72405. * Constant used to convert a value to linear space
  72406. * @ignorenaming
  72407. */
  72408. export const ToLinearSpace = 2.2;
  72409. /**
  72410. * Constant used to define the minimal number value in Babylon.js
  72411. * @ignorenaming
  72412. */
  72413. let Epsilon: number;
  72414. }
  72415. declare module BABYLON {
  72416. /**
  72417. * Class used to represent a viewport on screen
  72418. */
  72419. export class Viewport {
  72420. /** viewport left coordinate */
  72421. x: number;
  72422. /** viewport top coordinate */
  72423. y: number;
  72424. /**viewport width */
  72425. width: number;
  72426. /** viewport height */
  72427. height: number;
  72428. /**
  72429. * Creates a Viewport object located at (x, y) and sized (width, height)
  72430. * @param x defines viewport left coordinate
  72431. * @param y defines viewport top coordinate
  72432. * @param width defines the viewport width
  72433. * @param height defines the viewport height
  72434. */
  72435. constructor(
  72436. /** viewport left coordinate */
  72437. x: number,
  72438. /** viewport top coordinate */
  72439. y: number,
  72440. /**viewport width */
  72441. width: number,
  72442. /** viewport height */
  72443. height: number);
  72444. /**
  72445. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72446. * @param renderWidth defines the rendering width
  72447. * @param renderHeight defines the rendering height
  72448. * @returns a new Viewport
  72449. */
  72450. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  72451. /**
  72452. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72453. * @param renderWidth defines the rendering width
  72454. * @param renderHeight defines the rendering height
  72455. * @param ref defines the target viewport
  72456. * @returns the current viewport
  72457. */
  72458. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  72459. /**
  72460. * Returns a new Viewport copied from the current one
  72461. * @returns a new Viewport
  72462. */
  72463. clone(): Viewport;
  72464. }
  72465. }
  72466. declare module BABYLON {
  72467. /**
  72468. * Class containing a set of static utilities functions for arrays.
  72469. */
  72470. export class ArrayTools {
  72471. /**
  72472. * Returns an array of the given size filled with element built from the given constructor and the paramters
  72473. * @param size the number of element to construct and put in the array
  72474. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  72475. * @returns a new array filled with new objects
  72476. */
  72477. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  72478. }
  72479. }
  72480. declare module BABYLON {
  72481. /**
  72482. * Class representing a vector containing 2 coordinates
  72483. */
  72484. export class Vector2 {
  72485. /** defines the first coordinate */
  72486. x: number;
  72487. /** defines the second coordinate */
  72488. y: number;
  72489. /**
  72490. * Creates a new Vector2 from the given x and y coordinates
  72491. * @param x defines the first coordinate
  72492. * @param y defines the second coordinate
  72493. */
  72494. constructor(
  72495. /** defines the first coordinate */
  72496. x?: number,
  72497. /** defines the second coordinate */
  72498. y?: number);
  72499. /**
  72500. * Gets a string with the Vector2 coordinates
  72501. * @returns a string with the Vector2 coordinates
  72502. */
  72503. toString(): string;
  72504. /**
  72505. * Gets class name
  72506. * @returns the string "Vector2"
  72507. */
  72508. getClassName(): string;
  72509. /**
  72510. * Gets current vector hash code
  72511. * @returns the Vector2 hash code as a number
  72512. */
  72513. getHashCode(): number;
  72514. /**
  72515. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  72516. * @param array defines the source array
  72517. * @param index defines the offset in source array
  72518. * @returns the current Vector2
  72519. */
  72520. toArray(array: FloatArray, index?: number): Vector2;
  72521. /**
  72522. * Copy the current vector to an array
  72523. * @returns a new array with 2 elements: the Vector2 coordinates.
  72524. */
  72525. asArray(): number[];
  72526. /**
  72527. * Sets the Vector2 coordinates with the given Vector2 coordinates
  72528. * @param source defines the source Vector2
  72529. * @returns the current updated Vector2
  72530. */
  72531. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  72532. /**
  72533. * Sets the Vector2 coordinates with the given floats
  72534. * @param x defines the first coordinate
  72535. * @param y defines the second coordinate
  72536. * @returns the current updated Vector2
  72537. */
  72538. copyFromFloats(x: number, y: number): Vector2;
  72539. /**
  72540. * Sets the Vector2 coordinates with the given floats
  72541. * @param x defines the first coordinate
  72542. * @param y defines the second coordinate
  72543. * @returns the current updated Vector2
  72544. */
  72545. set(x: number, y: number): Vector2;
  72546. /**
  72547. * Add another vector with the current one
  72548. * @param otherVector defines the other vector
  72549. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  72550. */
  72551. add(otherVector: DeepImmutable<Vector2>): Vector2;
  72552. /**
  72553. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  72554. * @param otherVector defines the other vector
  72555. * @param result defines the target vector
  72556. * @returns the unmodified current Vector2
  72557. */
  72558. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72559. /**
  72560. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72561. * @param otherVector defines the other vector
  72562. * @returns the current updated Vector2
  72563. */
  72564. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72565. /**
  72566. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72567. * @param otherVector defines the other vector
  72568. * @returns a new Vector2
  72569. */
  72570. addVector3(otherVector: Vector3): Vector2;
  72571. /**
  72572. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72573. * @param otherVector defines the other vector
  72574. * @returns a new Vector2
  72575. */
  72576. subtract(otherVector: Vector2): Vector2;
  72577. /**
  72578. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72579. * @param otherVector defines the other vector
  72580. * @param result defines the target vector
  72581. * @returns the unmodified current Vector2
  72582. */
  72583. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72584. /**
  72585. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72586. * @param otherVector defines the other vector
  72587. * @returns the current updated Vector2
  72588. */
  72589. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72590. /**
  72591. * Multiplies in place the current Vector2 coordinates by the given ones
  72592. * @param otherVector defines the other vector
  72593. * @returns the current updated Vector2
  72594. */
  72595. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72596. /**
  72597. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72598. * @param otherVector defines the other vector
  72599. * @returns a new Vector2
  72600. */
  72601. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  72602. /**
  72603. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72604. * @param otherVector defines the other vector
  72605. * @param result defines the target vector
  72606. * @returns the unmodified current Vector2
  72607. */
  72608. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72609. /**
  72610. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72611. * @param x defines the first coordinate
  72612. * @param y defines the second coordinate
  72613. * @returns a new Vector2
  72614. */
  72615. multiplyByFloats(x: number, y: number): Vector2;
  72616. /**
  72617. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72618. * @param otherVector defines the other vector
  72619. * @returns a new Vector2
  72620. */
  72621. divide(otherVector: Vector2): Vector2;
  72622. /**
  72623. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72624. * @param otherVector defines the other vector
  72625. * @param result defines the target vector
  72626. * @returns the unmodified current Vector2
  72627. */
  72628. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72629. /**
  72630. * Divides the current Vector2 coordinates by the given ones
  72631. * @param otherVector defines the other vector
  72632. * @returns the current updated Vector2
  72633. */
  72634. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72635. /**
  72636. * Gets a new Vector2 with current Vector2 negated coordinates
  72637. * @returns a new Vector2
  72638. */
  72639. negate(): Vector2;
  72640. /**
  72641. * Multiply the Vector2 coordinates by scale
  72642. * @param scale defines the scaling factor
  72643. * @returns the current updated Vector2
  72644. */
  72645. scaleInPlace(scale: number): Vector2;
  72646. /**
  72647. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72648. * @param scale defines the scaling factor
  72649. * @returns a new Vector2
  72650. */
  72651. scale(scale: number): Vector2;
  72652. /**
  72653. * Scale the current Vector2 values by a factor to a given Vector2
  72654. * @param scale defines the scale factor
  72655. * @param result defines the Vector2 object where to store the result
  72656. * @returns the unmodified current Vector2
  72657. */
  72658. scaleToRef(scale: number, result: Vector2): Vector2;
  72659. /**
  72660. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72661. * @param scale defines the scale factor
  72662. * @param result defines the Vector2 object where to store the result
  72663. * @returns the unmodified current Vector2
  72664. */
  72665. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  72666. /**
  72667. * Gets a boolean if two vectors are equals
  72668. * @param otherVector defines the other vector
  72669. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72670. */
  72671. equals(otherVector: DeepImmutable<Vector2>): boolean;
  72672. /**
  72673. * Gets a boolean if two vectors are equals (using an epsilon value)
  72674. * @param otherVector defines the other vector
  72675. * @param epsilon defines the minimal distance to consider equality
  72676. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72677. */
  72678. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  72679. /**
  72680. * Gets a new Vector2 from current Vector2 floored values
  72681. * @returns a new Vector2
  72682. */
  72683. floor(): Vector2;
  72684. /**
  72685. * Gets a new Vector2 from current Vector2 floored values
  72686. * @returns a new Vector2
  72687. */
  72688. fract(): Vector2;
  72689. /**
  72690. * Gets the length of the vector
  72691. * @returns the vector length (float)
  72692. */
  72693. length(): number;
  72694. /**
  72695. * Gets the vector squared length
  72696. * @returns the vector squared length (float)
  72697. */
  72698. lengthSquared(): number;
  72699. /**
  72700. * Normalize the vector
  72701. * @returns the current updated Vector2
  72702. */
  72703. normalize(): Vector2;
  72704. /**
  72705. * Gets a new Vector2 copied from the Vector2
  72706. * @returns a new Vector2
  72707. */
  72708. clone(): Vector2;
  72709. /**
  72710. * Gets a new Vector2(0, 0)
  72711. * @returns a new Vector2
  72712. */
  72713. static Zero(): Vector2;
  72714. /**
  72715. * Gets a new Vector2(1, 1)
  72716. * @returns a new Vector2
  72717. */
  72718. static One(): Vector2;
  72719. /**
  72720. * Gets a new Vector2 set from the given index element of the given array
  72721. * @param array defines the data source
  72722. * @param offset defines the offset in the data source
  72723. * @returns a new Vector2
  72724. */
  72725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  72726. /**
  72727. * Sets "result" from the given index element of the given array
  72728. * @param array defines the data source
  72729. * @param offset defines the offset in the data source
  72730. * @param result defines the target vector
  72731. */
  72732. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  72733. /**
  72734. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72735. * @param value1 defines 1st point of control
  72736. * @param value2 defines 2nd point of control
  72737. * @param value3 defines 3rd point of control
  72738. * @param value4 defines 4th point of control
  72739. * @param amount defines the interpolation factor
  72740. * @returns a new Vector2
  72741. */
  72742. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  72743. /**
  72744. * 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".
  72745. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72746. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72747. * @param value defines the value to clamp
  72748. * @param min defines the lower limit
  72749. * @param max defines the upper limit
  72750. * @returns a new Vector2
  72751. */
  72752. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  72753. /**
  72754. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72755. * @param value1 defines the 1st control point
  72756. * @param tangent1 defines the outgoing tangent
  72757. * @param value2 defines the 2nd control point
  72758. * @param tangent2 defines the incoming tangent
  72759. * @param amount defines the interpolation factor
  72760. * @returns a new Vector2
  72761. */
  72762. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  72763. /**
  72764. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72765. * @param start defines the start vector
  72766. * @param end defines the end vector
  72767. * @param amount defines the interpolation factor
  72768. * @returns a new Vector2
  72769. */
  72770. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  72771. /**
  72772. * Gets the dot product of the vector "left" and the vector "right"
  72773. * @param left defines first vector
  72774. * @param right defines second vector
  72775. * @returns the dot product (float)
  72776. */
  72777. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  72778. /**
  72779. * Returns a new Vector2 equal to the normalized given vector
  72780. * @param vector defines the vector to normalize
  72781. * @returns a new Vector2
  72782. */
  72783. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  72784. /**
  72785. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72786. * @param left defines 1st vector
  72787. * @param right defines 2nd vector
  72788. * @returns a new Vector2
  72789. */
  72790. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72791. /**
  72792. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72793. * @param left defines 1st vector
  72794. * @param right defines 2nd vector
  72795. * @returns a new Vector2
  72796. */
  72797. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72798. /**
  72799. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72800. * @param vector defines the vector to transform
  72801. * @param transformation defines the matrix to apply
  72802. * @returns a new Vector2
  72803. */
  72804. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  72805. /**
  72806. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72807. * @param vector defines the vector to transform
  72808. * @param transformation defines the matrix to apply
  72809. * @param result defines the target vector
  72810. */
  72811. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  72812. /**
  72813. * Determines if a given vector is included in a triangle
  72814. * @param p defines the vector to test
  72815. * @param p0 defines 1st triangle point
  72816. * @param p1 defines 2nd triangle point
  72817. * @param p2 defines 3rd triangle point
  72818. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72819. */
  72820. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  72821. /**
  72822. * Gets the distance between the vectors "value1" and "value2"
  72823. * @param value1 defines first vector
  72824. * @param value2 defines second vector
  72825. * @returns the distance between vectors
  72826. */
  72827. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72828. /**
  72829. * Returns the squared distance between the vectors "value1" and "value2"
  72830. * @param value1 defines first vector
  72831. * @param value2 defines second vector
  72832. * @returns the squared distance between vectors
  72833. */
  72834. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72835. /**
  72836. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72837. * @param value1 defines first vector
  72838. * @param value2 defines second vector
  72839. * @returns a new Vector2
  72840. */
  72841. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  72842. /**
  72843. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72844. * @param p defines the middle point
  72845. * @param segA defines one point of the segment
  72846. * @param segB defines the other point of the segment
  72847. * @returns the shortest distance
  72848. */
  72849. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  72850. }
  72851. /**
  72852. * Class used to store (x,y,z) vector representation
  72853. * A Vector3 is the main object used in 3D geometry
  72854. * It can represent etiher the coordinates of a point the space, either a direction
  72855. * Reminder: js uses a left handed forward facing system
  72856. */
  72857. export class Vector3 {
  72858. /**
  72859. * Defines the first coordinates (on X axis)
  72860. */
  72861. x: number;
  72862. /**
  72863. * Defines the second coordinates (on Y axis)
  72864. */
  72865. y: number;
  72866. /**
  72867. * Defines the third coordinates (on Z axis)
  72868. */
  72869. z: number;
  72870. private static _UpReadOnly;
  72871. private static _ZeroReadOnly;
  72872. /**
  72873. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72874. * @param x defines the first coordinates (on X axis)
  72875. * @param y defines the second coordinates (on Y axis)
  72876. * @param z defines the third coordinates (on Z axis)
  72877. */
  72878. constructor(
  72879. /**
  72880. * Defines the first coordinates (on X axis)
  72881. */
  72882. x?: number,
  72883. /**
  72884. * Defines the second coordinates (on Y axis)
  72885. */
  72886. y?: number,
  72887. /**
  72888. * Defines the third coordinates (on Z axis)
  72889. */
  72890. z?: number);
  72891. /**
  72892. * Creates a string representation of the Vector3
  72893. * @returns a string with the Vector3 coordinates.
  72894. */
  72895. toString(): string;
  72896. /**
  72897. * Gets the class name
  72898. * @returns the string "Vector3"
  72899. */
  72900. getClassName(): string;
  72901. /**
  72902. * Creates the Vector3 hash code
  72903. * @returns a number which tends to be unique between Vector3 instances
  72904. */
  72905. getHashCode(): number;
  72906. /**
  72907. * Creates an array containing three elements : the coordinates of the Vector3
  72908. * @returns a new array of numbers
  72909. */
  72910. asArray(): number[];
  72911. /**
  72912. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  72913. * @param array defines the destination array
  72914. * @param index defines the offset in the destination array
  72915. * @returns the current Vector3
  72916. */
  72917. toArray(array: FloatArray, index?: number): Vector3;
  72918. /**
  72919. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  72920. * @returns a new Quaternion object, computed from the Vector3 coordinates
  72921. */
  72922. toQuaternion(): Quaternion;
  72923. /**
  72924. * Adds the given vector to the current Vector3
  72925. * @param otherVector defines the second operand
  72926. * @returns the current updated Vector3
  72927. */
  72928. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72929. /**
  72930. * Adds the given coordinates to the current Vector3
  72931. * @param x defines the x coordinate of the operand
  72932. * @param y defines the y coordinate of the operand
  72933. * @param z defines the z coordinate of the operand
  72934. * @returns the current updated Vector3
  72935. */
  72936. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  72937. /**
  72938. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  72939. * @param otherVector defines the second operand
  72940. * @returns the resulting Vector3
  72941. */
  72942. add(otherVector: DeepImmutable<Vector3>): Vector3;
  72943. /**
  72944. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  72945. * @param otherVector defines the second operand
  72946. * @param result defines the Vector3 object where to store the result
  72947. * @returns the current Vector3
  72948. */
  72949. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72950. /**
  72951. * Subtract the given vector from the current Vector3
  72952. * @param otherVector defines the second operand
  72953. * @returns the current updated Vector3
  72954. */
  72955. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72956. /**
  72957. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  72958. * @param otherVector defines the second operand
  72959. * @returns the resulting Vector3
  72960. */
  72961. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  72962. /**
  72963. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  72964. * @param otherVector defines the second operand
  72965. * @param result defines the Vector3 object where to store the result
  72966. * @returns the current Vector3
  72967. */
  72968. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72969. /**
  72970. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  72971. * @param x defines the x coordinate of the operand
  72972. * @param y defines the y coordinate of the operand
  72973. * @param z defines the z coordinate of the operand
  72974. * @returns the resulting Vector3
  72975. */
  72976. subtractFromFloats(x: number, y: number, z: number): Vector3;
  72977. /**
  72978. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  72979. * @param x defines the x coordinate of the operand
  72980. * @param y defines the y coordinate of the operand
  72981. * @param z defines the z coordinate of the operand
  72982. * @param result defines the Vector3 object where to store the result
  72983. * @returns the current Vector3
  72984. */
  72985. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  72986. /**
  72987. * Gets a new Vector3 set with the current Vector3 negated coordinates
  72988. * @returns a new Vector3
  72989. */
  72990. negate(): Vector3;
  72991. /**
  72992. * Multiplies the Vector3 coordinates by the float "scale"
  72993. * @param scale defines the multiplier factor
  72994. * @returns the current updated Vector3
  72995. */
  72996. scaleInPlace(scale: number): Vector3;
  72997. /**
  72998. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  72999. * @param scale defines the multiplier factor
  73000. * @returns a new Vector3
  73001. */
  73002. scale(scale: number): Vector3;
  73003. /**
  73004. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73005. * @param scale defines the multiplier factor
  73006. * @param result defines the Vector3 object where to store the result
  73007. * @returns the current Vector3
  73008. */
  73009. scaleToRef(scale: number, result: Vector3): Vector3;
  73010. /**
  73011. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73012. * @param scale defines the scale factor
  73013. * @param result defines the Vector3 object where to store the result
  73014. * @returns the unmodified current Vector3
  73015. */
  73016. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73017. /**
  73018. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73019. * @param otherVector defines the second operand
  73020. * @returns true if both vectors are equals
  73021. */
  73022. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73023. /**
  73024. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73025. * @param otherVector defines the second operand
  73026. * @param epsilon defines the minimal distance to define values as equals
  73027. * @returns true if both vectors are distant less than epsilon
  73028. */
  73029. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73030. /**
  73031. * Returns true if the current Vector3 coordinates equals the given floats
  73032. * @param x defines the x coordinate of the operand
  73033. * @param y defines the y coordinate of the operand
  73034. * @param z defines the z coordinate of the operand
  73035. * @returns true if both vectors are equals
  73036. */
  73037. equalsToFloats(x: number, y: number, z: number): boolean;
  73038. /**
  73039. * Multiplies the current Vector3 coordinates by the given ones
  73040. * @param otherVector defines the second operand
  73041. * @returns the current updated Vector3
  73042. */
  73043. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73044. /**
  73045. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73046. * @param otherVector defines the second operand
  73047. * @returns the new Vector3
  73048. */
  73049. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73050. /**
  73051. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73052. * @param otherVector defines the second operand
  73053. * @param result defines the Vector3 object where to store the result
  73054. * @returns the current Vector3
  73055. */
  73056. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73057. /**
  73058. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73059. * @param x defines the x coordinate of the operand
  73060. * @param y defines the y coordinate of the operand
  73061. * @param z defines the z coordinate of the operand
  73062. * @returns the new Vector3
  73063. */
  73064. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73065. /**
  73066. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73067. * @param otherVector defines the second operand
  73068. * @returns the new Vector3
  73069. */
  73070. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73071. /**
  73072. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73073. * @param otherVector defines the second operand
  73074. * @param result defines the Vector3 object where to store the result
  73075. * @returns the current Vector3
  73076. */
  73077. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73078. /**
  73079. * Divides the current Vector3 coordinates by the given ones.
  73080. * @param otherVector defines the second operand
  73081. * @returns the current updated Vector3
  73082. */
  73083. divideInPlace(otherVector: Vector3): Vector3;
  73084. /**
  73085. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73086. * @param other defines the second operand
  73087. * @returns the current updated Vector3
  73088. */
  73089. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73090. /**
  73091. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73092. * @param other defines the second operand
  73093. * @returns the current updated Vector3
  73094. */
  73095. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73096. /**
  73097. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73098. * @param x defines the x coordinate of the operand
  73099. * @param y defines the y coordinate of the operand
  73100. * @param z defines the z coordinate of the operand
  73101. * @returns the current updated Vector3
  73102. */
  73103. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73104. /**
  73105. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73106. * @param x defines the x coordinate of the operand
  73107. * @param y defines the y coordinate of the operand
  73108. * @param z defines the z coordinate of the operand
  73109. * @returns the current updated Vector3
  73110. */
  73111. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73112. /**
  73113. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73114. * Check if is non uniform within a certain amount of decimal places to account for this
  73115. * @param epsilon the amount the values can differ
  73116. * @returns if the the vector is non uniform to a certain number of decimal places
  73117. */
  73118. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73119. /**
  73120. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73121. */
  73122. get isNonUniform(): boolean;
  73123. /**
  73124. * Gets a new Vector3 from current Vector3 floored values
  73125. * @returns a new Vector3
  73126. */
  73127. floor(): Vector3;
  73128. /**
  73129. * Gets a new Vector3 from current Vector3 floored values
  73130. * @returns a new Vector3
  73131. */
  73132. fract(): Vector3;
  73133. /**
  73134. * Gets the length of the Vector3
  73135. * @returns the length of the Vector3
  73136. */
  73137. length(): number;
  73138. /**
  73139. * Gets the squared length of the Vector3
  73140. * @returns squared length of the Vector3
  73141. */
  73142. lengthSquared(): number;
  73143. /**
  73144. * Normalize the current Vector3.
  73145. * Please note that this is an in place operation.
  73146. * @returns the current updated Vector3
  73147. */
  73148. normalize(): Vector3;
  73149. /**
  73150. * Reorders the x y z properties of the vector in place
  73151. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73152. * @returns the current updated vector
  73153. */
  73154. reorderInPlace(order: string): this;
  73155. /**
  73156. * Rotates the vector around 0,0,0 by a quaternion
  73157. * @param quaternion the rotation quaternion
  73158. * @param result vector to store the result
  73159. * @returns the resulting vector
  73160. */
  73161. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  73162. /**
  73163. * Rotates a vector around a given point
  73164. * @param quaternion the rotation quaternion
  73165. * @param point the point to rotate around
  73166. * @param result vector to store the result
  73167. * @returns the resulting vector
  73168. */
  73169. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  73170. /**
  73171. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  73172. * The cross product is then orthogonal to both current and "other"
  73173. * @param other defines the right operand
  73174. * @returns the cross product
  73175. */
  73176. cross(other: Vector3): Vector3;
  73177. /**
  73178. * Normalize the current Vector3 with the given input length.
  73179. * Please note that this is an in place operation.
  73180. * @param len the length of the vector
  73181. * @returns the current updated Vector3
  73182. */
  73183. normalizeFromLength(len: number): Vector3;
  73184. /**
  73185. * Normalize the current Vector3 to a new vector
  73186. * @returns the new Vector3
  73187. */
  73188. normalizeToNew(): Vector3;
  73189. /**
  73190. * Normalize the current Vector3 to the reference
  73191. * @param reference define the Vector3 to update
  73192. * @returns the updated Vector3
  73193. */
  73194. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  73195. /**
  73196. * Creates a new Vector3 copied from the current Vector3
  73197. * @returns the new Vector3
  73198. */
  73199. clone(): Vector3;
  73200. /**
  73201. * Copies the given vector coordinates to the current Vector3 ones
  73202. * @param source defines the source Vector3
  73203. * @returns the current updated Vector3
  73204. */
  73205. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  73206. /**
  73207. * Copies the given floats to the current Vector3 coordinates
  73208. * @param x defines the x coordinate of the operand
  73209. * @param y defines the y coordinate of the operand
  73210. * @param z defines the z coordinate of the operand
  73211. * @returns the current updated Vector3
  73212. */
  73213. copyFromFloats(x: number, y: number, z: number): Vector3;
  73214. /**
  73215. * Copies the given floats to the current Vector3 coordinates
  73216. * @param x defines the x coordinate of the operand
  73217. * @param y defines the y coordinate of the operand
  73218. * @param z defines the z coordinate of the operand
  73219. * @returns the current updated Vector3
  73220. */
  73221. set(x: number, y: number, z: number): Vector3;
  73222. /**
  73223. * Copies the given float to the current Vector3 coordinates
  73224. * @param v defines the x, y and z coordinates of the operand
  73225. * @returns the current updated Vector3
  73226. */
  73227. setAll(v: number): Vector3;
  73228. /**
  73229. * Get the clip factor between two vectors
  73230. * @param vector0 defines the first operand
  73231. * @param vector1 defines the second operand
  73232. * @param axis defines the axis to use
  73233. * @param size defines the size along the axis
  73234. * @returns the clip factor
  73235. */
  73236. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  73237. /**
  73238. * Get angle between two vectors
  73239. * @param vector0 angle between vector0 and vector1
  73240. * @param vector1 angle between vector0 and vector1
  73241. * @param normal direction of the normal
  73242. * @return the angle between vector0 and vector1
  73243. */
  73244. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  73245. /**
  73246. * Returns a new Vector3 set from the index "offset" of the given array
  73247. * @param array defines the source array
  73248. * @param offset defines the offset in the source array
  73249. * @returns the new Vector3
  73250. */
  73251. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  73252. /**
  73253. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73254. * @param array defines the source array
  73255. * @param offset defines the offset in the source array
  73256. * @returns the new Vector3
  73257. * @deprecated Please use FromArray instead.
  73258. */
  73259. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  73260. /**
  73261. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73262. * @param array defines the source array
  73263. * @param offset defines the offset in the source array
  73264. * @param result defines the Vector3 where to store the result
  73265. */
  73266. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  73267. /**
  73268. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73269. * @param array defines the source array
  73270. * @param offset defines the offset in the source array
  73271. * @param result defines the Vector3 where to store the result
  73272. * @deprecated Please use FromArrayToRef instead.
  73273. */
  73274. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  73275. /**
  73276. * Sets the given vector "result" with the given floats.
  73277. * @param x defines the x coordinate of the source
  73278. * @param y defines the y coordinate of the source
  73279. * @param z defines the z coordinate of the source
  73280. * @param result defines the Vector3 where to store the result
  73281. */
  73282. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  73283. /**
  73284. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73285. * @returns a new empty Vector3
  73286. */
  73287. static Zero(): Vector3;
  73288. /**
  73289. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73290. * @returns a new unit Vector3
  73291. */
  73292. static One(): Vector3;
  73293. /**
  73294. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73295. * @returns a new up Vector3
  73296. */
  73297. static Up(): Vector3;
  73298. /**
  73299. * Gets a up Vector3 that must not be updated
  73300. */
  73301. static get UpReadOnly(): DeepImmutable<Vector3>;
  73302. /**
  73303. * Gets a zero Vector3 that must not be updated
  73304. */
  73305. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  73306. /**
  73307. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73308. * @returns a new down Vector3
  73309. */
  73310. static Down(): Vector3;
  73311. /**
  73312. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73313. * @returns a new forward Vector3
  73314. */
  73315. static Forward(): Vector3;
  73316. /**
  73317. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73318. * @returns a new forward Vector3
  73319. */
  73320. static Backward(): Vector3;
  73321. /**
  73322. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73323. * @returns a new right Vector3
  73324. */
  73325. static Right(): Vector3;
  73326. /**
  73327. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73328. * @returns a new left Vector3
  73329. */
  73330. static Left(): Vector3;
  73331. /**
  73332. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73333. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73334. * @param vector defines the Vector3 to transform
  73335. * @param transformation defines the transformation matrix
  73336. * @returns the transformed Vector3
  73337. */
  73338. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73339. /**
  73340. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73341. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73342. * @param vector defines the Vector3 to transform
  73343. * @param transformation defines the transformation matrix
  73344. * @param result defines the Vector3 where to store the result
  73345. */
  73346. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73347. /**
  73348. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73349. * This method computes tranformed coordinates only, not transformed direction vectors
  73350. * @param x define the x coordinate of the source vector
  73351. * @param y define the y coordinate of the source vector
  73352. * @param z define the z coordinate of the source vector
  73353. * @param transformation defines the transformation matrix
  73354. * @param result defines the Vector3 where to store the result
  73355. */
  73356. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73357. /**
  73358. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73359. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73360. * @param vector defines the Vector3 to transform
  73361. * @param transformation defines the transformation matrix
  73362. * @returns the new Vector3
  73363. */
  73364. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73365. /**
  73366. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73367. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73368. * @param vector defines the Vector3 to transform
  73369. * @param transformation defines the transformation matrix
  73370. * @param result defines the Vector3 where to store the result
  73371. */
  73372. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73373. /**
  73374. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73375. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73376. * @param x define the x coordinate of the source vector
  73377. * @param y define the y coordinate of the source vector
  73378. * @param z define the z coordinate of the source vector
  73379. * @param transformation defines the transformation matrix
  73380. * @param result defines the Vector3 where to store the result
  73381. */
  73382. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73383. /**
  73384. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73385. * @param value1 defines the first control point
  73386. * @param value2 defines the second control point
  73387. * @param value3 defines the third control point
  73388. * @param value4 defines the fourth control point
  73389. * @param amount defines the amount on the spline to use
  73390. * @returns the new Vector3
  73391. */
  73392. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  73393. /**
  73394. * 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"
  73395. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73396. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73397. * @param value defines the current value
  73398. * @param min defines the lower range value
  73399. * @param max defines the upper range value
  73400. * @returns the new Vector3
  73401. */
  73402. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  73403. /**
  73404. * 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"
  73405. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73406. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73407. * @param value defines the current value
  73408. * @param min defines the lower range value
  73409. * @param max defines the upper range value
  73410. * @param result defines the Vector3 where to store the result
  73411. */
  73412. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  73413. /**
  73414. * Checks if a given vector is inside a specific range
  73415. * @param v defines the vector to test
  73416. * @param min defines the minimum range
  73417. * @param max defines the maximum range
  73418. */
  73419. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  73420. /**
  73421. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73422. * @param value1 defines the first control point
  73423. * @param tangent1 defines the first tangent vector
  73424. * @param value2 defines the second control point
  73425. * @param tangent2 defines the second tangent vector
  73426. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73427. * @returns the new Vector3
  73428. */
  73429. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  73430. /**
  73431. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73432. * @param start defines the start value
  73433. * @param end defines the end value
  73434. * @param amount max defines amount between both (between 0 and 1)
  73435. * @returns the new Vector3
  73436. */
  73437. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  73438. /**
  73439. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73440. * @param start defines the start value
  73441. * @param end defines the end value
  73442. * @param amount max defines amount between both (between 0 and 1)
  73443. * @param result defines the Vector3 where to store the result
  73444. */
  73445. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  73446. /**
  73447. * Returns the dot product (float) between the vectors "left" and "right"
  73448. * @param left defines the left operand
  73449. * @param right defines the right operand
  73450. * @returns the dot product
  73451. */
  73452. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  73453. /**
  73454. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73455. * The cross product is then orthogonal to both "left" and "right"
  73456. * @param left defines the left operand
  73457. * @param right defines the right operand
  73458. * @returns the cross product
  73459. */
  73460. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73461. /**
  73462. * Sets the given vector "result" with the cross product of "left" and "right"
  73463. * The cross product is then orthogonal to both "left" and "right"
  73464. * @param left defines the left operand
  73465. * @param right defines the right operand
  73466. * @param result defines the Vector3 where to store the result
  73467. */
  73468. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  73469. /**
  73470. * Returns a new Vector3 as the normalization of the given vector
  73471. * @param vector defines the Vector3 to normalize
  73472. * @returns the new Vector3
  73473. */
  73474. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  73475. /**
  73476. * Sets the given vector "result" with the normalization of the given first vector
  73477. * @param vector defines the Vector3 to normalize
  73478. * @param result defines the Vector3 where to store the result
  73479. */
  73480. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  73481. /**
  73482. * Project a Vector3 onto screen space
  73483. * @param vector defines the Vector3 to project
  73484. * @param world defines the world matrix to use
  73485. * @param transform defines the transform (view x projection) matrix to use
  73486. * @param viewport defines the screen viewport to use
  73487. * @returns the new Vector3
  73488. */
  73489. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  73490. /** @hidden */
  73491. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  73492. /**
  73493. * Unproject from screen space to object space
  73494. * @param source defines the screen space Vector3 to use
  73495. * @param viewportWidth defines the current width of the viewport
  73496. * @param viewportHeight defines the current height of the viewport
  73497. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73498. * @param transform defines the transform (view x projection) matrix to use
  73499. * @returns the new Vector3
  73500. */
  73501. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  73502. /**
  73503. * Unproject from screen space to object space
  73504. * @param source defines the screen space Vector3 to use
  73505. * @param viewportWidth defines the current width of the viewport
  73506. * @param viewportHeight defines the current height of the viewport
  73507. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73508. * @param view defines the view matrix to use
  73509. * @param projection defines the projection matrix to use
  73510. * @returns the new Vector3
  73511. */
  73512. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  73513. /**
  73514. * Unproject from screen space to object space
  73515. * @param source defines the screen space Vector3 to use
  73516. * @param viewportWidth defines the current width of the viewport
  73517. * @param viewportHeight defines the current height of the viewport
  73518. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73519. * @param view defines the view matrix to use
  73520. * @param projection defines the projection matrix to use
  73521. * @param result defines the Vector3 where to store the result
  73522. */
  73523. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73524. /**
  73525. * Unproject from screen space to object space
  73526. * @param sourceX defines the screen space x coordinate to use
  73527. * @param sourceY defines the screen space y coordinate to use
  73528. * @param sourceZ defines the screen space z coordinate to use
  73529. * @param viewportWidth defines the current width of the viewport
  73530. * @param viewportHeight defines the current height of the viewport
  73531. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73532. * @param view defines the view matrix to use
  73533. * @param projection defines the projection matrix to use
  73534. * @param result defines the Vector3 where to store the result
  73535. */
  73536. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73537. /**
  73538. * Gets the minimal coordinate values between two Vector3
  73539. * @param left defines the first operand
  73540. * @param right defines the second operand
  73541. * @returns the new Vector3
  73542. */
  73543. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73544. /**
  73545. * Gets the maximal coordinate values between two Vector3
  73546. * @param left defines the first operand
  73547. * @param right defines the second operand
  73548. * @returns the new Vector3
  73549. */
  73550. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73551. /**
  73552. * Returns the distance between the vectors "value1" and "value2"
  73553. * @param value1 defines the first operand
  73554. * @param value2 defines the second operand
  73555. * @returns the distance
  73556. */
  73557. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73558. /**
  73559. * Returns the squared distance between the vectors "value1" and "value2"
  73560. * @param value1 defines the first operand
  73561. * @param value2 defines the second operand
  73562. * @returns the squared distance
  73563. */
  73564. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73565. /**
  73566. * Returns a new Vector3 located at the center between "value1" and "value2"
  73567. * @param value1 defines the first operand
  73568. * @param value2 defines the second operand
  73569. * @returns the new Vector3
  73570. */
  73571. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  73572. /**
  73573. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73574. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73575. * to something in order to rotate it from its local system to the given target system
  73576. * Note: axis1, axis2 and axis3 are normalized during this operation
  73577. * @param axis1 defines the first axis
  73578. * @param axis2 defines the second axis
  73579. * @param axis3 defines the third axis
  73580. * @returns a new Vector3
  73581. */
  73582. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  73583. /**
  73584. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73585. * @param axis1 defines the first axis
  73586. * @param axis2 defines the second axis
  73587. * @param axis3 defines the third axis
  73588. * @param ref defines the Vector3 where to store the result
  73589. */
  73590. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  73591. }
  73592. /**
  73593. * Vector4 class created for EulerAngle class conversion to Quaternion
  73594. */
  73595. export class Vector4 {
  73596. /** x value of the vector */
  73597. x: number;
  73598. /** y value of the vector */
  73599. y: number;
  73600. /** z value of the vector */
  73601. z: number;
  73602. /** w value of the vector */
  73603. w: number;
  73604. /**
  73605. * Creates a Vector4 object from the given floats.
  73606. * @param x x value of the vector
  73607. * @param y y value of the vector
  73608. * @param z z value of the vector
  73609. * @param w w value of the vector
  73610. */
  73611. constructor(
  73612. /** x value of the vector */
  73613. x: number,
  73614. /** y value of the vector */
  73615. y: number,
  73616. /** z value of the vector */
  73617. z: number,
  73618. /** w value of the vector */
  73619. w: number);
  73620. /**
  73621. * Returns the string with the Vector4 coordinates.
  73622. * @returns a string containing all the vector values
  73623. */
  73624. toString(): string;
  73625. /**
  73626. * Returns the string "Vector4".
  73627. * @returns "Vector4"
  73628. */
  73629. getClassName(): string;
  73630. /**
  73631. * Returns the Vector4 hash code.
  73632. * @returns a unique hash code
  73633. */
  73634. getHashCode(): number;
  73635. /**
  73636. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73637. * @returns the resulting array
  73638. */
  73639. asArray(): number[];
  73640. /**
  73641. * Populates the given array from the given index with the Vector4 coordinates.
  73642. * @param array array to populate
  73643. * @param index index of the array to start at (default: 0)
  73644. * @returns the Vector4.
  73645. */
  73646. toArray(array: FloatArray, index?: number): Vector4;
  73647. /**
  73648. * Adds the given vector to the current Vector4.
  73649. * @param otherVector the vector to add
  73650. * @returns the updated Vector4.
  73651. */
  73652. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73653. /**
  73654. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73655. * @param otherVector the vector to add
  73656. * @returns the resulting vector
  73657. */
  73658. add(otherVector: DeepImmutable<Vector4>): Vector4;
  73659. /**
  73660. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73661. * @param otherVector the vector to add
  73662. * @param result the vector to store the result
  73663. * @returns the current Vector4.
  73664. */
  73665. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73666. /**
  73667. * Subtract in place the given vector from the current Vector4.
  73668. * @param otherVector the vector to subtract
  73669. * @returns the updated Vector4.
  73670. */
  73671. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73672. /**
  73673. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73674. * @param otherVector the vector to add
  73675. * @returns the new vector with the result
  73676. */
  73677. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  73678. /**
  73679. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73680. * @param otherVector the vector to subtract
  73681. * @param result the vector to store the result
  73682. * @returns the current Vector4.
  73683. */
  73684. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73685. /**
  73686. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73687. */
  73688. /**
  73689. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73690. * @param x value to subtract
  73691. * @param y value to subtract
  73692. * @param z value to subtract
  73693. * @param w value to subtract
  73694. * @returns new vector containing the result
  73695. */
  73696. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73697. /**
  73698. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73699. * @param x value to subtract
  73700. * @param y value to subtract
  73701. * @param z value to subtract
  73702. * @param w value to subtract
  73703. * @param result the vector to store the result in
  73704. * @returns the current Vector4.
  73705. */
  73706. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  73707. /**
  73708. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73709. * @returns a new vector with the negated values
  73710. */
  73711. negate(): Vector4;
  73712. /**
  73713. * Multiplies the current Vector4 coordinates by scale (float).
  73714. * @param scale the number to scale with
  73715. * @returns the updated Vector4.
  73716. */
  73717. scaleInPlace(scale: number): Vector4;
  73718. /**
  73719. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73720. * @param scale the number to scale with
  73721. * @returns a new vector with the result
  73722. */
  73723. scale(scale: number): Vector4;
  73724. /**
  73725. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73726. * @param scale the number to scale with
  73727. * @param result a vector to store the result in
  73728. * @returns the current Vector4.
  73729. */
  73730. scaleToRef(scale: number, result: Vector4): Vector4;
  73731. /**
  73732. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73733. * @param scale defines the scale factor
  73734. * @param result defines the Vector4 object where to store the result
  73735. * @returns the unmodified current Vector4
  73736. */
  73737. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  73738. /**
  73739. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73740. * @param otherVector the vector to compare against
  73741. * @returns true if they are equal
  73742. */
  73743. equals(otherVector: DeepImmutable<Vector4>): boolean;
  73744. /**
  73745. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73746. * @param otherVector vector to compare against
  73747. * @param epsilon (Default: very small number)
  73748. * @returns true if they are equal
  73749. */
  73750. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  73751. /**
  73752. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73753. * @param x x value to compare against
  73754. * @param y y value to compare against
  73755. * @param z z value to compare against
  73756. * @param w w value to compare against
  73757. * @returns true if equal
  73758. */
  73759. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  73760. /**
  73761. * Multiplies in place the current Vector4 by the given one.
  73762. * @param otherVector vector to multiple with
  73763. * @returns the updated Vector4.
  73764. */
  73765. multiplyInPlace(otherVector: Vector4): Vector4;
  73766. /**
  73767. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73768. * @param otherVector vector to multiple with
  73769. * @returns resulting new vector
  73770. */
  73771. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  73772. /**
  73773. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73774. * @param otherVector vector to multiple with
  73775. * @param result vector to store the result
  73776. * @returns the current Vector4.
  73777. */
  73778. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73779. /**
  73780. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73781. * @param x x value multiply with
  73782. * @param y y value multiply with
  73783. * @param z z value multiply with
  73784. * @param w w value multiply with
  73785. * @returns resulting new vector
  73786. */
  73787. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  73788. /**
  73789. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73790. * @param otherVector vector to devide with
  73791. * @returns resulting new vector
  73792. */
  73793. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  73794. /**
  73795. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73796. * @param otherVector vector to devide with
  73797. * @param result vector to store the result
  73798. * @returns the current Vector4.
  73799. */
  73800. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73801. /**
  73802. * Divides the current Vector3 coordinates by the given ones.
  73803. * @param otherVector vector to devide with
  73804. * @returns the updated Vector3.
  73805. */
  73806. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73807. /**
  73808. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73809. * @param other defines the second operand
  73810. * @returns the current updated Vector4
  73811. */
  73812. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73813. /**
  73814. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73815. * @param other defines the second operand
  73816. * @returns the current updated Vector4
  73817. */
  73818. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73819. /**
  73820. * Gets a new Vector4 from current Vector4 floored values
  73821. * @returns a new Vector4
  73822. */
  73823. floor(): Vector4;
  73824. /**
  73825. * Gets a new Vector4 from current Vector3 floored values
  73826. * @returns a new Vector4
  73827. */
  73828. fract(): Vector4;
  73829. /**
  73830. * Returns the Vector4 length (float).
  73831. * @returns the length
  73832. */
  73833. length(): number;
  73834. /**
  73835. * Returns the Vector4 squared length (float).
  73836. * @returns the length squared
  73837. */
  73838. lengthSquared(): number;
  73839. /**
  73840. * Normalizes in place the Vector4.
  73841. * @returns the updated Vector4.
  73842. */
  73843. normalize(): Vector4;
  73844. /**
  73845. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73846. * @returns this converted to a new vector3
  73847. */
  73848. toVector3(): Vector3;
  73849. /**
  73850. * Returns a new Vector4 copied from the current one.
  73851. * @returns the new cloned vector
  73852. */
  73853. clone(): Vector4;
  73854. /**
  73855. * Updates the current Vector4 with the given one coordinates.
  73856. * @param source the source vector to copy from
  73857. * @returns the updated Vector4.
  73858. */
  73859. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  73860. /**
  73861. * Updates the current Vector4 coordinates with the given floats.
  73862. * @param x float to copy from
  73863. * @param y float to copy from
  73864. * @param z float to copy from
  73865. * @param w float to copy from
  73866. * @returns the updated Vector4.
  73867. */
  73868. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73869. /**
  73870. * Updates the current Vector4 coordinates with the given floats.
  73871. * @param x float to set from
  73872. * @param y float to set from
  73873. * @param z float to set from
  73874. * @param w float to set from
  73875. * @returns the updated Vector4.
  73876. */
  73877. set(x: number, y: number, z: number, w: number): Vector4;
  73878. /**
  73879. * Copies the given float to the current Vector3 coordinates
  73880. * @param v defines the x, y, z and w coordinates of the operand
  73881. * @returns the current updated Vector3
  73882. */
  73883. setAll(v: number): Vector4;
  73884. /**
  73885. * Returns a new Vector4 set from the starting index of the given array.
  73886. * @param array the array to pull values from
  73887. * @param offset the offset into the array to start at
  73888. * @returns the new vector
  73889. */
  73890. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  73891. /**
  73892. * Updates the given vector "result" from the starting index of the given array.
  73893. * @param array the array to pull values from
  73894. * @param offset the offset into the array to start at
  73895. * @param result the vector to store the result in
  73896. */
  73897. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  73898. /**
  73899. * Updates the given vector "result" from the starting index of the given Float32Array.
  73900. * @param array the array to pull values from
  73901. * @param offset the offset into the array to start at
  73902. * @param result the vector to store the result in
  73903. */
  73904. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  73905. /**
  73906. * Updates the given vector "result" coordinates from the given floats.
  73907. * @param x float to set from
  73908. * @param y float to set from
  73909. * @param z float to set from
  73910. * @param w float to set from
  73911. * @param result the vector to the floats in
  73912. */
  73913. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  73914. /**
  73915. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  73916. * @returns the new vector
  73917. */
  73918. static Zero(): Vector4;
  73919. /**
  73920. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  73921. * @returns the new vector
  73922. */
  73923. static One(): Vector4;
  73924. /**
  73925. * Returns a new normalized Vector4 from the given one.
  73926. * @param vector the vector to normalize
  73927. * @returns the vector
  73928. */
  73929. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  73930. /**
  73931. * Updates the given vector "result" from the normalization of the given one.
  73932. * @param vector the vector to normalize
  73933. * @param result the vector to store the result in
  73934. */
  73935. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  73936. /**
  73937. * Returns a vector with the minimum values from the left and right vectors
  73938. * @param left left vector to minimize
  73939. * @param right right vector to minimize
  73940. * @returns a new vector with the minimum of the left and right vector values
  73941. */
  73942. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  73943. /**
  73944. * Returns a vector with the maximum values from the left and right vectors
  73945. * @param left left vector to maximize
  73946. * @param right right vector to maximize
  73947. * @returns a new vector with the maximum of the left and right vector values
  73948. */
  73949. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  73950. /**
  73951. * Returns the distance (float) between the vectors "value1" and "value2".
  73952. * @param value1 value to calulate the distance between
  73953. * @param value2 value to calulate the distance between
  73954. * @return the distance between the two vectors
  73955. */
  73956. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  73957. /**
  73958. * Returns the squared distance (float) between the vectors "value1" and "value2".
  73959. * @param value1 value to calulate the distance between
  73960. * @param value2 value to calulate the distance between
  73961. * @return the distance between the two vectors squared
  73962. */
  73963. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  73964. /**
  73965. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  73966. * @param value1 value to calulate the center between
  73967. * @param value2 value to calulate the center between
  73968. * @return the center between the two vectors
  73969. */
  73970. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  73971. /**
  73972. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  73973. * This methods computes transformed normalized direction vectors only.
  73974. * @param vector the vector to transform
  73975. * @param transformation the transformation matrix to apply
  73976. * @returns the new vector
  73977. */
  73978. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  73979. /**
  73980. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  73981. * This methods computes transformed normalized direction vectors only.
  73982. * @param vector the vector to transform
  73983. * @param transformation the transformation matrix to apply
  73984. * @param result the vector to store the result in
  73985. */
  73986. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  73987. /**
  73988. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  73989. * This methods computes transformed normalized direction vectors only.
  73990. * @param x value to transform
  73991. * @param y value to transform
  73992. * @param z value to transform
  73993. * @param w value to transform
  73994. * @param transformation the transformation matrix to apply
  73995. * @param result the vector to store the results in
  73996. */
  73997. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  73998. /**
  73999. * Creates a new Vector4 from a Vector3
  74000. * @param source defines the source data
  74001. * @param w defines the 4th component (default is 0)
  74002. * @returns a new Vector4
  74003. */
  74004. static FromVector3(source: Vector3, w?: number): Vector4;
  74005. }
  74006. /**
  74007. * Class used to store quaternion data
  74008. * @see https://en.wikipedia.org/wiki/Quaternion
  74009. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74010. */
  74011. export class Quaternion {
  74012. /** defines the first component (0 by default) */
  74013. x: number;
  74014. /** defines the second component (0 by default) */
  74015. y: number;
  74016. /** defines the third component (0 by default) */
  74017. z: number;
  74018. /** defines the fourth component (1.0 by default) */
  74019. w: number;
  74020. /**
  74021. * Creates a new Quaternion from the given floats
  74022. * @param x defines the first component (0 by default)
  74023. * @param y defines the second component (0 by default)
  74024. * @param z defines the third component (0 by default)
  74025. * @param w defines the fourth component (1.0 by default)
  74026. */
  74027. constructor(
  74028. /** defines the first component (0 by default) */
  74029. x?: number,
  74030. /** defines the second component (0 by default) */
  74031. y?: number,
  74032. /** defines the third component (0 by default) */
  74033. z?: number,
  74034. /** defines the fourth component (1.0 by default) */
  74035. w?: number);
  74036. /**
  74037. * Gets a string representation for the current quaternion
  74038. * @returns a string with the Quaternion coordinates
  74039. */
  74040. toString(): string;
  74041. /**
  74042. * Gets the class name of the quaternion
  74043. * @returns the string "Quaternion"
  74044. */
  74045. getClassName(): string;
  74046. /**
  74047. * Gets a hash code for this quaternion
  74048. * @returns the quaternion hash code
  74049. */
  74050. getHashCode(): number;
  74051. /**
  74052. * Copy the quaternion to an array
  74053. * @returns a new array populated with 4 elements from the quaternion coordinates
  74054. */
  74055. asArray(): number[];
  74056. /**
  74057. * Check if two quaternions are equals
  74058. * @param otherQuaternion defines the second operand
  74059. * @return true if the current quaternion and the given one coordinates are strictly equals
  74060. */
  74061. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74062. /**
  74063. * Clone the current quaternion
  74064. * @returns a new quaternion copied from the current one
  74065. */
  74066. clone(): Quaternion;
  74067. /**
  74068. * Copy a quaternion to the current one
  74069. * @param other defines the other quaternion
  74070. * @returns the updated current quaternion
  74071. */
  74072. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74073. /**
  74074. * Updates the current quaternion with the given float coordinates
  74075. * @param x defines the x coordinate
  74076. * @param y defines the y coordinate
  74077. * @param z defines the z coordinate
  74078. * @param w defines the w coordinate
  74079. * @returns the updated current quaternion
  74080. */
  74081. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74082. /**
  74083. * Updates the current quaternion from the given float coordinates
  74084. * @param x defines the x coordinate
  74085. * @param y defines the y coordinate
  74086. * @param z defines the z coordinate
  74087. * @param w defines the w coordinate
  74088. * @returns the updated current quaternion
  74089. */
  74090. set(x: number, y: number, z: number, w: number): Quaternion;
  74091. /**
  74092. * Adds two quaternions
  74093. * @param other defines the second operand
  74094. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74095. */
  74096. add(other: DeepImmutable<Quaternion>): Quaternion;
  74097. /**
  74098. * Add a quaternion to the current one
  74099. * @param other defines the quaternion to add
  74100. * @returns the current quaternion
  74101. */
  74102. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74103. /**
  74104. * Subtract two quaternions
  74105. * @param other defines the second operand
  74106. * @returns a new quaternion as the subtraction result of the given one from the current one
  74107. */
  74108. subtract(other: Quaternion): Quaternion;
  74109. /**
  74110. * Multiplies the current quaternion by a scale factor
  74111. * @param value defines the scale factor
  74112. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74113. */
  74114. scale(value: number): Quaternion;
  74115. /**
  74116. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74117. * @param scale defines the scale factor
  74118. * @param result defines the Quaternion object where to store the result
  74119. * @returns the unmodified current quaternion
  74120. */
  74121. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74122. /**
  74123. * Multiplies in place the current quaternion by a scale factor
  74124. * @param value defines the scale factor
  74125. * @returns the current modified quaternion
  74126. */
  74127. scaleInPlace(value: number): Quaternion;
  74128. /**
  74129. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74130. * @param scale defines the scale factor
  74131. * @param result defines the Quaternion object where to store the result
  74132. * @returns the unmodified current quaternion
  74133. */
  74134. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  74135. /**
  74136. * Multiplies two quaternions
  74137. * @param q1 defines the second operand
  74138. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74139. */
  74140. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  74141. /**
  74142. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74143. * @param q1 defines the second operand
  74144. * @param result defines the target quaternion
  74145. * @returns the current quaternion
  74146. */
  74147. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  74148. /**
  74149. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74150. * @param q1 defines the second operand
  74151. * @returns the currentupdated quaternion
  74152. */
  74153. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  74154. /**
  74155. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74156. * @param ref defines the target quaternion
  74157. * @returns the current quaternion
  74158. */
  74159. conjugateToRef(ref: Quaternion): Quaternion;
  74160. /**
  74161. * Conjugates in place (1-q) the current quaternion
  74162. * @returns the current updated quaternion
  74163. */
  74164. conjugateInPlace(): Quaternion;
  74165. /**
  74166. * Conjugates in place (1-q) the current quaternion
  74167. * @returns a new quaternion
  74168. */
  74169. conjugate(): Quaternion;
  74170. /**
  74171. * Gets length of current quaternion
  74172. * @returns the quaternion length (float)
  74173. */
  74174. length(): number;
  74175. /**
  74176. * Normalize in place the current quaternion
  74177. * @returns the current updated quaternion
  74178. */
  74179. normalize(): Quaternion;
  74180. /**
  74181. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74182. * @param order is a reserved parameter and is ignore for now
  74183. * @returns a new Vector3 containing the Euler angles
  74184. */
  74185. toEulerAngles(order?: string): Vector3;
  74186. /**
  74187. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74188. * @param result defines the vector which will be filled with the Euler angles
  74189. * @param order is a reserved parameter and is ignore for now
  74190. * @returns the current unchanged quaternion
  74191. */
  74192. toEulerAnglesToRef(result: Vector3): Quaternion;
  74193. /**
  74194. * Updates the given rotation matrix with the current quaternion values
  74195. * @param result defines the target matrix
  74196. * @returns the current unchanged quaternion
  74197. */
  74198. toRotationMatrix(result: Matrix): Quaternion;
  74199. /**
  74200. * Updates the current quaternion from the given rotation matrix values
  74201. * @param matrix defines the source matrix
  74202. * @returns the current updated quaternion
  74203. */
  74204. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74205. /**
  74206. * Creates a new quaternion from a rotation matrix
  74207. * @param matrix defines the source matrix
  74208. * @returns a new quaternion created from the given rotation matrix values
  74209. */
  74210. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74211. /**
  74212. * Updates the given quaternion with the given rotation matrix values
  74213. * @param matrix defines the source matrix
  74214. * @param result defines the target quaternion
  74215. */
  74216. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  74217. /**
  74218. * Returns the dot product (float) between the quaternions "left" and "right"
  74219. * @param left defines the left operand
  74220. * @param right defines the right operand
  74221. * @returns the dot product
  74222. */
  74223. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  74224. /**
  74225. * Checks if the two quaternions are close to each other
  74226. * @param quat0 defines the first quaternion to check
  74227. * @param quat1 defines the second quaternion to check
  74228. * @returns true if the two quaternions are close to each other
  74229. */
  74230. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  74231. /**
  74232. * Creates an empty quaternion
  74233. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74234. */
  74235. static Zero(): Quaternion;
  74236. /**
  74237. * Inverse a given quaternion
  74238. * @param q defines the source quaternion
  74239. * @returns a new quaternion as the inverted current quaternion
  74240. */
  74241. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  74242. /**
  74243. * Inverse a given quaternion
  74244. * @param q defines the source quaternion
  74245. * @param result the quaternion the result will be stored in
  74246. * @returns the result quaternion
  74247. */
  74248. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  74249. /**
  74250. * Creates an identity quaternion
  74251. * @returns the identity quaternion
  74252. */
  74253. static Identity(): Quaternion;
  74254. /**
  74255. * Gets a boolean indicating if the given quaternion is identity
  74256. * @param quaternion defines the quaternion to check
  74257. * @returns true if the quaternion is identity
  74258. */
  74259. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  74260. /**
  74261. * Creates a quaternion from a rotation around an axis
  74262. * @param axis defines the axis to use
  74263. * @param angle defines the angle to use
  74264. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74265. */
  74266. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  74267. /**
  74268. * Creates a rotation around an axis and stores it into the given quaternion
  74269. * @param axis defines the axis to use
  74270. * @param angle defines the angle to use
  74271. * @param result defines the target quaternion
  74272. * @returns the target quaternion
  74273. */
  74274. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  74275. /**
  74276. * Creates a new quaternion from data stored into an array
  74277. * @param array defines the data source
  74278. * @param offset defines the offset in the source array where the data starts
  74279. * @returns a new quaternion
  74280. */
  74281. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  74282. /**
  74283. * Create a quaternion from Euler rotation angles
  74284. * @param x Pitch
  74285. * @param y Yaw
  74286. * @param z Roll
  74287. * @returns the new Quaternion
  74288. */
  74289. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  74290. /**
  74291. * Updates a quaternion from Euler rotation angles
  74292. * @param x Pitch
  74293. * @param y Yaw
  74294. * @param z Roll
  74295. * @param result the quaternion to store the result
  74296. * @returns the updated quaternion
  74297. */
  74298. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  74299. /**
  74300. * Create a quaternion from Euler rotation vector
  74301. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74302. * @returns the new Quaternion
  74303. */
  74304. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  74305. /**
  74306. * Updates a quaternion from Euler rotation vector
  74307. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74308. * @param result the quaternion to store the result
  74309. * @returns the updated quaternion
  74310. */
  74311. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  74312. /**
  74313. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74314. * @param yaw defines the rotation around Y axis
  74315. * @param pitch defines the rotation around X axis
  74316. * @param roll defines the rotation around Z axis
  74317. * @returns the new quaternion
  74318. */
  74319. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  74320. /**
  74321. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74322. * @param yaw defines the rotation around Y axis
  74323. * @param pitch defines the rotation around X axis
  74324. * @param roll defines the rotation around Z axis
  74325. * @param result defines the target quaternion
  74326. */
  74327. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  74328. /**
  74329. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74330. * @param alpha defines the rotation around first axis
  74331. * @param beta defines the rotation around second axis
  74332. * @param gamma defines the rotation around third axis
  74333. * @returns the new quaternion
  74334. */
  74335. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  74336. /**
  74337. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74338. * @param alpha defines the rotation around first axis
  74339. * @param beta defines the rotation around second axis
  74340. * @param gamma defines the rotation around third axis
  74341. * @param result defines the target quaternion
  74342. */
  74343. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  74344. /**
  74345. * 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)
  74346. * @param axis1 defines the first axis
  74347. * @param axis2 defines the second axis
  74348. * @param axis3 defines the third axis
  74349. * @returns the new quaternion
  74350. */
  74351. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  74352. /**
  74353. * 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
  74354. * @param axis1 defines the first axis
  74355. * @param axis2 defines the second axis
  74356. * @param axis3 defines the third axis
  74357. * @param ref defines the target quaternion
  74358. */
  74359. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  74360. /**
  74361. * Interpolates between two quaternions
  74362. * @param left defines first quaternion
  74363. * @param right defines second quaternion
  74364. * @param amount defines the gradient to use
  74365. * @returns the new interpolated quaternion
  74366. */
  74367. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74368. /**
  74369. * Interpolates between two quaternions and stores it into a target quaternion
  74370. * @param left defines first quaternion
  74371. * @param right defines second quaternion
  74372. * @param amount defines the gradient to use
  74373. * @param result defines the target quaternion
  74374. */
  74375. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  74376. /**
  74377. * Interpolate between two quaternions using Hermite interpolation
  74378. * @param value1 defines first quaternion
  74379. * @param tangent1 defines the incoming tangent
  74380. * @param value2 defines second quaternion
  74381. * @param tangent2 defines the outgoing tangent
  74382. * @param amount defines the target quaternion
  74383. * @returns the new interpolated quaternion
  74384. */
  74385. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74386. }
  74387. /**
  74388. * Class used to store matrix data (4x4)
  74389. */
  74390. export class Matrix {
  74391. private static _updateFlagSeed;
  74392. private static _identityReadOnly;
  74393. private _isIdentity;
  74394. private _isIdentityDirty;
  74395. private _isIdentity3x2;
  74396. private _isIdentity3x2Dirty;
  74397. /**
  74398. * Gets the update flag of the matrix which is an unique number for the matrix.
  74399. * It will be incremented every time the matrix data change.
  74400. * You can use it to speed the comparison between two versions of the same matrix.
  74401. */
  74402. updateFlag: number;
  74403. private readonly _m;
  74404. /**
  74405. * Gets the internal data of the matrix
  74406. */
  74407. get m(): DeepImmutable<Float32Array>;
  74408. /** @hidden */
  74409. _markAsUpdated(): void;
  74410. /** @hidden */
  74411. private _updateIdentityStatus;
  74412. /**
  74413. * Creates an empty matrix (filled with zeros)
  74414. */
  74415. constructor();
  74416. /**
  74417. * Check if the current matrix is identity
  74418. * @returns true is the matrix is the identity matrix
  74419. */
  74420. isIdentity(): boolean;
  74421. /**
  74422. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74423. * @returns true is the matrix is the identity matrix
  74424. */
  74425. isIdentityAs3x2(): boolean;
  74426. /**
  74427. * Gets the determinant of the matrix
  74428. * @returns the matrix determinant
  74429. */
  74430. determinant(): number;
  74431. /**
  74432. * Returns the matrix as a Float32Array
  74433. * @returns the matrix underlying array
  74434. */
  74435. toArray(): DeepImmutable<Float32Array>;
  74436. /**
  74437. * Returns the matrix as a Float32Array
  74438. * @returns the matrix underlying array.
  74439. */
  74440. asArray(): DeepImmutable<Float32Array>;
  74441. /**
  74442. * Inverts the current matrix in place
  74443. * @returns the current inverted matrix
  74444. */
  74445. invert(): Matrix;
  74446. /**
  74447. * Sets all the matrix elements to zero
  74448. * @returns the current matrix
  74449. */
  74450. reset(): Matrix;
  74451. /**
  74452. * Adds the current matrix with a second one
  74453. * @param other defines the matrix to add
  74454. * @returns a new matrix as the addition of the current matrix and the given one
  74455. */
  74456. add(other: DeepImmutable<Matrix>): Matrix;
  74457. /**
  74458. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74459. * @param other defines the matrix to add
  74460. * @param result defines the target matrix
  74461. * @returns the current matrix
  74462. */
  74463. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74464. /**
  74465. * Adds in place the given matrix to the current matrix
  74466. * @param other defines the second operand
  74467. * @returns the current updated matrix
  74468. */
  74469. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  74470. /**
  74471. * Sets the given matrix to the current inverted Matrix
  74472. * @param other defines the target matrix
  74473. * @returns the unmodified current matrix
  74474. */
  74475. invertToRef(other: Matrix): Matrix;
  74476. /**
  74477. * add a value at the specified position in the current Matrix
  74478. * @param index the index of the value within the matrix. between 0 and 15.
  74479. * @param value the value to be added
  74480. * @returns the current updated matrix
  74481. */
  74482. addAtIndex(index: number, value: number): Matrix;
  74483. /**
  74484. * mutiply the specified position in the current Matrix by a value
  74485. * @param index the index of the value within the matrix. between 0 and 15.
  74486. * @param value the value to be added
  74487. * @returns the current updated matrix
  74488. */
  74489. multiplyAtIndex(index: number, value: number): Matrix;
  74490. /**
  74491. * Inserts the translation vector (using 3 floats) in the current matrix
  74492. * @param x defines the 1st component of the translation
  74493. * @param y defines the 2nd component of the translation
  74494. * @param z defines the 3rd component of the translation
  74495. * @returns the current updated matrix
  74496. */
  74497. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74498. /**
  74499. * Adds the translation vector (using 3 floats) in the current matrix
  74500. * @param x defines the 1st component of the translation
  74501. * @param y defines the 2nd component of the translation
  74502. * @param z defines the 3rd component of the translation
  74503. * @returns the current updated matrix
  74504. */
  74505. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74506. /**
  74507. * Inserts the translation vector in the current matrix
  74508. * @param vector3 defines the translation to insert
  74509. * @returns the current updated matrix
  74510. */
  74511. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  74512. /**
  74513. * Gets the translation value of the current matrix
  74514. * @returns a new Vector3 as the extracted translation from the matrix
  74515. */
  74516. getTranslation(): Vector3;
  74517. /**
  74518. * Fill a Vector3 with the extracted translation from the matrix
  74519. * @param result defines the Vector3 where to store the translation
  74520. * @returns the current matrix
  74521. */
  74522. getTranslationToRef(result: Vector3): Matrix;
  74523. /**
  74524. * Remove rotation and scaling part from the matrix
  74525. * @returns the updated matrix
  74526. */
  74527. removeRotationAndScaling(): Matrix;
  74528. /**
  74529. * Multiply two matrices
  74530. * @param other defines the second operand
  74531. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74532. */
  74533. multiply(other: DeepImmutable<Matrix>): Matrix;
  74534. /**
  74535. * Copy the current matrix from the given one
  74536. * @param other defines the source matrix
  74537. * @returns the current updated matrix
  74538. */
  74539. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  74540. /**
  74541. * Populates the given array from the starting index with the current matrix values
  74542. * @param array defines the target array
  74543. * @param offset defines the offset in the target array where to start storing values
  74544. * @returns the current matrix
  74545. */
  74546. copyToArray(array: Float32Array, offset?: number): Matrix;
  74547. /**
  74548. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74549. * @param other defines the second operand
  74550. * @param result defines the matrix where to store the multiplication
  74551. * @returns the current matrix
  74552. */
  74553. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74554. /**
  74555. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74556. * @param other defines the second operand
  74557. * @param result defines the array where to store the multiplication
  74558. * @param offset defines the offset in the target array where to start storing values
  74559. * @returns the current matrix
  74560. */
  74561. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  74562. /**
  74563. * Check equality between this matrix and a second one
  74564. * @param value defines the second matrix to compare
  74565. * @returns true is the current matrix and the given one values are strictly equal
  74566. */
  74567. equals(value: DeepImmutable<Matrix>): boolean;
  74568. /**
  74569. * Clone the current matrix
  74570. * @returns a new matrix from the current matrix
  74571. */
  74572. clone(): Matrix;
  74573. /**
  74574. * Returns the name of the current matrix class
  74575. * @returns the string "Matrix"
  74576. */
  74577. getClassName(): string;
  74578. /**
  74579. * Gets the hash code of the current matrix
  74580. * @returns the hash code
  74581. */
  74582. getHashCode(): number;
  74583. /**
  74584. * Decomposes the current Matrix into a translation, rotation and scaling components
  74585. * @param scale defines the scale vector3 given as a reference to update
  74586. * @param rotation defines the rotation quaternion given as a reference to update
  74587. * @param translation defines the translation vector3 given as a reference to update
  74588. * @returns true if operation was successful
  74589. */
  74590. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  74591. /**
  74592. * Gets specific row of the matrix
  74593. * @param index defines the number of the row to get
  74594. * @returns the index-th row of the current matrix as a new Vector4
  74595. */
  74596. getRow(index: number): Nullable<Vector4>;
  74597. /**
  74598. * Sets the index-th row of the current matrix to the vector4 values
  74599. * @param index defines the number of the row to set
  74600. * @param row defines the target vector4
  74601. * @returns the updated current matrix
  74602. */
  74603. setRow(index: number, row: Vector4): Matrix;
  74604. /**
  74605. * Compute the transpose of the matrix
  74606. * @returns the new transposed matrix
  74607. */
  74608. transpose(): Matrix;
  74609. /**
  74610. * Compute the transpose of the matrix and store it in a given matrix
  74611. * @param result defines the target matrix
  74612. * @returns the current matrix
  74613. */
  74614. transposeToRef(result: Matrix): Matrix;
  74615. /**
  74616. * Sets the index-th row of the current matrix with the given 4 x float values
  74617. * @param index defines the row index
  74618. * @param x defines the x component to set
  74619. * @param y defines the y component to set
  74620. * @param z defines the z component to set
  74621. * @param w defines the w component to set
  74622. * @returns the updated current matrix
  74623. */
  74624. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  74625. /**
  74626. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74627. * @param scale defines the scale factor
  74628. * @returns a new matrix
  74629. */
  74630. scale(scale: number): Matrix;
  74631. /**
  74632. * Scale the current matrix values by a factor to a given result matrix
  74633. * @param scale defines the scale factor
  74634. * @param result defines the matrix to store the result
  74635. * @returns the current matrix
  74636. */
  74637. scaleToRef(scale: number, result: Matrix): Matrix;
  74638. /**
  74639. * Scale the current matrix values by a factor and add the result to a given matrix
  74640. * @param scale defines the scale factor
  74641. * @param result defines the Matrix to store the result
  74642. * @returns the current matrix
  74643. */
  74644. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  74645. /**
  74646. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74647. * @param ref matrix to store the result
  74648. */
  74649. toNormalMatrix(ref: Matrix): void;
  74650. /**
  74651. * Gets only rotation part of the current matrix
  74652. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74653. */
  74654. getRotationMatrix(): Matrix;
  74655. /**
  74656. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74657. * @param result defines the target matrix to store data to
  74658. * @returns the current matrix
  74659. */
  74660. getRotationMatrixToRef(result: Matrix): Matrix;
  74661. /**
  74662. * Toggles model matrix from being right handed to left handed in place and vice versa
  74663. */
  74664. toggleModelMatrixHandInPlace(): void;
  74665. /**
  74666. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74667. */
  74668. toggleProjectionMatrixHandInPlace(): void;
  74669. /**
  74670. * Creates a matrix from an array
  74671. * @param array defines the source array
  74672. * @param offset defines an offset in the source array
  74673. * @returns a new Matrix set from the starting index of the given array
  74674. */
  74675. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  74676. /**
  74677. * Copy the content of an array into a given matrix
  74678. * @param array defines the source array
  74679. * @param offset defines an offset in the source array
  74680. * @param result defines the target matrix
  74681. */
  74682. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  74683. /**
  74684. * Stores an array into a matrix after having multiplied each component by a given factor
  74685. * @param array defines the source array
  74686. * @param offset defines the offset in the source array
  74687. * @param scale defines the scaling factor
  74688. * @param result defines the target matrix
  74689. */
  74690. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  74691. /**
  74692. * Gets an identity matrix that must not be updated
  74693. */
  74694. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  74695. /**
  74696. * Stores a list of values (16) inside a given matrix
  74697. * @param initialM11 defines 1st value of 1st row
  74698. * @param initialM12 defines 2nd value of 1st row
  74699. * @param initialM13 defines 3rd value of 1st row
  74700. * @param initialM14 defines 4th value of 1st row
  74701. * @param initialM21 defines 1st value of 2nd row
  74702. * @param initialM22 defines 2nd value of 2nd row
  74703. * @param initialM23 defines 3rd value of 2nd row
  74704. * @param initialM24 defines 4th value of 2nd row
  74705. * @param initialM31 defines 1st value of 3rd row
  74706. * @param initialM32 defines 2nd value of 3rd row
  74707. * @param initialM33 defines 3rd value of 3rd row
  74708. * @param initialM34 defines 4th value of 3rd row
  74709. * @param initialM41 defines 1st value of 4th row
  74710. * @param initialM42 defines 2nd value of 4th row
  74711. * @param initialM43 defines 3rd value of 4th row
  74712. * @param initialM44 defines 4th value of 4th row
  74713. * @param result defines the target matrix
  74714. */
  74715. 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;
  74716. /**
  74717. * Creates new matrix from a list of values (16)
  74718. * @param initialM11 defines 1st value of 1st row
  74719. * @param initialM12 defines 2nd value of 1st row
  74720. * @param initialM13 defines 3rd value of 1st row
  74721. * @param initialM14 defines 4th value of 1st row
  74722. * @param initialM21 defines 1st value of 2nd row
  74723. * @param initialM22 defines 2nd value of 2nd row
  74724. * @param initialM23 defines 3rd value of 2nd row
  74725. * @param initialM24 defines 4th value of 2nd row
  74726. * @param initialM31 defines 1st value of 3rd row
  74727. * @param initialM32 defines 2nd value of 3rd row
  74728. * @param initialM33 defines 3rd value of 3rd row
  74729. * @param initialM34 defines 4th value of 3rd row
  74730. * @param initialM41 defines 1st value of 4th row
  74731. * @param initialM42 defines 2nd value of 4th row
  74732. * @param initialM43 defines 3rd value of 4th row
  74733. * @param initialM44 defines 4th value of 4th row
  74734. * @returns the new matrix
  74735. */
  74736. 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;
  74737. /**
  74738. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74739. * @param scale defines the scale vector3
  74740. * @param rotation defines the rotation quaternion
  74741. * @param translation defines the translation vector3
  74742. * @returns a new matrix
  74743. */
  74744. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  74745. /**
  74746. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74747. * @param scale defines the scale vector3
  74748. * @param rotation defines the rotation quaternion
  74749. * @param translation defines the translation vector3
  74750. * @param result defines the target matrix
  74751. */
  74752. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  74753. /**
  74754. * Creates a new identity matrix
  74755. * @returns a new identity matrix
  74756. */
  74757. static Identity(): Matrix;
  74758. /**
  74759. * Creates a new identity matrix and stores the result in a given matrix
  74760. * @param result defines the target matrix
  74761. */
  74762. static IdentityToRef(result: Matrix): void;
  74763. /**
  74764. * Creates a new zero matrix
  74765. * @returns a new zero matrix
  74766. */
  74767. static Zero(): Matrix;
  74768. /**
  74769. * Creates a new rotation matrix for "angle" radians around the X axis
  74770. * @param angle defines the angle (in radians) to use
  74771. * @return the new matrix
  74772. */
  74773. static RotationX(angle: number): Matrix;
  74774. /**
  74775. * Creates a new matrix as the invert of a given matrix
  74776. * @param source defines the source matrix
  74777. * @returns the new matrix
  74778. */
  74779. static Invert(source: DeepImmutable<Matrix>): Matrix;
  74780. /**
  74781. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74782. * @param angle defines the angle (in radians) to use
  74783. * @param result defines the target matrix
  74784. */
  74785. static RotationXToRef(angle: number, result: Matrix): void;
  74786. /**
  74787. * Creates a new rotation matrix for "angle" radians around the Y axis
  74788. * @param angle defines the angle (in radians) to use
  74789. * @return the new matrix
  74790. */
  74791. static RotationY(angle: number): Matrix;
  74792. /**
  74793. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74794. * @param angle defines the angle (in radians) to use
  74795. * @param result defines the target matrix
  74796. */
  74797. static RotationYToRef(angle: number, result: Matrix): void;
  74798. /**
  74799. * Creates a new rotation matrix for "angle" radians around the Z axis
  74800. * @param angle defines the angle (in radians) to use
  74801. * @return the new matrix
  74802. */
  74803. static RotationZ(angle: number): Matrix;
  74804. /**
  74805. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74806. * @param angle defines the angle (in radians) to use
  74807. * @param result defines the target matrix
  74808. */
  74809. static RotationZToRef(angle: number, result: Matrix): void;
  74810. /**
  74811. * Creates a new rotation matrix for "angle" radians around the given axis
  74812. * @param axis defines the axis to use
  74813. * @param angle defines the angle (in radians) to use
  74814. * @return the new matrix
  74815. */
  74816. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  74817. /**
  74818. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74819. * @param axis defines the axis to use
  74820. * @param angle defines the angle (in radians) to use
  74821. * @param result defines the target matrix
  74822. */
  74823. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  74824. /**
  74825. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  74826. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  74827. * @param from defines the vector to align
  74828. * @param to defines the vector to align to
  74829. * @param result defines the target matrix
  74830. */
  74831. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  74832. /**
  74833. * Creates a rotation matrix
  74834. * @param yaw defines the yaw angle in radians (Y axis)
  74835. * @param pitch defines the pitch angle in radians (X axis)
  74836. * @param roll defines the roll angle in radians (X axis)
  74837. * @returns the new rotation matrix
  74838. */
  74839. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  74840. /**
  74841. * Creates a rotation matrix and stores it in a given matrix
  74842. * @param yaw defines the yaw angle in radians (Y axis)
  74843. * @param pitch defines the pitch angle in radians (X axis)
  74844. * @param roll defines the roll angle in radians (X axis)
  74845. * @param result defines the target matrix
  74846. */
  74847. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  74848. /**
  74849. * Creates a scaling matrix
  74850. * @param x defines the scale factor on X axis
  74851. * @param y defines the scale factor on Y axis
  74852. * @param z defines the scale factor on Z axis
  74853. * @returns the new matrix
  74854. */
  74855. static Scaling(x: number, y: number, z: number): Matrix;
  74856. /**
  74857. * Creates a scaling matrix and stores it in a given matrix
  74858. * @param x defines the scale factor on X axis
  74859. * @param y defines the scale factor on Y axis
  74860. * @param z defines the scale factor on Z axis
  74861. * @param result defines the target matrix
  74862. */
  74863. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  74864. /**
  74865. * Creates a translation matrix
  74866. * @param x defines the translation on X axis
  74867. * @param y defines the translation on Y axis
  74868. * @param z defines the translationon Z axis
  74869. * @returns the new matrix
  74870. */
  74871. static Translation(x: number, y: number, z: number): Matrix;
  74872. /**
  74873. * Creates a translation matrix and stores it in a given matrix
  74874. * @param x defines the translation on X axis
  74875. * @param y defines the translation on Y axis
  74876. * @param z defines the translationon Z axis
  74877. * @param result defines the target matrix
  74878. */
  74879. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  74880. /**
  74881. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74882. * @param startValue defines the start value
  74883. * @param endValue defines the end value
  74884. * @param gradient defines the gradient factor
  74885. * @returns the new matrix
  74886. */
  74887. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74888. /**
  74889. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74890. * @param startValue defines the start value
  74891. * @param endValue defines the end value
  74892. * @param gradient defines the gradient factor
  74893. * @param result defines the Matrix object where to store data
  74894. */
  74895. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74896. /**
  74897. * Builds a new matrix whose values are computed by:
  74898. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74899. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74900. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74901. * @param startValue defines the first matrix
  74902. * @param endValue defines the second matrix
  74903. * @param gradient defines the gradient between the two matrices
  74904. * @returns the new matrix
  74905. */
  74906. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74907. /**
  74908. * Update a matrix to values which are computed by:
  74909. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74910. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74911. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74912. * @param startValue defines the first matrix
  74913. * @param endValue defines the second matrix
  74914. * @param gradient defines the gradient between the two matrices
  74915. * @param result defines the target matrix
  74916. */
  74917. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74918. /**
  74919. * 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"
  74920. * This function works in left handed mode
  74921. * @param eye defines the final position of the entity
  74922. * @param target defines where the entity should look at
  74923. * @param up defines the up vector for the entity
  74924. * @returns the new matrix
  74925. */
  74926. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  74927. /**
  74928. * 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".
  74929. * This function works in left handed mode
  74930. * @param eye defines the final position of the entity
  74931. * @param target defines where the entity should look at
  74932. * @param up defines the up vector for the entity
  74933. * @param result defines the target matrix
  74934. */
  74935. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  74936. /**
  74937. * 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"
  74938. * This function works in right handed mode
  74939. * @param eye defines the final position of the entity
  74940. * @param target defines where the entity should look at
  74941. * @param up defines the up vector for the entity
  74942. * @returns the new matrix
  74943. */
  74944. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  74945. /**
  74946. * 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".
  74947. * This function works in right handed mode
  74948. * @param eye defines the final position of the entity
  74949. * @param target defines where the entity should look at
  74950. * @param up defines the up vector for the entity
  74951. * @param result defines the target matrix
  74952. */
  74953. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  74954. /**
  74955. * Create a left-handed orthographic projection matrix
  74956. * @param width defines the viewport width
  74957. * @param height defines the viewport height
  74958. * @param znear defines the near clip plane
  74959. * @param zfar defines the far clip plane
  74960. * @returns a new matrix as a left-handed orthographic projection matrix
  74961. */
  74962. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  74963. /**
  74964. * Store a left-handed orthographic projection to a given matrix
  74965. * @param width defines the viewport width
  74966. * @param height defines the viewport height
  74967. * @param znear defines the near clip plane
  74968. * @param zfar defines the far clip plane
  74969. * @param result defines the target matrix
  74970. */
  74971. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  74972. /**
  74973. * Create a left-handed orthographic projection matrix
  74974. * @param left defines the viewport left coordinate
  74975. * @param right defines the viewport right coordinate
  74976. * @param bottom defines the viewport bottom coordinate
  74977. * @param top defines the viewport top coordinate
  74978. * @param znear defines the near clip plane
  74979. * @param zfar defines the far clip plane
  74980. * @returns a new matrix as a left-handed orthographic projection matrix
  74981. */
  74982. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  74983. /**
  74984. * Stores a left-handed orthographic projection into a given matrix
  74985. * @param left defines the viewport left coordinate
  74986. * @param right defines the viewport right coordinate
  74987. * @param bottom defines the viewport bottom coordinate
  74988. * @param top defines the viewport top coordinate
  74989. * @param znear defines the near clip plane
  74990. * @param zfar defines the far clip plane
  74991. * @param result defines the target matrix
  74992. */
  74993. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  74994. /**
  74995. * Creates a right-handed orthographic projection matrix
  74996. * @param left defines the viewport left coordinate
  74997. * @param right defines the viewport right coordinate
  74998. * @param bottom defines the viewport bottom coordinate
  74999. * @param top defines the viewport top coordinate
  75000. * @param znear defines the near clip plane
  75001. * @param zfar defines the far clip plane
  75002. * @returns a new matrix as a right-handed orthographic projection matrix
  75003. */
  75004. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75005. /**
  75006. * Stores a right-handed orthographic projection into a given matrix
  75007. * @param left defines the viewport left coordinate
  75008. * @param right defines the viewport right coordinate
  75009. * @param bottom defines the viewport bottom coordinate
  75010. * @param top defines the viewport top coordinate
  75011. * @param znear defines the near clip plane
  75012. * @param zfar defines the far clip plane
  75013. * @param result defines the target matrix
  75014. */
  75015. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75016. /**
  75017. * Creates a left-handed perspective projection matrix
  75018. * @param width defines the viewport width
  75019. * @param height defines the viewport height
  75020. * @param znear defines the near clip plane
  75021. * @param zfar defines the far clip plane
  75022. * @returns a new matrix as a left-handed perspective projection matrix
  75023. */
  75024. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75025. /**
  75026. * Creates a left-handed perspective projection matrix
  75027. * @param fov defines the horizontal field of view
  75028. * @param aspect defines the aspect ratio
  75029. * @param znear defines the near clip plane
  75030. * @param zfar defines the far clip plane
  75031. * @returns a new matrix as a left-handed perspective projection matrix
  75032. */
  75033. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75034. /**
  75035. * Stores a left-handed perspective projection into a given matrix
  75036. * @param fov defines the horizontal field of view
  75037. * @param aspect defines the aspect ratio
  75038. * @param znear defines the near clip plane
  75039. * @param zfar defines the far clip plane
  75040. * @param result defines the target matrix
  75041. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75042. */
  75043. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75044. /**
  75045. * Stores a left-handed perspective projection into a given matrix with depth reversed
  75046. * @param fov defines the horizontal field of view
  75047. * @param aspect defines the aspect ratio
  75048. * @param znear defines the near clip plane
  75049. * @param zfar not used as infinity is used as far clip
  75050. * @param result defines the target matrix
  75051. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75052. */
  75053. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75054. /**
  75055. * Creates a right-handed perspective projection matrix
  75056. * @param fov defines the horizontal field of view
  75057. * @param aspect defines the aspect ratio
  75058. * @param znear defines the near clip plane
  75059. * @param zfar defines the far clip plane
  75060. * @returns a new matrix as a right-handed perspective projection matrix
  75061. */
  75062. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75063. /**
  75064. * Stores a right-handed perspective projection into a given matrix
  75065. * @param fov defines the horizontal field of view
  75066. * @param aspect defines the aspect ratio
  75067. * @param znear defines the near clip plane
  75068. * @param zfar defines the far clip plane
  75069. * @param result defines the target matrix
  75070. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75071. */
  75072. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75073. /**
  75074. * Stores a right-handed perspective projection into a given matrix
  75075. * @param fov defines the horizontal field of view
  75076. * @param aspect defines the aspect ratio
  75077. * @param znear defines the near clip plane
  75078. * @param zfar not used as infinity is used as far clip
  75079. * @param result defines the target matrix
  75080. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75081. */
  75082. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75083. /**
  75084. * Stores a perspective projection for WebVR info a given matrix
  75085. * @param fov defines the field of view
  75086. * @param znear defines the near clip plane
  75087. * @param zfar defines the far clip plane
  75088. * @param result defines the target matrix
  75089. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75090. */
  75091. static PerspectiveFovWebVRToRef(fov: {
  75092. upDegrees: number;
  75093. downDegrees: number;
  75094. leftDegrees: number;
  75095. rightDegrees: number;
  75096. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75097. /**
  75098. * Computes a complete transformation matrix
  75099. * @param viewport defines the viewport to use
  75100. * @param world defines the world matrix
  75101. * @param view defines the view matrix
  75102. * @param projection defines the projection matrix
  75103. * @param zmin defines the near clip plane
  75104. * @param zmax defines the far clip plane
  75105. * @returns the transformation matrix
  75106. */
  75107. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75108. /**
  75109. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75110. * @param matrix defines the matrix to use
  75111. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75112. */
  75113. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75114. /**
  75115. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75116. * @param matrix defines the matrix to use
  75117. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75118. */
  75119. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75120. /**
  75121. * Compute the transpose of a given matrix
  75122. * @param matrix defines the matrix to transpose
  75123. * @returns the new matrix
  75124. */
  75125. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75126. /**
  75127. * Compute the transpose of a matrix and store it in a target matrix
  75128. * @param matrix defines the matrix to transpose
  75129. * @param result defines the target matrix
  75130. */
  75131. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  75132. /**
  75133. * Computes a reflection matrix from a plane
  75134. * @param plane defines the reflection plane
  75135. * @returns a new matrix
  75136. */
  75137. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  75138. /**
  75139. * Computes a reflection matrix from a plane
  75140. * @param plane defines the reflection plane
  75141. * @param result defines the target matrix
  75142. */
  75143. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  75144. /**
  75145. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75146. * @param xaxis defines the value of the 1st axis
  75147. * @param yaxis defines the value of the 2nd axis
  75148. * @param zaxis defines the value of the 3rd axis
  75149. * @param result defines the target matrix
  75150. */
  75151. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  75152. /**
  75153. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75154. * @param quat defines the quaternion to use
  75155. * @param result defines the target matrix
  75156. */
  75157. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  75158. }
  75159. /**
  75160. * @hidden
  75161. */
  75162. export class TmpVectors {
  75163. static Vector2: Vector2[];
  75164. static Vector3: Vector3[];
  75165. static Vector4: Vector4[];
  75166. static Quaternion: Quaternion[];
  75167. static Matrix: Matrix[];
  75168. }
  75169. }
  75170. declare module BABYLON {
  75171. /**
  75172. * Defines potential orientation for back face culling
  75173. */
  75174. export enum Orientation {
  75175. /**
  75176. * Clockwise
  75177. */
  75178. CW = 0,
  75179. /** Counter clockwise */
  75180. CCW = 1
  75181. }
  75182. /** Class used to represent a Bezier curve */
  75183. export class BezierCurve {
  75184. /**
  75185. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75186. * @param t defines the time
  75187. * @param x1 defines the left coordinate on X axis
  75188. * @param y1 defines the left coordinate on Y axis
  75189. * @param x2 defines the right coordinate on X axis
  75190. * @param y2 defines the right coordinate on Y axis
  75191. * @returns the interpolated value
  75192. */
  75193. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  75194. }
  75195. /**
  75196. * Defines angle representation
  75197. */
  75198. export class Angle {
  75199. private _radians;
  75200. /**
  75201. * Creates an Angle object of "radians" radians (float).
  75202. * @param radians the angle in radians
  75203. */
  75204. constructor(radians: number);
  75205. /**
  75206. * Get value in degrees
  75207. * @returns the Angle value in degrees (float)
  75208. */
  75209. degrees(): number;
  75210. /**
  75211. * Get value in radians
  75212. * @returns the Angle value in radians (float)
  75213. */
  75214. radians(): number;
  75215. /**
  75216. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75217. * @param a defines first vector
  75218. * @param b defines second vector
  75219. * @returns a new Angle
  75220. */
  75221. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  75222. /**
  75223. * Gets a new Angle object from the given float in radians
  75224. * @param radians defines the angle value in radians
  75225. * @returns a new Angle
  75226. */
  75227. static FromRadians(radians: number): Angle;
  75228. /**
  75229. * Gets a new Angle object from the given float in degrees
  75230. * @param degrees defines the angle value in degrees
  75231. * @returns a new Angle
  75232. */
  75233. static FromDegrees(degrees: number): Angle;
  75234. }
  75235. /**
  75236. * This represents an arc in a 2d space.
  75237. */
  75238. export class Arc2 {
  75239. /** Defines the start point of the arc */
  75240. startPoint: Vector2;
  75241. /** Defines the mid point of the arc */
  75242. midPoint: Vector2;
  75243. /** Defines the end point of the arc */
  75244. endPoint: Vector2;
  75245. /**
  75246. * Defines the center point of the arc.
  75247. */
  75248. centerPoint: Vector2;
  75249. /**
  75250. * Defines the radius of the arc.
  75251. */
  75252. radius: number;
  75253. /**
  75254. * Defines the angle of the arc (from mid point to end point).
  75255. */
  75256. angle: Angle;
  75257. /**
  75258. * Defines the start angle of the arc (from start point to middle point).
  75259. */
  75260. startAngle: Angle;
  75261. /**
  75262. * Defines the orientation of the arc (clock wise/counter clock wise).
  75263. */
  75264. orientation: Orientation;
  75265. /**
  75266. * Creates an Arc object from the three given points : start, middle and end.
  75267. * @param startPoint Defines the start point of the arc
  75268. * @param midPoint Defines the midlle point of the arc
  75269. * @param endPoint Defines the end point of the arc
  75270. */
  75271. constructor(
  75272. /** Defines the start point of the arc */
  75273. startPoint: Vector2,
  75274. /** Defines the mid point of the arc */
  75275. midPoint: Vector2,
  75276. /** Defines the end point of the arc */
  75277. endPoint: Vector2);
  75278. }
  75279. /**
  75280. * Represents a 2D path made up of multiple 2D points
  75281. */
  75282. export class Path2 {
  75283. private _points;
  75284. private _length;
  75285. /**
  75286. * If the path start and end point are the same
  75287. */
  75288. closed: boolean;
  75289. /**
  75290. * Creates a Path2 object from the starting 2D coordinates x and y.
  75291. * @param x the starting points x value
  75292. * @param y the starting points y value
  75293. */
  75294. constructor(x: number, y: number);
  75295. /**
  75296. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  75297. * @param x the added points x value
  75298. * @param y the added points y value
  75299. * @returns the updated Path2.
  75300. */
  75301. addLineTo(x: number, y: number): Path2;
  75302. /**
  75303. * 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.
  75304. * @param midX middle point x value
  75305. * @param midY middle point y value
  75306. * @param endX end point x value
  75307. * @param endY end point y value
  75308. * @param numberOfSegments (default: 36)
  75309. * @returns the updated Path2.
  75310. */
  75311. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  75312. /**
  75313. * Closes the Path2.
  75314. * @returns the Path2.
  75315. */
  75316. close(): Path2;
  75317. /**
  75318. * Gets the sum of the distance between each sequential point in the path
  75319. * @returns the Path2 total length (float).
  75320. */
  75321. length(): number;
  75322. /**
  75323. * Gets the points which construct the path
  75324. * @returns the Path2 internal array of points.
  75325. */
  75326. getPoints(): Vector2[];
  75327. /**
  75328. * Retreives the point at the distance aways from the starting point
  75329. * @param normalizedLengthPosition the length along the path to retreive the point from
  75330. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  75331. */
  75332. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  75333. /**
  75334. * Creates a new path starting from an x and y position
  75335. * @param x starting x value
  75336. * @param y starting y value
  75337. * @returns a new Path2 starting at the coordinates (x, y).
  75338. */
  75339. static StartingAt(x: number, y: number): Path2;
  75340. }
  75341. /**
  75342. * Represents a 3D path made up of multiple 3D points
  75343. */
  75344. export class Path3D {
  75345. /**
  75346. * an array of Vector3, the curve axis of the Path3D
  75347. */
  75348. path: Vector3[];
  75349. private _curve;
  75350. private _distances;
  75351. private _tangents;
  75352. private _normals;
  75353. private _binormals;
  75354. private _raw;
  75355. private _alignTangentsWithPath;
  75356. private readonly _pointAtData;
  75357. /**
  75358. * new Path3D(path, normal, raw)
  75359. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  75360. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  75361. * @param path an array of Vector3, the curve axis of the Path3D
  75362. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  75363. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  75364. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  75365. */
  75366. constructor(
  75367. /**
  75368. * an array of Vector3, the curve axis of the Path3D
  75369. */
  75370. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  75371. /**
  75372. * Returns the Path3D array of successive Vector3 designing its curve.
  75373. * @returns the Path3D array of successive Vector3 designing its curve.
  75374. */
  75375. getCurve(): Vector3[];
  75376. /**
  75377. * Returns the Path3D array of successive Vector3 designing its curve.
  75378. * @returns the Path3D array of successive Vector3 designing its curve.
  75379. */
  75380. getPoints(): Vector3[];
  75381. /**
  75382. * @returns the computed length (float) of the path.
  75383. */
  75384. length(): number;
  75385. /**
  75386. * Returns an array populated with tangent vectors on each Path3D curve point.
  75387. * @returns an array populated with tangent vectors on each Path3D curve point.
  75388. */
  75389. getTangents(): Vector3[];
  75390. /**
  75391. * Returns an array populated with normal vectors on each Path3D curve point.
  75392. * @returns an array populated with normal vectors on each Path3D curve point.
  75393. */
  75394. getNormals(): Vector3[];
  75395. /**
  75396. * Returns an array populated with binormal vectors on each Path3D curve point.
  75397. * @returns an array populated with binormal vectors on each Path3D curve point.
  75398. */
  75399. getBinormals(): Vector3[];
  75400. /**
  75401. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  75402. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  75403. */
  75404. getDistances(): number[];
  75405. /**
  75406. * Returns an interpolated point along this path
  75407. * @param position the position of the point along this path, from 0.0 to 1.0
  75408. * @returns a new Vector3 as the point
  75409. */
  75410. getPointAt(position: number): Vector3;
  75411. /**
  75412. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75413. * @param position the position of the point along this path, from 0.0 to 1.0
  75414. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  75415. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  75416. */
  75417. getTangentAt(position: number, interpolated?: boolean): Vector3;
  75418. /**
  75419. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75420. * @param position the position of the point along this path, from 0.0 to 1.0
  75421. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  75422. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  75423. */
  75424. getNormalAt(position: number, interpolated?: boolean): Vector3;
  75425. /**
  75426. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  75427. * @param position the position of the point along this path, from 0.0 to 1.0
  75428. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  75429. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  75430. */
  75431. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  75432. /**
  75433. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  75434. * @param position the position of the point along this path, from 0.0 to 1.0
  75435. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  75436. */
  75437. getDistanceAt(position: number): number;
  75438. /**
  75439. * Returns the array index of the previous point of an interpolated point along this path
  75440. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75441. * @returns the array index
  75442. */
  75443. getPreviousPointIndexAt(position: number): number;
  75444. /**
  75445. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  75446. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75447. * @returns the sub position
  75448. */
  75449. getSubPositionAt(position: number): number;
  75450. /**
  75451. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  75452. * @param target the vector of which to get the closest position to
  75453. * @returns the position of the closest virtual point on this path to the target vector
  75454. */
  75455. getClosestPositionTo(target: Vector3): number;
  75456. /**
  75457. * Returns a sub path (slice) of this path
  75458. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  75459. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  75460. * @returns a sub path (slice) of this path
  75461. */
  75462. slice(start?: number, end?: number): Path3D;
  75463. /**
  75464. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  75465. * @param path path which all values are copied into the curves points
  75466. * @param firstNormal which should be projected onto the curve
  75467. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  75468. * @returns the same object updated.
  75469. */
  75470. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  75471. private _compute;
  75472. private _getFirstNonNullVector;
  75473. private _getLastNonNullVector;
  75474. private _normalVector;
  75475. /**
  75476. * Updates the point at data for an interpolated point along this curve
  75477. * @param position the position of the point along this curve, from 0.0 to 1.0
  75478. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  75479. * @returns the (updated) point at data
  75480. */
  75481. private _updatePointAtData;
  75482. /**
  75483. * Updates the point at data from the specified parameters
  75484. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  75485. * @param point the interpolated point
  75486. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  75487. */
  75488. private _setPointAtData;
  75489. /**
  75490. * Updates the point at interpolation matrix for the tangents, normals and binormals
  75491. */
  75492. private _updateInterpolationMatrix;
  75493. }
  75494. /**
  75495. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75496. * A Curve3 is designed from a series of successive Vector3.
  75497. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  75498. */
  75499. export class Curve3 {
  75500. private _points;
  75501. private _length;
  75502. /**
  75503. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  75504. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  75505. * @param v1 (Vector3) the control point
  75506. * @param v2 (Vector3) the end point of the Quadratic Bezier
  75507. * @param nbPoints (integer) the wanted number of points in the curve
  75508. * @returns the created Curve3
  75509. */
  75510. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75511. /**
  75512. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  75513. * @param v0 (Vector3) the origin point of the Cubic Bezier
  75514. * @param v1 (Vector3) the first control point
  75515. * @param v2 (Vector3) the second control point
  75516. * @param v3 (Vector3) the end point of the Cubic Bezier
  75517. * @param nbPoints (integer) the wanted number of points in the curve
  75518. * @returns the created Curve3
  75519. */
  75520. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75521. /**
  75522. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  75523. * @param p1 (Vector3) the origin point of the Hermite Spline
  75524. * @param t1 (Vector3) the tangent vector at the origin point
  75525. * @param p2 (Vector3) the end point of the Hermite Spline
  75526. * @param t2 (Vector3) the tangent vector at the end point
  75527. * @param nbPoints (integer) the wanted number of points in the curve
  75528. * @returns the created Curve3
  75529. */
  75530. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75531. /**
  75532. * Returns a Curve3 object along a CatmullRom Spline curve :
  75533. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  75534. * @param nbPoints (integer) the wanted number of points between each curve control points
  75535. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  75536. * @returns the created Curve3
  75537. */
  75538. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  75539. /**
  75540. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75541. * A Curve3 is designed from a series of successive Vector3.
  75542. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  75543. * @param points points which make up the curve
  75544. */
  75545. constructor(points: Vector3[]);
  75546. /**
  75547. * @returns the Curve3 stored array of successive Vector3
  75548. */
  75549. getPoints(): Vector3[];
  75550. /**
  75551. * @returns the computed length (float) of the curve.
  75552. */
  75553. length(): number;
  75554. /**
  75555. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  75556. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  75557. * curveA and curveB keep unchanged.
  75558. * @param curve the curve to continue from this curve
  75559. * @returns the newly constructed curve
  75560. */
  75561. continue(curve: DeepImmutable<Curve3>): Curve3;
  75562. private _computeLength;
  75563. }
  75564. }
  75565. declare module BABYLON {
  75566. /**
  75567. * This represents the main contract an easing function should follow.
  75568. * Easing functions are used throughout the animation system.
  75569. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75570. */
  75571. export interface IEasingFunction {
  75572. /**
  75573. * Given an input gradient between 0 and 1, this returns the corrseponding value
  75574. * of the easing function.
  75575. * The link below provides some of the most common examples of easing functions.
  75576. * @see https://easings.net/
  75577. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75578. * @returns the corresponding value on the curve defined by the easing function
  75579. */
  75580. ease(gradient: number): number;
  75581. }
  75582. /**
  75583. * Base class used for every default easing function.
  75584. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75585. */
  75586. export class EasingFunction implements IEasingFunction {
  75587. /**
  75588. * Interpolation follows the mathematical formula associated with the easing function.
  75589. */
  75590. static readonly EASINGMODE_EASEIN: number;
  75591. /**
  75592. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  75593. */
  75594. static readonly EASINGMODE_EASEOUT: number;
  75595. /**
  75596. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  75597. */
  75598. static readonly EASINGMODE_EASEINOUT: number;
  75599. private _easingMode;
  75600. /**
  75601. * Sets the easing mode of the current function.
  75602. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  75603. */
  75604. setEasingMode(easingMode: number): void;
  75605. /**
  75606. * Gets the current easing mode.
  75607. * @returns the easing mode
  75608. */
  75609. getEasingMode(): number;
  75610. /**
  75611. * @hidden
  75612. */
  75613. easeInCore(gradient: number): number;
  75614. /**
  75615. * Given an input gradient between 0 and 1, this returns the corresponding value
  75616. * of the easing function.
  75617. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75618. * @returns the corresponding value on the curve defined by the easing function
  75619. */
  75620. ease(gradient: number): number;
  75621. }
  75622. /**
  75623. * Easing function with a circle shape (see link below).
  75624. * @see https://easings.net/#easeInCirc
  75625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75626. */
  75627. export class CircleEase extends EasingFunction implements IEasingFunction {
  75628. /** @hidden */
  75629. easeInCore(gradient: number): number;
  75630. }
  75631. /**
  75632. * Easing function with a ease back shape (see link below).
  75633. * @see https://easings.net/#easeInBack
  75634. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75635. */
  75636. export class BackEase extends EasingFunction implements IEasingFunction {
  75637. /** Defines the amplitude of the function */
  75638. amplitude: number;
  75639. /**
  75640. * Instantiates a back ease easing
  75641. * @see https://easings.net/#easeInBack
  75642. * @param amplitude Defines the amplitude of the function
  75643. */
  75644. constructor(
  75645. /** Defines the amplitude of the function */
  75646. amplitude?: number);
  75647. /** @hidden */
  75648. easeInCore(gradient: number): number;
  75649. }
  75650. /**
  75651. * Easing function with a bouncing shape (see link below).
  75652. * @see https://easings.net/#easeInBounce
  75653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75654. */
  75655. export class BounceEase extends EasingFunction implements IEasingFunction {
  75656. /** Defines the number of bounces */
  75657. bounces: number;
  75658. /** Defines the amplitude of the bounce */
  75659. bounciness: number;
  75660. /**
  75661. * Instantiates a bounce easing
  75662. * @see https://easings.net/#easeInBounce
  75663. * @param bounces Defines the number of bounces
  75664. * @param bounciness Defines the amplitude of the bounce
  75665. */
  75666. constructor(
  75667. /** Defines the number of bounces */
  75668. bounces?: number,
  75669. /** Defines the amplitude of the bounce */
  75670. bounciness?: number);
  75671. /** @hidden */
  75672. easeInCore(gradient: number): number;
  75673. }
  75674. /**
  75675. * Easing function with a power of 3 shape (see link below).
  75676. * @see https://easings.net/#easeInCubic
  75677. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75678. */
  75679. export class CubicEase extends EasingFunction implements IEasingFunction {
  75680. /** @hidden */
  75681. easeInCore(gradient: number): number;
  75682. }
  75683. /**
  75684. * Easing function with an elastic shape (see link below).
  75685. * @see https://easings.net/#easeInElastic
  75686. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75687. */
  75688. export class ElasticEase extends EasingFunction implements IEasingFunction {
  75689. /** Defines the number of oscillations*/
  75690. oscillations: number;
  75691. /** Defines the amplitude of the oscillations*/
  75692. springiness: number;
  75693. /**
  75694. * Instantiates an elastic easing function
  75695. * @see https://easings.net/#easeInElastic
  75696. * @param oscillations Defines the number of oscillations
  75697. * @param springiness Defines the amplitude of the oscillations
  75698. */
  75699. constructor(
  75700. /** Defines the number of oscillations*/
  75701. oscillations?: number,
  75702. /** Defines the amplitude of the oscillations*/
  75703. springiness?: number);
  75704. /** @hidden */
  75705. easeInCore(gradient: number): number;
  75706. }
  75707. /**
  75708. * Easing function with an exponential shape (see link below).
  75709. * @see https://easings.net/#easeInExpo
  75710. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75711. */
  75712. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  75713. /** Defines the exponent of the function */
  75714. exponent: number;
  75715. /**
  75716. * Instantiates an exponential easing function
  75717. * @see https://easings.net/#easeInExpo
  75718. * @param exponent Defines the exponent of the function
  75719. */
  75720. constructor(
  75721. /** Defines the exponent of the function */
  75722. exponent?: number);
  75723. /** @hidden */
  75724. easeInCore(gradient: number): number;
  75725. }
  75726. /**
  75727. * Easing function with a power shape (see link below).
  75728. * @see https://easings.net/#easeInQuad
  75729. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75730. */
  75731. export class PowerEase extends EasingFunction implements IEasingFunction {
  75732. /** Defines the power of the function */
  75733. power: number;
  75734. /**
  75735. * Instantiates an power base easing function
  75736. * @see https://easings.net/#easeInQuad
  75737. * @param power Defines the power of the function
  75738. */
  75739. constructor(
  75740. /** Defines the power of the function */
  75741. power?: number);
  75742. /** @hidden */
  75743. easeInCore(gradient: number): number;
  75744. }
  75745. /**
  75746. * Easing function with a power of 2 shape (see link below).
  75747. * @see https://easings.net/#easeInQuad
  75748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75749. */
  75750. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  75751. /** @hidden */
  75752. easeInCore(gradient: number): number;
  75753. }
  75754. /**
  75755. * Easing function with a power of 4 shape (see link below).
  75756. * @see https://easings.net/#easeInQuart
  75757. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75758. */
  75759. export class QuarticEase extends EasingFunction implements IEasingFunction {
  75760. /** @hidden */
  75761. easeInCore(gradient: number): number;
  75762. }
  75763. /**
  75764. * Easing function with a power of 5 shape (see link below).
  75765. * @see https://easings.net/#easeInQuint
  75766. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75767. */
  75768. export class QuinticEase extends EasingFunction implements IEasingFunction {
  75769. /** @hidden */
  75770. easeInCore(gradient: number): number;
  75771. }
  75772. /**
  75773. * Easing function with a sin shape (see link below).
  75774. * @see https://easings.net/#easeInSine
  75775. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75776. */
  75777. export class SineEase extends EasingFunction implements IEasingFunction {
  75778. /** @hidden */
  75779. easeInCore(gradient: number): number;
  75780. }
  75781. /**
  75782. * Easing function with a bezier shape (see link below).
  75783. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75784. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75785. */
  75786. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  75787. /** Defines the x component of the start tangent in the bezier curve */
  75788. x1: number;
  75789. /** Defines the y component of the start tangent in the bezier curve */
  75790. y1: number;
  75791. /** Defines the x component of the end tangent in the bezier curve */
  75792. x2: number;
  75793. /** Defines the y component of the end tangent in the bezier curve */
  75794. y2: number;
  75795. /**
  75796. * Instantiates a bezier function
  75797. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75798. * @param x1 Defines the x component of the start tangent in the bezier curve
  75799. * @param y1 Defines the y component of the start tangent in the bezier curve
  75800. * @param x2 Defines the x component of the end tangent in the bezier curve
  75801. * @param y2 Defines the y component of the end tangent in the bezier curve
  75802. */
  75803. constructor(
  75804. /** Defines the x component of the start tangent in the bezier curve */
  75805. x1?: number,
  75806. /** Defines the y component of the start tangent in the bezier curve */
  75807. y1?: number,
  75808. /** Defines the x component of the end tangent in the bezier curve */
  75809. x2?: number,
  75810. /** Defines the y component of the end tangent in the bezier curve */
  75811. y2?: number);
  75812. /** @hidden */
  75813. easeInCore(gradient: number): number;
  75814. }
  75815. }
  75816. declare module BABYLON {
  75817. /**
  75818. * Class used to hold a RBG color
  75819. */
  75820. export class Color3 {
  75821. /**
  75822. * Defines the red component (between 0 and 1, default is 0)
  75823. */
  75824. r: number;
  75825. /**
  75826. * Defines the green component (between 0 and 1, default is 0)
  75827. */
  75828. g: number;
  75829. /**
  75830. * Defines the blue component (between 0 and 1, default is 0)
  75831. */
  75832. b: number;
  75833. /**
  75834. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  75835. * @param r defines the red component (between 0 and 1, default is 0)
  75836. * @param g defines the green component (between 0 and 1, default is 0)
  75837. * @param b defines the blue component (between 0 and 1, default is 0)
  75838. */
  75839. constructor(
  75840. /**
  75841. * Defines the red component (between 0 and 1, default is 0)
  75842. */
  75843. r?: number,
  75844. /**
  75845. * Defines the green component (between 0 and 1, default is 0)
  75846. */
  75847. g?: number,
  75848. /**
  75849. * Defines the blue component (between 0 and 1, default is 0)
  75850. */
  75851. b?: number);
  75852. /**
  75853. * Creates a string with the Color3 current values
  75854. * @returns the string representation of the Color3 object
  75855. */
  75856. toString(): string;
  75857. /**
  75858. * Returns the string "Color3"
  75859. * @returns "Color3"
  75860. */
  75861. getClassName(): string;
  75862. /**
  75863. * Compute the Color3 hash code
  75864. * @returns an unique number that can be used to hash Color3 objects
  75865. */
  75866. getHashCode(): number;
  75867. /**
  75868. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  75869. * @param array defines the array where to store the r,g,b components
  75870. * @param index defines an optional index in the target array to define where to start storing values
  75871. * @returns the current Color3 object
  75872. */
  75873. toArray(array: FloatArray, index?: number): Color3;
  75874. /**
  75875. * Returns a new Color4 object from the current Color3 and the given alpha
  75876. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  75877. * @returns a new Color4 object
  75878. */
  75879. toColor4(alpha?: number): Color4;
  75880. /**
  75881. * Returns a new array populated with 3 numeric elements : red, green and blue values
  75882. * @returns the new array
  75883. */
  75884. asArray(): number[];
  75885. /**
  75886. * Returns the luminance value
  75887. * @returns a float value
  75888. */
  75889. toLuminance(): number;
  75890. /**
  75891. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  75892. * @param otherColor defines the second operand
  75893. * @returns the new Color3 object
  75894. */
  75895. multiply(otherColor: DeepImmutable<Color3>): Color3;
  75896. /**
  75897. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  75898. * @param otherColor defines the second operand
  75899. * @param result defines the Color3 object where to store the result
  75900. * @returns the current Color3
  75901. */
  75902. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75903. /**
  75904. * Determines equality between Color3 objects
  75905. * @param otherColor defines the second operand
  75906. * @returns true if the rgb values are equal to the given ones
  75907. */
  75908. equals(otherColor: DeepImmutable<Color3>): boolean;
  75909. /**
  75910. * Determines equality between the current Color3 object and a set of r,b,g values
  75911. * @param r defines the red component to check
  75912. * @param g defines the green component to check
  75913. * @param b defines the blue component to check
  75914. * @returns true if the rgb values are equal to the given ones
  75915. */
  75916. equalsFloats(r: number, g: number, b: number): boolean;
  75917. /**
  75918. * Multiplies in place each rgb value by scale
  75919. * @param scale defines the scaling factor
  75920. * @returns the updated Color3
  75921. */
  75922. scale(scale: number): Color3;
  75923. /**
  75924. * Multiplies the rgb values by scale and stores the result into "result"
  75925. * @param scale defines the scaling factor
  75926. * @param result defines the Color3 object where to store the result
  75927. * @returns the unmodified current Color3
  75928. */
  75929. scaleToRef(scale: number, result: Color3): Color3;
  75930. /**
  75931. * Scale the current Color3 values by a factor and add the result to a given Color3
  75932. * @param scale defines the scale factor
  75933. * @param result defines color to store the result into
  75934. * @returns the unmodified current Color3
  75935. */
  75936. scaleAndAddToRef(scale: number, result: Color3): Color3;
  75937. /**
  75938. * Clamps the rgb values by the min and max values and stores the result into "result"
  75939. * @param min defines minimum clamping value (default is 0)
  75940. * @param max defines maximum clamping value (default is 1)
  75941. * @param result defines color to store the result into
  75942. * @returns the original Color3
  75943. */
  75944. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  75945. /**
  75946. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  75947. * @param otherColor defines the second operand
  75948. * @returns the new Color3
  75949. */
  75950. add(otherColor: DeepImmutable<Color3>): Color3;
  75951. /**
  75952. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  75953. * @param otherColor defines the second operand
  75954. * @param result defines Color3 object to store the result into
  75955. * @returns the unmodified current Color3
  75956. */
  75957. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75958. /**
  75959. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  75960. * @param otherColor defines the second operand
  75961. * @returns the new Color3
  75962. */
  75963. subtract(otherColor: DeepImmutable<Color3>): Color3;
  75964. /**
  75965. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  75966. * @param otherColor defines the second operand
  75967. * @param result defines Color3 object to store the result into
  75968. * @returns the unmodified current Color3
  75969. */
  75970. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75971. /**
  75972. * Copy the current object
  75973. * @returns a new Color3 copied the current one
  75974. */
  75975. clone(): Color3;
  75976. /**
  75977. * Copies the rgb values from the source in the current Color3
  75978. * @param source defines the source Color3 object
  75979. * @returns the updated Color3 object
  75980. */
  75981. copyFrom(source: DeepImmutable<Color3>): Color3;
  75982. /**
  75983. * Updates the Color3 rgb values from the given floats
  75984. * @param r defines the red component to read from
  75985. * @param g defines the green component to read from
  75986. * @param b defines the blue component to read from
  75987. * @returns the current Color3 object
  75988. */
  75989. copyFromFloats(r: number, g: number, b: number): Color3;
  75990. /**
  75991. * Updates the Color3 rgb values from the given floats
  75992. * @param r defines the red component to read from
  75993. * @param g defines the green component to read from
  75994. * @param b defines the blue component to read from
  75995. * @returns the current Color3 object
  75996. */
  75997. set(r: number, g: number, b: number): Color3;
  75998. /**
  75999. * Compute the Color3 hexadecimal code as a string
  76000. * @returns a string containing the hexadecimal representation of the Color3 object
  76001. */
  76002. toHexString(): string;
  76003. /**
  76004. * Computes a new Color3 converted from the current one to linear space
  76005. * @returns a new Color3 object
  76006. */
  76007. toLinearSpace(): Color3;
  76008. /**
  76009. * Converts current color in rgb space to HSV values
  76010. * @returns a new color3 representing the HSV values
  76011. */
  76012. toHSV(): Color3;
  76013. /**
  76014. * Converts current color in rgb space to HSV values
  76015. * @param result defines the Color3 where to store the HSV values
  76016. */
  76017. toHSVToRef(result: Color3): void;
  76018. /**
  76019. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76020. * @param convertedColor defines the Color3 object where to store the linear space version
  76021. * @returns the unmodified Color3
  76022. */
  76023. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76024. /**
  76025. * Computes a new Color3 converted from the current one to gamma space
  76026. * @returns a new Color3 object
  76027. */
  76028. toGammaSpace(): Color3;
  76029. /**
  76030. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76031. * @param convertedColor defines the Color3 object where to store the gamma space version
  76032. * @returns the unmodified Color3
  76033. */
  76034. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76035. private static _BlackReadOnly;
  76036. /**
  76037. * Convert Hue, saturation and value to a Color3 (RGB)
  76038. * @param hue defines the hue
  76039. * @param saturation defines the saturation
  76040. * @param value defines the value
  76041. * @param result defines the Color3 where to store the RGB values
  76042. */
  76043. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76044. /**
  76045. * Creates a new Color3 from the string containing valid hexadecimal values
  76046. * @param hex defines a string containing valid hexadecimal values
  76047. * @returns a new Color3 object
  76048. */
  76049. static FromHexString(hex: string): Color3;
  76050. /**
  76051. * Creates a new Color3 from the starting index of the given array
  76052. * @param array defines the source array
  76053. * @param offset defines an offset in the source array
  76054. * @returns a new Color3 object
  76055. */
  76056. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76057. /**
  76058. * Creates a new Color3 from integer values (< 256)
  76059. * @param r defines the red component to read from (value between 0 and 255)
  76060. * @param g defines the green component to read from (value between 0 and 255)
  76061. * @param b defines the blue component to read from (value between 0 and 255)
  76062. * @returns a new Color3 object
  76063. */
  76064. static FromInts(r: number, g: number, b: number): Color3;
  76065. /**
  76066. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76067. * @param start defines the start Color3 value
  76068. * @param end defines the end Color3 value
  76069. * @param amount defines the gradient value between start and end
  76070. * @returns a new Color3 object
  76071. */
  76072. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76073. /**
  76074. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76075. * @param left defines the start value
  76076. * @param right defines the end value
  76077. * @param amount defines the gradient factor
  76078. * @param result defines the Color3 object where to store the result
  76079. */
  76080. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76081. /**
  76082. * Returns a Color3 value containing a red color
  76083. * @returns a new Color3 object
  76084. */
  76085. static Red(): Color3;
  76086. /**
  76087. * Returns a Color3 value containing a green color
  76088. * @returns a new Color3 object
  76089. */
  76090. static Green(): Color3;
  76091. /**
  76092. * Returns a Color3 value containing a blue color
  76093. * @returns a new Color3 object
  76094. */
  76095. static Blue(): Color3;
  76096. /**
  76097. * Returns a Color3 value containing a black color
  76098. * @returns a new Color3 object
  76099. */
  76100. static Black(): Color3;
  76101. /**
  76102. * Gets a Color3 value containing a black color that must not be updated
  76103. */
  76104. static get BlackReadOnly(): DeepImmutable<Color3>;
  76105. /**
  76106. * Returns a Color3 value containing a white color
  76107. * @returns a new Color3 object
  76108. */
  76109. static White(): Color3;
  76110. /**
  76111. * Returns a Color3 value containing a purple color
  76112. * @returns a new Color3 object
  76113. */
  76114. static Purple(): Color3;
  76115. /**
  76116. * Returns a Color3 value containing a magenta color
  76117. * @returns a new Color3 object
  76118. */
  76119. static Magenta(): Color3;
  76120. /**
  76121. * Returns a Color3 value containing a yellow color
  76122. * @returns a new Color3 object
  76123. */
  76124. static Yellow(): Color3;
  76125. /**
  76126. * Returns a Color3 value containing a gray color
  76127. * @returns a new Color3 object
  76128. */
  76129. static Gray(): Color3;
  76130. /**
  76131. * Returns a Color3 value containing a teal color
  76132. * @returns a new Color3 object
  76133. */
  76134. static Teal(): Color3;
  76135. /**
  76136. * Returns a Color3 value containing a random color
  76137. * @returns a new Color3 object
  76138. */
  76139. static Random(): Color3;
  76140. }
  76141. /**
  76142. * Class used to hold a RBGA color
  76143. */
  76144. export class Color4 {
  76145. /**
  76146. * Defines the red component (between 0 and 1, default is 0)
  76147. */
  76148. r: number;
  76149. /**
  76150. * Defines the green component (between 0 and 1, default is 0)
  76151. */
  76152. g: number;
  76153. /**
  76154. * Defines the blue component (between 0 and 1, default is 0)
  76155. */
  76156. b: number;
  76157. /**
  76158. * Defines the alpha component (between 0 and 1, default is 1)
  76159. */
  76160. a: number;
  76161. /**
  76162. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  76163. * @param r defines the red component (between 0 and 1, default is 0)
  76164. * @param g defines the green component (between 0 and 1, default is 0)
  76165. * @param b defines the blue component (between 0 and 1, default is 0)
  76166. * @param a defines the alpha component (between 0 and 1, default is 1)
  76167. */
  76168. constructor(
  76169. /**
  76170. * Defines the red component (between 0 and 1, default is 0)
  76171. */
  76172. r?: number,
  76173. /**
  76174. * Defines the green component (between 0 and 1, default is 0)
  76175. */
  76176. g?: number,
  76177. /**
  76178. * Defines the blue component (between 0 and 1, default is 0)
  76179. */
  76180. b?: number,
  76181. /**
  76182. * Defines the alpha component (between 0 and 1, default is 1)
  76183. */
  76184. a?: number);
  76185. /**
  76186. * Adds in place the given Color4 values to the current Color4 object
  76187. * @param right defines the second operand
  76188. * @returns the current updated Color4 object
  76189. */
  76190. addInPlace(right: DeepImmutable<Color4>): Color4;
  76191. /**
  76192. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  76193. * @returns the new array
  76194. */
  76195. asArray(): number[];
  76196. /**
  76197. * Stores from the starting index in the given array the Color4 successive values
  76198. * @param array defines the array where to store the r,g,b components
  76199. * @param index defines an optional index in the target array to define where to start storing values
  76200. * @returns the current Color4 object
  76201. */
  76202. toArray(array: number[], index?: number): Color4;
  76203. /**
  76204. * Determines equality between Color4 objects
  76205. * @param otherColor defines the second operand
  76206. * @returns true if the rgba values are equal to the given ones
  76207. */
  76208. equals(otherColor: DeepImmutable<Color4>): boolean;
  76209. /**
  76210. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  76211. * @param right defines the second operand
  76212. * @returns a new Color4 object
  76213. */
  76214. add(right: DeepImmutable<Color4>): Color4;
  76215. /**
  76216. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  76217. * @param right defines the second operand
  76218. * @returns a new Color4 object
  76219. */
  76220. subtract(right: DeepImmutable<Color4>): Color4;
  76221. /**
  76222. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  76223. * @param right defines the second operand
  76224. * @param result defines the Color4 object where to store the result
  76225. * @returns the current Color4 object
  76226. */
  76227. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  76228. /**
  76229. * Creates a new Color4 with the current Color4 values multiplied by scale
  76230. * @param scale defines the scaling factor to apply
  76231. * @returns a new Color4 object
  76232. */
  76233. scale(scale: number): Color4;
  76234. /**
  76235. * Multiplies the current Color4 values by scale and stores the result in "result"
  76236. * @param scale defines the scaling factor to apply
  76237. * @param result defines the Color4 object where to store the result
  76238. * @returns the current unmodified Color4
  76239. */
  76240. scaleToRef(scale: number, result: Color4): Color4;
  76241. /**
  76242. * Scale the current Color4 values by a factor and add the result to a given Color4
  76243. * @param scale defines the scale factor
  76244. * @param result defines the Color4 object where to store the result
  76245. * @returns the unmodified current Color4
  76246. */
  76247. scaleAndAddToRef(scale: number, result: Color4): Color4;
  76248. /**
  76249. * Clamps the rgb values by the min and max values and stores the result into "result"
  76250. * @param min defines minimum clamping value (default is 0)
  76251. * @param max defines maximum clamping value (default is 1)
  76252. * @param result defines color to store the result into.
  76253. * @returns the cuurent Color4
  76254. */
  76255. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  76256. /**
  76257. * Multipy an Color4 value by another and return a new Color4 object
  76258. * @param color defines the Color4 value to multiply by
  76259. * @returns a new Color4 object
  76260. */
  76261. multiply(color: Color4): Color4;
  76262. /**
  76263. * Multipy a Color4 value by another and push the result in a reference value
  76264. * @param color defines the Color4 value to multiply by
  76265. * @param result defines the Color4 to fill the result in
  76266. * @returns the result Color4
  76267. */
  76268. multiplyToRef(color: Color4, result: Color4): Color4;
  76269. /**
  76270. * Creates a string with the Color4 current values
  76271. * @returns the string representation of the Color4 object
  76272. */
  76273. toString(): string;
  76274. /**
  76275. * Returns the string "Color4"
  76276. * @returns "Color4"
  76277. */
  76278. getClassName(): string;
  76279. /**
  76280. * Compute the Color4 hash code
  76281. * @returns an unique number that can be used to hash Color4 objects
  76282. */
  76283. getHashCode(): number;
  76284. /**
  76285. * Creates a new Color4 copied from the current one
  76286. * @returns a new Color4 object
  76287. */
  76288. clone(): Color4;
  76289. /**
  76290. * Copies the given Color4 values into the current one
  76291. * @param source defines the source Color4 object
  76292. * @returns the current updated Color4 object
  76293. */
  76294. copyFrom(source: Color4): Color4;
  76295. /**
  76296. * Copies the given float values into the current one
  76297. * @param r defines the red component to read from
  76298. * @param g defines the green component to read from
  76299. * @param b defines the blue component to read from
  76300. * @param a defines the alpha component to read from
  76301. * @returns the current updated Color4 object
  76302. */
  76303. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  76304. /**
  76305. * Copies the given float values into the current one
  76306. * @param r defines the red component to read from
  76307. * @param g defines the green component to read from
  76308. * @param b defines the blue component to read from
  76309. * @param a defines the alpha component to read from
  76310. * @returns the current updated Color4 object
  76311. */
  76312. set(r: number, g: number, b: number, a: number): Color4;
  76313. /**
  76314. * Compute the Color4 hexadecimal code as a string
  76315. * @returns a string containing the hexadecimal representation of the Color4 object
  76316. */
  76317. toHexString(): string;
  76318. /**
  76319. * Computes a new Color4 converted from the current one to linear space
  76320. * @returns a new Color4 object
  76321. */
  76322. toLinearSpace(): Color4;
  76323. /**
  76324. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  76325. * @param convertedColor defines the Color4 object where to store the linear space version
  76326. * @returns the unmodified Color4
  76327. */
  76328. toLinearSpaceToRef(convertedColor: Color4): Color4;
  76329. /**
  76330. * Computes a new Color4 converted from the current one to gamma space
  76331. * @returns a new Color4 object
  76332. */
  76333. toGammaSpace(): Color4;
  76334. /**
  76335. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  76336. * @param convertedColor defines the Color4 object where to store the gamma space version
  76337. * @returns the unmodified Color4
  76338. */
  76339. toGammaSpaceToRef(convertedColor: Color4): Color4;
  76340. /**
  76341. * Creates a new Color4 from the string containing valid hexadecimal values
  76342. * @param hex defines a string containing valid hexadecimal values
  76343. * @returns a new Color4 object
  76344. */
  76345. static FromHexString(hex: string): Color4;
  76346. /**
  76347. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76348. * @param left defines the start value
  76349. * @param right defines the end value
  76350. * @param amount defines the gradient factor
  76351. * @returns a new Color4 object
  76352. */
  76353. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  76354. /**
  76355. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76356. * @param left defines the start value
  76357. * @param right defines the end value
  76358. * @param amount defines the gradient factor
  76359. * @param result defines the Color4 object where to store data
  76360. */
  76361. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  76362. /**
  76363. * Creates a new Color4 from a Color3 and an alpha value
  76364. * @param color3 defines the source Color3 to read from
  76365. * @param alpha defines the alpha component (1.0 by default)
  76366. * @returns a new Color4 object
  76367. */
  76368. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  76369. /**
  76370. * Creates a new Color4 from the starting index element of the given array
  76371. * @param array defines the source array to read from
  76372. * @param offset defines the offset in the source array
  76373. * @returns a new Color4 object
  76374. */
  76375. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  76376. /**
  76377. * Creates a new Color3 from integer values (< 256)
  76378. * @param r defines the red component to read from (value between 0 and 255)
  76379. * @param g defines the green component to read from (value between 0 and 255)
  76380. * @param b defines the blue component to read from (value between 0 and 255)
  76381. * @param a defines the alpha component to read from (value between 0 and 255)
  76382. * @returns a new Color3 object
  76383. */
  76384. static FromInts(r: number, g: number, b: number, a: number): Color4;
  76385. /**
  76386. * Check the content of a given array and convert it to an array containing RGBA data
  76387. * If the original array was already containing count * 4 values then it is returned directly
  76388. * @param colors defines the array to check
  76389. * @param count defines the number of RGBA data to expect
  76390. * @returns an array containing count * 4 values (RGBA)
  76391. */
  76392. static CheckColors4(colors: number[], count: number): number[];
  76393. }
  76394. /**
  76395. * @hidden
  76396. */
  76397. export class TmpColors {
  76398. static Color3: Color3[];
  76399. static Color4: Color4[];
  76400. }
  76401. }
  76402. declare module BABYLON {
  76403. /**
  76404. * Defines an interface which represents an animation key frame
  76405. */
  76406. export interface IAnimationKey {
  76407. /**
  76408. * Frame of the key frame
  76409. */
  76410. frame: number;
  76411. /**
  76412. * Value at the specifies key frame
  76413. */
  76414. value: any;
  76415. /**
  76416. * The input tangent for the cubic hermite spline
  76417. */
  76418. inTangent?: any;
  76419. /**
  76420. * The output tangent for the cubic hermite spline
  76421. */
  76422. outTangent?: any;
  76423. /**
  76424. * The animation interpolation type
  76425. */
  76426. interpolation?: AnimationKeyInterpolation;
  76427. }
  76428. /**
  76429. * Enum for the animation key frame interpolation type
  76430. */
  76431. export enum AnimationKeyInterpolation {
  76432. /**
  76433. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  76434. */
  76435. STEP = 1
  76436. }
  76437. }
  76438. declare module BABYLON {
  76439. /**
  76440. * Represents the range of an animation
  76441. */
  76442. export class AnimationRange {
  76443. /**The name of the animation range**/
  76444. name: string;
  76445. /**The starting frame of the animation */
  76446. from: number;
  76447. /**The ending frame of the animation*/
  76448. to: number;
  76449. /**
  76450. * Initializes the range of an animation
  76451. * @param name The name of the animation range
  76452. * @param from The starting frame of the animation
  76453. * @param to The ending frame of the animation
  76454. */
  76455. constructor(
  76456. /**The name of the animation range**/
  76457. name: string,
  76458. /**The starting frame of the animation */
  76459. from: number,
  76460. /**The ending frame of the animation*/
  76461. to: number);
  76462. /**
  76463. * Makes a copy of the animation range
  76464. * @returns A copy of the animation range
  76465. */
  76466. clone(): AnimationRange;
  76467. }
  76468. }
  76469. declare module BABYLON {
  76470. /**
  76471. * Composed of a frame, and an action function
  76472. */
  76473. export class AnimationEvent {
  76474. /** The frame for which the event is triggered **/
  76475. frame: number;
  76476. /** The event to perform when triggered **/
  76477. action: (currentFrame: number) => void;
  76478. /** Specifies if the event should be triggered only once**/
  76479. onlyOnce?: boolean | undefined;
  76480. /**
  76481. * Specifies if the animation event is done
  76482. */
  76483. isDone: boolean;
  76484. /**
  76485. * Initializes the animation event
  76486. * @param frame The frame for which the event is triggered
  76487. * @param action The event to perform when triggered
  76488. * @param onlyOnce Specifies if the event should be triggered only once
  76489. */
  76490. constructor(
  76491. /** The frame for which the event is triggered **/
  76492. frame: number,
  76493. /** The event to perform when triggered **/
  76494. action: (currentFrame: number) => void,
  76495. /** Specifies if the event should be triggered only once**/
  76496. onlyOnce?: boolean | undefined);
  76497. /** @hidden */
  76498. _clone(): AnimationEvent;
  76499. }
  76500. }
  76501. declare module BABYLON {
  76502. /**
  76503. * Interface used to define a behavior
  76504. */
  76505. export interface Behavior<T> {
  76506. /** gets or sets behavior's name */
  76507. name: string;
  76508. /**
  76509. * Function called when the behavior needs to be initialized (after attaching it to a target)
  76510. */
  76511. init(): void;
  76512. /**
  76513. * Called when the behavior is attached to a target
  76514. * @param target defines the target where the behavior is attached to
  76515. */
  76516. attach(target: T): void;
  76517. /**
  76518. * Called when the behavior is detached from its target
  76519. */
  76520. detach(): void;
  76521. }
  76522. /**
  76523. * Interface implemented by classes supporting behaviors
  76524. */
  76525. export interface IBehaviorAware<T> {
  76526. /**
  76527. * Attach a behavior
  76528. * @param behavior defines the behavior to attach
  76529. * @returns the current host
  76530. */
  76531. addBehavior(behavior: Behavior<T>): T;
  76532. /**
  76533. * Remove a behavior from the current object
  76534. * @param behavior defines the behavior to detach
  76535. * @returns the current host
  76536. */
  76537. removeBehavior(behavior: Behavior<T>): T;
  76538. /**
  76539. * Gets a behavior using its name to search
  76540. * @param name defines the name to search
  76541. * @returns the behavior or null if not found
  76542. */
  76543. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  76544. }
  76545. }
  76546. declare module BABYLON {
  76547. /**
  76548. * Defines an array and its length.
  76549. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  76550. */
  76551. export interface ISmartArrayLike<T> {
  76552. /**
  76553. * The data of the array.
  76554. */
  76555. data: Array<T>;
  76556. /**
  76557. * The active length of the array.
  76558. */
  76559. length: number;
  76560. }
  76561. /**
  76562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76563. */
  76564. export class SmartArray<T> implements ISmartArrayLike<T> {
  76565. /**
  76566. * The full set of data from the array.
  76567. */
  76568. data: Array<T>;
  76569. /**
  76570. * The active length of the array.
  76571. */
  76572. length: number;
  76573. protected _id: number;
  76574. /**
  76575. * Instantiates a Smart Array.
  76576. * @param capacity defines the default capacity of the array.
  76577. */
  76578. constructor(capacity: number);
  76579. /**
  76580. * Pushes a value at the end of the active data.
  76581. * @param value defines the object to push in the array.
  76582. */
  76583. push(value: T): void;
  76584. /**
  76585. * Iterates over the active data and apply the lambda to them.
  76586. * @param func defines the action to apply on each value.
  76587. */
  76588. forEach(func: (content: T) => void): void;
  76589. /**
  76590. * Sorts the full sets of data.
  76591. * @param compareFn defines the comparison function to apply.
  76592. */
  76593. sort(compareFn: (a: T, b: T) => number): void;
  76594. /**
  76595. * Resets the active data to an empty array.
  76596. */
  76597. reset(): void;
  76598. /**
  76599. * Releases all the data from the array as well as the array.
  76600. */
  76601. dispose(): void;
  76602. /**
  76603. * Concats the active data with a given array.
  76604. * @param array defines the data to concatenate with.
  76605. */
  76606. concat(array: any): void;
  76607. /**
  76608. * Returns the position of a value in the active data.
  76609. * @param value defines the value to find the index for
  76610. * @returns the index if found in the active data otherwise -1
  76611. */
  76612. indexOf(value: T): number;
  76613. /**
  76614. * Returns whether an element is part of the active data.
  76615. * @param value defines the value to look for
  76616. * @returns true if found in the active data otherwise false
  76617. */
  76618. contains(value: T): boolean;
  76619. private static _GlobalId;
  76620. }
  76621. /**
  76622. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76623. * The data in this array can only be present once
  76624. */
  76625. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  76626. private _duplicateId;
  76627. /**
  76628. * Pushes a value at the end of the active data.
  76629. * THIS DOES NOT PREVENT DUPPLICATE DATA
  76630. * @param value defines the object to push in the array.
  76631. */
  76632. push(value: T): void;
  76633. /**
  76634. * Pushes a value at the end of the active data.
  76635. * If the data is already present, it won t be added again
  76636. * @param value defines the object to push in the array.
  76637. * @returns true if added false if it was already present
  76638. */
  76639. pushNoDuplicate(value: T): boolean;
  76640. /**
  76641. * Resets the active data to an empty array.
  76642. */
  76643. reset(): void;
  76644. /**
  76645. * Concats the active data with a given array.
  76646. * This ensures no dupplicate will be present in the result.
  76647. * @param array defines the data to concatenate with.
  76648. */
  76649. concatWithNoDuplicate(array: any): void;
  76650. }
  76651. }
  76652. declare module BABYLON {
  76653. /**
  76654. * @ignore
  76655. * This is a list of all the different input types that are available in the application.
  76656. * Fo instance: ArcRotateCameraGamepadInput...
  76657. */
  76658. export var CameraInputTypes: {};
  76659. /**
  76660. * This is the contract to implement in order to create a new input class.
  76661. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  76662. */
  76663. export interface ICameraInput<TCamera extends Camera> {
  76664. /**
  76665. * Defines the camera the input is attached to.
  76666. */
  76667. camera: Nullable<TCamera>;
  76668. /**
  76669. * Gets the class name of the current intput.
  76670. * @returns the class name
  76671. */
  76672. getClassName(): string;
  76673. /**
  76674. * Get the friendly name associated with the input class.
  76675. * @returns the input friendly name
  76676. */
  76677. getSimpleName(): string;
  76678. /**
  76679. * Attach the input controls to a specific dom element to get the input from.
  76680. * @param element Defines the element the controls should be listened from
  76681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76682. */
  76683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76684. /**
  76685. * Detach the current controls from the specified dom element.
  76686. * @param element Defines the element to stop listening the inputs from
  76687. */
  76688. detachControl(element: Nullable<HTMLElement>): void;
  76689. /**
  76690. * Update the current camera state depending on the inputs that have been used this frame.
  76691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76692. */
  76693. checkInputs?: () => void;
  76694. }
  76695. /**
  76696. * Represents a map of input types to input instance or input index to input instance.
  76697. */
  76698. export interface CameraInputsMap<TCamera extends Camera> {
  76699. /**
  76700. * Accessor to the input by input type.
  76701. */
  76702. [name: string]: ICameraInput<TCamera>;
  76703. /**
  76704. * Accessor to the input by input index.
  76705. */
  76706. [idx: number]: ICameraInput<TCamera>;
  76707. }
  76708. /**
  76709. * This represents the input manager used within a camera.
  76710. * It helps dealing with all the different kind of input attached to a camera.
  76711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76712. */
  76713. export class CameraInputsManager<TCamera extends Camera> {
  76714. /**
  76715. * Defines the list of inputs attahed to the camera.
  76716. */
  76717. attached: CameraInputsMap<TCamera>;
  76718. /**
  76719. * Defines the dom element the camera is collecting inputs from.
  76720. * This is null if the controls have not been attached.
  76721. */
  76722. attachedElement: Nullable<HTMLElement>;
  76723. /**
  76724. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76725. */
  76726. noPreventDefault: boolean;
  76727. /**
  76728. * Defined the camera the input manager belongs to.
  76729. */
  76730. camera: TCamera;
  76731. /**
  76732. * Update the current camera state depending on the inputs that have been used this frame.
  76733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76734. */
  76735. checkInputs: () => void;
  76736. /**
  76737. * Instantiate a new Camera Input Manager.
  76738. * @param camera Defines the camera the input manager blongs to
  76739. */
  76740. constructor(camera: TCamera);
  76741. /**
  76742. * Add an input method to a camera
  76743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76744. * @param input camera input method
  76745. */
  76746. add(input: ICameraInput<TCamera>): void;
  76747. /**
  76748. * Remove a specific input method from a camera
  76749. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  76750. * @param inputToRemove camera input method
  76751. */
  76752. remove(inputToRemove: ICameraInput<TCamera>): void;
  76753. /**
  76754. * Remove a specific input type from a camera
  76755. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  76756. * @param inputType the type of the input to remove
  76757. */
  76758. removeByType(inputType: string): void;
  76759. private _addCheckInputs;
  76760. /**
  76761. * Attach the input controls to the currently attached dom element to listen the events from.
  76762. * @param input Defines the input to attach
  76763. */
  76764. attachInput(input: ICameraInput<TCamera>): void;
  76765. /**
  76766. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  76767. * @param element Defines the dom element to collect the events from
  76768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76769. */
  76770. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  76771. /**
  76772. * Detach the current manager inputs controls from a specific dom element.
  76773. * @param element Defines the dom element to collect the events from
  76774. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  76775. */
  76776. detachElement(element: HTMLElement, disconnect?: boolean): void;
  76777. /**
  76778. * Rebuild the dynamic inputCheck function from the current list of
  76779. * defined inputs in the manager.
  76780. */
  76781. rebuildInputCheck(): void;
  76782. /**
  76783. * Remove all attached input methods from a camera
  76784. */
  76785. clear(): void;
  76786. /**
  76787. * Serialize the current input manager attached to a camera.
  76788. * This ensures than once parsed,
  76789. * the input associated to the camera will be identical to the current ones
  76790. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  76791. */
  76792. serialize(serializedCamera: any): void;
  76793. /**
  76794. * Parses an input manager serialized JSON to restore the previous list of inputs
  76795. * and states associated to a camera.
  76796. * @param parsedCamera Defines the JSON to parse
  76797. */
  76798. parse(parsedCamera: any): void;
  76799. }
  76800. }
  76801. declare module BABYLON {
  76802. /**
  76803. * Class used to store data that will be store in GPU memory
  76804. */
  76805. export class Buffer {
  76806. private _engine;
  76807. private _buffer;
  76808. /** @hidden */
  76809. _data: Nullable<DataArray>;
  76810. private _updatable;
  76811. private _instanced;
  76812. private _divisor;
  76813. /**
  76814. * Gets the byte stride.
  76815. */
  76816. readonly byteStride: number;
  76817. /**
  76818. * Constructor
  76819. * @param engine the engine
  76820. * @param data the data to use for this buffer
  76821. * @param updatable whether the data is updatable
  76822. * @param stride the stride (optional)
  76823. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76824. * @param instanced whether the buffer is instanced (optional)
  76825. * @param useBytes set to true if the stride in in bytes (optional)
  76826. * @param divisor sets an optional divisor for instances (1 by default)
  76827. */
  76828. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  76829. /**
  76830. * Create a new VertexBuffer based on the current buffer
  76831. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76832. * @param offset defines offset in the buffer (0 by default)
  76833. * @param size defines the size in floats of attributes (position is 3 for instance)
  76834. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76835. * @param instanced defines if the vertex buffer contains indexed data
  76836. * @param useBytes defines if the offset and stride are in bytes *
  76837. * @param divisor sets an optional divisor for instances (1 by default)
  76838. * @returns the new vertex buffer
  76839. */
  76840. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  76841. /**
  76842. * Gets a boolean indicating if the Buffer is updatable?
  76843. * @returns true if the buffer is updatable
  76844. */
  76845. isUpdatable(): boolean;
  76846. /**
  76847. * Gets current buffer's data
  76848. * @returns a DataArray or null
  76849. */
  76850. getData(): Nullable<DataArray>;
  76851. /**
  76852. * Gets underlying native buffer
  76853. * @returns underlying native buffer
  76854. */
  76855. getBuffer(): Nullable<DataBuffer>;
  76856. /**
  76857. * Gets the stride in float32 units (i.e. byte stride / 4).
  76858. * May not be an integer if the byte stride is not divisible by 4.
  76859. * @returns the stride in float32 units
  76860. * @deprecated Please use byteStride instead.
  76861. */
  76862. getStrideSize(): number;
  76863. /**
  76864. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76865. * @param data defines the data to store
  76866. */
  76867. create(data?: Nullable<DataArray>): void;
  76868. /** @hidden */
  76869. _rebuild(): void;
  76870. /**
  76871. * Update current buffer data
  76872. * @param data defines the data to store
  76873. */
  76874. update(data: DataArray): void;
  76875. /**
  76876. * Updates the data directly.
  76877. * @param data the new data
  76878. * @param offset the new offset
  76879. * @param vertexCount the vertex count (optional)
  76880. * @param useBytes set to true if the offset is in bytes
  76881. */
  76882. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  76883. /**
  76884. * Release all resources
  76885. */
  76886. dispose(): void;
  76887. }
  76888. /**
  76889. * Specialized buffer used to store vertex data
  76890. */
  76891. export class VertexBuffer {
  76892. /** @hidden */
  76893. _buffer: Buffer;
  76894. private _kind;
  76895. private _size;
  76896. private _ownsBuffer;
  76897. private _instanced;
  76898. private _instanceDivisor;
  76899. /**
  76900. * The byte type.
  76901. */
  76902. static readonly BYTE: number;
  76903. /**
  76904. * The unsigned byte type.
  76905. */
  76906. static readonly UNSIGNED_BYTE: number;
  76907. /**
  76908. * The short type.
  76909. */
  76910. static readonly SHORT: number;
  76911. /**
  76912. * The unsigned short type.
  76913. */
  76914. static readonly UNSIGNED_SHORT: number;
  76915. /**
  76916. * The integer type.
  76917. */
  76918. static readonly INT: number;
  76919. /**
  76920. * The unsigned integer type.
  76921. */
  76922. static readonly UNSIGNED_INT: number;
  76923. /**
  76924. * The float type.
  76925. */
  76926. static readonly FLOAT: number;
  76927. /**
  76928. * Gets or sets the instance divisor when in instanced mode
  76929. */
  76930. get instanceDivisor(): number;
  76931. set instanceDivisor(value: number);
  76932. /**
  76933. * Gets the byte stride.
  76934. */
  76935. readonly byteStride: number;
  76936. /**
  76937. * Gets the byte offset.
  76938. */
  76939. readonly byteOffset: number;
  76940. /**
  76941. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  76942. */
  76943. readonly normalized: boolean;
  76944. /**
  76945. * Gets the data type of each component in the array.
  76946. */
  76947. readonly type: number;
  76948. /**
  76949. * Constructor
  76950. * @param engine the engine
  76951. * @param data the data to use for this vertex buffer
  76952. * @param kind the vertex buffer kind
  76953. * @param updatable whether the data is updatable
  76954. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76955. * @param stride the stride (optional)
  76956. * @param instanced whether the buffer is instanced (optional)
  76957. * @param offset the offset of the data (optional)
  76958. * @param size the number of components (optional)
  76959. * @param type the type of the component (optional)
  76960. * @param normalized whether the data contains normalized data (optional)
  76961. * @param useBytes set to true if stride and offset are in bytes (optional)
  76962. * @param divisor defines the instance divisor to use (1 by default)
  76963. */
  76964. 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, divisor?: number);
  76965. /** @hidden */
  76966. _rebuild(): void;
  76967. /**
  76968. * Returns the kind of the VertexBuffer (string)
  76969. * @returns a string
  76970. */
  76971. getKind(): string;
  76972. /**
  76973. * Gets a boolean indicating if the VertexBuffer is updatable?
  76974. * @returns true if the buffer is updatable
  76975. */
  76976. isUpdatable(): boolean;
  76977. /**
  76978. * Gets current buffer's data
  76979. * @returns a DataArray or null
  76980. */
  76981. getData(): Nullable<DataArray>;
  76982. /**
  76983. * Gets underlying native buffer
  76984. * @returns underlying native buffer
  76985. */
  76986. getBuffer(): Nullable<DataBuffer>;
  76987. /**
  76988. * Gets the stride in float32 units (i.e. byte stride / 4).
  76989. * May not be an integer if the byte stride is not divisible by 4.
  76990. * @returns the stride in float32 units
  76991. * @deprecated Please use byteStride instead.
  76992. */
  76993. getStrideSize(): number;
  76994. /**
  76995. * Returns the offset as a multiple of the type byte length.
  76996. * @returns the offset in bytes
  76997. * @deprecated Please use byteOffset instead.
  76998. */
  76999. getOffset(): number;
  77000. /**
  77001. * Returns the number of components per vertex attribute (integer)
  77002. * @returns the size in float
  77003. */
  77004. getSize(): number;
  77005. /**
  77006. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77007. * @returns true if this buffer is instanced
  77008. */
  77009. getIsInstanced(): boolean;
  77010. /**
  77011. * Returns the instancing divisor, zero for non-instanced (integer).
  77012. * @returns a number
  77013. */
  77014. getInstanceDivisor(): number;
  77015. /**
  77016. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77017. * @param data defines the data to store
  77018. */
  77019. create(data?: DataArray): void;
  77020. /**
  77021. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77022. * This function will create a new buffer if the current one is not updatable
  77023. * @param data defines the data to store
  77024. */
  77025. update(data: DataArray): void;
  77026. /**
  77027. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77028. * Returns the directly updated WebGLBuffer.
  77029. * @param data the new data
  77030. * @param offset the new offset
  77031. * @param useBytes set to true if the offset is in bytes
  77032. */
  77033. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77034. /**
  77035. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77036. */
  77037. dispose(): void;
  77038. /**
  77039. * Enumerates each value of this vertex buffer as numbers.
  77040. * @param count the number of values to enumerate
  77041. * @param callback the callback function called for each value
  77042. */
  77043. forEach(count: number, callback: (value: number, index: number) => void): void;
  77044. /**
  77045. * Positions
  77046. */
  77047. static readonly PositionKind: string;
  77048. /**
  77049. * Normals
  77050. */
  77051. static readonly NormalKind: string;
  77052. /**
  77053. * Tangents
  77054. */
  77055. static readonly TangentKind: string;
  77056. /**
  77057. * Texture coordinates
  77058. */
  77059. static readonly UVKind: string;
  77060. /**
  77061. * Texture coordinates 2
  77062. */
  77063. static readonly UV2Kind: string;
  77064. /**
  77065. * Texture coordinates 3
  77066. */
  77067. static readonly UV3Kind: string;
  77068. /**
  77069. * Texture coordinates 4
  77070. */
  77071. static readonly UV4Kind: string;
  77072. /**
  77073. * Texture coordinates 5
  77074. */
  77075. static readonly UV5Kind: string;
  77076. /**
  77077. * Texture coordinates 6
  77078. */
  77079. static readonly UV6Kind: string;
  77080. /**
  77081. * Colors
  77082. */
  77083. static readonly ColorKind: string;
  77084. /**
  77085. * Matrix indices (for bones)
  77086. */
  77087. static readonly MatricesIndicesKind: string;
  77088. /**
  77089. * Matrix weights (for bones)
  77090. */
  77091. static readonly MatricesWeightsKind: string;
  77092. /**
  77093. * Additional matrix indices (for bones)
  77094. */
  77095. static readonly MatricesIndicesExtraKind: string;
  77096. /**
  77097. * Additional matrix weights (for bones)
  77098. */
  77099. static readonly MatricesWeightsExtraKind: string;
  77100. /**
  77101. * Deduces the stride given a kind.
  77102. * @param kind The kind string to deduce
  77103. * @returns The deduced stride
  77104. */
  77105. static DeduceStride(kind: string): number;
  77106. /**
  77107. * Gets the byte length of the given type.
  77108. * @param type the type
  77109. * @returns the number of bytes
  77110. */
  77111. static GetTypeByteLength(type: number): number;
  77112. /**
  77113. * Enumerates each value of the given parameters as numbers.
  77114. * @param data the data to enumerate
  77115. * @param byteOffset the byte offset of the data
  77116. * @param byteStride the byte stride of the data
  77117. * @param componentCount the number of components per element
  77118. * @param componentType the type of the component
  77119. * @param count the number of values to enumerate
  77120. * @param normalized whether the data is normalized
  77121. * @param callback the callback function called for each value
  77122. */
  77123. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77124. private static _GetFloatValue;
  77125. }
  77126. }
  77127. declare module BABYLON {
  77128. /**
  77129. * @hidden
  77130. */
  77131. export class IntersectionInfo {
  77132. bu: Nullable<number>;
  77133. bv: Nullable<number>;
  77134. distance: number;
  77135. faceId: number;
  77136. subMeshId: number;
  77137. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  77138. }
  77139. }
  77140. declare module BABYLON {
  77141. /**
  77142. * Represens a plane by the equation ax + by + cz + d = 0
  77143. */
  77144. export class Plane {
  77145. private static _TmpMatrix;
  77146. /**
  77147. * Normal of the plane (a,b,c)
  77148. */
  77149. normal: Vector3;
  77150. /**
  77151. * d component of the plane
  77152. */
  77153. d: number;
  77154. /**
  77155. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77156. * @param a a component of the plane
  77157. * @param b b component of the plane
  77158. * @param c c component of the plane
  77159. * @param d d component of the plane
  77160. */
  77161. constructor(a: number, b: number, c: number, d: number);
  77162. /**
  77163. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77164. */
  77165. asArray(): number[];
  77166. /**
  77167. * @returns a new plane copied from the current Plane.
  77168. */
  77169. clone(): Plane;
  77170. /**
  77171. * @returns the string "Plane".
  77172. */
  77173. getClassName(): string;
  77174. /**
  77175. * @returns the Plane hash code.
  77176. */
  77177. getHashCode(): number;
  77178. /**
  77179. * Normalize the current Plane in place.
  77180. * @returns the updated Plane.
  77181. */
  77182. normalize(): Plane;
  77183. /**
  77184. * Applies a transformation the plane and returns the result
  77185. * @param transformation the transformation matrix to be applied to the plane
  77186. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77187. */
  77188. transform(transformation: DeepImmutable<Matrix>): Plane;
  77189. /**
  77190. * Calcualtte the dot product between the point and the plane normal
  77191. * @param point point to calculate the dot product with
  77192. * @returns the dot product (float) of the point coordinates and the plane normal.
  77193. */
  77194. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77195. /**
  77196. * Updates the current Plane from the plane defined by the three given points.
  77197. * @param point1 one of the points used to contruct the plane
  77198. * @param point2 one of the points used to contruct the plane
  77199. * @param point3 one of the points used to contruct the plane
  77200. * @returns the updated Plane.
  77201. */
  77202. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77203. /**
  77204. * Checks if the plane is facing a given direction
  77205. * @param direction the direction to check if the plane is facing
  77206. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77207. * @returns True is the vector "direction" is the same side than the plane normal.
  77208. */
  77209. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77210. /**
  77211. * Calculates the distance to a point
  77212. * @param point point to calculate distance to
  77213. * @returns the signed distance (float) from the given point to the Plane.
  77214. */
  77215. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77216. /**
  77217. * Creates a plane from an array
  77218. * @param array the array to create a plane from
  77219. * @returns a new Plane from the given array.
  77220. */
  77221. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77222. /**
  77223. * Creates a plane from three points
  77224. * @param point1 point used to create the plane
  77225. * @param point2 point used to create the plane
  77226. * @param point3 point used to create the plane
  77227. * @returns a new Plane defined by the three given points.
  77228. */
  77229. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77230. /**
  77231. * Creates a plane from an origin point and a normal
  77232. * @param origin origin of the plane to be constructed
  77233. * @param normal normal of the plane to be constructed
  77234. * @returns a new Plane the normal vector to this plane at the given origin point.
  77235. * Note : the vector "normal" is updated because normalized.
  77236. */
  77237. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77238. /**
  77239. * Calculates the distance from a plane and a point
  77240. * @param origin origin of the plane to be constructed
  77241. * @param normal normal of the plane to be constructed
  77242. * @param point point to calculate distance to
  77243. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77244. */
  77245. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77246. }
  77247. }
  77248. declare module BABYLON {
  77249. /**
  77250. * Class used to store bounding sphere information
  77251. */
  77252. export class BoundingSphere {
  77253. /**
  77254. * Gets the center of the bounding sphere in local space
  77255. */
  77256. readonly center: Vector3;
  77257. /**
  77258. * Radius of the bounding sphere in local space
  77259. */
  77260. radius: number;
  77261. /**
  77262. * Gets the center of the bounding sphere in world space
  77263. */
  77264. readonly centerWorld: Vector3;
  77265. /**
  77266. * Radius of the bounding sphere in world space
  77267. */
  77268. radiusWorld: number;
  77269. /**
  77270. * Gets the minimum vector in local space
  77271. */
  77272. readonly minimum: Vector3;
  77273. /**
  77274. * Gets the maximum vector in local space
  77275. */
  77276. readonly maximum: Vector3;
  77277. private _worldMatrix;
  77278. private static readonly TmpVector3;
  77279. /**
  77280. * Creates a new bounding sphere
  77281. * @param min defines the minimum vector (in local space)
  77282. * @param max defines the maximum vector (in local space)
  77283. * @param worldMatrix defines the new world matrix
  77284. */
  77285. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77286. /**
  77287. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  77288. * @param min defines the new minimum vector (in local space)
  77289. * @param max defines the new maximum vector (in local space)
  77290. * @param worldMatrix defines the new world matrix
  77291. */
  77292. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77293. /**
  77294. * Scale the current bounding sphere by applying a scale factor
  77295. * @param factor defines the scale factor to apply
  77296. * @returns the current bounding box
  77297. */
  77298. scale(factor: number): BoundingSphere;
  77299. /**
  77300. * Gets the world matrix of the bounding box
  77301. * @returns a matrix
  77302. */
  77303. getWorldMatrix(): DeepImmutable<Matrix>;
  77304. /** @hidden */
  77305. _update(worldMatrix: DeepImmutable<Matrix>): void;
  77306. /**
  77307. * Tests if the bounding sphere is intersecting the frustum planes
  77308. * @param frustumPlanes defines the frustum planes to test
  77309. * @returns true if there is an intersection
  77310. */
  77311. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77312. /**
  77313. * Tests if the bounding sphere center is in between the frustum planes.
  77314. * Used for optimistic fast inclusion.
  77315. * @param frustumPlanes defines the frustum planes to test
  77316. * @returns true if the sphere center is in between the frustum planes
  77317. */
  77318. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77319. /**
  77320. * Tests if a point is inside the bounding sphere
  77321. * @param point defines the point to test
  77322. * @returns true if the point is inside the bounding sphere
  77323. */
  77324. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77325. /**
  77326. * Checks if two sphere intersct
  77327. * @param sphere0 sphere 0
  77328. * @param sphere1 sphere 1
  77329. * @returns true if the speres intersect
  77330. */
  77331. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  77332. }
  77333. }
  77334. declare module BABYLON {
  77335. /**
  77336. * Class used to store bounding box information
  77337. */
  77338. export class BoundingBox implements ICullable {
  77339. /**
  77340. * Gets the 8 vectors representing the bounding box in local space
  77341. */
  77342. readonly vectors: Vector3[];
  77343. /**
  77344. * Gets the center of the bounding box in local space
  77345. */
  77346. readonly center: Vector3;
  77347. /**
  77348. * Gets the center of the bounding box in world space
  77349. */
  77350. readonly centerWorld: Vector3;
  77351. /**
  77352. * Gets the extend size in local space
  77353. */
  77354. readonly extendSize: Vector3;
  77355. /**
  77356. * Gets the extend size in world space
  77357. */
  77358. readonly extendSizeWorld: Vector3;
  77359. /**
  77360. * Gets the OBB (object bounding box) directions
  77361. */
  77362. readonly directions: Vector3[];
  77363. /**
  77364. * Gets the 8 vectors representing the bounding box in world space
  77365. */
  77366. readonly vectorsWorld: Vector3[];
  77367. /**
  77368. * Gets the minimum vector in world space
  77369. */
  77370. readonly minimumWorld: Vector3;
  77371. /**
  77372. * Gets the maximum vector in world space
  77373. */
  77374. readonly maximumWorld: Vector3;
  77375. /**
  77376. * Gets the minimum vector in local space
  77377. */
  77378. readonly minimum: Vector3;
  77379. /**
  77380. * Gets the maximum vector in local space
  77381. */
  77382. readonly maximum: Vector3;
  77383. private _worldMatrix;
  77384. private static readonly TmpVector3;
  77385. /**
  77386. * @hidden
  77387. */
  77388. _tag: number;
  77389. /**
  77390. * Creates a new bounding box
  77391. * @param min defines the minimum vector (in local space)
  77392. * @param max defines the maximum vector (in local space)
  77393. * @param worldMatrix defines the new world matrix
  77394. */
  77395. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77396. /**
  77397. * Recreates the entire bounding box from scratch as if we call the constructor in place
  77398. * @param min defines the new minimum vector (in local space)
  77399. * @param max defines the new maximum vector (in local space)
  77400. * @param worldMatrix defines the new world matrix
  77401. */
  77402. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77403. /**
  77404. * Scale the current bounding box by applying a scale factor
  77405. * @param factor defines the scale factor to apply
  77406. * @returns the current bounding box
  77407. */
  77408. scale(factor: number): BoundingBox;
  77409. /**
  77410. * Gets the world matrix of the bounding box
  77411. * @returns a matrix
  77412. */
  77413. getWorldMatrix(): DeepImmutable<Matrix>;
  77414. /** @hidden */
  77415. _update(world: DeepImmutable<Matrix>): void;
  77416. /**
  77417. * Tests if the bounding box is intersecting the frustum planes
  77418. * @param frustumPlanes defines the frustum planes to test
  77419. * @returns true if there is an intersection
  77420. */
  77421. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77422. /**
  77423. * Tests if the bounding box is entirely inside the frustum planes
  77424. * @param frustumPlanes defines the frustum planes to test
  77425. * @returns true if there is an inclusion
  77426. */
  77427. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77428. /**
  77429. * Tests if a point is inside the bounding box
  77430. * @param point defines the point to test
  77431. * @returns true if the point is inside the bounding box
  77432. */
  77433. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77434. /**
  77435. * Tests if the bounding box intersects with a bounding sphere
  77436. * @param sphere defines the sphere to test
  77437. * @returns true if there is an intersection
  77438. */
  77439. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  77440. /**
  77441. * Tests if the bounding box intersects with a box defined by a min and max vectors
  77442. * @param min defines the min vector to use
  77443. * @param max defines the max vector to use
  77444. * @returns true if there is an intersection
  77445. */
  77446. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  77447. /**
  77448. * Tests if two bounding boxes are intersections
  77449. * @param box0 defines the first box to test
  77450. * @param box1 defines the second box to test
  77451. * @returns true if there is an intersection
  77452. */
  77453. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  77454. /**
  77455. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  77456. * @param minPoint defines the minimum vector of the bounding box
  77457. * @param maxPoint defines the maximum vector of the bounding box
  77458. * @param sphereCenter defines the sphere center
  77459. * @param sphereRadius defines the sphere radius
  77460. * @returns true if there is an intersection
  77461. */
  77462. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  77463. /**
  77464. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  77465. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77466. * @param frustumPlanes defines the frustum planes to test
  77467. * @return true if there is an inclusion
  77468. */
  77469. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77470. /**
  77471. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  77472. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77473. * @param frustumPlanes defines the frustum planes to test
  77474. * @return true if there is an intersection
  77475. */
  77476. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77477. }
  77478. }
  77479. declare module BABYLON {
  77480. /** @hidden */
  77481. export class Collider {
  77482. /** Define if a collision was found */
  77483. collisionFound: boolean;
  77484. /**
  77485. * Define last intersection point in local space
  77486. */
  77487. intersectionPoint: Vector3;
  77488. /**
  77489. * Define last collided mesh
  77490. */
  77491. collidedMesh: Nullable<AbstractMesh>;
  77492. private _collisionPoint;
  77493. private _planeIntersectionPoint;
  77494. private _tempVector;
  77495. private _tempVector2;
  77496. private _tempVector3;
  77497. private _tempVector4;
  77498. private _edge;
  77499. private _baseToVertex;
  77500. private _destinationPoint;
  77501. private _slidePlaneNormal;
  77502. private _displacementVector;
  77503. /** @hidden */
  77504. _radius: Vector3;
  77505. /** @hidden */
  77506. _retry: number;
  77507. private _velocity;
  77508. private _basePoint;
  77509. private _epsilon;
  77510. /** @hidden */
  77511. _velocityWorldLength: number;
  77512. /** @hidden */
  77513. _basePointWorld: Vector3;
  77514. private _velocityWorld;
  77515. private _normalizedVelocity;
  77516. /** @hidden */
  77517. _initialVelocity: Vector3;
  77518. /** @hidden */
  77519. _initialPosition: Vector3;
  77520. private _nearestDistance;
  77521. private _collisionMask;
  77522. get collisionMask(): number;
  77523. set collisionMask(mask: number);
  77524. /**
  77525. * Gets the plane normal used to compute the sliding response (in local space)
  77526. */
  77527. get slidePlaneNormal(): Vector3;
  77528. /** @hidden */
  77529. _initialize(source: Vector3, dir: Vector3, e: number): void;
  77530. /** @hidden */
  77531. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  77532. /** @hidden */
  77533. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  77534. /** @hidden */
  77535. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77536. /** @hidden */
  77537. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77538. /** @hidden */
  77539. _getResponse(pos: Vector3, vel: Vector3): void;
  77540. }
  77541. }
  77542. declare module BABYLON {
  77543. /**
  77544. * Interface for cullable objects
  77545. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  77546. */
  77547. export interface ICullable {
  77548. /**
  77549. * Checks if the object or part of the object is in the frustum
  77550. * @param frustumPlanes Camera near/planes
  77551. * @returns true if the object is in frustum otherwise false
  77552. */
  77553. isInFrustum(frustumPlanes: Plane[]): boolean;
  77554. /**
  77555. * Checks if a cullable object (mesh...) is in the camera frustum
  77556. * Unlike isInFrustum this cheks the full bounding box
  77557. * @param frustumPlanes Camera near/planes
  77558. * @returns true if the object is in frustum otherwise false
  77559. */
  77560. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77561. }
  77562. /**
  77563. * Info for a bounding data of a mesh
  77564. */
  77565. export class BoundingInfo implements ICullable {
  77566. /**
  77567. * Bounding box for the mesh
  77568. */
  77569. readonly boundingBox: BoundingBox;
  77570. /**
  77571. * Bounding sphere for the mesh
  77572. */
  77573. readonly boundingSphere: BoundingSphere;
  77574. private _isLocked;
  77575. private static readonly TmpVector3;
  77576. /**
  77577. * Constructs bounding info
  77578. * @param minimum min vector of the bounding box/sphere
  77579. * @param maximum max vector of the bounding box/sphere
  77580. * @param worldMatrix defines the new world matrix
  77581. */
  77582. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77583. /**
  77584. * Recreates the entire bounding info from scratch as if we call the constructor in place
  77585. * @param min defines the new minimum vector (in local space)
  77586. * @param max defines the new maximum vector (in local space)
  77587. * @param worldMatrix defines the new world matrix
  77588. */
  77589. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77590. /**
  77591. * min vector of the bounding box/sphere
  77592. */
  77593. get minimum(): Vector3;
  77594. /**
  77595. * max vector of the bounding box/sphere
  77596. */
  77597. get maximum(): Vector3;
  77598. /**
  77599. * If the info is locked and won't be updated to avoid perf overhead
  77600. */
  77601. get isLocked(): boolean;
  77602. set isLocked(value: boolean);
  77603. /**
  77604. * Updates the bounding sphere and box
  77605. * @param world world matrix to be used to update
  77606. */
  77607. update(world: DeepImmutable<Matrix>): void;
  77608. /**
  77609. * Recreate the bounding info to be centered around a specific point given a specific extend.
  77610. * @param center New center of the bounding info
  77611. * @param extend New extend of the bounding info
  77612. * @returns the current bounding info
  77613. */
  77614. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  77615. /**
  77616. * Scale the current bounding info by applying a scale factor
  77617. * @param factor defines the scale factor to apply
  77618. * @returns the current bounding info
  77619. */
  77620. scale(factor: number): BoundingInfo;
  77621. /**
  77622. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  77623. * @param frustumPlanes defines the frustum to test
  77624. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  77625. * @returns true if the bounding info is in the frustum planes
  77626. */
  77627. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  77628. /**
  77629. * Gets the world distance between the min and max points of the bounding box
  77630. */
  77631. get diagonalLength(): number;
  77632. /**
  77633. * Checks if a cullable object (mesh...) is in the camera frustum
  77634. * Unlike isInFrustum this cheks the full bounding box
  77635. * @param frustumPlanes Camera near/planes
  77636. * @returns true if the object is in frustum otherwise false
  77637. */
  77638. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77639. /** @hidden */
  77640. _checkCollision(collider: Collider): boolean;
  77641. /**
  77642. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  77643. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77644. * @param point the point to check intersection with
  77645. * @returns if the point intersects
  77646. */
  77647. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77648. /**
  77649. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  77650. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77651. * @param boundingInfo the bounding info to check intersection with
  77652. * @param precise if the intersection should be done using OBB
  77653. * @returns if the bounding info intersects
  77654. */
  77655. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  77656. }
  77657. }
  77658. declare module BABYLON {
  77659. /**
  77660. * Extracts minimum and maximum values from a list of indexed positions
  77661. * @param positions defines the positions to use
  77662. * @param indices defines the indices to the positions
  77663. * @param indexStart defines the start index
  77664. * @param indexCount defines the end index
  77665. * @param bias defines bias value to add to the result
  77666. * @return minimum and maximum values
  77667. */
  77668. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  77669. minimum: Vector3;
  77670. maximum: Vector3;
  77671. };
  77672. /**
  77673. * Extracts minimum and maximum values from a list of positions
  77674. * @param positions defines the positions to use
  77675. * @param start defines the start index in the positions array
  77676. * @param count defines the number of positions to handle
  77677. * @param bias defines bias value to add to the result
  77678. * @param stride defines the stride size to use (distance between two positions in the positions array)
  77679. * @return minimum and maximum values
  77680. */
  77681. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  77682. minimum: Vector3;
  77683. maximum: Vector3;
  77684. };
  77685. }
  77686. declare module BABYLON {
  77687. /** @hidden */
  77688. export class WebGLDataBuffer extends DataBuffer {
  77689. private _buffer;
  77690. constructor(resource: WebGLBuffer);
  77691. get underlyingResource(): any;
  77692. }
  77693. }
  77694. declare module BABYLON {
  77695. /** @hidden */
  77696. export class WebGLPipelineContext implements IPipelineContext {
  77697. engine: ThinEngine;
  77698. program: Nullable<WebGLProgram>;
  77699. context?: WebGLRenderingContext;
  77700. vertexShader?: WebGLShader;
  77701. fragmentShader?: WebGLShader;
  77702. isParallelCompiled: boolean;
  77703. onCompiled?: () => void;
  77704. transformFeedback?: WebGLTransformFeedback | null;
  77705. vertexCompilationError: Nullable<string>;
  77706. fragmentCompilationError: Nullable<string>;
  77707. programLinkError: Nullable<string>;
  77708. programValidationError: Nullable<string>;
  77709. get isAsync(): boolean;
  77710. get isReady(): boolean;
  77711. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  77712. }
  77713. }
  77714. declare module BABYLON {
  77715. interface ThinEngine {
  77716. /**
  77717. * Create an uniform buffer
  77718. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77719. * @param elements defines the content of the uniform buffer
  77720. * @returns the webGL uniform buffer
  77721. */
  77722. createUniformBuffer(elements: FloatArray): DataBuffer;
  77723. /**
  77724. * Create a dynamic uniform buffer
  77725. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77726. * @param elements defines the content of the uniform buffer
  77727. * @returns the webGL uniform buffer
  77728. */
  77729. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  77730. /**
  77731. * Update an existing uniform buffer
  77732. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77733. * @param uniformBuffer defines the target uniform buffer
  77734. * @param elements defines the content to update
  77735. * @param offset defines the offset in the uniform buffer where update should start
  77736. * @param count defines the size of the data to update
  77737. */
  77738. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  77739. /**
  77740. * Bind an uniform buffer to the current webGL context
  77741. * @param buffer defines the buffer to bind
  77742. */
  77743. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  77744. /**
  77745. * Bind a buffer to the current webGL context at a given location
  77746. * @param buffer defines the buffer to bind
  77747. * @param location defines the index where to bind the buffer
  77748. */
  77749. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  77750. /**
  77751. * Bind a specific block at a given index in a specific shader program
  77752. * @param pipelineContext defines the pipeline context to use
  77753. * @param blockName defines the block name
  77754. * @param index defines the index where to bind the block
  77755. */
  77756. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  77757. }
  77758. }
  77759. declare module BABYLON {
  77760. /**
  77761. * Uniform buffer objects.
  77762. *
  77763. * Handles blocks of uniform on the GPU.
  77764. *
  77765. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77766. *
  77767. * For more information, please refer to :
  77768. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77769. */
  77770. export class UniformBuffer {
  77771. private _engine;
  77772. private _buffer;
  77773. private _data;
  77774. private _bufferData;
  77775. private _dynamic?;
  77776. private _uniformLocations;
  77777. private _uniformSizes;
  77778. private _uniformLocationPointer;
  77779. private _needSync;
  77780. private _noUBO;
  77781. private _currentEffect;
  77782. /** @hidden */
  77783. _alreadyBound: boolean;
  77784. private static _MAX_UNIFORM_SIZE;
  77785. private static _tempBuffer;
  77786. /**
  77787. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  77788. * This is dynamic to allow compat with webgl 1 and 2.
  77789. * You will need to pass the name of the uniform as well as the value.
  77790. */
  77791. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  77792. /**
  77793. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  77794. * This is dynamic to allow compat with webgl 1 and 2.
  77795. * You will need to pass the name of the uniform as well as the value.
  77796. */
  77797. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  77798. /**
  77799. * Lambda to Update a single float in a uniform buffer.
  77800. * This is dynamic to allow compat with webgl 1 and 2.
  77801. * You will need to pass the name of the uniform as well as the value.
  77802. */
  77803. updateFloat: (name: string, x: number) => void;
  77804. /**
  77805. * Lambda to Update a vec2 of float in a uniform buffer.
  77806. * This is dynamic to allow compat with webgl 1 and 2.
  77807. * You will need to pass the name of the uniform as well as the value.
  77808. */
  77809. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  77810. /**
  77811. * Lambda to Update a vec3 of float in a uniform buffer.
  77812. * This is dynamic to allow compat with webgl 1 and 2.
  77813. * You will need to pass the name of the uniform as well as the value.
  77814. */
  77815. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  77816. /**
  77817. * Lambda to Update a vec4 of float in a uniform buffer.
  77818. * This is dynamic to allow compat with webgl 1 and 2.
  77819. * You will need to pass the name of the uniform as well as the value.
  77820. */
  77821. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  77822. /**
  77823. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  77824. * This is dynamic to allow compat with webgl 1 and 2.
  77825. * You will need to pass the name of the uniform as well as the value.
  77826. */
  77827. updateMatrix: (name: string, mat: Matrix) => void;
  77828. /**
  77829. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  77830. * This is dynamic to allow compat with webgl 1 and 2.
  77831. * You will need to pass the name of the uniform as well as the value.
  77832. */
  77833. updateVector3: (name: string, vector: Vector3) => void;
  77834. /**
  77835. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  77836. * This is dynamic to allow compat with webgl 1 and 2.
  77837. * You will need to pass the name of the uniform as well as the value.
  77838. */
  77839. updateVector4: (name: string, vector: Vector4) => void;
  77840. /**
  77841. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  77842. * This is dynamic to allow compat with webgl 1 and 2.
  77843. * You will need to pass the name of the uniform as well as the value.
  77844. */
  77845. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  77846. /**
  77847. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  77848. * This is dynamic to allow compat with webgl 1 and 2.
  77849. * You will need to pass the name of the uniform as well as the value.
  77850. */
  77851. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  77852. /**
  77853. * Instantiates a new Uniform buffer objects.
  77854. *
  77855. * Handles blocks of uniform on the GPU.
  77856. *
  77857. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77858. *
  77859. * For more information, please refer to :
  77860. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77861. * @param engine Define the engine the buffer is associated with
  77862. * @param data Define the data contained in the buffer
  77863. * @param dynamic Define if the buffer is updatable
  77864. */
  77865. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  77866. /**
  77867. * Indicates if the buffer is using the WebGL2 UBO implementation,
  77868. * or just falling back on setUniformXXX calls.
  77869. */
  77870. get useUbo(): boolean;
  77871. /**
  77872. * Indicates if the WebGL underlying uniform buffer is in sync
  77873. * with the javascript cache data.
  77874. */
  77875. get isSync(): boolean;
  77876. /**
  77877. * Indicates if the WebGL underlying uniform buffer is dynamic.
  77878. * Also, a dynamic UniformBuffer will disable cache verification and always
  77879. * update the underlying WebGL uniform buffer to the GPU.
  77880. * @returns if Dynamic, otherwise false
  77881. */
  77882. isDynamic(): boolean;
  77883. /**
  77884. * The data cache on JS side.
  77885. * @returns the underlying data as a float array
  77886. */
  77887. getData(): Float32Array;
  77888. /**
  77889. * The underlying WebGL Uniform buffer.
  77890. * @returns the webgl buffer
  77891. */
  77892. getBuffer(): Nullable<DataBuffer>;
  77893. /**
  77894. * std140 layout specifies how to align data within an UBO structure.
  77895. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  77896. * for specs.
  77897. */
  77898. private _fillAlignment;
  77899. /**
  77900. * Adds an uniform in the buffer.
  77901. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  77902. * for the layout to be correct !
  77903. * @param name Name of the uniform, as used in the uniform block in the shader.
  77904. * @param size Data size, or data directly.
  77905. */
  77906. addUniform(name: string, size: number | number[]): void;
  77907. /**
  77908. * Adds a Matrix 4x4 to the uniform buffer.
  77909. * @param name Name of the uniform, as used in the uniform block in the shader.
  77910. * @param mat A 4x4 matrix.
  77911. */
  77912. addMatrix(name: string, mat: Matrix): void;
  77913. /**
  77914. * Adds a vec2 to the uniform buffer.
  77915. * @param name Name of the uniform, as used in the uniform block in the shader.
  77916. * @param x Define the x component value of the vec2
  77917. * @param y Define the y component value of the vec2
  77918. */
  77919. addFloat2(name: string, x: number, y: number): void;
  77920. /**
  77921. * Adds a vec3 to the uniform buffer.
  77922. * @param name Name of the uniform, as used in the uniform block in the shader.
  77923. * @param x Define the x component value of the vec3
  77924. * @param y Define the y component value of the vec3
  77925. * @param z Define the z component value of the vec3
  77926. */
  77927. addFloat3(name: string, x: number, y: number, z: number): void;
  77928. /**
  77929. * Adds a vec3 to the uniform buffer.
  77930. * @param name Name of the uniform, as used in the uniform block in the shader.
  77931. * @param color Define the vec3 from a Color
  77932. */
  77933. addColor3(name: string, color: Color3): void;
  77934. /**
  77935. * Adds a vec4 to the uniform buffer.
  77936. * @param name Name of the uniform, as used in the uniform block in the shader.
  77937. * @param color Define the rgb components from a Color
  77938. * @param alpha Define the a component of the vec4
  77939. */
  77940. addColor4(name: string, color: Color3, alpha: number): void;
  77941. /**
  77942. * Adds a vec3 to the uniform buffer.
  77943. * @param name Name of the uniform, as used in the uniform block in the shader.
  77944. * @param vector Define the vec3 components from a Vector
  77945. */
  77946. addVector3(name: string, vector: Vector3): void;
  77947. /**
  77948. * Adds a Matrix 3x3 to the uniform buffer.
  77949. * @param name Name of the uniform, as used in the uniform block in the shader.
  77950. */
  77951. addMatrix3x3(name: string): void;
  77952. /**
  77953. * Adds a Matrix 2x2 to the uniform buffer.
  77954. * @param name Name of the uniform, as used in the uniform block in the shader.
  77955. */
  77956. addMatrix2x2(name: string): void;
  77957. /**
  77958. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  77959. */
  77960. create(): void;
  77961. /** @hidden */
  77962. _rebuild(): void;
  77963. /**
  77964. * Updates the WebGL Uniform Buffer on the GPU.
  77965. * If the `dynamic` flag is set to true, no cache comparison is done.
  77966. * Otherwise, the buffer will be updated only if the cache differs.
  77967. */
  77968. update(): void;
  77969. /**
  77970. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  77971. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  77972. * @param data Define the flattened data
  77973. * @param size Define the size of the data.
  77974. */
  77975. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  77976. private _valueCache;
  77977. private _cacheMatrix;
  77978. private _updateMatrix3x3ForUniform;
  77979. private _updateMatrix3x3ForEffect;
  77980. private _updateMatrix2x2ForEffect;
  77981. private _updateMatrix2x2ForUniform;
  77982. private _updateFloatForEffect;
  77983. private _updateFloatForUniform;
  77984. private _updateFloat2ForEffect;
  77985. private _updateFloat2ForUniform;
  77986. private _updateFloat3ForEffect;
  77987. private _updateFloat3ForUniform;
  77988. private _updateFloat4ForEffect;
  77989. private _updateFloat4ForUniform;
  77990. private _updateMatrixForEffect;
  77991. private _updateMatrixForUniform;
  77992. private _updateVector3ForEffect;
  77993. private _updateVector3ForUniform;
  77994. private _updateVector4ForEffect;
  77995. private _updateVector4ForUniform;
  77996. private _updateColor3ForEffect;
  77997. private _updateColor3ForUniform;
  77998. private _updateColor4ForEffect;
  77999. private _updateColor4ForUniform;
  78000. /**
  78001. * Sets a sampler uniform on the effect.
  78002. * @param name Define the name of the sampler.
  78003. * @param texture Define the texture to set in the sampler
  78004. */
  78005. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78006. /**
  78007. * Directly updates the value of the uniform in the cache AND on the GPU.
  78008. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78009. * @param data Define the flattened data
  78010. */
  78011. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78012. /**
  78013. * Binds this uniform buffer to an effect.
  78014. * @param effect Define the effect to bind the buffer to
  78015. * @param name Name of the uniform block in the shader.
  78016. */
  78017. bindToEffect(effect: Effect, name: string): void;
  78018. /**
  78019. * Disposes the uniform buffer.
  78020. */
  78021. dispose(): void;
  78022. }
  78023. }
  78024. declare module BABYLON {
  78025. /**
  78026. * Enum that determines the text-wrapping mode to use.
  78027. */
  78028. export enum InspectableType {
  78029. /**
  78030. * Checkbox for booleans
  78031. */
  78032. Checkbox = 0,
  78033. /**
  78034. * Sliders for numbers
  78035. */
  78036. Slider = 1,
  78037. /**
  78038. * Vector3
  78039. */
  78040. Vector3 = 2,
  78041. /**
  78042. * Quaternions
  78043. */
  78044. Quaternion = 3,
  78045. /**
  78046. * Color3
  78047. */
  78048. Color3 = 4,
  78049. /**
  78050. * String
  78051. */
  78052. String = 5
  78053. }
  78054. /**
  78055. * Interface used to define custom inspectable properties.
  78056. * This interface is used by the inspector to display custom property grids
  78057. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78058. */
  78059. export interface IInspectable {
  78060. /**
  78061. * Gets the label to display
  78062. */
  78063. label: string;
  78064. /**
  78065. * Gets the name of the property to edit
  78066. */
  78067. propertyName: string;
  78068. /**
  78069. * Gets the type of the editor to use
  78070. */
  78071. type: InspectableType;
  78072. /**
  78073. * Gets the minimum value of the property when using in "slider" mode
  78074. */
  78075. min?: number;
  78076. /**
  78077. * Gets the maximum value of the property when using in "slider" mode
  78078. */
  78079. max?: number;
  78080. /**
  78081. * Gets the setp to use when using in "slider" mode
  78082. */
  78083. step?: number;
  78084. }
  78085. }
  78086. declare module BABYLON {
  78087. /**
  78088. * Class used to provide helper for timing
  78089. */
  78090. export class TimingTools {
  78091. /**
  78092. * Polyfill for setImmediate
  78093. * @param action defines the action to execute after the current execution block
  78094. */
  78095. static SetImmediate(action: () => void): void;
  78096. }
  78097. }
  78098. declare module BABYLON {
  78099. /**
  78100. * Class used to enable instatition of objects by class name
  78101. */
  78102. export class InstantiationTools {
  78103. /**
  78104. * Use this object to register external classes like custom textures or material
  78105. * to allow the laoders to instantiate them
  78106. */
  78107. static RegisteredExternalClasses: {
  78108. [key: string]: Object;
  78109. };
  78110. /**
  78111. * Tries to instantiate a new object from a given class name
  78112. * @param className defines the class name to instantiate
  78113. * @returns the new object or null if the system was not able to do the instantiation
  78114. */
  78115. static Instantiate(className: string): any;
  78116. }
  78117. }
  78118. declare module BABYLON {
  78119. /**
  78120. * Define options used to create a depth texture
  78121. */
  78122. export class DepthTextureCreationOptions {
  78123. /** Specifies whether or not a stencil should be allocated in the texture */
  78124. generateStencil?: boolean;
  78125. /** Specifies whether or not bilinear filtering is enable on the texture */
  78126. bilinearFiltering?: boolean;
  78127. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78128. comparisonFunction?: number;
  78129. /** Specifies if the created texture is a cube texture */
  78130. isCube?: boolean;
  78131. }
  78132. }
  78133. declare module BABYLON {
  78134. interface ThinEngine {
  78135. /**
  78136. * Creates a depth stencil cube texture.
  78137. * This is only available in WebGL 2.
  78138. * @param size The size of face edge in the cube texture.
  78139. * @param options The options defining the cube texture.
  78140. * @returns The cube texture
  78141. */
  78142. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  78143. /**
  78144. * Creates a cube texture
  78145. * @param rootUrl defines the url where the files to load is located
  78146. * @param scene defines the current scene
  78147. * @param files defines the list of files to load (1 per face)
  78148. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78149. * @param onLoad defines an optional callback raised when the texture is loaded
  78150. * @param onError defines an optional callback raised if there is an issue to load the texture
  78151. * @param format defines the format of the data
  78152. * @param forcedExtension defines the extension to use to pick the right loader
  78153. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78154. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78155. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78156. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  78157. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  78158. * @returns the cube texture as an InternalTexture
  78159. */
  78160. 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;
  78161. /**
  78162. * Creates a cube texture
  78163. * @param rootUrl defines the url where the files to load is located
  78164. * @param scene defines the current scene
  78165. * @param files defines the list of files to load (1 per face)
  78166. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78167. * @param onLoad defines an optional callback raised when the texture is loaded
  78168. * @param onError defines an optional callback raised if there is an issue to load the texture
  78169. * @param format defines the format of the data
  78170. * @param forcedExtension defines the extension to use to pick the right loader
  78171. * @returns the cube texture as an InternalTexture
  78172. */
  78173. 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;
  78174. /**
  78175. * Creates a cube texture
  78176. * @param rootUrl defines the url where the files to load is located
  78177. * @param scene defines the current scene
  78178. * @param files defines the list of files to load (1 per face)
  78179. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78180. * @param onLoad defines an optional callback raised when the texture is loaded
  78181. * @param onError defines an optional callback raised if there is an issue to load the texture
  78182. * @param format defines the format of the data
  78183. * @param forcedExtension defines the extension to use to pick the right loader
  78184. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78185. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78186. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78187. * @returns the cube texture as an InternalTexture
  78188. */
  78189. 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;
  78190. /** @hidden */
  78191. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  78192. /** @hidden */
  78193. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  78194. /** @hidden */
  78195. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78196. /** @hidden */
  78197. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78198. /**
  78199. * @hidden
  78200. */
  78201. _setCubeMapTextureParams(loadMipmap: boolean): void;
  78202. }
  78203. }
  78204. declare module BABYLON {
  78205. /**
  78206. * Class for creating a cube texture
  78207. */
  78208. export class CubeTexture extends BaseTexture {
  78209. private _delayedOnLoad;
  78210. /**
  78211. * The url of the texture
  78212. */
  78213. url: string;
  78214. /**
  78215. * Gets or sets the center of the bounding box associated with the cube texture.
  78216. * It must define where the camera used to render the texture was set
  78217. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78218. */
  78219. boundingBoxPosition: Vector3;
  78220. private _boundingBoxSize;
  78221. /**
  78222. * Gets or sets the size of the bounding box associated with the cube texture
  78223. * When defined, the cubemap will switch to local mode
  78224. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  78225. * @example https://www.babylonjs-playground.com/#RNASML
  78226. */
  78227. set boundingBoxSize(value: Vector3);
  78228. /**
  78229. * Returns the bounding box size
  78230. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78231. */
  78232. get boundingBoxSize(): Vector3;
  78233. protected _rotationY: number;
  78234. /**
  78235. * Sets texture matrix rotation angle around Y axis in radians.
  78236. */
  78237. set rotationY(value: number);
  78238. /**
  78239. * Gets texture matrix rotation angle around Y axis radians.
  78240. */
  78241. get rotationY(): number;
  78242. /**
  78243. * Are mip maps generated for this texture or not.
  78244. */
  78245. get noMipmap(): boolean;
  78246. private _noMipmap;
  78247. private _files;
  78248. protected _forcedExtension: Nullable<string>;
  78249. private _extensions;
  78250. private _textureMatrix;
  78251. private _format;
  78252. private _createPolynomials;
  78253. /** @hidden */
  78254. _prefiltered: boolean;
  78255. /**
  78256. * Creates a cube texture from an array of image urls
  78257. * @param files defines an array of image urls
  78258. * @param scene defines the hosting scene
  78259. * @param noMipmap specifies if mip maps are not used
  78260. * @returns a cube texture
  78261. */
  78262. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  78263. /**
  78264. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  78265. * @param url defines the url of the prefiltered texture
  78266. * @param scene defines the scene the texture is attached to
  78267. * @param forcedExtension defines the extension of the file if different from the url
  78268. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78269. * @return the prefiltered texture
  78270. */
  78271. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  78272. /**
  78273. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  78274. * as prefiltered data.
  78275. * @param rootUrl defines the url of the texture or the root name of the six images
  78276. * @param scene defines the scene the texture is attached to
  78277. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  78278. * @param noMipmap defines if mipmaps should be created or not
  78279. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  78280. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  78281. * @param onError defines a callback triggered in case of error during load
  78282. * @param format defines the internal format to use for the texture once loaded
  78283. * @param prefiltered defines whether or not the texture is created from prefiltered data
  78284. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  78285. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78286. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78287. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78288. * @return the cube texture
  78289. */
  78290. 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);
  78291. /**
  78292. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  78293. */
  78294. get isPrefiltered(): boolean;
  78295. /**
  78296. * Get the current class name of the texture useful for serialization or dynamic coding.
  78297. * @returns "CubeTexture"
  78298. */
  78299. getClassName(): string;
  78300. /**
  78301. * Update the url (and optional buffer) of this texture if url was null during construction.
  78302. * @param url the url of the texture
  78303. * @param forcedExtension defines the extension to use
  78304. * @param onLoad callback called when the texture is loaded (defaults to null)
  78305. */
  78306. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  78307. /**
  78308. * Delays loading of the cube texture
  78309. * @param forcedExtension defines the extension to use
  78310. */
  78311. delayLoad(forcedExtension?: string): void;
  78312. /**
  78313. * Returns the reflection texture matrix
  78314. * @returns the reflection texture matrix
  78315. */
  78316. getReflectionTextureMatrix(): Matrix;
  78317. /**
  78318. * Sets the reflection texture matrix
  78319. * @param value Reflection texture matrix
  78320. */
  78321. setReflectionTextureMatrix(value: Matrix): void;
  78322. /**
  78323. * Parses text to create a cube texture
  78324. * @param parsedTexture define the serialized text to read from
  78325. * @param scene defines the hosting scene
  78326. * @param rootUrl defines the root url of the cube texture
  78327. * @returns a cube texture
  78328. */
  78329. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  78330. /**
  78331. * Makes a clone, or deep copy, of the cube texture
  78332. * @returns a new cube texture
  78333. */
  78334. clone(): CubeTexture;
  78335. }
  78336. }
  78337. declare module BABYLON {
  78338. /**
  78339. * Manages the defines for the Material
  78340. */
  78341. export class MaterialDefines {
  78342. /** @hidden */
  78343. protected _keys: string[];
  78344. private _isDirty;
  78345. /** @hidden */
  78346. _renderId: number;
  78347. /** @hidden */
  78348. _areLightsDirty: boolean;
  78349. /** @hidden */
  78350. _areLightsDisposed: boolean;
  78351. /** @hidden */
  78352. _areAttributesDirty: boolean;
  78353. /** @hidden */
  78354. _areTexturesDirty: boolean;
  78355. /** @hidden */
  78356. _areFresnelDirty: boolean;
  78357. /** @hidden */
  78358. _areMiscDirty: boolean;
  78359. /** @hidden */
  78360. _areImageProcessingDirty: boolean;
  78361. /** @hidden */
  78362. _normals: boolean;
  78363. /** @hidden */
  78364. _uvs: boolean;
  78365. /** @hidden */
  78366. _needNormals: boolean;
  78367. /** @hidden */
  78368. _needUVs: boolean;
  78369. [id: string]: any;
  78370. /**
  78371. * Specifies if the material needs to be re-calculated
  78372. */
  78373. get isDirty(): boolean;
  78374. /**
  78375. * Marks the material to indicate that it has been re-calculated
  78376. */
  78377. markAsProcessed(): void;
  78378. /**
  78379. * Marks the material to indicate that it needs to be re-calculated
  78380. */
  78381. markAsUnprocessed(): void;
  78382. /**
  78383. * Marks the material to indicate all of its defines need to be re-calculated
  78384. */
  78385. markAllAsDirty(): void;
  78386. /**
  78387. * Marks the material to indicate that image processing needs to be re-calculated
  78388. */
  78389. markAsImageProcessingDirty(): void;
  78390. /**
  78391. * Marks the material to indicate the lights need to be re-calculated
  78392. * @param disposed Defines whether the light is dirty due to dispose or not
  78393. */
  78394. markAsLightDirty(disposed?: boolean): void;
  78395. /**
  78396. * Marks the attribute state as changed
  78397. */
  78398. markAsAttributesDirty(): void;
  78399. /**
  78400. * Marks the texture state as changed
  78401. */
  78402. markAsTexturesDirty(): void;
  78403. /**
  78404. * Marks the fresnel state as changed
  78405. */
  78406. markAsFresnelDirty(): void;
  78407. /**
  78408. * Marks the misc state as changed
  78409. */
  78410. markAsMiscDirty(): void;
  78411. /**
  78412. * Rebuilds the material defines
  78413. */
  78414. rebuild(): void;
  78415. /**
  78416. * Specifies if two material defines are equal
  78417. * @param other - A material define instance to compare to
  78418. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  78419. */
  78420. isEqual(other: MaterialDefines): boolean;
  78421. /**
  78422. * Clones this instance's defines to another instance
  78423. * @param other - material defines to clone values to
  78424. */
  78425. cloneTo(other: MaterialDefines): void;
  78426. /**
  78427. * Resets the material define values
  78428. */
  78429. reset(): void;
  78430. /**
  78431. * Converts the material define values to a string
  78432. * @returns - String of material define information
  78433. */
  78434. toString(): string;
  78435. }
  78436. }
  78437. declare module BABYLON {
  78438. /**
  78439. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  78440. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  78441. * 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;
  78442. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  78443. */
  78444. export class ColorCurves {
  78445. private _dirty;
  78446. private _tempColor;
  78447. private _globalCurve;
  78448. private _highlightsCurve;
  78449. private _midtonesCurve;
  78450. private _shadowsCurve;
  78451. private _positiveCurve;
  78452. private _negativeCurve;
  78453. private _globalHue;
  78454. private _globalDensity;
  78455. private _globalSaturation;
  78456. private _globalExposure;
  78457. /**
  78458. * Gets the global Hue value.
  78459. * 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).
  78460. */
  78461. get globalHue(): number;
  78462. /**
  78463. * Sets the global Hue value.
  78464. * 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).
  78465. */
  78466. set globalHue(value: number);
  78467. /**
  78468. * Gets the global Density value.
  78469. * 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.
  78470. * Values less than zero provide a filter of opposite hue.
  78471. */
  78472. get globalDensity(): number;
  78473. /**
  78474. * Sets the global Density value.
  78475. * 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.
  78476. * Values less than zero provide a filter of opposite hue.
  78477. */
  78478. set globalDensity(value: number);
  78479. /**
  78480. * Gets the global Saturation value.
  78481. * 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.
  78482. */
  78483. get globalSaturation(): number;
  78484. /**
  78485. * Sets the global Saturation value.
  78486. * 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.
  78487. */
  78488. set globalSaturation(value: number);
  78489. /**
  78490. * Gets the global Exposure value.
  78491. * 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.
  78492. */
  78493. get globalExposure(): number;
  78494. /**
  78495. * Sets the global Exposure value.
  78496. * 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.
  78497. */
  78498. set globalExposure(value: number);
  78499. private _highlightsHue;
  78500. private _highlightsDensity;
  78501. private _highlightsSaturation;
  78502. private _highlightsExposure;
  78503. /**
  78504. * Gets the highlights Hue value.
  78505. * 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).
  78506. */
  78507. get highlightsHue(): number;
  78508. /**
  78509. * Sets the highlights Hue value.
  78510. * 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).
  78511. */
  78512. set highlightsHue(value: number);
  78513. /**
  78514. * Gets the highlights Density value.
  78515. * 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.
  78516. * Values less than zero provide a filter of opposite hue.
  78517. */
  78518. get highlightsDensity(): number;
  78519. /**
  78520. * Sets the highlights Density value.
  78521. * 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.
  78522. * Values less than zero provide a filter of opposite hue.
  78523. */
  78524. set highlightsDensity(value: number);
  78525. /**
  78526. * Gets the highlights Saturation value.
  78527. * 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.
  78528. */
  78529. get highlightsSaturation(): number;
  78530. /**
  78531. * Sets the highlights Saturation value.
  78532. * 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.
  78533. */
  78534. set highlightsSaturation(value: number);
  78535. /**
  78536. * Gets the highlights Exposure value.
  78537. * 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.
  78538. */
  78539. get highlightsExposure(): number;
  78540. /**
  78541. * Sets the highlights Exposure value.
  78542. * 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.
  78543. */
  78544. set highlightsExposure(value: number);
  78545. private _midtonesHue;
  78546. private _midtonesDensity;
  78547. private _midtonesSaturation;
  78548. private _midtonesExposure;
  78549. /**
  78550. * Gets the midtones Hue value.
  78551. * 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).
  78552. */
  78553. get midtonesHue(): number;
  78554. /**
  78555. * Sets the midtones Hue value.
  78556. * 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).
  78557. */
  78558. set midtonesHue(value: number);
  78559. /**
  78560. * Gets the midtones Density value.
  78561. * 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.
  78562. * Values less than zero provide a filter of opposite hue.
  78563. */
  78564. get midtonesDensity(): number;
  78565. /**
  78566. * Sets the midtones Density value.
  78567. * 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.
  78568. * Values less than zero provide a filter of opposite hue.
  78569. */
  78570. set midtonesDensity(value: number);
  78571. /**
  78572. * Gets the midtones Saturation value.
  78573. * 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.
  78574. */
  78575. get midtonesSaturation(): number;
  78576. /**
  78577. * Sets the midtones Saturation value.
  78578. * 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.
  78579. */
  78580. set midtonesSaturation(value: number);
  78581. /**
  78582. * Gets the midtones Exposure value.
  78583. * 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.
  78584. */
  78585. get midtonesExposure(): number;
  78586. /**
  78587. * Sets the midtones Exposure value.
  78588. * 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.
  78589. */
  78590. set midtonesExposure(value: number);
  78591. private _shadowsHue;
  78592. private _shadowsDensity;
  78593. private _shadowsSaturation;
  78594. private _shadowsExposure;
  78595. /**
  78596. * Gets the shadows Hue value.
  78597. * 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).
  78598. */
  78599. get shadowsHue(): number;
  78600. /**
  78601. * Sets the shadows Hue value.
  78602. * 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).
  78603. */
  78604. set shadowsHue(value: number);
  78605. /**
  78606. * Gets the shadows Density value.
  78607. * 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.
  78608. * Values less than zero provide a filter of opposite hue.
  78609. */
  78610. get shadowsDensity(): number;
  78611. /**
  78612. * Sets the shadows Density value.
  78613. * 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.
  78614. * Values less than zero provide a filter of opposite hue.
  78615. */
  78616. set shadowsDensity(value: number);
  78617. /**
  78618. * Gets the shadows Saturation value.
  78619. * 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.
  78620. */
  78621. get shadowsSaturation(): number;
  78622. /**
  78623. * Sets the shadows Saturation value.
  78624. * 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.
  78625. */
  78626. set shadowsSaturation(value: number);
  78627. /**
  78628. * Gets the shadows Exposure value.
  78629. * 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.
  78630. */
  78631. get shadowsExposure(): number;
  78632. /**
  78633. * Sets the shadows Exposure value.
  78634. * 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.
  78635. */
  78636. set shadowsExposure(value: number);
  78637. /**
  78638. * Returns the class name
  78639. * @returns The class name
  78640. */
  78641. getClassName(): string;
  78642. /**
  78643. * Binds the color curves to the shader.
  78644. * @param colorCurves The color curve to bind
  78645. * @param effect The effect to bind to
  78646. * @param positiveUniform The positive uniform shader parameter
  78647. * @param neutralUniform The neutral uniform shader parameter
  78648. * @param negativeUniform The negative uniform shader parameter
  78649. */
  78650. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  78651. /**
  78652. * Prepare the list of uniforms associated with the ColorCurves effects.
  78653. * @param uniformsList The list of uniforms used in the effect
  78654. */
  78655. static PrepareUniforms(uniformsList: string[]): void;
  78656. /**
  78657. * Returns color grading data based on a hue, density, saturation and exposure value.
  78658. * @param filterHue The hue of the color filter.
  78659. * @param filterDensity The density of the color filter.
  78660. * @param saturation The saturation.
  78661. * @param exposure The exposure.
  78662. * @param result The result data container.
  78663. */
  78664. private getColorGradingDataToRef;
  78665. /**
  78666. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  78667. * @param value The input slider value in range [-100,100].
  78668. * @returns Adjusted value.
  78669. */
  78670. private static applyColorGradingSliderNonlinear;
  78671. /**
  78672. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  78673. * @param hue The hue (H) input.
  78674. * @param saturation The saturation (S) input.
  78675. * @param brightness The brightness (B) input.
  78676. * @result An RGBA color represented as Vector4.
  78677. */
  78678. private static fromHSBToRef;
  78679. /**
  78680. * Returns a value clamped between min and max
  78681. * @param value The value to clamp
  78682. * @param min The minimum of value
  78683. * @param max The maximum of value
  78684. * @returns The clamped value.
  78685. */
  78686. private static clamp;
  78687. /**
  78688. * Clones the current color curve instance.
  78689. * @return The cloned curves
  78690. */
  78691. clone(): ColorCurves;
  78692. /**
  78693. * Serializes the current color curve instance to a json representation.
  78694. * @return a JSON representation
  78695. */
  78696. serialize(): any;
  78697. /**
  78698. * Parses the color curve from a json representation.
  78699. * @param source the JSON source to parse
  78700. * @return The parsed curves
  78701. */
  78702. static Parse(source: any): ColorCurves;
  78703. }
  78704. }
  78705. declare module BABYLON {
  78706. /**
  78707. * Interface to follow in your material defines to integrate easily the
  78708. * Image proccessing functions.
  78709. * @hidden
  78710. */
  78711. export interface IImageProcessingConfigurationDefines {
  78712. IMAGEPROCESSING: boolean;
  78713. VIGNETTE: boolean;
  78714. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78715. VIGNETTEBLENDMODEOPAQUE: boolean;
  78716. TONEMAPPING: boolean;
  78717. TONEMAPPING_ACES: boolean;
  78718. CONTRAST: boolean;
  78719. EXPOSURE: boolean;
  78720. COLORCURVES: boolean;
  78721. COLORGRADING: boolean;
  78722. COLORGRADING3D: boolean;
  78723. SAMPLER3DGREENDEPTH: boolean;
  78724. SAMPLER3DBGRMAP: boolean;
  78725. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78726. }
  78727. /**
  78728. * @hidden
  78729. */
  78730. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  78731. IMAGEPROCESSING: boolean;
  78732. VIGNETTE: boolean;
  78733. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78734. VIGNETTEBLENDMODEOPAQUE: boolean;
  78735. TONEMAPPING: boolean;
  78736. TONEMAPPING_ACES: boolean;
  78737. CONTRAST: boolean;
  78738. COLORCURVES: boolean;
  78739. COLORGRADING: boolean;
  78740. COLORGRADING3D: boolean;
  78741. SAMPLER3DGREENDEPTH: boolean;
  78742. SAMPLER3DBGRMAP: boolean;
  78743. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78744. EXPOSURE: boolean;
  78745. constructor();
  78746. }
  78747. /**
  78748. * This groups together the common properties used for image processing either in direct forward pass
  78749. * or through post processing effect depending on the use of the image processing pipeline in your scene
  78750. * or not.
  78751. */
  78752. export class ImageProcessingConfiguration {
  78753. /**
  78754. * Default tone mapping applied in BabylonJS.
  78755. */
  78756. static readonly TONEMAPPING_STANDARD: number;
  78757. /**
  78758. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  78759. * to other engines rendering to increase portability.
  78760. */
  78761. static readonly TONEMAPPING_ACES: number;
  78762. /**
  78763. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  78764. */
  78765. colorCurves: Nullable<ColorCurves>;
  78766. private _colorCurvesEnabled;
  78767. /**
  78768. * Gets wether the color curves effect is enabled.
  78769. */
  78770. get colorCurvesEnabled(): boolean;
  78771. /**
  78772. * Sets wether the color curves effect is enabled.
  78773. */
  78774. set colorCurvesEnabled(value: boolean);
  78775. private _colorGradingTexture;
  78776. /**
  78777. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78778. */
  78779. get colorGradingTexture(): Nullable<BaseTexture>;
  78780. /**
  78781. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78782. */
  78783. set colorGradingTexture(value: Nullable<BaseTexture>);
  78784. private _colorGradingEnabled;
  78785. /**
  78786. * Gets wether the color grading effect is enabled.
  78787. */
  78788. get colorGradingEnabled(): boolean;
  78789. /**
  78790. * Sets wether the color grading effect is enabled.
  78791. */
  78792. set colorGradingEnabled(value: boolean);
  78793. private _colorGradingWithGreenDepth;
  78794. /**
  78795. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  78796. */
  78797. get colorGradingWithGreenDepth(): boolean;
  78798. /**
  78799. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  78800. */
  78801. set colorGradingWithGreenDepth(value: boolean);
  78802. private _colorGradingBGR;
  78803. /**
  78804. * Gets wether the color grading texture contains BGR values.
  78805. */
  78806. get colorGradingBGR(): boolean;
  78807. /**
  78808. * Sets wether the color grading texture contains BGR values.
  78809. */
  78810. set colorGradingBGR(value: boolean);
  78811. /** @hidden */
  78812. _exposure: number;
  78813. /**
  78814. * Gets the Exposure used in the effect.
  78815. */
  78816. get exposure(): number;
  78817. /**
  78818. * Sets the Exposure used in the effect.
  78819. */
  78820. set exposure(value: number);
  78821. private _toneMappingEnabled;
  78822. /**
  78823. * Gets wether the tone mapping effect is enabled.
  78824. */
  78825. get toneMappingEnabled(): boolean;
  78826. /**
  78827. * Sets wether the tone mapping effect is enabled.
  78828. */
  78829. set toneMappingEnabled(value: boolean);
  78830. private _toneMappingType;
  78831. /**
  78832. * Gets the type of tone mapping effect.
  78833. */
  78834. get toneMappingType(): number;
  78835. /**
  78836. * Sets the type of tone mapping effect used in BabylonJS.
  78837. */
  78838. set toneMappingType(value: number);
  78839. protected _contrast: number;
  78840. /**
  78841. * Gets the contrast used in the effect.
  78842. */
  78843. get contrast(): number;
  78844. /**
  78845. * Sets the contrast used in the effect.
  78846. */
  78847. set contrast(value: number);
  78848. /**
  78849. * Vignette stretch size.
  78850. */
  78851. vignetteStretch: number;
  78852. /**
  78853. * Vignette centre X Offset.
  78854. */
  78855. vignetteCentreX: number;
  78856. /**
  78857. * Vignette centre Y Offset.
  78858. */
  78859. vignetteCentreY: number;
  78860. /**
  78861. * Vignette weight or intensity of the vignette effect.
  78862. */
  78863. vignetteWeight: number;
  78864. /**
  78865. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  78866. * if vignetteEnabled is set to true.
  78867. */
  78868. vignetteColor: Color4;
  78869. /**
  78870. * Camera field of view used by the Vignette effect.
  78871. */
  78872. vignetteCameraFov: number;
  78873. private _vignetteBlendMode;
  78874. /**
  78875. * Gets the vignette blend mode allowing different kind of effect.
  78876. */
  78877. get vignetteBlendMode(): number;
  78878. /**
  78879. * Sets the vignette blend mode allowing different kind of effect.
  78880. */
  78881. set vignetteBlendMode(value: number);
  78882. private _vignetteEnabled;
  78883. /**
  78884. * Gets wether the vignette effect is enabled.
  78885. */
  78886. get vignetteEnabled(): boolean;
  78887. /**
  78888. * Sets wether the vignette effect is enabled.
  78889. */
  78890. set vignetteEnabled(value: boolean);
  78891. private _applyByPostProcess;
  78892. /**
  78893. * Gets wether the image processing is applied through a post process or not.
  78894. */
  78895. get applyByPostProcess(): boolean;
  78896. /**
  78897. * Sets wether the image processing is applied through a post process or not.
  78898. */
  78899. set applyByPostProcess(value: boolean);
  78900. private _isEnabled;
  78901. /**
  78902. * Gets wether the image processing is enabled or not.
  78903. */
  78904. get isEnabled(): boolean;
  78905. /**
  78906. * Sets wether the image processing is enabled or not.
  78907. */
  78908. set isEnabled(value: boolean);
  78909. /**
  78910. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  78911. */
  78912. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  78913. /**
  78914. * Method called each time the image processing information changes requires to recompile the effect.
  78915. */
  78916. protected _updateParameters(): void;
  78917. /**
  78918. * Gets the current class name.
  78919. * @return "ImageProcessingConfiguration"
  78920. */
  78921. getClassName(): string;
  78922. /**
  78923. * Prepare the list of uniforms associated with the Image Processing effects.
  78924. * @param uniforms The list of uniforms used in the effect
  78925. * @param defines the list of defines currently in use
  78926. */
  78927. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  78928. /**
  78929. * Prepare the list of samplers associated with the Image Processing effects.
  78930. * @param samplersList The list of uniforms used in the effect
  78931. * @param defines the list of defines currently in use
  78932. */
  78933. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  78934. /**
  78935. * Prepare the list of defines associated to the shader.
  78936. * @param defines the list of defines to complete
  78937. * @param forPostProcess Define if we are currently in post process mode or not
  78938. */
  78939. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  78940. /**
  78941. * Returns true if all the image processing information are ready.
  78942. * @returns True if ready, otherwise, false
  78943. */
  78944. isReady(): boolean;
  78945. /**
  78946. * Binds the image processing to the shader.
  78947. * @param effect The effect to bind to
  78948. * @param overrideAspectRatio Override the aspect ratio of the effect
  78949. */
  78950. bind(effect: Effect, overrideAspectRatio?: number): void;
  78951. /**
  78952. * Clones the current image processing instance.
  78953. * @return The cloned image processing
  78954. */
  78955. clone(): ImageProcessingConfiguration;
  78956. /**
  78957. * Serializes the current image processing instance to a json representation.
  78958. * @return a JSON representation
  78959. */
  78960. serialize(): any;
  78961. /**
  78962. * Parses the image processing from a json representation.
  78963. * @param source the JSON source to parse
  78964. * @return The parsed image processing
  78965. */
  78966. static Parse(source: any): ImageProcessingConfiguration;
  78967. private static _VIGNETTEMODE_MULTIPLY;
  78968. private static _VIGNETTEMODE_OPAQUE;
  78969. /**
  78970. * Used to apply the vignette as a mix with the pixel color.
  78971. */
  78972. static get VIGNETTEMODE_MULTIPLY(): number;
  78973. /**
  78974. * Used to apply the vignette as a replacement of the pixel color.
  78975. */
  78976. static get VIGNETTEMODE_OPAQUE(): number;
  78977. }
  78978. }
  78979. declare module BABYLON {
  78980. /** @hidden */
  78981. export var postprocessVertexShader: {
  78982. name: string;
  78983. shader: string;
  78984. };
  78985. }
  78986. declare module BABYLON {
  78987. interface ThinEngine {
  78988. /**
  78989. * Creates a new render target texture
  78990. * @param size defines the size of the texture
  78991. * @param options defines the options used to create the texture
  78992. * @returns a new render target texture stored in an InternalTexture
  78993. */
  78994. createRenderTargetTexture(size: number | {
  78995. width: number;
  78996. height: number;
  78997. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  78998. /**
  78999. * Creates a depth stencil texture.
  79000. * This is only available in WebGL 2 or with the depth texture extension available.
  79001. * @param size The size of face edge in the texture.
  79002. * @param options The options defining the texture.
  79003. * @returns The texture
  79004. */
  79005. createDepthStencilTexture(size: number | {
  79006. width: number;
  79007. height: number;
  79008. }, options: DepthTextureCreationOptions): InternalTexture;
  79009. /** @hidden */
  79010. _createDepthStencilTexture(size: number | {
  79011. width: number;
  79012. height: number;
  79013. }, options: DepthTextureCreationOptions): InternalTexture;
  79014. }
  79015. }
  79016. declare module BABYLON {
  79017. /** Defines supported spaces */
  79018. export enum Space {
  79019. /** Local (object) space */
  79020. LOCAL = 0,
  79021. /** World space */
  79022. WORLD = 1,
  79023. /** Bone space */
  79024. BONE = 2
  79025. }
  79026. /** Defines the 3 main axes */
  79027. export class Axis {
  79028. /** X axis */
  79029. static X: Vector3;
  79030. /** Y axis */
  79031. static Y: Vector3;
  79032. /** Z axis */
  79033. static Z: Vector3;
  79034. }
  79035. }
  79036. declare module BABYLON {
  79037. /**
  79038. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79039. * This is the base of the follow, arc rotate cameras and Free camera
  79040. * @see http://doc.babylonjs.com/features/cameras
  79041. */
  79042. export class TargetCamera extends Camera {
  79043. private static _RigCamTransformMatrix;
  79044. private static _TargetTransformMatrix;
  79045. private static _TargetFocalPoint;
  79046. /**
  79047. * Define the current direction the camera is moving to
  79048. */
  79049. cameraDirection: Vector3;
  79050. /**
  79051. * Define the current rotation the camera is rotating to
  79052. */
  79053. cameraRotation: Vector2;
  79054. /**
  79055. * When set, the up vector of the camera will be updated by the rotation of the camera
  79056. */
  79057. updateUpVectorFromRotation: boolean;
  79058. private _tmpQuaternion;
  79059. /**
  79060. * Define the current rotation of the camera
  79061. */
  79062. rotation: Vector3;
  79063. /**
  79064. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79065. */
  79066. rotationQuaternion: Quaternion;
  79067. /**
  79068. * Define the current speed of the camera
  79069. */
  79070. speed: number;
  79071. /**
  79072. * Add constraint to the camera to prevent it to move freely in all directions and
  79073. * around all axis.
  79074. */
  79075. noRotationConstraint: boolean;
  79076. /**
  79077. * Define the current target of the camera as an object or a position.
  79078. */
  79079. lockedTarget: any;
  79080. /** @hidden */
  79081. _currentTarget: Vector3;
  79082. /** @hidden */
  79083. _initialFocalDistance: number;
  79084. /** @hidden */
  79085. _viewMatrix: Matrix;
  79086. /** @hidden */
  79087. _camMatrix: Matrix;
  79088. /** @hidden */
  79089. _cameraTransformMatrix: Matrix;
  79090. /** @hidden */
  79091. _cameraRotationMatrix: Matrix;
  79092. /** @hidden */
  79093. _referencePoint: Vector3;
  79094. /** @hidden */
  79095. _transformedReferencePoint: Vector3;
  79096. protected _globalCurrentTarget: Vector3;
  79097. protected _globalCurrentUpVector: Vector3;
  79098. /** @hidden */
  79099. _reset: () => void;
  79100. private _defaultUp;
  79101. /**
  79102. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79103. * This is the base of the follow, arc rotate cameras and Free camera
  79104. * @see http://doc.babylonjs.com/features/cameras
  79105. * @param name Defines the name of the camera in the scene
  79106. * @param position Defines the start position of the camera in the scene
  79107. * @param scene Defines the scene the camera belongs to
  79108. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79109. */
  79110. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79111. /**
  79112. * Gets the position in front of the camera at a given distance.
  79113. * @param distance The distance from the camera we want the position to be
  79114. * @returns the position
  79115. */
  79116. getFrontPosition(distance: number): Vector3;
  79117. /** @hidden */
  79118. _getLockedTargetPosition(): Nullable<Vector3>;
  79119. private _storedPosition;
  79120. private _storedRotation;
  79121. private _storedRotationQuaternion;
  79122. /**
  79123. * Store current camera state of the camera (fov, position, rotation, etc..)
  79124. * @returns the camera
  79125. */
  79126. storeState(): Camera;
  79127. /**
  79128. * Restored camera state. You must call storeState() first
  79129. * @returns whether it was successful or not
  79130. * @hidden
  79131. */
  79132. _restoreStateValues(): boolean;
  79133. /** @hidden */
  79134. _initCache(): void;
  79135. /** @hidden */
  79136. _updateCache(ignoreParentClass?: boolean): void;
  79137. /** @hidden */
  79138. _isSynchronizedViewMatrix(): boolean;
  79139. /** @hidden */
  79140. _computeLocalCameraSpeed(): number;
  79141. /**
  79142. * Defines the target the camera should look at.
  79143. * @param target Defines the new target as a Vector or a mesh
  79144. */
  79145. setTarget(target: Vector3): void;
  79146. /**
  79147. * Return the current target position of the camera. This value is expressed in local space.
  79148. * @returns the target position
  79149. */
  79150. getTarget(): Vector3;
  79151. /** @hidden */
  79152. _decideIfNeedsToMove(): boolean;
  79153. /** @hidden */
  79154. _updatePosition(): void;
  79155. /** @hidden */
  79156. _checkInputs(): void;
  79157. protected _updateCameraRotationMatrix(): void;
  79158. /**
  79159. * 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)
  79160. * @returns the current camera
  79161. */
  79162. private _rotateUpVectorWithCameraRotationMatrix;
  79163. private _cachedRotationZ;
  79164. private _cachedQuaternionRotationZ;
  79165. /** @hidden */
  79166. _getViewMatrix(): Matrix;
  79167. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  79168. /**
  79169. * @hidden
  79170. */
  79171. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  79172. /**
  79173. * @hidden
  79174. */
  79175. _updateRigCameras(): void;
  79176. private _getRigCamPositionAndTarget;
  79177. /**
  79178. * Gets the current object class name.
  79179. * @return the class name
  79180. */
  79181. getClassName(): string;
  79182. }
  79183. }
  79184. declare module BABYLON {
  79185. /**
  79186. * Gather the list of keyboard event types as constants.
  79187. */
  79188. export class KeyboardEventTypes {
  79189. /**
  79190. * The keydown event is fired when a key becomes active (pressed).
  79191. */
  79192. static readonly KEYDOWN: number;
  79193. /**
  79194. * The keyup event is fired when a key has been released.
  79195. */
  79196. static readonly KEYUP: number;
  79197. }
  79198. /**
  79199. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79200. */
  79201. export class KeyboardInfo {
  79202. /**
  79203. * Defines the type of event (KeyboardEventTypes)
  79204. */
  79205. type: number;
  79206. /**
  79207. * Defines the related dom event
  79208. */
  79209. event: KeyboardEvent;
  79210. /**
  79211. * Instantiates a new keyboard info.
  79212. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79213. * @param type Defines the type of event (KeyboardEventTypes)
  79214. * @param event Defines the related dom event
  79215. */
  79216. constructor(
  79217. /**
  79218. * Defines the type of event (KeyboardEventTypes)
  79219. */
  79220. type: number,
  79221. /**
  79222. * Defines the related dom event
  79223. */
  79224. event: KeyboardEvent);
  79225. }
  79226. /**
  79227. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79228. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  79229. */
  79230. export class KeyboardInfoPre extends KeyboardInfo {
  79231. /**
  79232. * Defines the type of event (KeyboardEventTypes)
  79233. */
  79234. type: number;
  79235. /**
  79236. * Defines the related dom event
  79237. */
  79238. event: KeyboardEvent;
  79239. /**
  79240. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  79241. */
  79242. skipOnPointerObservable: boolean;
  79243. /**
  79244. * Instantiates a new keyboard pre info.
  79245. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79246. * @param type Defines the type of event (KeyboardEventTypes)
  79247. * @param event Defines the related dom event
  79248. */
  79249. constructor(
  79250. /**
  79251. * Defines the type of event (KeyboardEventTypes)
  79252. */
  79253. type: number,
  79254. /**
  79255. * Defines the related dom event
  79256. */
  79257. event: KeyboardEvent);
  79258. }
  79259. }
  79260. declare module BABYLON {
  79261. /**
  79262. * Manage the keyboard inputs to control the movement of a free camera.
  79263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79264. */
  79265. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  79266. /**
  79267. * Defines the camera the input is attached to.
  79268. */
  79269. camera: FreeCamera;
  79270. /**
  79271. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79272. */
  79273. keysUp: number[];
  79274. /**
  79275. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79276. */
  79277. keysDown: number[];
  79278. /**
  79279. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79280. */
  79281. keysLeft: number[];
  79282. /**
  79283. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79284. */
  79285. keysRight: number[];
  79286. private _keys;
  79287. private _onCanvasBlurObserver;
  79288. private _onKeyboardObserver;
  79289. private _engine;
  79290. private _scene;
  79291. /**
  79292. * Attach the input controls to a specific dom element to get the input from.
  79293. * @param element Defines the element the controls should be listened from
  79294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79295. */
  79296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79297. /**
  79298. * Detach the current controls from the specified dom element.
  79299. * @param element Defines the element to stop listening the inputs from
  79300. */
  79301. detachControl(element: Nullable<HTMLElement>): void;
  79302. /**
  79303. * Update the current camera state depending on the inputs that have been used this frame.
  79304. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79305. */
  79306. checkInputs(): void;
  79307. /**
  79308. * Gets the class name of the current intput.
  79309. * @returns the class name
  79310. */
  79311. getClassName(): string;
  79312. /** @hidden */
  79313. _onLostFocus(): void;
  79314. /**
  79315. * Get the friendly name associated with the input class.
  79316. * @returns the input friendly name
  79317. */
  79318. getSimpleName(): string;
  79319. }
  79320. }
  79321. declare module BABYLON {
  79322. /**
  79323. * Interface describing all the common properties and methods a shadow light needs to implement.
  79324. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  79325. * as well as binding the different shadow properties to the effects.
  79326. */
  79327. export interface IShadowLight extends Light {
  79328. /**
  79329. * The light id in the scene (used in scene.findLighById for instance)
  79330. */
  79331. id: string;
  79332. /**
  79333. * The position the shdow will be casted from.
  79334. */
  79335. position: Vector3;
  79336. /**
  79337. * In 2d mode (needCube being false), the direction used to cast the shadow.
  79338. */
  79339. direction: Vector3;
  79340. /**
  79341. * The transformed position. Position of the light in world space taking parenting in account.
  79342. */
  79343. transformedPosition: Vector3;
  79344. /**
  79345. * The transformed direction. Direction of the light in world space taking parenting in account.
  79346. */
  79347. transformedDirection: Vector3;
  79348. /**
  79349. * The friendly name of the light in the scene.
  79350. */
  79351. name: string;
  79352. /**
  79353. * Defines the shadow projection clipping minimum z value.
  79354. */
  79355. shadowMinZ: number;
  79356. /**
  79357. * Defines the shadow projection clipping maximum z value.
  79358. */
  79359. shadowMaxZ: number;
  79360. /**
  79361. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79362. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79363. */
  79364. computeTransformedInformation(): boolean;
  79365. /**
  79366. * Gets the scene the light belongs to.
  79367. * @returns The scene
  79368. */
  79369. getScene(): Scene;
  79370. /**
  79371. * Callback defining a custom Projection Matrix Builder.
  79372. * This can be used to override the default projection matrix computation.
  79373. */
  79374. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79375. /**
  79376. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79377. * @param matrix The materix to updated with the projection information
  79378. * @param viewMatrix The transform matrix of the light
  79379. * @param renderList The list of mesh to render in the map
  79380. * @returns The current light
  79381. */
  79382. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79383. /**
  79384. * Gets the current depth scale used in ESM.
  79385. * @returns The scale
  79386. */
  79387. getDepthScale(): number;
  79388. /**
  79389. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79390. * @returns true if a cube texture needs to be use
  79391. */
  79392. needCube(): boolean;
  79393. /**
  79394. * Detects if the projection matrix requires to be recomputed this frame.
  79395. * @returns true if it requires to be recomputed otherwise, false.
  79396. */
  79397. needProjectionMatrixCompute(): boolean;
  79398. /**
  79399. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79400. */
  79401. forceProjectionMatrixCompute(): void;
  79402. /**
  79403. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79404. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79405. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79406. */
  79407. getShadowDirection(faceIndex?: number): Vector3;
  79408. /**
  79409. * Gets the minZ used for shadow according to both the scene and the light.
  79410. * @param activeCamera The camera we are returning the min for
  79411. * @returns the depth min z
  79412. */
  79413. getDepthMinZ(activeCamera: Camera): number;
  79414. /**
  79415. * Gets the maxZ used for shadow according to both the scene and the light.
  79416. * @param activeCamera The camera we are returning the max for
  79417. * @returns the depth max z
  79418. */
  79419. getDepthMaxZ(activeCamera: Camera): number;
  79420. }
  79421. /**
  79422. * Base implementation IShadowLight
  79423. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  79424. */
  79425. export abstract class ShadowLight extends Light implements IShadowLight {
  79426. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  79427. protected _position: Vector3;
  79428. protected _setPosition(value: Vector3): void;
  79429. /**
  79430. * Sets the position the shadow will be casted from. Also use as the light position for both
  79431. * point and spot lights.
  79432. */
  79433. get position(): Vector3;
  79434. /**
  79435. * Sets the position the shadow will be casted from. Also use as the light position for both
  79436. * point and spot lights.
  79437. */
  79438. set position(value: Vector3);
  79439. protected _direction: Vector3;
  79440. protected _setDirection(value: Vector3): void;
  79441. /**
  79442. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  79443. * Also use as the light direction on spot and directional lights.
  79444. */
  79445. get direction(): Vector3;
  79446. /**
  79447. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  79448. * Also use as the light direction on spot and directional lights.
  79449. */
  79450. set direction(value: Vector3);
  79451. private _shadowMinZ;
  79452. /**
  79453. * Gets the shadow projection clipping minimum z value.
  79454. */
  79455. get shadowMinZ(): number;
  79456. /**
  79457. * Sets the shadow projection clipping minimum z value.
  79458. */
  79459. set shadowMinZ(value: number);
  79460. private _shadowMaxZ;
  79461. /**
  79462. * Sets the shadow projection clipping maximum z value.
  79463. */
  79464. get shadowMaxZ(): number;
  79465. /**
  79466. * Gets the shadow projection clipping maximum z value.
  79467. */
  79468. set shadowMaxZ(value: number);
  79469. /**
  79470. * Callback defining a custom Projection Matrix Builder.
  79471. * This can be used to override the default projection matrix computation.
  79472. */
  79473. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79474. /**
  79475. * The transformed position. Position of the light in world space taking parenting in account.
  79476. */
  79477. transformedPosition: Vector3;
  79478. /**
  79479. * The transformed direction. Direction of the light in world space taking parenting in account.
  79480. */
  79481. transformedDirection: Vector3;
  79482. private _needProjectionMatrixCompute;
  79483. /**
  79484. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79485. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79486. */
  79487. computeTransformedInformation(): boolean;
  79488. /**
  79489. * Return the depth scale used for the shadow map.
  79490. * @returns the depth scale.
  79491. */
  79492. getDepthScale(): number;
  79493. /**
  79494. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79495. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79496. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79497. */
  79498. getShadowDirection(faceIndex?: number): Vector3;
  79499. /**
  79500. * Returns the ShadowLight absolute position in the World.
  79501. * @returns the position vector in world space
  79502. */
  79503. getAbsolutePosition(): Vector3;
  79504. /**
  79505. * Sets the ShadowLight direction toward the passed target.
  79506. * @param target The point to target in local space
  79507. * @returns the updated ShadowLight direction
  79508. */
  79509. setDirectionToTarget(target: Vector3): Vector3;
  79510. /**
  79511. * Returns the light rotation in euler definition.
  79512. * @returns the x y z rotation in local space.
  79513. */
  79514. getRotation(): Vector3;
  79515. /**
  79516. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79517. * @returns true if a cube texture needs to be use
  79518. */
  79519. needCube(): boolean;
  79520. /**
  79521. * Detects if the projection matrix requires to be recomputed this frame.
  79522. * @returns true if it requires to be recomputed otherwise, false.
  79523. */
  79524. needProjectionMatrixCompute(): boolean;
  79525. /**
  79526. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79527. */
  79528. forceProjectionMatrixCompute(): void;
  79529. /** @hidden */
  79530. _initCache(): void;
  79531. /** @hidden */
  79532. _isSynchronized(): boolean;
  79533. /**
  79534. * Computes the world matrix of the node
  79535. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79536. * @returns the world matrix
  79537. */
  79538. computeWorldMatrix(force?: boolean): Matrix;
  79539. /**
  79540. * Gets the minZ used for shadow according to both the scene and the light.
  79541. * @param activeCamera The camera we are returning the min for
  79542. * @returns the depth min z
  79543. */
  79544. getDepthMinZ(activeCamera: Camera): number;
  79545. /**
  79546. * Gets the maxZ used for shadow according to both the scene and the light.
  79547. * @param activeCamera The camera we are returning the max for
  79548. * @returns the depth max z
  79549. */
  79550. getDepthMaxZ(activeCamera: Camera): number;
  79551. /**
  79552. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79553. * @param matrix The materix to updated with the projection information
  79554. * @param viewMatrix The transform matrix of the light
  79555. * @param renderList The list of mesh to render in the map
  79556. * @returns The current light
  79557. */
  79558. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79559. }
  79560. }
  79561. declare module BABYLON {
  79562. /**
  79563. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  79564. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  79565. */
  79566. export class EffectFallbacks implements IEffectFallbacks {
  79567. private _defines;
  79568. private _currentRank;
  79569. private _maxRank;
  79570. private _mesh;
  79571. /**
  79572. * Removes the fallback from the bound mesh.
  79573. */
  79574. unBindMesh(): void;
  79575. /**
  79576. * Adds a fallback on the specified property.
  79577. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79578. * @param define The name of the define in the shader
  79579. */
  79580. addFallback(rank: number, define: string): void;
  79581. /**
  79582. * Sets the mesh to use CPU skinning when needing to fallback.
  79583. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79584. * @param mesh The mesh to use the fallbacks.
  79585. */
  79586. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  79587. /**
  79588. * Checks to see if more fallbacks are still availible.
  79589. */
  79590. get hasMoreFallbacks(): boolean;
  79591. /**
  79592. * Removes the defines that should be removed when falling back.
  79593. * @param currentDefines defines the current define statements for the shader.
  79594. * @param effect defines the current effect we try to compile
  79595. * @returns The resulting defines with defines of the current rank removed.
  79596. */
  79597. reduce(currentDefines: string, effect: Effect): string;
  79598. }
  79599. }
  79600. declare module BABYLON {
  79601. /**
  79602. * "Static Class" containing the most commonly used helper while dealing with material for
  79603. * rendering purpose.
  79604. *
  79605. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  79606. *
  79607. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  79608. */
  79609. export class MaterialHelper {
  79610. /**
  79611. * Bind the current view position to an effect.
  79612. * @param effect The effect to be bound
  79613. * @param scene The scene the eyes position is used from
  79614. */
  79615. static BindEyePosition(effect: Effect, scene: Scene): void;
  79616. /**
  79617. * Helps preparing the defines values about the UVs in used in the effect.
  79618. * UVs are shared as much as we can accross channels in the shaders.
  79619. * @param texture The texture we are preparing the UVs for
  79620. * @param defines The defines to update
  79621. * @param key The channel key "diffuse", "specular"... used in the shader
  79622. */
  79623. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  79624. /**
  79625. * Binds a texture matrix value to its corrsponding uniform
  79626. * @param texture The texture to bind the matrix for
  79627. * @param uniformBuffer The uniform buffer receivin the data
  79628. * @param key The channel key "diffuse", "specular"... used in the shader
  79629. */
  79630. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  79631. /**
  79632. * Gets the current status of the fog (should it be enabled?)
  79633. * @param mesh defines the mesh to evaluate for fog support
  79634. * @param scene defines the hosting scene
  79635. * @returns true if fog must be enabled
  79636. */
  79637. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  79638. /**
  79639. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  79640. * @param mesh defines the current mesh
  79641. * @param scene defines the current scene
  79642. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  79643. * @param pointsCloud defines if point cloud rendering has to be turned on
  79644. * @param fogEnabled defines if fog has to be turned on
  79645. * @param alphaTest defines if alpha testing has to be turned on
  79646. * @param defines defines the current list of defines
  79647. */
  79648. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  79649. /**
  79650. * Helper used to prepare the list of defines associated with frame values for shader compilation
  79651. * @param scene defines the current scene
  79652. * @param engine defines the current engine
  79653. * @param defines specifies the list of active defines
  79654. * @param useInstances defines if instances have to be turned on
  79655. * @param useClipPlane defines if clip plane have to be turned on
  79656. */
  79657. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  79658. /**
  79659. * Prepares the defines for bones
  79660. * @param mesh The mesh containing the geometry data we will draw
  79661. * @param defines The defines to update
  79662. */
  79663. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  79664. /**
  79665. * Prepares the defines for morph targets
  79666. * @param mesh The mesh containing the geometry data we will draw
  79667. * @param defines The defines to update
  79668. */
  79669. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  79670. /**
  79671. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  79672. * @param mesh The mesh containing the geometry data we will draw
  79673. * @param defines The defines to update
  79674. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  79675. * @param useBones Precise whether bones should be used or not (override mesh info)
  79676. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  79677. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  79678. * @returns false if defines are considered not dirty and have not been checked
  79679. */
  79680. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  79681. /**
  79682. * Prepares the defines related to multiview
  79683. * @param scene The scene we are intending to draw
  79684. * @param defines The defines to update
  79685. */
  79686. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  79687. /**
  79688. * Prepares the defines related to the light information passed in parameter
  79689. * @param scene The scene we are intending to draw
  79690. * @param mesh The mesh the effect is compiling for
  79691. * @param light The light the effect is compiling for
  79692. * @param lightIndex The index of the light
  79693. * @param defines The defines to update
  79694. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79695. * @param state Defines the current state regarding what is needed (normals, etc...)
  79696. */
  79697. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  79698. needNormals: boolean;
  79699. needRebuild: boolean;
  79700. shadowEnabled: boolean;
  79701. specularEnabled: boolean;
  79702. lightmapMode: boolean;
  79703. }): void;
  79704. /**
  79705. * Prepares the defines related to the light information passed in parameter
  79706. * @param scene The scene we are intending to draw
  79707. * @param mesh The mesh the effect is compiling for
  79708. * @param defines The defines to update
  79709. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79710. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  79711. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  79712. * @returns true if normals will be required for the rest of the effect
  79713. */
  79714. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  79715. /**
  79716. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  79717. * @param lightIndex defines the light index
  79718. * @param uniformsList The uniform list
  79719. * @param samplersList The sampler list
  79720. * @param projectedLightTexture defines if projected texture must be used
  79721. * @param uniformBuffersList defines an optional list of uniform buffers
  79722. */
  79723. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  79724. /**
  79725. * Prepares the uniforms and samplers list to be used in the effect
  79726. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  79727. * @param samplersList The sampler list
  79728. * @param defines The defines helping in the list generation
  79729. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  79730. */
  79731. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  79732. /**
  79733. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  79734. * @param defines The defines to update while falling back
  79735. * @param fallbacks The authorized effect fallbacks
  79736. * @param maxSimultaneousLights The maximum number of lights allowed
  79737. * @param rank the current rank of the Effect
  79738. * @returns The newly affected rank
  79739. */
  79740. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  79741. private static _TmpMorphInfluencers;
  79742. /**
  79743. * Prepares the list of attributes required for morph targets according to the effect defines.
  79744. * @param attribs The current list of supported attribs
  79745. * @param mesh The mesh to prepare the morph targets attributes for
  79746. * @param influencers The number of influencers
  79747. */
  79748. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  79749. /**
  79750. * Prepares the list of attributes required for morph targets according to the effect defines.
  79751. * @param attribs The current list of supported attribs
  79752. * @param mesh The mesh to prepare the morph targets attributes for
  79753. * @param defines The current Defines of the effect
  79754. */
  79755. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  79756. /**
  79757. * Prepares the list of attributes required for bones according to the effect defines.
  79758. * @param attribs The current list of supported attribs
  79759. * @param mesh The mesh to prepare the bones attributes for
  79760. * @param defines The current Defines of the effect
  79761. * @param fallbacks The current efffect fallback strategy
  79762. */
  79763. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  79764. /**
  79765. * Check and prepare the list of attributes required for instances according to the effect defines.
  79766. * @param attribs The current list of supported attribs
  79767. * @param defines The current MaterialDefines of the effect
  79768. */
  79769. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  79770. /**
  79771. * Add the list of attributes required for instances to the attribs array.
  79772. * @param attribs The current list of supported attribs
  79773. */
  79774. static PushAttributesForInstances(attribs: string[]): void;
  79775. /**
  79776. * Binds the light information to the effect.
  79777. * @param light The light containing the generator
  79778. * @param effect The effect we are binding the data to
  79779. * @param lightIndex The light index in the effect used to render
  79780. */
  79781. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  79782. /**
  79783. * Binds the lights information from the scene to the effect for the given mesh.
  79784. * @param light Light to bind
  79785. * @param lightIndex Light index
  79786. * @param scene The scene where the light belongs to
  79787. * @param effect The effect we are binding the data to
  79788. * @param useSpecular Defines if specular is supported
  79789. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79790. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79791. */
  79792. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79793. /**
  79794. * Binds the lights information from the scene to the effect for the given mesh.
  79795. * @param scene The scene the lights belongs to
  79796. * @param mesh The mesh we are binding the information to render
  79797. * @param effect The effect we are binding the data to
  79798. * @param defines The generated defines for the effect
  79799. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  79800. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79801. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79802. */
  79803. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79804. private static _tempFogColor;
  79805. /**
  79806. * Binds the fog information from the scene to the effect for the given mesh.
  79807. * @param scene The scene the lights belongs to
  79808. * @param mesh The mesh we are binding the information to render
  79809. * @param effect The effect we are binding the data to
  79810. * @param linearSpace Defines if the fog effect is applied in linear space
  79811. */
  79812. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  79813. /**
  79814. * Binds the bones information from the mesh to the effect.
  79815. * @param mesh The mesh we are binding the information to render
  79816. * @param effect The effect we are binding the data to
  79817. */
  79818. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  79819. /**
  79820. * Binds the morph targets information from the mesh to the effect.
  79821. * @param abstractMesh The mesh we are binding the information to render
  79822. * @param effect The effect we are binding the data to
  79823. */
  79824. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  79825. /**
  79826. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  79827. * @param defines The generated defines used in the effect
  79828. * @param effect The effect we are binding the data to
  79829. * @param scene The scene we are willing to render with logarithmic scale for
  79830. */
  79831. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  79832. /**
  79833. * Binds the clip plane information from the scene to the effect.
  79834. * @param scene The scene the clip plane information are extracted from
  79835. * @param effect The effect we are binding the data to
  79836. */
  79837. static BindClipPlane(effect: Effect, scene: Scene): void;
  79838. }
  79839. }
  79840. declare module BABYLON {
  79841. /** @hidden */
  79842. export var packingFunctions: {
  79843. name: string;
  79844. shader: string;
  79845. };
  79846. }
  79847. declare module BABYLON {
  79848. /** @hidden */
  79849. export var shadowMapPixelShader: {
  79850. name: string;
  79851. shader: string;
  79852. };
  79853. }
  79854. declare module BABYLON {
  79855. /** @hidden */
  79856. export var bonesDeclaration: {
  79857. name: string;
  79858. shader: string;
  79859. };
  79860. }
  79861. declare module BABYLON {
  79862. /** @hidden */
  79863. export var morphTargetsVertexGlobalDeclaration: {
  79864. name: string;
  79865. shader: string;
  79866. };
  79867. }
  79868. declare module BABYLON {
  79869. /** @hidden */
  79870. export var morphTargetsVertexDeclaration: {
  79871. name: string;
  79872. shader: string;
  79873. };
  79874. }
  79875. declare module BABYLON {
  79876. /** @hidden */
  79877. export var instancesDeclaration: {
  79878. name: string;
  79879. shader: string;
  79880. };
  79881. }
  79882. declare module BABYLON {
  79883. /** @hidden */
  79884. export var helperFunctions: {
  79885. name: string;
  79886. shader: string;
  79887. };
  79888. }
  79889. declare module BABYLON {
  79890. /** @hidden */
  79891. export var morphTargetsVertex: {
  79892. name: string;
  79893. shader: string;
  79894. };
  79895. }
  79896. declare module BABYLON {
  79897. /** @hidden */
  79898. export var instancesVertex: {
  79899. name: string;
  79900. shader: string;
  79901. };
  79902. }
  79903. declare module BABYLON {
  79904. /** @hidden */
  79905. export var bonesVertex: {
  79906. name: string;
  79907. shader: string;
  79908. };
  79909. }
  79910. declare module BABYLON {
  79911. /** @hidden */
  79912. export var shadowMapVertexShader: {
  79913. name: string;
  79914. shader: string;
  79915. };
  79916. }
  79917. declare module BABYLON {
  79918. /** @hidden */
  79919. export var depthBoxBlurPixelShader: {
  79920. name: string;
  79921. shader: string;
  79922. };
  79923. }
  79924. declare module BABYLON {
  79925. /**
  79926. * Defines the options associated with the creation of a custom shader for a shadow generator.
  79927. */
  79928. export interface ICustomShaderOptions {
  79929. /**
  79930. * Gets or sets the custom shader name to use
  79931. */
  79932. shaderName: string;
  79933. /**
  79934. * The list of attribute names used in the shader
  79935. */
  79936. attributes?: string[];
  79937. /**
  79938. * The list of unifrom names used in the shader
  79939. */
  79940. uniforms?: string[];
  79941. /**
  79942. * The list of sampler names used in the shader
  79943. */
  79944. samplers?: string[];
  79945. /**
  79946. * The list of defines used in the shader
  79947. */
  79948. defines?: string[];
  79949. }
  79950. /**
  79951. * Interface to implement to create a shadow generator compatible with BJS.
  79952. */
  79953. export interface IShadowGenerator {
  79954. /**
  79955. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  79956. * @returns The render target texture if present otherwise, null
  79957. */
  79958. getShadowMap(): Nullable<RenderTargetTexture>;
  79959. /**
  79960. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  79961. * @returns The render target texture if the shadow map is present otherwise, null
  79962. */
  79963. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  79964. /**
  79965. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  79966. * @param subMesh The submesh we want to render in the shadow map
  79967. * @param useInstances Defines wether will draw in the map using instances
  79968. * @returns true if ready otherwise, false
  79969. */
  79970. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  79971. /**
  79972. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  79973. * @param defines Defines of the material we want to update
  79974. * @param lightIndex Index of the light in the enabled light list of the material
  79975. */
  79976. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  79977. /**
  79978. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  79979. * defined in the generator but impacting the effect).
  79980. * It implies the unifroms available on the materials are the standard BJS ones.
  79981. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  79982. * @param effect The effect we are binfing the information for
  79983. */
  79984. bindShadowLight(lightIndex: string, effect: Effect): void;
  79985. /**
  79986. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  79987. * (eq to shadow prjection matrix * light transform matrix)
  79988. * @returns The transform matrix used to create the shadow map
  79989. */
  79990. getTransformMatrix(): Matrix;
  79991. /**
  79992. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  79993. * Cube and 2D textures for instance.
  79994. */
  79995. recreateShadowMap(): void;
  79996. /**
  79997. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79998. * @param onCompiled Callback triggered at the and of the effects compilation
  79999. * @param options Sets of optional options forcing the compilation with different modes
  80000. */
  80001. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80002. useInstances: boolean;
  80003. }>): void;
  80004. /**
  80005. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80006. * @param options Sets of optional options forcing the compilation with different modes
  80007. * @returns A promise that resolves when the compilation completes
  80008. */
  80009. forceCompilationAsync(options?: Partial<{
  80010. useInstances: boolean;
  80011. }>): Promise<void>;
  80012. /**
  80013. * Serializes the shadow generator setup to a json object.
  80014. * @returns The serialized JSON object
  80015. */
  80016. serialize(): any;
  80017. /**
  80018. * Disposes the Shadow map and related Textures and effects.
  80019. */
  80020. dispose(): void;
  80021. }
  80022. /**
  80023. * Default implementation IShadowGenerator.
  80024. * This is the main object responsible of generating shadows in the framework.
  80025. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80026. */
  80027. export class ShadowGenerator implements IShadowGenerator {
  80028. /**
  80029. * Shadow generator mode None: no filtering applied.
  80030. */
  80031. static readonly FILTER_NONE: number;
  80032. /**
  80033. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80034. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80035. */
  80036. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80037. /**
  80038. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80039. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80040. */
  80041. static readonly FILTER_POISSONSAMPLING: number;
  80042. /**
  80043. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80044. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80045. */
  80046. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80047. /**
  80048. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80049. * edge artifacts on steep falloff.
  80050. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80051. */
  80052. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80053. /**
  80054. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80055. * edge artifacts on steep falloff.
  80056. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80057. */
  80058. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80059. /**
  80060. * Shadow generator mode PCF: Percentage Closer Filtering
  80061. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80062. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80063. */
  80064. static readonly FILTER_PCF: number;
  80065. /**
  80066. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80067. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80068. * Contact Hardening
  80069. */
  80070. static readonly FILTER_PCSS: number;
  80071. /**
  80072. * Reserved for PCF and PCSS
  80073. * Highest Quality.
  80074. *
  80075. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80076. *
  80077. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80078. */
  80079. static readonly QUALITY_HIGH: number;
  80080. /**
  80081. * Reserved for PCF and PCSS
  80082. * Good tradeoff for quality/perf cross devices
  80083. *
  80084. * Execute PCF on a 3*3 kernel.
  80085. *
  80086. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80087. */
  80088. static readonly QUALITY_MEDIUM: number;
  80089. /**
  80090. * Reserved for PCF and PCSS
  80091. * The lowest quality but the fastest.
  80092. *
  80093. * Execute PCF on a 1*1 kernel.
  80094. *
  80095. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80096. */
  80097. static readonly QUALITY_LOW: number;
  80098. /** Gets or sets the custom shader name to use */
  80099. customShaderOptions: ICustomShaderOptions;
  80100. /**
  80101. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80102. */
  80103. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80104. /**
  80105. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80106. */
  80107. onAfterShadowMapRenderObservable: Observable<Effect>;
  80108. /**
  80109. * Observable triggered before a mesh is rendered in the shadow map.
  80110. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80111. */
  80112. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80113. /**
  80114. * Observable triggered after a mesh is rendered in the shadow map.
  80115. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80116. */
  80117. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80118. private _bias;
  80119. /**
  80120. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80121. */
  80122. get bias(): number;
  80123. /**
  80124. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80125. */
  80126. set bias(bias: number);
  80127. private _normalBias;
  80128. /**
  80129. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80130. */
  80131. get normalBias(): number;
  80132. /**
  80133. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80134. */
  80135. set normalBias(normalBias: number);
  80136. private _blurBoxOffset;
  80137. /**
  80138. * Gets the blur box offset: offset applied during the blur pass.
  80139. * Only useful if useKernelBlur = false
  80140. */
  80141. get blurBoxOffset(): number;
  80142. /**
  80143. * Sets the blur box offset: offset applied during the blur pass.
  80144. * Only useful if useKernelBlur = false
  80145. */
  80146. set blurBoxOffset(value: number);
  80147. private _blurScale;
  80148. /**
  80149. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  80150. * 2 means half of the size.
  80151. */
  80152. get blurScale(): number;
  80153. /**
  80154. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  80155. * 2 means half of the size.
  80156. */
  80157. set blurScale(value: number);
  80158. private _blurKernel;
  80159. /**
  80160. * Gets the blur kernel: kernel size of the blur pass.
  80161. * Only useful if useKernelBlur = true
  80162. */
  80163. get blurKernel(): number;
  80164. /**
  80165. * Sets the blur kernel: kernel size of the blur pass.
  80166. * Only useful if useKernelBlur = true
  80167. */
  80168. set blurKernel(value: number);
  80169. private _useKernelBlur;
  80170. /**
  80171. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  80172. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80173. */
  80174. get useKernelBlur(): boolean;
  80175. /**
  80176. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  80177. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80178. */
  80179. set useKernelBlur(value: boolean);
  80180. private _depthScale;
  80181. /**
  80182. * Gets the depth scale used in ESM mode.
  80183. */
  80184. get depthScale(): number;
  80185. /**
  80186. * Sets the depth scale used in ESM mode.
  80187. * This can override the scale stored on the light.
  80188. */
  80189. set depthScale(value: number);
  80190. private _filter;
  80191. /**
  80192. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  80193. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80194. */
  80195. get filter(): number;
  80196. /**
  80197. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  80198. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80199. */
  80200. set filter(value: number);
  80201. /**
  80202. * Gets if the current filter is set to Poisson Sampling.
  80203. */
  80204. get usePoissonSampling(): boolean;
  80205. /**
  80206. * Sets the current filter to Poisson Sampling.
  80207. */
  80208. set usePoissonSampling(value: boolean);
  80209. /**
  80210. * Gets if the current filter is set to ESM.
  80211. */
  80212. get useExponentialShadowMap(): boolean;
  80213. /**
  80214. * Sets the current filter is to ESM.
  80215. */
  80216. set useExponentialShadowMap(value: boolean);
  80217. /**
  80218. * Gets if the current filter is set to filtered ESM.
  80219. */
  80220. get useBlurExponentialShadowMap(): boolean;
  80221. /**
  80222. * Gets if the current filter is set to filtered ESM.
  80223. */
  80224. set useBlurExponentialShadowMap(value: boolean);
  80225. /**
  80226. * Gets if the current filter is set to "close ESM" (using the inverse of the
  80227. * exponential to prevent steep falloff artifacts).
  80228. */
  80229. get useCloseExponentialShadowMap(): boolean;
  80230. /**
  80231. * Sets the current filter to "close ESM" (using the inverse of the
  80232. * exponential to prevent steep falloff artifacts).
  80233. */
  80234. set useCloseExponentialShadowMap(value: boolean);
  80235. /**
  80236. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  80237. * exponential to prevent steep falloff artifacts).
  80238. */
  80239. get useBlurCloseExponentialShadowMap(): boolean;
  80240. /**
  80241. * Sets the current filter to filtered "close ESM" (using the inverse of the
  80242. * exponential to prevent steep falloff artifacts).
  80243. */
  80244. set useBlurCloseExponentialShadowMap(value: boolean);
  80245. /**
  80246. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  80247. */
  80248. get usePercentageCloserFiltering(): boolean;
  80249. /**
  80250. * Sets the current filter to "PCF" (percentage closer filtering).
  80251. */
  80252. set usePercentageCloserFiltering(value: boolean);
  80253. private _filteringQuality;
  80254. /**
  80255. * Gets the PCF or PCSS Quality.
  80256. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80257. */
  80258. get filteringQuality(): number;
  80259. /**
  80260. * Sets the PCF or PCSS Quality.
  80261. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80262. */
  80263. set filteringQuality(filteringQuality: number);
  80264. /**
  80265. * Gets if the current filter is set to "PCSS" (contact hardening).
  80266. */
  80267. get useContactHardeningShadow(): boolean;
  80268. /**
  80269. * Sets the current filter to "PCSS" (contact hardening).
  80270. */
  80271. set useContactHardeningShadow(value: boolean);
  80272. private _contactHardeningLightSizeUVRatio;
  80273. /**
  80274. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80275. * Using a ratio helps keeping shape stability independently of the map size.
  80276. *
  80277. * It does not account for the light projection as it was having too much
  80278. * instability during the light setup or during light position changes.
  80279. *
  80280. * Only valid if useContactHardeningShadow is true.
  80281. */
  80282. get contactHardeningLightSizeUVRatio(): number;
  80283. /**
  80284. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80285. * Using a ratio helps keeping shape stability independently of the map size.
  80286. *
  80287. * It does not account for the light projection as it was having too much
  80288. * instability during the light setup or during light position changes.
  80289. *
  80290. * Only valid if useContactHardeningShadow is true.
  80291. */
  80292. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  80293. private _darkness;
  80294. /** Gets or sets the actual darkness of a shadow */
  80295. get darkness(): number;
  80296. set darkness(value: number);
  80297. /**
  80298. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  80299. * 0 means strongest and 1 would means no shadow.
  80300. * @returns the darkness.
  80301. */
  80302. getDarkness(): number;
  80303. /**
  80304. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  80305. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  80306. * @returns the shadow generator allowing fluent coding.
  80307. */
  80308. setDarkness(darkness: number): ShadowGenerator;
  80309. private _transparencyShadow;
  80310. /** Gets or sets the ability to have transparent shadow */
  80311. get transparencyShadow(): boolean;
  80312. set transparencyShadow(value: boolean);
  80313. /**
  80314. * Sets the ability to have transparent shadow (boolean).
  80315. * @param transparent True if transparent else False
  80316. * @returns the shadow generator allowing fluent coding
  80317. */
  80318. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  80319. private _shadowMap;
  80320. private _shadowMap2;
  80321. /**
  80322. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80323. * @returns The render target texture if present otherwise, null
  80324. */
  80325. getShadowMap(): Nullable<RenderTargetTexture>;
  80326. /**
  80327. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80328. * @returns The render target texture if the shadow map is present otherwise, null
  80329. */
  80330. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80331. /**
  80332. * Gets the class name of that object
  80333. * @returns "ShadowGenerator"
  80334. */
  80335. getClassName(): string;
  80336. /**
  80337. * Helper function to add a mesh and its descendants to the list of shadow casters.
  80338. * @param mesh Mesh to add
  80339. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  80340. * @returns the Shadow Generator itself
  80341. */
  80342. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80343. /**
  80344. * Helper function to remove a mesh and its descendants from the list of shadow casters
  80345. * @param mesh Mesh to remove
  80346. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  80347. * @returns the Shadow Generator itself
  80348. */
  80349. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80350. /**
  80351. * Controls the extent to which the shadows fade out at the edge of the frustum
  80352. * Used only by directionals and spots
  80353. */
  80354. frustumEdgeFalloff: number;
  80355. private _light;
  80356. /**
  80357. * Returns the associated light object.
  80358. * @returns the light generating the shadow
  80359. */
  80360. getLight(): IShadowLight;
  80361. /**
  80362. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  80363. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  80364. * It might on the other hand introduce peter panning.
  80365. */
  80366. forceBackFacesOnly: boolean;
  80367. private _scene;
  80368. private _lightDirection;
  80369. private _effect;
  80370. private _viewMatrix;
  80371. private _projectionMatrix;
  80372. private _transformMatrix;
  80373. private _cachedPosition;
  80374. private _cachedDirection;
  80375. private _cachedDefines;
  80376. private _currentRenderID;
  80377. private _boxBlurPostprocess;
  80378. private _kernelBlurXPostprocess;
  80379. private _kernelBlurYPostprocess;
  80380. private _blurPostProcesses;
  80381. private _mapSize;
  80382. private _currentFaceIndex;
  80383. private _currentFaceIndexCache;
  80384. private _textureType;
  80385. private _defaultTextureMatrix;
  80386. private _storedUniqueId;
  80387. /** @hidden */
  80388. static _SceneComponentInitialization: (scene: Scene) => void;
  80389. /**
  80390. * Creates a ShadowGenerator object.
  80391. * A ShadowGenerator is the required tool to use the shadows.
  80392. * Each light casting shadows needs to use its own ShadowGenerator.
  80393. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  80394. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  80395. * @param light The light object generating the shadows.
  80396. * @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.
  80397. */
  80398. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  80399. private _initializeGenerator;
  80400. private _initializeShadowMap;
  80401. private _initializeBlurRTTAndPostProcesses;
  80402. private _renderForShadowMap;
  80403. private _renderSubMeshForShadowMap;
  80404. private _applyFilterValues;
  80405. /**
  80406. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80407. * @param onCompiled Callback triggered at the and of the effects compilation
  80408. * @param options Sets of optional options forcing the compilation with different modes
  80409. */
  80410. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80411. useInstances: boolean;
  80412. }>): void;
  80413. /**
  80414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80415. * @param options Sets of optional options forcing the compilation with different modes
  80416. * @returns A promise that resolves when the compilation completes
  80417. */
  80418. forceCompilationAsync(options?: Partial<{
  80419. useInstances: boolean;
  80420. }>): Promise<void>;
  80421. /**
  80422. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80423. * @param subMesh The submesh we want to render in the shadow map
  80424. * @param useInstances Defines wether will draw in the map using instances
  80425. * @returns true if ready otherwise, false
  80426. */
  80427. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80428. /**
  80429. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80430. * @param defines Defines of the material we want to update
  80431. * @param lightIndex Index of the light in the enabled light list of the material
  80432. */
  80433. prepareDefines(defines: any, lightIndex: number): void;
  80434. /**
  80435. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80436. * defined in the generator but impacting the effect).
  80437. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80438. * @param effect The effect we are binfing the information for
  80439. */
  80440. bindShadowLight(lightIndex: string, effect: Effect): void;
  80441. /**
  80442. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80443. * (eq to shadow prjection matrix * light transform matrix)
  80444. * @returns The transform matrix used to create the shadow map
  80445. */
  80446. getTransformMatrix(): Matrix;
  80447. /**
  80448. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80449. * Cube and 2D textures for instance.
  80450. */
  80451. recreateShadowMap(): void;
  80452. private _disposeBlurPostProcesses;
  80453. private _disposeRTTandPostProcesses;
  80454. /**
  80455. * Disposes the ShadowGenerator.
  80456. * Returns nothing.
  80457. */
  80458. dispose(): void;
  80459. /**
  80460. * Serializes the shadow generator setup to a json object.
  80461. * @returns The serialized JSON object
  80462. */
  80463. serialize(): any;
  80464. /**
  80465. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  80466. * @param parsedShadowGenerator The JSON object to parse
  80467. * @param scene The scene to create the shadow map for
  80468. * @returns The parsed shadow generator
  80469. */
  80470. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  80471. }
  80472. }
  80473. declare module BABYLON {
  80474. /**
  80475. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  80476. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  80477. * 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.
  80478. */
  80479. export abstract class Light extends Node {
  80480. /**
  80481. * Falloff Default: light is falling off following the material specification:
  80482. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  80483. */
  80484. static readonly FALLOFF_DEFAULT: number;
  80485. /**
  80486. * Falloff Physical: light is falling off following the inverse squared distance law.
  80487. */
  80488. static readonly FALLOFF_PHYSICAL: number;
  80489. /**
  80490. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  80491. * to enhance interoperability with other engines.
  80492. */
  80493. static readonly FALLOFF_GLTF: number;
  80494. /**
  80495. * Falloff Standard: light is falling off like in the standard material
  80496. * to enhance interoperability with other materials.
  80497. */
  80498. static readonly FALLOFF_STANDARD: number;
  80499. /**
  80500. * If every light affecting the material is in this lightmapMode,
  80501. * material.lightmapTexture adds or multiplies
  80502. * (depends on material.useLightmapAsShadowmap)
  80503. * after every other light calculations.
  80504. */
  80505. static readonly LIGHTMAP_DEFAULT: number;
  80506. /**
  80507. * material.lightmapTexture as only diffuse lighting from this light
  80508. * adds only specular lighting from this light
  80509. * adds dynamic shadows
  80510. */
  80511. static readonly LIGHTMAP_SPECULAR: number;
  80512. /**
  80513. * material.lightmapTexture as only lighting
  80514. * no light calculation from this light
  80515. * only adds dynamic shadows from this light
  80516. */
  80517. static readonly LIGHTMAP_SHADOWSONLY: number;
  80518. /**
  80519. * Each light type uses the default quantity according to its type:
  80520. * point/spot lights use luminous intensity
  80521. * directional lights use illuminance
  80522. */
  80523. static readonly INTENSITYMODE_AUTOMATIC: number;
  80524. /**
  80525. * lumen (lm)
  80526. */
  80527. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  80528. /**
  80529. * candela (lm/sr)
  80530. */
  80531. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  80532. /**
  80533. * lux (lm/m^2)
  80534. */
  80535. static readonly INTENSITYMODE_ILLUMINANCE: number;
  80536. /**
  80537. * nit (cd/m^2)
  80538. */
  80539. static readonly INTENSITYMODE_LUMINANCE: number;
  80540. /**
  80541. * Light type const id of the point light.
  80542. */
  80543. static readonly LIGHTTYPEID_POINTLIGHT: number;
  80544. /**
  80545. * Light type const id of the directional light.
  80546. */
  80547. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  80548. /**
  80549. * Light type const id of the spot light.
  80550. */
  80551. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  80552. /**
  80553. * Light type const id of the hemispheric light.
  80554. */
  80555. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  80556. /**
  80557. * Diffuse gives the basic color to an object.
  80558. */
  80559. diffuse: Color3;
  80560. /**
  80561. * Specular produces a highlight color on an object.
  80562. * Note: This is note affecting PBR materials.
  80563. */
  80564. specular: Color3;
  80565. /**
  80566. * Defines the falloff type for this light. This lets overrriding how punctual light are
  80567. * falling off base on range or angle.
  80568. * This can be set to any values in Light.FALLOFF_x.
  80569. *
  80570. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  80571. * other types of materials.
  80572. */
  80573. falloffType: number;
  80574. /**
  80575. * Strength of the light.
  80576. * Note: By default it is define in the framework own unit.
  80577. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  80578. */
  80579. intensity: number;
  80580. private _range;
  80581. protected _inverseSquaredRange: number;
  80582. /**
  80583. * Defines how far from the source the light is impacting in scene units.
  80584. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80585. */
  80586. get range(): number;
  80587. /**
  80588. * Defines how far from the source the light is impacting in scene units.
  80589. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80590. */
  80591. set range(value: number);
  80592. /**
  80593. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  80594. * of light.
  80595. */
  80596. private _photometricScale;
  80597. private _intensityMode;
  80598. /**
  80599. * Gets the photometric scale used to interpret the intensity.
  80600. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80601. */
  80602. get intensityMode(): number;
  80603. /**
  80604. * Sets the photometric scale used to interpret the intensity.
  80605. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80606. */
  80607. set intensityMode(value: number);
  80608. private _radius;
  80609. /**
  80610. * Gets the light radius used by PBR Materials to simulate soft area lights.
  80611. */
  80612. get radius(): number;
  80613. /**
  80614. * sets the light radius used by PBR Materials to simulate soft area lights.
  80615. */
  80616. set radius(value: number);
  80617. private _renderPriority;
  80618. /**
  80619. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  80620. * exceeding the number allowed of the materials.
  80621. */
  80622. renderPriority: number;
  80623. private _shadowEnabled;
  80624. /**
  80625. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80626. * the current shadow generator.
  80627. */
  80628. get shadowEnabled(): boolean;
  80629. /**
  80630. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80631. * the current shadow generator.
  80632. */
  80633. set shadowEnabled(value: boolean);
  80634. private _includedOnlyMeshes;
  80635. /**
  80636. * Gets the only meshes impacted by this light.
  80637. */
  80638. get includedOnlyMeshes(): AbstractMesh[];
  80639. /**
  80640. * Sets the only meshes impacted by this light.
  80641. */
  80642. set includedOnlyMeshes(value: AbstractMesh[]);
  80643. private _excludedMeshes;
  80644. /**
  80645. * Gets the meshes not impacted by this light.
  80646. */
  80647. get excludedMeshes(): AbstractMesh[];
  80648. /**
  80649. * Sets the meshes not impacted by this light.
  80650. */
  80651. set excludedMeshes(value: AbstractMesh[]);
  80652. private _excludeWithLayerMask;
  80653. /**
  80654. * Gets the layer id use to find what meshes are not impacted by the light.
  80655. * Inactive if 0
  80656. */
  80657. get excludeWithLayerMask(): number;
  80658. /**
  80659. * Sets the layer id use to find what meshes are not impacted by the light.
  80660. * Inactive if 0
  80661. */
  80662. set excludeWithLayerMask(value: number);
  80663. private _includeOnlyWithLayerMask;
  80664. /**
  80665. * Gets the layer id use to find what meshes are impacted by the light.
  80666. * Inactive if 0
  80667. */
  80668. get includeOnlyWithLayerMask(): number;
  80669. /**
  80670. * Sets the layer id use to find what meshes are impacted by the light.
  80671. * Inactive if 0
  80672. */
  80673. set includeOnlyWithLayerMask(value: number);
  80674. private _lightmapMode;
  80675. /**
  80676. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80677. */
  80678. get lightmapMode(): number;
  80679. /**
  80680. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80681. */
  80682. set lightmapMode(value: number);
  80683. /**
  80684. * Shadow generator associted to the light.
  80685. * @hidden Internal use only.
  80686. */
  80687. _shadowGenerator: Nullable<IShadowGenerator>;
  80688. /**
  80689. * @hidden Internal use only.
  80690. */
  80691. _excludedMeshesIds: string[];
  80692. /**
  80693. * @hidden Internal use only.
  80694. */
  80695. _includedOnlyMeshesIds: string[];
  80696. /**
  80697. * The current light unifom buffer.
  80698. * @hidden Internal use only.
  80699. */
  80700. _uniformBuffer: UniformBuffer;
  80701. /** @hidden */
  80702. _renderId: number;
  80703. /**
  80704. * Creates a Light object in the scene.
  80705. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80706. * @param name The firendly name of the light
  80707. * @param scene The scene the light belongs too
  80708. */
  80709. constructor(name: string, scene: Scene);
  80710. protected abstract _buildUniformLayout(): void;
  80711. /**
  80712. * Sets the passed Effect "effect" with the Light information.
  80713. * @param effect The effect to update
  80714. * @param lightIndex The index of the light in the effect to update
  80715. * @returns The light
  80716. */
  80717. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  80718. /**
  80719. * Sets the passed Effect "effect" with the Light textures.
  80720. * @param effect The effect to update
  80721. * @param lightIndex The index of the light in the effect to update
  80722. * @returns The light
  80723. */
  80724. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  80725. /**
  80726. * Binds the lights information from the scene to the effect for the given mesh.
  80727. * @param lightIndex Light index
  80728. * @param scene The scene where the light belongs to
  80729. * @param effect The effect we are binding the data to
  80730. * @param useSpecular Defines if specular is supported
  80731. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  80732. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80733. */
  80734. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  80735. /**
  80736. * Sets the passed Effect "effect" with the Light information.
  80737. * @param effect The effect to update
  80738. * @param lightDataUniformName The uniform used to store light data (position or direction)
  80739. * @returns The light
  80740. */
  80741. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  80742. /**
  80743. * Returns the string "Light".
  80744. * @returns the class name
  80745. */
  80746. getClassName(): string;
  80747. /** @hidden */
  80748. readonly _isLight: boolean;
  80749. /**
  80750. * Converts the light information to a readable string for debug purpose.
  80751. * @param fullDetails Supports for multiple levels of logging within scene loading
  80752. * @returns the human readable light info
  80753. */
  80754. toString(fullDetails?: boolean): string;
  80755. /** @hidden */
  80756. protected _syncParentEnabledState(): void;
  80757. /**
  80758. * Set the enabled state of this node.
  80759. * @param value - the new enabled state
  80760. */
  80761. setEnabled(value: boolean): void;
  80762. /**
  80763. * Returns the Light associated shadow generator if any.
  80764. * @return the associated shadow generator.
  80765. */
  80766. getShadowGenerator(): Nullable<IShadowGenerator>;
  80767. /**
  80768. * Returns a Vector3, the absolute light position in the World.
  80769. * @returns the world space position of the light
  80770. */
  80771. getAbsolutePosition(): Vector3;
  80772. /**
  80773. * Specifies if the light will affect the passed mesh.
  80774. * @param mesh The mesh to test against the light
  80775. * @return true the mesh is affected otherwise, false.
  80776. */
  80777. canAffectMesh(mesh: AbstractMesh): boolean;
  80778. /**
  80779. * Sort function to order lights for rendering.
  80780. * @param a First Light object to compare to second.
  80781. * @param b Second Light object to compare first.
  80782. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  80783. */
  80784. static CompareLightsPriority(a: Light, b: Light): number;
  80785. /**
  80786. * Releases resources associated with this node.
  80787. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80788. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80789. */
  80790. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80791. /**
  80792. * Returns the light type ID (integer).
  80793. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80794. */
  80795. getTypeID(): number;
  80796. /**
  80797. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  80798. * @returns the scaled intensity in intensity mode unit
  80799. */
  80800. getScaledIntensity(): number;
  80801. /**
  80802. * Returns a new Light object, named "name", from the current one.
  80803. * @param name The name of the cloned light
  80804. * @returns the new created light
  80805. */
  80806. clone(name: string): Nullable<Light>;
  80807. /**
  80808. * Serializes the current light into a Serialization object.
  80809. * @returns the serialized object.
  80810. */
  80811. serialize(): any;
  80812. /**
  80813. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  80814. * This new light is named "name" and added to the passed scene.
  80815. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  80816. * @param name The friendly name of the light
  80817. * @param scene The scene the new light will belong to
  80818. * @returns the constructor function
  80819. */
  80820. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  80821. /**
  80822. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  80823. * @param parsedLight The JSON representation of the light
  80824. * @param scene The scene to create the parsed light in
  80825. * @returns the created light after parsing
  80826. */
  80827. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  80828. private _hookArrayForExcluded;
  80829. private _hookArrayForIncludedOnly;
  80830. private _resyncMeshes;
  80831. /**
  80832. * Forces the meshes to update their light related information in their rendering used effects
  80833. * @hidden Internal Use Only
  80834. */
  80835. _markMeshesAsLightDirty(): void;
  80836. /**
  80837. * Recomputes the cached photometric scale if needed.
  80838. */
  80839. private _computePhotometricScale;
  80840. /**
  80841. * Returns the Photometric Scale according to the light type and intensity mode.
  80842. */
  80843. private _getPhotometricScale;
  80844. /**
  80845. * Reorder the light in the scene according to their defined priority.
  80846. * @hidden Internal Use Only
  80847. */
  80848. _reorderLightsInScene(): void;
  80849. /**
  80850. * Prepares the list of defines specific to the light type.
  80851. * @param defines the list of defines
  80852. * @param lightIndex defines the index of the light for the effect
  80853. */
  80854. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80855. }
  80856. }
  80857. declare module BABYLON {
  80858. /**
  80859. * Interface used to define Action
  80860. */
  80861. export interface IAction {
  80862. /**
  80863. * Trigger for the action
  80864. */
  80865. trigger: number;
  80866. /** Options of the trigger */
  80867. triggerOptions: any;
  80868. /**
  80869. * Gets the trigger parameters
  80870. * @returns the trigger parameters
  80871. */
  80872. getTriggerParameter(): any;
  80873. /**
  80874. * Internal only - executes current action event
  80875. * @hidden
  80876. */
  80877. _executeCurrent(evt?: ActionEvent): void;
  80878. /**
  80879. * Serialize placeholder for child classes
  80880. * @param parent of child
  80881. * @returns the serialized object
  80882. */
  80883. serialize(parent: any): any;
  80884. /**
  80885. * Internal only
  80886. * @hidden
  80887. */
  80888. _prepare(): void;
  80889. /**
  80890. * Internal only - manager for action
  80891. * @hidden
  80892. */
  80893. _actionManager: AbstractActionManager;
  80894. /**
  80895. * Adds action to chain of actions, may be a DoNothingAction
  80896. * @param action defines the next action to execute
  80897. * @returns The action passed in
  80898. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80899. */
  80900. then(action: IAction): IAction;
  80901. }
  80902. /**
  80903. * The action to be carried out following a trigger
  80904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  80905. */
  80906. export class Action implements IAction {
  80907. /** the trigger, with or without parameters, for the action */
  80908. triggerOptions: any;
  80909. /**
  80910. * Trigger for the action
  80911. */
  80912. trigger: number;
  80913. /**
  80914. * Internal only - manager for action
  80915. * @hidden
  80916. */
  80917. _actionManager: ActionManager;
  80918. private _nextActiveAction;
  80919. private _child;
  80920. private _condition?;
  80921. private _triggerParameter;
  80922. /**
  80923. * An event triggered prior to action being executed.
  80924. */
  80925. onBeforeExecuteObservable: Observable<Action>;
  80926. /**
  80927. * Creates a new Action
  80928. * @param triggerOptions the trigger, with or without parameters, for the action
  80929. * @param condition an optional determinant of action
  80930. */
  80931. constructor(
  80932. /** the trigger, with or without parameters, for the action */
  80933. triggerOptions: any, condition?: Condition);
  80934. /**
  80935. * Internal only
  80936. * @hidden
  80937. */
  80938. _prepare(): void;
  80939. /**
  80940. * Gets the trigger parameters
  80941. * @returns the trigger parameters
  80942. */
  80943. getTriggerParameter(): any;
  80944. /**
  80945. * Internal only - executes current action event
  80946. * @hidden
  80947. */
  80948. _executeCurrent(evt?: ActionEvent): void;
  80949. /**
  80950. * Execute placeholder for child classes
  80951. * @param evt optional action event
  80952. */
  80953. execute(evt?: ActionEvent): void;
  80954. /**
  80955. * Skips to next active action
  80956. */
  80957. skipToNextActiveAction(): void;
  80958. /**
  80959. * Adds action to chain of actions, may be a DoNothingAction
  80960. * @param action defines the next action to execute
  80961. * @returns The action passed in
  80962. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80963. */
  80964. then(action: Action): Action;
  80965. /**
  80966. * Internal only
  80967. * @hidden
  80968. */
  80969. _getProperty(propertyPath: string): string;
  80970. /**
  80971. * Internal only
  80972. * @hidden
  80973. */
  80974. _getEffectiveTarget(target: any, propertyPath: string): any;
  80975. /**
  80976. * Serialize placeholder for child classes
  80977. * @param parent of child
  80978. * @returns the serialized object
  80979. */
  80980. serialize(parent: any): any;
  80981. /**
  80982. * Internal only called by serialize
  80983. * @hidden
  80984. */
  80985. protected _serialize(serializedAction: any, parent?: any): any;
  80986. /**
  80987. * Internal only
  80988. * @hidden
  80989. */
  80990. static _SerializeValueAsString: (value: any) => string;
  80991. /**
  80992. * Internal only
  80993. * @hidden
  80994. */
  80995. static _GetTargetProperty: (target: Node | Scene) => {
  80996. name: string;
  80997. targetType: string;
  80998. value: string;
  80999. };
  81000. }
  81001. }
  81002. declare module BABYLON {
  81003. /**
  81004. * A Condition applied to an Action
  81005. */
  81006. export class Condition {
  81007. /**
  81008. * Internal only - manager for action
  81009. * @hidden
  81010. */
  81011. _actionManager: ActionManager;
  81012. /**
  81013. * Internal only
  81014. * @hidden
  81015. */
  81016. _evaluationId: number;
  81017. /**
  81018. * Internal only
  81019. * @hidden
  81020. */
  81021. _currentResult: boolean;
  81022. /**
  81023. * Creates a new Condition
  81024. * @param actionManager the manager of the action the condition is applied to
  81025. */
  81026. constructor(actionManager: ActionManager);
  81027. /**
  81028. * Check if the current condition is valid
  81029. * @returns a boolean
  81030. */
  81031. isValid(): boolean;
  81032. /**
  81033. * Internal only
  81034. * @hidden
  81035. */
  81036. _getProperty(propertyPath: string): string;
  81037. /**
  81038. * Internal only
  81039. * @hidden
  81040. */
  81041. _getEffectiveTarget(target: any, propertyPath: string): any;
  81042. /**
  81043. * Serialize placeholder for child classes
  81044. * @returns the serialized object
  81045. */
  81046. serialize(): any;
  81047. /**
  81048. * Internal only
  81049. * @hidden
  81050. */
  81051. protected _serialize(serializedCondition: any): any;
  81052. }
  81053. /**
  81054. * Defines specific conditional operators as extensions of Condition
  81055. */
  81056. export class ValueCondition extends Condition {
  81057. /** path to specify the property of the target the conditional operator uses */
  81058. propertyPath: string;
  81059. /** the value compared by the conditional operator against the current value of the property */
  81060. value: any;
  81061. /** the conditional operator, default ValueCondition.IsEqual */
  81062. operator: number;
  81063. /**
  81064. * Internal only
  81065. * @hidden
  81066. */
  81067. private static _IsEqual;
  81068. /**
  81069. * Internal only
  81070. * @hidden
  81071. */
  81072. private static _IsDifferent;
  81073. /**
  81074. * Internal only
  81075. * @hidden
  81076. */
  81077. private static _IsGreater;
  81078. /**
  81079. * Internal only
  81080. * @hidden
  81081. */
  81082. private static _IsLesser;
  81083. /**
  81084. * returns the number for IsEqual
  81085. */
  81086. static get IsEqual(): number;
  81087. /**
  81088. * Returns the number for IsDifferent
  81089. */
  81090. static get IsDifferent(): number;
  81091. /**
  81092. * Returns the number for IsGreater
  81093. */
  81094. static get IsGreater(): number;
  81095. /**
  81096. * Returns the number for IsLesser
  81097. */
  81098. static get IsLesser(): number;
  81099. /**
  81100. * Internal only The action manager for the condition
  81101. * @hidden
  81102. */
  81103. _actionManager: ActionManager;
  81104. /**
  81105. * Internal only
  81106. * @hidden
  81107. */
  81108. private _target;
  81109. /**
  81110. * Internal only
  81111. * @hidden
  81112. */
  81113. private _effectiveTarget;
  81114. /**
  81115. * Internal only
  81116. * @hidden
  81117. */
  81118. private _property;
  81119. /**
  81120. * Creates a new ValueCondition
  81121. * @param actionManager manager for the action the condition applies to
  81122. * @param target for the action
  81123. * @param propertyPath path to specify the property of the target the conditional operator uses
  81124. * @param value the value compared by the conditional operator against the current value of the property
  81125. * @param operator the conditional operator, default ValueCondition.IsEqual
  81126. */
  81127. constructor(actionManager: ActionManager, target: any,
  81128. /** path to specify the property of the target the conditional operator uses */
  81129. propertyPath: string,
  81130. /** the value compared by the conditional operator against the current value of the property */
  81131. value: any,
  81132. /** the conditional operator, default ValueCondition.IsEqual */
  81133. operator?: number);
  81134. /**
  81135. * Compares the given value with the property value for the specified conditional operator
  81136. * @returns the result of the comparison
  81137. */
  81138. isValid(): boolean;
  81139. /**
  81140. * Serialize the ValueCondition into a JSON compatible object
  81141. * @returns serialization object
  81142. */
  81143. serialize(): any;
  81144. /**
  81145. * Gets the name of the conditional operator for the ValueCondition
  81146. * @param operator the conditional operator
  81147. * @returns the name
  81148. */
  81149. static GetOperatorName(operator: number): string;
  81150. }
  81151. /**
  81152. * Defines a predicate condition as an extension of Condition
  81153. */
  81154. export class PredicateCondition extends Condition {
  81155. /** defines the predicate function used to validate the condition */
  81156. predicate: () => boolean;
  81157. /**
  81158. * Internal only - manager for action
  81159. * @hidden
  81160. */
  81161. _actionManager: ActionManager;
  81162. /**
  81163. * Creates a new PredicateCondition
  81164. * @param actionManager manager for the action the condition applies to
  81165. * @param predicate defines the predicate function used to validate the condition
  81166. */
  81167. constructor(actionManager: ActionManager,
  81168. /** defines the predicate function used to validate the condition */
  81169. predicate: () => boolean);
  81170. /**
  81171. * @returns the validity of the predicate condition
  81172. */
  81173. isValid(): boolean;
  81174. }
  81175. /**
  81176. * Defines a state condition as an extension of Condition
  81177. */
  81178. export class StateCondition extends Condition {
  81179. /** Value to compare with target state */
  81180. value: string;
  81181. /**
  81182. * Internal only - manager for action
  81183. * @hidden
  81184. */
  81185. _actionManager: ActionManager;
  81186. /**
  81187. * Internal only
  81188. * @hidden
  81189. */
  81190. private _target;
  81191. /**
  81192. * Creates a new StateCondition
  81193. * @param actionManager manager for the action the condition applies to
  81194. * @param target of the condition
  81195. * @param value to compare with target state
  81196. */
  81197. constructor(actionManager: ActionManager, target: any,
  81198. /** Value to compare with target state */
  81199. value: string);
  81200. /**
  81201. * Gets a boolean indicating if the current condition is met
  81202. * @returns the validity of the state
  81203. */
  81204. isValid(): boolean;
  81205. /**
  81206. * Serialize the StateCondition into a JSON compatible object
  81207. * @returns serialization object
  81208. */
  81209. serialize(): any;
  81210. }
  81211. }
  81212. declare module BABYLON {
  81213. /**
  81214. * This defines an action responsible to toggle a boolean once triggered.
  81215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81216. */
  81217. export class SwitchBooleanAction extends Action {
  81218. /**
  81219. * The path to the boolean property in the target object
  81220. */
  81221. propertyPath: string;
  81222. private _target;
  81223. private _effectiveTarget;
  81224. private _property;
  81225. /**
  81226. * Instantiate the action
  81227. * @param triggerOptions defines the trigger options
  81228. * @param target defines the object containing the boolean
  81229. * @param propertyPath defines the path to the boolean property in the target object
  81230. * @param condition defines the trigger related conditions
  81231. */
  81232. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  81233. /** @hidden */
  81234. _prepare(): void;
  81235. /**
  81236. * Execute the action toggle the boolean value.
  81237. */
  81238. execute(): void;
  81239. /**
  81240. * Serializes the actions and its related information.
  81241. * @param parent defines the object to serialize in
  81242. * @returns the serialized object
  81243. */
  81244. serialize(parent: any): any;
  81245. }
  81246. /**
  81247. * This defines an action responsible to set a the state field of the target
  81248. * to a desired value once triggered.
  81249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81250. */
  81251. export class SetStateAction extends Action {
  81252. /**
  81253. * The value to store in the state field.
  81254. */
  81255. value: string;
  81256. private _target;
  81257. /**
  81258. * Instantiate the action
  81259. * @param triggerOptions defines the trigger options
  81260. * @param target defines the object containing the state property
  81261. * @param value defines the value to store in the state field
  81262. * @param condition defines the trigger related conditions
  81263. */
  81264. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  81265. /**
  81266. * Execute the action and store the value on the target state property.
  81267. */
  81268. execute(): void;
  81269. /**
  81270. * Serializes the actions and its related information.
  81271. * @param parent defines the object to serialize in
  81272. * @returns the serialized object
  81273. */
  81274. serialize(parent: any): any;
  81275. }
  81276. /**
  81277. * This defines an action responsible to set a property of the target
  81278. * to a desired value once triggered.
  81279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81280. */
  81281. export class SetValueAction extends Action {
  81282. /**
  81283. * The path of the property to set in the target.
  81284. */
  81285. propertyPath: string;
  81286. /**
  81287. * The value to set in the property
  81288. */
  81289. value: any;
  81290. private _target;
  81291. private _effectiveTarget;
  81292. private _property;
  81293. /**
  81294. * Instantiate the action
  81295. * @param triggerOptions defines the trigger options
  81296. * @param target defines the object containing the property
  81297. * @param propertyPath defines the path of the property to set in the target
  81298. * @param value defines the value to set in the property
  81299. * @param condition defines the trigger related conditions
  81300. */
  81301. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81302. /** @hidden */
  81303. _prepare(): void;
  81304. /**
  81305. * Execute the action and set the targetted property to the desired value.
  81306. */
  81307. execute(): void;
  81308. /**
  81309. * Serializes the actions and its related information.
  81310. * @param parent defines the object to serialize in
  81311. * @returns the serialized object
  81312. */
  81313. serialize(parent: any): any;
  81314. }
  81315. /**
  81316. * This defines an action responsible to increment the target value
  81317. * to a desired value once triggered.
  81318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81319. */
  81320. export class IncrementValueAction extends Action {
  81321. /**
  81322. * The path of the property to increment in the target.
  81323. */
  81324. propertyPath: string;
  81325. /**
  81326. * The value we should increment the property by.
  81327. */
  81328. value: any;
  81329. private _target;
  81330. private _effectiveTarget;
  81331. private _property;
  81332. /**
  81333. * Instantiate the action
  81334. * @param triggerOptions defines the trigger options
  81335. * @param target defines the object containing the property
  81336. * @param propertyPath defines the path of the property to increment in the target
  81337. * @param value defines the value value we should increment the property by
  81338. * @param condition defines the trigger related conditions
  81339. */
  81340. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81341. /** @hidden */
  81342. _prepare(): void;
  81343. /**
  81344. * Execute the action and increment the target of the value amount.
  81345. */
  81346. execute(): void;
  81347. /**
  81348. * Serializes the actions and its related information.
  81349. * @param parent defines the object to serialize in
  81350. * @returns the serialized object
  81351. */
  81352. serialize(parent: any): any;
  81353. }
  81354. /**
  81355. * This defines an action responsible to start an animation once triggered.
  81356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81357. */
  81358. export class PlayAnimationAction extends Action {
  81359. /**
  81360. * Where the animation should start (animation frame)
  81361. */
  81362. from: number;
  81363. /**
  81364. * Where the animation should stop (animation frame)
  81365. */
  81366. to: number;
  81367. /**
  81368. * Define if the animation should loop or stop after the first play.
  81369. */
  81370. loop?: boolean;
  81371. private _target;
  81372. /**
  81373. * Instantiate the action
  81374. * @param triggerOptions defines the trigger options
  81375. * @param target defines the target animation or animation name
  81376. * @param from defines from where the animation should start (animation frame)
  81377. * @param end defines where the animation should stop (animation frame)
  81378. * @param loop defines if the animation should loop or stop after the first play
  81379. * @param condition defines the trigger related conditions
  81380. */
  81381. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  81382. /** @hidden */
  81383. _prepare(): void;
  81384. /**
  81385. * Execute the action and play the animation.
  81386. */
  81387. execute(): void;
  81388. /**
  81389. * Serializes the actions and its related information.
  81390. * @param parent defines the object to serialize in
  81391. * @returns the serialized object
  81392. */
  81393. serialize(parent: any): any;
  81394. }
  81395. /**
  81396. * This defines an action responsible to stop an animation once triggered.
  81397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81398. */
  81399. export class StopAnimationAction extends Action {
  81400. private _target;
  81401. /**
  81402. * Instantiate the action
  81403. * @param triggerOptions defines the trigger options
  81404. * @param target defines the target animation or animation name
  81405. * @param condition defines the trigger related conditions
  81406. */
  81407. constructor(triggerOptions: any, target: any, condition?: Condition);
  81408. /** @hidden */
  81409. _prepare(): void;
  81410. /**
  81411. * Execute the action and stop the animation.
  81412. */
  81413. execute(): void;
  81414. /**
  81415. * Serializes the actions and its related information.
  81416. * @param parent defines the object to serialize in
  81417. * @returns the serialized object
  81418. */
  81419. serialize(parent: any): any;
  81420. }
  81421. /**
  81422. * This defines an action responsible that does nothing once triggered.
  81423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81424. */
  81425. export class DoNothingAction extends Action {
  81426. /**
  81427. * Instantiate the action
  81428. * @param triggerOptions defines the trigger options
  81429. * @param condition defines the trigger related conditions
  81430. */
  81431. constructor(triggerOptions?: any, condition?: Condition);
  81432. /**
  81433. * Execute the action and do nothing.
  81434. */
  81435. execute(): void;
  81436. /**
  81437. * Serializes the actions and its related information.
  81438. * @param parent defines the object to serialize in
  81439. * @returns the serialized object
  81440. */
  81441. serialize(parent: any): any;
  81442. }
  81443. /**
  81444. * This defines an action responsible to trigger several actions once triggered.
  81445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81446. */
  81447. export class CombineAction extends Action {
  81448. /**
  81449. * The list of aggregated animations to run.
  81450. */
  81451. children: Action[];
  81452. /**
  81453. * Instantiate the action
  81454. * @param triggerOptions defines the trigger options
  81455. * @param children defines the list of aggregated animations to run
  81456. * @param condition defines the trigger related conditions
  81457. */
  81458. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  81459. /** @hidden */
  81460. _prepare(): void;
  81461. /**
  81462. * Execute the action and executes all the aggregated actions.
  81463. */
  81464. execute(evt: ActionEvent): void;
  81465. /**
  81466. * Serializes the actions and its related information.
  81467. * @param parent defines the object to serialize in
  81468. * @returns the serialized object
  81469. */
  81470. serialize(parent: any): any;
  81471. }
  81472. /**
  81473. * This defines an action responsible to run code (external event) once triggered.
  81474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81475. */
  81476. export class ExecuteCodeAction extends Action {
  81477. /**
  81478. * The callback function to run.
  81479. */
  81480. func: (evt: ActionEvent) => void;
  81481. /**
  81482. * Instantiate the action
  81483. * @param triggerOptions defines the trigger options
  81484. * @param func defines the callback function to run
  81485. * @param condition defines the trigger related conditions
  81486. */
  81487. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  81488. /**
  81489. * Execute the action and run the attached code.
  81490. */
  81491. execute(evt: ActionEvent): void;
  81492. }
  81493. /**
  81494. * This defines an action responsible to set the parent property of the target once triggered.
  81495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81496. */
  81497. export class SetParentAction extends Action {
  81498. private _parent;
  81499. private _target;
  81500. /**
  81501. * Instantiate the action
  81502. * @param triggerOptions defines the trigger options
  81503. * @param target defines the target containing the parent property
  81504. * @param parent defines from where the animation should start (animation frame)
  81505. * @param condition defines the trigger related conditions
  81506. */
  81507. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  81508. /** @hidden */
  81509. _prepare(): void;
  81510. /**
  81511. * Execute the action and set the parent property.
  81512. */
  81513. execute(): void;
  81514. /**
  81515. * Serializes the actions and its related information.
  81516. * @param parent defines the object to serialize in
  81517. * @returns the serialized object
  81518. */
  81519. serialize(parent: any): any;
  81520. }
  81521. }
  81522. declare module BABYLON {
  81523. /**
  81524. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  81525. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  81526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81527. */
  81528. export class ActionManager extends AbstractActionManager {
  81529. /**
  81530. * Nothing
  81531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81532. */
  81533. static readonly NothingTrigger: number;
  81534. /**
  81535. * On pick
  81536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81537. */
  81538. static readonly OnPickTrigger: number;
  81539. /**
  81540. * On left pick
  81541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81542. */
  81543. static readonly OnLeftPickTrigger: number;
  81544. /**
  81545. * On right pick
  81546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81547. */
  81548. static readonly OnRightPickTrigger: number;
  81549. /**
  81550. * On center pick
  81551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81552. */
  81553. static readonly OnCenterPickTrigger: number;
  81554. /**
  81555. * On pick down
  81556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81557. */
  81558. static readonly OnPickDownTrigger: number;
  81559. /**
  81560. * On double pick
  81561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81562. */
  81563. static readonly OnDoublePickTrigger: number;
  81564. /**
  81565. * On pick up
  81566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81567. */
  81568. static readonly OnPickUpTrigger: number;
  81569. /**
  81570. * On pick out.
  81571. * This trigger will only be raised if you also declared a OnPickDown
  81572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81573. */
  81574. static readonly OnPickOutTrigger: number;
  81575. /**
  81576. * On long press
  81577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81578. */
  81579. static readonly OnLongPressTrigger: number;
  81580. /**
  81581. * On pointer over
  81582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81583. */
  81584. static readonly OnPointerOverTrigger: number;
  81585. /**
  81586. * On pointer out
  81587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81588. */
  81589. static readonly OnPointerOutTrigger: number;
  81590. /**
  81591. * On every frame
  81592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81593. */
  81594. static readonly OnEveryFrameTrigger: number;
  81595. /**
  81596. * On intersection enter
  81597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81598. */
  81599. static readonly OnIntersectionEnterTrigger: number;
  81600. /**
  81601. * On intersection exit
  81602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81603. */
  81604. static readonly OnIntersectionExitTrigger: number;
  81605. /**
  81606. * On key down
  81607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81608. */
  81609. static readonly OnKeyDownTrigger: number;
  81610. /**
  81611. * On key up
  81612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81613. */
  81614. static readonly OnKeyUpTrigger: number;
  81615. private _scene;
  81616. /**
  81617. * Creates a new action manager
  81618. * @param scene defines the hosting scene
  81619. */
  81620. constructor(scene: Scene);
  81621. /**
  81622. * Releases all associated resources
  81623. */
  81624. dispose(): void;
  81625. /**
  81626. * Gets hosting scene
  81627. * @returns the hosting scene
  81628. */
  81629. getScene(): Scene;
  81630. /**
  81631. * Does this action manager handles actions of any of the given triggers
  81632. * @param triggers defines the triggers to be tested
  81633. * @return a boolean indicating whether one (or more) of the triggers is handled
  81634. */
  81635. hasSpecificTriggers(triggers: number[]): boolean;
  81636. /**
  81637. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81638. * speed.
  81639. * @param triggerA defines the trigger to be tested
  81640. * @param triggerB defines the trigger to be tested
  81641. * @return a boolean indicating whether one (or more) of the triggers is handled
  81642. */
  81643. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81644. /**
  81645. * Does this action manager handles actions of a given trigger
  81646. * @param trigger defines the trigger to be tested
  81647. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81648. * @return whether the trigger is handled
  81649. */
  81650. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81651. /**
  81652. * Does this action manager has pointer triggers
  81653. */
  81654. get hasPointerTriggers(): boolean;
  81655. /**
  81656. * Does this action manager has pick triggers
  81657. */
  81658. get hasPickTriggers(): boolean;
  81659. /**
  81660. * Registers an action to this action manager
  81661. * @param action defines the action to be registered
  81662. * @return the action amended (prepared) after registration
  81663. */
  81664. registerAction(action: IAction): Nullable<IAction>;
  81665. /**
  81666. * Unregisters an action to this action manager
  81667. * @param action defines the action to be unregistered
  81668. * @return a boolean indicating whether the action has been unregistered
  81669. */
  81670. unregisterAction(action: IAction): Boolean;
  81671. /**
  81672. * Process a specific trigger
  81673. * @param trigger defines the trigger to process
  81674. * @param evt defines the event details to be processed
  81675. */
  81676. processTrigger(trigger: number, evt?: IActionEvent): void;
  81677. /** @hidden */
  81678. _getEffectiveTarget(target: any, propertyPath: string): any;
  81679. /** @hidden */
  81680. _getProperty(propertyPath: string): string;
  81681. /**
  81682. * Serialize this manager to a JSON object
  81683. * @param name defines the property name to store this manager
  81684. * @returns a JSON representation of this manager
  81685. */
  81686. serialize(name: string): any;
  81687. /**
  81688. * Creates a new ActionManager from a JSON data
  81689. * @param parsedActions defines the JSON data to read from
  81690. * @param object defines the hosting mesh
  81691. * @param scene defines the hosting scene
  81692. */
  81693. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  81694. /**
  81695. * Get a trigger name by index
  81696. * @param trigger defines the trigger index
  81697. * @returns a trigger name
  81698. */
  81699. static GetTriggerName(trigger: number): string;
  81700. }
  81701. }
  81702. declare module BABYLON {
  81703. /**
  81704. * Class representing a ray with position and direction
  81705. */
  81706. export class Ray {
  81707. /** origin point */
  81708. origin: Vector3;
  81709. /** direction */
  81710. direction: Vector3;
  81711. /** length of the ray */
  81712. length: number;
  81713. private static readonly TmpVector3;
  81714. private _tmpRay;
  81715. /**
  81716. * Creates a new ray
  81717. * @param origin origin point
  81718. * @param direction direction
  81719. * @param length length of the ray
  81720. */
  81721. constructor(
  81722. /** origin point */
  81723. origin: Vector3,
  81724. /** direction */
  81725. direction: Vector3,
  81726. /** length of the ray */
  81727. length?: number);
  81728. /**
  81729. * Checks if the ray intersects a box
  81730. * @param minimum bound of the box
  81731. * @param maximum bound of the box
  81732. * @param intersectionTreshold extra extend to be added to the box in all direction
  81733. * @returns if the box was hit
  81734. */
  81735. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  81736. /**
  81737. * Checks if the ray intersects a box
  81738. * @param box the bounding box to check
  81739. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  81740. * @returns if the box was hit
  81741. */
  81742. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  81743. /**
  81744. * If the ray hits a sphere
  81745. * @param sphere the bounding sphere to check
  81746. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  81747. * @returns true if it hits the sphere
  81748. */
  81749. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  81750. /**
  81751. * If the ray hits a triange
  81752. * @param vertex0 triangle vertex
  81753. * @param vertex1 triangle vertex
  81754. * @param vertex2 triangle vertex
  81755. * @returns intersection information if hit
  81756. */
  81757. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  81758. /**
  81759. * Checks if ray intersects a plane
  81760. * @param plane the plane to check
  81761. * @returns the distance away it was hit
  81762. */
  81763. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  81764. /**
  81765. * Calculate the intercept of a ray on a given axis
  81766. * @param axis to check 'x' | 'y' | 'z'
  81767. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  81768. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  81769. */
  81770. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  81771. /**
  81772. * Checks if ray intersects a mesh
  81773. * @param mesh the mesh to check
  81774. * @param fastCheck if only the bounding box should checked
  81775. * @returns picking info of the intersecton
  81776. */
  81777. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  81778. /**
  81779. * Checks if ray intersects a mesh
  81780. * @param meshes the meshes to check
  81781. * @param fastCheck if only the bounding box should checked
  81782. * @param results array to store result in
  81783. * @returns Array of picking infos
  81784. */
  81785. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  81786. private _comparePickingInfo;
  81787. private static smallnum;
  81788. private static rayl;
  81789. /**
  81790. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  81791. * @param sega the first point of the segment to test the intersection against
  81792. * @param segb the second point of the segment to test the intersection against
  81793. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  81794. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  81795. */
  81796. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  81797. /**
  81798. * Update the ray from viewport position
  81799. * @param x position
  81800. * @param y y position
  81801. * @param viewportWidth viewport width
  81802. * @param viewportHeight viewport height
  81803. * @param world world matrix
  81804. * @param view view matrix
  81805. * @param projection projection matrix
  81806. * @returns this ray updated
  81807. */
  81808. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81809. /**
  81810. * Creates a ray with origin and direction of 0,0,0
  81811. * @returns the new ray
  81812. */
  81813. static Zero(): Ray;
  81814. /**
  81815. * Creates a new ray from screen space and viewport
  81816. * @param x position
  81817. * @param y y position
  81818. * @param viewportWidth viewport width
  81819. * @param viewportHeight viewport height
  81820. * @param world world matrix
  81821. * @param view view matrix
  81822. * @param projection projection matrix
  81823. * @returns new ray
  81824. */
  81825. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81826. /**
  81827. * 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
  81828. * transformed to the given world matrix.
  81829. * @param origin The origin point
  81830. * @param end The end point
  81831. * @param world a matrix to transform the ray to. Default is the identity matrix.
  81832. * @returns the new ray
  81833. */
  81834. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  81835. /**
  81836. * Transforms a ray by a matrix
  81837. * @param ray ray to transform
  81838. * @param matrix matrix to apply
  81839. * @returns the resulting new ray
  81840. */
  81841. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  81842. /**
  81843. * Transforms a ray by a matrix
  81844. * @param ray ray to transform
  81845. * @param matrix matrix to apply
  81846. * @param result ray to store result in
  81847. */
  81848. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  81849. /**
  81850. * Unproject a ray from screen space to object space
  81851. * @param sourceX defines the screen space x coordinate to use
  81852. * @param sourceY defines the screen space y coordinate to use
  81853. * @param viewportWidth defines the current width of the viewport
  81854. * @param viewportHeight defines the current height of the viewport
  81855. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81856. * @param view defines the view matrix to use
  81857. * @param projection defines the projection matrix to use
  81858. */
  81859. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  81860. }
  81861. /**
  81862. * Type used to define predicate used to select faces when a mesh intersection is detected
  81863. */
  81864. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  81865. interface Scene {
  81866. /** @hidden */
  81867. _tempPickingRay: Nullable<Ray>;
  81868. /** @hidden */
  81869. _cachedRayForTransform: Ray;
  81870. /** @hidden */
  81871. _pickWithRayInverseMatrix: Matrix;
  81872. /** @hidden */
  81873. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  81874. /** @hidden */
  81875. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  81876. }
  81877. }
  81878. declare module BABYLON {
  81879. /**
  81880. * Groups all the scene component constants in one place to ease maintenance.
  81881. * @hidden
  81882. */
  81883. export class SceneComponentConstants {
  81884. static readonly NAME_EFFECTLAYER: string;
  81885. static readonly NAME_LAYER: string;
  81886. static readonly NAME_LENSFLARESYSTEM: string;
  81887. static readonly NAME_BOUNDINGBOXRENDERER: string;
  81888. static readonly NAME_PARTICLESYSTEM: string;
  81889. static readonly NAME_GAMEPAD: string;
  81890. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  81891. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  81892. static readonly NAME_DEPTHRENDERER: string;
  81893. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  81894. static readonly NAME_SPRITE: string;
  81895. static readonly NAME_OUTLINERENDERER: string;
  81896. static readonly NAME_PROCEDURALTEXTURE: string;
  81897. static readonly NAME_SHADOWGENERATOR: string;
  81898. static readonly NAME_OCTREE: string;
  81899. static readonly NAME_PHYSICSENGINE: string;
  81900. static readonly NAME_AUDIO: string;
  81901. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  81902. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81903. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  81904. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81905. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  81906. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  81907. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  81908. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  81909. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  81910. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  81911. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  81912. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  81913. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  81914. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  81915. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  81916. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  81917. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  81918. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  81919. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  81920. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  81921. static readonly STEP_AFTERRENDER_AUDIO: number;
  81922. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  81923. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  81924. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  81925. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  81926. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  81927. static readonly STEP_POINTERMOVE_SPRITE: number;
  81928. static readonly STEP_POINTERDOWN_SPRITE: number;
  81929. static readonly STEP_POINTERUP_SPRITE: number;
  81930. }
  81931. /**
  81932. * This represents a scene component.
  81933. *
  81934. * This is used to decouple the dependency the scene is having on the different workloads like
  81935. * layers, post processes...
  81936. */
  81937. export interface ISceneComponent {
  81938. /**
  81939. * The name of the component. Each component must have a unique name.
  81940. */
  81941. name: string;
  81942. /**
  81943. * The scene the component belongs to.
  81944. */
  81945. scene: Scene;
  81946. /**
  81947. * Register the component to one instance of a scene.
  81948. */
  81949. register(): void;
  81950. /**
  81951. * Rebuilds the elements related to this component in case of
  81952. * context lost for instance.
  81953. */
  81954. rebuild(): void;
  81955. /**
  81956. * Disposes the component and the associated ressources.
  81957. */
  81958. dispose(): void;
  81959. }
  81960. /**
  81961. * This represents a SERIALIZABLE scene component.
  81962. *
  81963. * This extends Scene Component to add Serialization methods on top.
  81964. */
  81965. export interface ISceneSerializableComponent extends ISceneComponent {
  81966. /**
  81967. * Adds all the elements from the container to the scene
  81968. * @param container the container holding the elements
  81969. */
  81970. addFromContainer(container: AbstractScene): void;
  81971. /**
  81972. * Removes all the elements in the container from the scene
  81973. * @param container contains the elements to remove
  81974. * @param dispose if the removed element should be disposed (default: false)
  81975. */
  81976. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  81977. /**
  81978. * Serializes the component data to the specified json object
  81979. * @param serializationObject The object to serialize to
  81980. */
  81981. serialize(serializationObject: any): void;
  81982. }
  81983. /**
  81984. * Strong typing of a Mesh related stage step action
  81985. */
  81986. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  81987. /**
  81988. * Strong typing of a Evaluate Sub Mesh related stage step action
  81989. */
  81990. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  81991. /**
  81992. * Strong typing of a Active Mesh related stage step action
  81993. */
  81994. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  81995. /**
  81996. * Strong typing of a Camera related stage step action
  81997. */
  81998. export type CameraStageAction = (camera: Camera) => void;
  81999. /**
  82000. * Strong typing of a Camera Frame buffer related stage step action
  82001. */
  82002. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82003. /**
  82004. * Strong typing of a Render Target related stage step action
  82005. */
  82006. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82007. /**
  82008. * Strong typing of a RenderingGroup related stage step action
  82009. */
  82010. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82011. /**
  82012. * Strong typing of a Mesh Render related stage step action
  82013. */
  82014. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82015. /**
  82016. * Strong typing of a simple stage step action
  82017. */
  82018. export type SimpleStageAction = () => void;
  82019. /**
  82020. * Strong typing of a render target action.
  82021. */
  82022. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82023. /**
  82024. * Strong typing of a pointer move action.
  82025. */
  82026. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82027. /**
  82028. * Strong typing of a pointer up/down action.
  82029. */
  82030. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82031. /**
  82032. * Representation of a stage in the scene (Basically a list of ordered steps)
  82033. * @hidden
  82034. */
  82035. export class Stage<T extends Function> extends Array<{
  82036. index: number;
  82037. component: ISceneComponent;
  82038. action: T;
  82039. }> {
  82040. /**
  82041. * Hide ctor from the rest of the world.
  82042. * @param items The items to add.
  82043. */
  82044. private constructor();
  82045. /**
  82046. * Creates a new Stage.
  82047. * @returns A new instance of a Stage
  82048. */
  82049. static Create<T extends Function>(): Stage<T>;
  82050. /**
  82051. * Registers a step in an ordered way in the targeted stage.
  82052. * @param index Defines the position to register the step in
  82053. * @param component Defines the component attached to the step
  82054. * @param action Defines the action to launch during the step
  82055. */
  82056. registerStep(index: number, component: ISceneComponent, action: T): void;
  82057. /**
  82058. * Clears all the steps from the stage.
  82059. */
  82060. clear(): void;
  82061. }
  82062. }
  82063. declare module BABYLON {
  82064. interface Scene {
  82065. /** @hidden */
  82066. _pointerOverSprite: Nullable<Sprite>;
  82067. /** @hidden */
  82068. _pickedDownSprite: Nullable<Sprite>;
  82069. /** @hidden */
  82070. _tempSpritePickingRay: Nullable<Ray>;
  82071. /**
  82072. * All of the sprite managers added to this scene
  82073. * @see http://doc.babylonjs.com/babylon101/sprites
  82074. */
  82075. spriteManagers: Array<ISpriteManager>;
  82076. /**
  82077. * An event triggered when sprites rendering is about to start
  82078. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82079. */
  82080. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82081. /**
  82082. * An event triggered when sprites rendering is done
  82083. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82084. */
  82085. onAfterSpritesRenderingObservable: Observable<Scene>;
  82086. /** @hidden */
  82087. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82088. /** Launch a ray to try to pick a sprite in the scene
  82089. * @param x position on screen
  82090. * @param y position on screen
  82091. * @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
  82092. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82093. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82094. * @returns a PickingInfo
  82095. */
  82096. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82097. /** Use the given ray to pick a sprite in the scene
  82098. * @param ray The ray (in world space) to use to pick meshes
  82099. * @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
  82100. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82101. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82102. * @returns a PickingInfo
  82103. */
  82104. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82105. /** @hidden */
  82106. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82107. /** Launch a ray to try to pick sprites in the scene
  82108. * @param x position on screen
  82109. * @param y position on screen
  82110. * @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
  82111. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82112. * @returns a PickingInfo array
  82113. */
  82114. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82115. /** Use the given ray to pick sprites in the scene
  82116. * @param ray The ray (in world space) to use to pick meshes
  82117. * @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
  82118. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82119. * @returns a PickingInfo array
  82120. */
  82121. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82122. /**
  82123. * Force the sprite under the pointer
  82124. * @param sprite defines the sprite to use
  82125. */
  82126. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82127. /**
  82128. * Gets the sprite under the pointer
  82129. * @returns a Sprite or null if no sprite is under the pointer
  82130. */
  82131. getPointerOverSprite(): Nullable<Sprite>;
  82132. }
  82133. /**
  82134. * Defines the sprite scene component responsible to manage sprites
  82135. * in a given scene.
  82136. */
  82137. export class SpriteSceneComponent implements ISceneComponent {
  82138. /**
  82139. * The component name helpfull to identify the component in the list of scene components.
  82140. */
  82141. readonly name: string;
  82142. /**
  82143. * The scene the component belongs to.
  82144. */
  82145. scene: Scene;
  82146. /** @hidden */
  82147. private _spritePredicate;
  82148. /**
  82149. * Creates a new instance of the component for the given scene
  82150. * @param scene Defines the scene to register the component in
  82151. */
  82152. constructor(scene: Scene);
  82153. /**
  82154. * Registers the component in a given scene
  82155. */
  82156. register(): void;
  82157. /**
  82158. * Rebuilds the elements related to this component in case of
  82159. * context lost for instance.
  82160. */
  82161. rebuild(): void;
  82162. /**
  82163. * Disposes the component and the associated ressources.
  82164. */
  82165. dispose(): void;
  82166. private _pickSpriteButKeepRay;
  82167. private _pointerMove;
  82168. private _pointerDown;
  82169. private _pointerUp;
  82170. }
  82171. }
  82172. declare module BABYLON {
  82173. /** @hidden */
  82174. export var fogFragmentDeclaration: {
  82175. name: string;
  82176. shader: string;
  82177. };
  82178. }
  82179. declare module BABYLON {
  82180. /** @hidden */
  82181. export var fogFragment: {
  82182. name: string;
  82183. shader: string;
  82184. };
  82185. }
  82186. declare module BABYLON {
  82187. /** @hidden */
  82188. export var spritesPixelShader: {
  82189. name: string;
  82190. shader: string;
  82191. };
  82192. }
  82193. declare module BABYLON {
  82194. /** @hidden */
  82195. export var fogVertexDeclaration: {
  82196. name: string;
  82197. shader: string;
  82198. };
  82199. }
  82200. declare module BABYLON {
  82201. /** @hidden */
  82202. export var spritesVertexShader: {
  82203. name: string;
  82204. shader: string;
  82205. };
  82206. }
  82207. declare module BABYLON {
  82208. /**
  82209. * Defines the minimum interface to fullfil in order to be a sprite manager.
  82210. */
  82211. export interface ISpriteManager extends IDisposable {
  82212. /**
  82213. * Restricts the camera to viewing objects with the same layerMask.
  82214. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  82215. */
  82216. layerMask: number;
  82217. /**
  82218. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82219. */
  82220. isPickable: boolean;
  82221. /**
  82222. * Specifies the rendering group id for this mesh (0 by default)
  82223. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82224. */
  82225. renderingGroupId: number;
  82226. /**
  82227. * Defines the list of sprites managed by the manager.
  82228. */
  82229. sprites: Array<Sprite>;
  82230. /**
  82231. * Tests the intersection of a sprite with a specific ray.
  82232. * @param ray The ray we are sending to test the collision
  82233. * @param camera The camera space we are sending rays in
  82234. * @param predicate A predicate allowing excluding sprites from the list of object to test
  82235. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  82236. * @returns picking info or null.
  82237. */
  82238. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82239. /**
  82240. * Intersects the sprites with a ray
  82241. * @param ray defines the ray to intersect with
  82242. * @param camera defines the current active camera
  82243. * @param predicate defines a predicate used to select candidate sprites
  82244. * @returns null if no hit or a PickingInfo array
  82245. */
  82246. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82247. /**
  82248. * Renders the list of sprites on screen.
  82249. */
  82250. render(): void;
  82251. }
  82252. /**
  82253. * Class used to manage multiple sprites on the same spritesheet
  82254. * @see http://doc.babylonjs.com/babylon101/sprites
  82255. */
  82256. export class SpriteManager implements ISpriteManager {
  82257. /** defines the manager's name */
  82258. name: string;
  82259. /** Gets the list of sprites */
  82260. sprites: Sprite[];
  82261. /** Gets or sets the rendering group id (0 by default) */
  82262. renderingGroupId: number;
  82263. /** Gets or sets camera layer mask */
  82264. layerMask: number;
  82265. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  82266. fogEnabled: boolean;
  82267. /** Gets or sets a boolean indicating if the sprites are pickable */
  82268. isPickable: boolean;
  82269. /** Defines the default width of a cell in the spritesheet */
  82270. cellWidth: number;
  82271. /** Defines the default height of a cell in the spritesheet */
  82272. cellHeight: number;
  82273. /** Associative array from JSON sprite data file */
  82274. private _cellData;
  82275. /** Array of sprite names from JSON sprite data file */
  82276. private _spriteMap;
  82277. /** True when packed cell data from JSON file is ready*/
  82278. private _packedAndReady;
  82279. /**
  82280. * An event triggered when the manager is disposed.
  82281. */
  82282. onDisposeObservable: Observable<SpriteManager>;
  82283. private _onDisposeObserver;
  82284. /**
  82285. * Callback called when the manager is disposed
  82286. */
  82287. set onDispose(callback: () => void);
  82288. private _capacity;
  82289. private _fromPacked;
  82290. private _spriteTexture;
  82291. private _epsilon;
  82292. private _scene;
  82293. private _vertexData;
  82294. private _buffer;
  82295. private _vertexBuffers;
  82296. private _indexBuffer;
  82297. private _effectBase;
  82298. private _effectFog;
  82299. /**
  82300. * Gets or sets the spritesheet texture
  82301. */
  82302. get texture(): Texture;
  82303. set texture(value: Texture);
  82304. /**
  82305. * Creates a new sprite manager
  82306. * @param name defines the manager's name
  82307. * @param imgUrl defines the sprite sheet url
  82308. * @param capacity defines the maximum allowed number of sprites
  82309. * @param cellSize defines the size of a sprite cell
  82310. * @param scene defines the hosting scene
  82311. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  82312. * @param samplingMode defines the smapling mode to use with spritesheet
  82313. * @param fromPacked set to false; do not alter
  82314. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  82315. */
  82316. constructor(
  82317. /** defines the manager's name */
  82318. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  82319. private _makePacked;
  82320. private _appendSpriteVertex;
  82321. /**
  82322. * Intersects the sprites with a ray
  82323. * @param ray defines the ray to intersect with
  82324. * @param camera defines the current active camera
  82325. * @param predicate defines a predicate used to select candidate sprites
  82326. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  82327. * @returns null if no hit or a PickingInfo
  82328. */
  82329. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82330. /**
  82331. * Intersects the sprites with a ray
  82332. * @param ray defines the ray to intersect with
  82333. * @param camera defines the current active camera
  82334. * @param predicate defines a predicate used to select candidate sprites
  82335. * @returns null if no hit or a PickingInfo array
  82336. */
  82337. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82338. /**
  82339. * Render all child sprites
  82340. */
  82341. render(): void;
  82342. /**
  82343. * Release associated resources
  82344. */
  82345. dispose(): void;
  82346. }
  82347. }
  82348. declare module BABYLON {
  82349. /**
  82350. * Class used to represent a sprite
  82351. * @see http://doc.babylonjs.com/babylon101/sprites
  82352. */
  82353. export class Sprite {
  82354. /** defines the name */
  82355. name: string;
  82356. /** Gets or sets the current world position */
  82357. position: Vector3;
  82358. /** Gets or sets the main color */
  82359. color: Color4;
  82360. /** Gets or sets the width */
  82361. width: number;
  82362. /** Gets or sets the height */
  82363. height: number;
  82364. /** Gets or sets rotation angle */
  82365. angle: number;
  82366. /** Gets or sets the cell index in the sprite sheet */
  82367. cellIndex: number;
  82368. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  82369. cellRef: string;
  82370. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  82371. invertU: number;
  82372. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  82373. invertV: number;
  82374. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  82375. disposeWhenFinishedAnimating: boolean;
  82376. /** Gets the list of attached animations */
  82377. animations: Animation[];
  82378. /** Gets or sets a boolean indicating if the sprite can be picked */
  82379. isPickable: boolean;
  82380. /**
  82381. * Gets or sets the associated action manager
  82382. */
  82383. actionManager: Nullable<ActionManager>;
  82384. private _animationStarted;
  82385. private _loopAnimation;
  82386. private _fromIndex;
  82387. private _toIndex;
  82388. private _delay;
  82389. private _direction;
  82390. private _manager;
  82391. private _time;
  82392. private _onAnimationEnd;
  82393. /**
  82394. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  82395. */
  82396. isVisible: boolean;
  82397. /**
  82398. * Gets or sets the sprite size
  82399. */
  82400. get size(): number;
  82401. set size(value: number);
  82402. /**
  82403. * Creates a new Sprite
  82404. * @param name defines the name
  82405. * @param manager defines the manager
  82406. */
  82407. constructor(
  82408. /** defines the name */
  82409. name: string, manager: ISpriteManager);
  82410. /**
  82411. * Starts an animation
  82412. * @param from defines the initial key
  82413. * @param to defines the end key
  82414. * @param loop defines if the animation must loop
  82415. * @param delay defines the start delay (in ms)
  82416. * @param onAnimationEnd defines a callback to call when animation ends
  82417. */
  82418. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  82419. /** Stops current animation (if any) */
  82420. stopAnimation(): void;
  82421. /** @hidden */
  82422. _animate(deltaTime: number): void;
  82423. /** Release associated resources */
  82424. dispose(): void;
  82425. }
  82426. }
  82427. declare module BABYLON {
  82428. /**
  82429. * Information about the result of picking within a scene
  82430. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  82431. */
  82432. export class PickingInfo {
  82433. /** @hidden */
  82434. _pickingUnavailable: boolean;
  82435. /**
  82436. * If the pick collided with an object
  82437. */
  82438. hit: boolean;
  82439. /**
  82440. * Distance away where the pick collided
  82441. */
  82442. distance: number;
  82443. /**
  82444. * The location of pick collision
  82445. */
  82446. pickedPoint: Nullable<Vector3>;
  82447. /**
  82448. * The mesh corresponding the the pick collision
  82449. */
  82450. pickedMesh: Nullable<AbstractMesh>;
  82451. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  82452. bu: number;
  82453. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  82454. bv: number;
  82455. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  82456. faceId: number;
  82457. /** Id of the the submesh that was picked */
  82458. subMeshId: number;
  82459. /** If a sprite was picked, this will be the sprite the pick collided with */
  82460. pickedSprite: Nullable<Sprite>;
  82461. /**
  82462. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  82463. */
  82464. originMesh: Nullable<AbstractMesh>;
  82465. /**
  82466. * The ray that was used to perform the picking.
  82467. */
  82468. ray: Nullable<Ray>;
  82469. /**
  82470. * Gets the normal correspodning to the face the pick collided with
  82471. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  82472. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  82473. * @returns The normal correspodning to the face the pick collided with
  82474. */
  82475. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  82476. /**
  82477. * Gets the texture coordinates of where the pick occured
  82478. * @returns the vector containing the coordnates of the texture
  82479. */
  82480. getTextureCoordinates(): Nullable<Vector2>;
  82481. }
  82482. }
  82483. declare module BABYLON {
  82484. /**
  82485. * Gather the list of pointer event types as constants.
  82486. */
  82487. export class PointerEventTypes {
  82488. /**
  82489. * 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.
  82490. */
  82491. static readonly POINTERDOWN: number;
  82492. /**
  82493. * The pointerup event is fired when a pointer is no longer active.
  82494. */
  82495. static readonly POINTERUP: number;
  82496. /**
  82497. * The pointermove event is fired when a pointer changes coordinates.
  82498. */
  82499. static readonly POINTERMOVE: number;
  82500. /**
  82501. * The pointerwheel event is fired when a mouse wheel has been rotated.
  82502. */
  82503. static readonly POINTERWHEEL: number;
  82504. /**
  82505. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  82506. */
  82507. static readonly POINTERPICK: number;
  82508. /**
  82509. * The pointertap event is fired when a the object has been touched and released without drag.
  82510. */
  82511. static readonly POINTERTAP: number;
  82512. /**
  82513. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  82514. */
  82515. static readonly POINTERDOUBLETAP: number;
  82516. }
  82517. /**
  82518. * Base class of pointer info types.
  82519. */
  82520. export class PointerInfoBase {
  82521. /**
  82522. * Defines the type of event (PointerEventTypes)
  82523. */
  82524. type: number;
  82525. /**
  82526. * Defines the related dom event
  82527. */
  82528. event: PointerEvent | MouseWheelEvent;
  82529. /**
  82530. * Instantiates the base class of pointers info.
  82531. * @param type Defines the type of event (PointerEventTypes)
  82532. * @param event Defines the related dom event
  82533. */
  82534. constructor(
  82535. /**
  82536. * Defines the type of event (PointerEventTypes)
  82537. */
  82538. type: number,
  82539. /**
  82540. * Defines the related dom event
  82541. */
  82542. event: PointerEvent | MouseWheelEvent);
  82543. }
  82544. /**
  82545. * This class is used to store pointer related info for the onPrePointerObservable event.
  82546. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  82547. */
  82548. export class PointerInfoPre extends PointerInfoBase {
  82549. /**
  82550. * Ray from a pointer if availible (eg. 6dof controller)
  82551. */
  82552. ray: Nullable<Ray>;
  82553. /**
  82554. * Defines the local position of the pointer on the canvas.
  82555. */
  82556. localPosition: Vector2;
  82557. /**
  82558. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  82559. */
  82560. skipOnPointerObservable: boolean;
  82561. /**
  82562. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  82563. * @param type Defines the type of event (PointerEventTypes)
  82564. * @param event Defines the related dom event
  82565. * @param localX Defines the local x coordinates of the pointer when the event occured
  82566. * @param localY Defines the local y coordinates of the pointer when the event occured
  82567. */
  82568. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  82569. }
  82570. /**
  82571. * This type contains all the data related to a pointer event in Babylon.js.
  82572. * 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.
  82573. */
  82574. export class PointerInfo extends PointerInfoBase {
  82575. /**
  82576. * Defines the picking info associated to the info (if any)\
  82577. */
  82578. pickInfo: Nullable<PickingInfo>;
  82579. /**
  82580. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  82581. * @param type Defines the type of event (PointerEventTypes)
  82582. * @param event Defines the related dom event
  82583. * @param pickInfo Defines the picking info associated to the info (if any)\
  82584. */
  82585. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  82586. /**
  82587. * Defines the picking info associated to the info (if any)\
  82588. */
  82589. pickInfo: Nullable<PickingInfo>);
  82590. }
  82591. /**
  82592. * Data relating to a touch event on the screen.
  82593. */
  82594. export interface PointerTouch {
  82595. /**
  82596. * X coordinate of touch.
  82597. */
  82598. x: number;
  82599. /**
  82600. * Y coordinate of touch.
  82601. */
  82602. y: number;
  82603. /**
  82604. * Id of touch. Unique for each finger.
  82605. */
  82606. pointerId: number;
  82607. /**
  82608. * Event type passed from DOM.
  82609. */
  82610. type: any;
  82611. }
  82612. }
  82613. declare module BABYLON {
  82614. /**
  82615. * Manage the mouse inputs to control the movement of a free camera.
  82616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82617. */
  82618. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  82619. /**
  82620. * Define if touch is enabled in the mouse input
  82621. */
  82622. touchEnabled: boolean;
  82623. /**
  82624. * Defines the camera the input is attached to.
  82625. */
  82626. camera: FreeCamera;
  82627. /**
  82628. * Defines the buttons associated with the input to handle camera move.
  82629. */
  82630. buttons: number[];
  82631. /**
  82632. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  82633. */
  82634. angularSensibility: number;
  82635. private _pointerInput;
  82636. private _onMouseMove;
  82637. private _observer;
  82638. private previousPosition;
  82639. /**
  82640. * Observable for when a pointer move event occurs containing the move offset
  82641. */
  82642. onPointerMovedObservable: Observable<{
  82643. offsetX: number;
  82644. offsetY: number;
  82645. }>;
  82646. /**
  82647. * @hidden
  82648. * If the camera should be rotated automatically based on pointer movement
  82649. */
  82650. _allowCameraRotation: boolean;
  82651. /**
  82652. * Manage the mouse inputs to control the movement of a free camera.
  82653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82654. * @param touchEnabled Defines if touch is enabled or not
  82655. */
  82656. constructor(
  82657. /**
  82658. * Define if touch is enabled in the mouse input
  82659. */
  82660. touchEnabled?: boolean);
  82661. /**
  82662. * Attach the input controls to a specific dom element to get the input from.
  82663. * @param element Defines the element the controls should be listened from
  82664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82665. */
  82666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82667. /**
  82668. * Called on JS contextmenu event.
  82669. * Override this method to provide functionality.
  82670. */
  82671. protected onContextMenu(evt: PointerEvent): void;
  82672. /**
  82673. * Detach the current controls from the specified dom element.
  82674. * @param element Defines the element to stop listening the inputs from
  82675. */
  82676. detachControl(element: Nullable<HTMLElement>): void;
  82677. /**
  82678. * Gets the class name of the current intput.
  82679. * @returns the class name
  82680. */
  82681. getClassName(): string;
  82682. /**
  82683. * Get the friendly name associated with the input class.
  82684. * @returns the input friendly name
  82685. */
  82686. getSimpleName(): string;
  82687. }
  82688. }
  82689. declare module BABYLON {
  82690. /**
  82691. * Manage the touch inputs to control the movement of a free camera.
  82692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82693. */
  82694. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  82695. /**
  82696. * Defines the camera the input is attached to.
  82697. */
  82698. camera: FreeCamera;
  82699. /**
  82700. * Defines the touch sensibility for rotation.
  82701. * The higher the faster.
  82702. */
  82703. touchAngularSensibility: number;
  82704. /**
  82705. * Defines the touch sensibility for move.
  82706. * The higher the faster.
  82707. */
  82708. touchMoveSensibility: number;
  82709. private _offsetX;
  82710. private _offsetY;
  82711. private _pointerPressed;
  82712. private _pointerInput;
  82713. private _observer;
  82714. private _onLostFocus;
  82715. /**
  82716. * Attach the input controls to a specific dom element to get the input from.
  82717. * @param element Defines the element the controls should be listened from
  82718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82719. */
  82720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82721. /**
  82722. * Detach the current controls from the specified dom element.
  82723. * @param element Defines the element to stop listening the inputs from
  82724. */
  82725. detachControl(element: Nullable<HTMLElement>): void;
  82726. /**
  82727. * Update the current camera state depending on the inputs that have been used this frame.
  82728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82729. */
  82730. checkInputs(): void;
  82731. /**
  82732. * Gets the class name of the current intput.
  82733. * @returns the class name
  82734. */
  82735. getClassName(): string;
  82736. /**
  82737. * Get the friendly name associated with the input class.
  82738. * @returns the input friendly name
  82739. */
  82740. getSimpleName(): string;
  82741. }
  82742. }
  82743. declare module BABYLON {
  82744. /**
  82745. * Default Inputs manager for the FreeCamera.
  82746. * It groups all the default supported inputs for ease of use.
  82747. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82748. */
  82749. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  82750. /**
  82751. * @hidden
  82752. */
  82753. _mouseInput: Nullable<FreeCameraMouseInput>;
  82754. /**
  82755. * Instantiates a new FreeCameraInputsManager.
  82756. * @param camera Defines the camera the inputs belong to
  82757. */
  82758. constructor(camera: FreeCamera);
  82759. /**
  82760. * Add keyboard input support to the input manager.
  82761. * @returns the current input manager
  82762. */
  82763. addKeyboard(): FreeCameraInputsManager;
  82764. /**
  82765. * Add mouse input support to the input manager.
  82766. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  82767. * @returns the current input manager
  82768. */
  82769. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  82770. /**
  82771. * Removes the mouse input support from the manager
  82772. * @returns the current input manager
  82773. */
  82774. removeMouse(): FreeCameraInputsManager;
  82775. /**
  82776. * Add touch input support to the input manager.
  82777. * @returns the current input manager
  82778. */
  82779. addTouch(): FreeCameraInputsManager;
  82780. /**
  82781. * Remove all attached input methods from a camera
  82782. */
  82783. clear(): void;
  82784. }
  82785. }
  82786. declare module BABYLON {
  82787. /**
  82788. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82789. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  82790. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82791. */
  82792. export class FreeCamera extends TargetCamera {
  82793. /**
  82794. * Define the collision ellipsoid of the camera.
  82795. * This is helpful to simulate a camera body like the player body around the camera
  82796. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  82797. */
  82798. ellipsoid: Vector3;
  82799. /**
  82800. * Define an offset for the position of the ellipsoid around the camera.
  82801. * This can be helpful to determine the center of the body near the gravity center of the body
  82802. * instead of its head.
  82803. */
  82804. ellipsoidOffset: Vector3;
  82805. /**
  82806. * Enable or disable collisions of the camera with the rest of the scene objects.
  82807. */
  82808. checkCollisions: boolean;
  82809. /**
  82810. * Enable or disable gravity on the camera.
  82811. */
  82812. applyGravity: boolean;
  82813. /**
  82814. * Define the input manager associated to the camera.
  82815. */
  82816. inputs: FreeCameraInputsManager;
  82817. /**
  82818. * Gets the input sensibility for a mouse input. (default is 2000.0)
  82819. * Higher values reduce sensitivity.
  82820. */
  82821. get angularSensibility(): number;
  82822. /**
  82823. * Sets the input sensibility for a mouse input. (default is 2000.0)
  82824. * Higher values reduce sensitivity.
  82825. */
  82826. set angularSensibility(value: number);
  82827. /**
  82828. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82829. */
  82830. get keysUp(): number[];
  82831. set keysUp(value: number[]);
  82832. /**
  82833. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82834. */
  82835. get keysDown(): number[];
  82836. set keysDown(value: number[]);
  82837. /**
  82838. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82839. */
  82840. get keysLeft(): number[];
  82841. set keysLeft(value: number[]);
  82842. /**
  82843. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82844. */
  82845. get keysRight(): number[];
  82846. set keysRight(value: number[]);
  82847. /**
  82848. * Event raised when the camera collide with a mesh in the scene.
  82849. */
  82850. onCollide: (collidedMesh: AbstractMesh) => void;
  82851. private _collider;
  82852. private _needMoveForGravity;
  82853. private _oldPosition;
  82854. private _diffPosition;
  82855. private _newPosition;
  82856. /** @hidden */
  82857. _localDirection: Vector3;
  82858. /** @hidden */
  82859. _transformedDirection: Vector3;
  82860. /**
  82861. * Instantiates a Free Camera.
  82862. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82863. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  82864. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82865. * @param name Define the name of the camera in the scene
  82866. * @param position Define the start position of the camera in the scene
  82867. * @param scene Define the scene the camera belongs to
  82868. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82869. */
  82870. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82871. /**
  82872. * Attached controls to the current camera.
  82873. * @param element Defines the element the controls should be listened from
  82874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82875. */
  82876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82877. /**
  82878. * Detach the current controls from the camera.
  82879. * The camera will stop reacting to inputs.
  82880. * @param element Defines the element to stop listening the inputs from
  82881. */
  82882. detachControl(element: HTMLElement): void;
  82883. private _collisionMask;
  82884. /**
  82885. * Define a collision mask to limit the list of object the camera can collide with
  82886. */
  82887. get collisionMask(): number;
  82888. set collisionMask(mask: number);
  82889. /** @hidden */
  82890. _collideWithWorld(displacement: Vector3): void;
  82891. private _onCollisionPositionChange;
  82892. /** @hidden */
  82893. _checkInputs(): void;
  82894. /** @hidden */
  82895. _decideIfNeedsToMove(): boolean;
  82896. /** @hidden */
  82897. _updatePosition(): void;
  82898. /**
  82899. * Destroy the camera and release the current resources hold by it.
  82900. */
  82901. dispose(): void;
  82902. /**
  82903. * Gets the current object class name.
  82904. * @return the class name
  82905. */
  82906. getClassName(): string;
  82907. }
  82908. }
  82909. declare module BABYLON {
  82910. /**
  82911. * Represents a gamepad control stick position
  82912. */
  82913. export class StickValues {
  82914. /**
  82915. * The x component of the control stick
  82916. */
  82917. x: number;
  82918. /**
  82919. * The y component of the control stick
  82920. */
  82921. y: number;
  82922. /**
  82923. * Initializes the gamepad x and y control stick values
  82924. * @param x The x component of the gamepad control stick value
  82925. * @param y The y component of the gamepad control stick value
  82926. */
  82927. constructor(
  82928. /**
  82929. * The x component of the control stick
  82930. */
  82931. x: number,
  82932. /**
  82933. * The y component of the control stick
  82934. */
  82935. y: number);
  82936. }
  82937. /**
  82938. * An interface which manages callbacks for gamepad button changes
  82939. */
  82940. export interface GamepadButtonChanges {
  82941. /**
  82942. * Called when a gamepad has been changed
  82943. */
  82944. changed: boolean;
  82945. /**
  82946. * Called when a gamepad press event has been triggered
  82947. */
  82948. pressChanged: boolean;
  82949. /**
  82950. * Called when a touch event has been triggered
  82951. */
  82952. touchChanged: boolean;
  82953. /**
  82954. * Called when a value has changed
  82955. */
  82956. valueChanged: boolean;
  82957. }
  82958. /**
  82959. * Represents a gamepad
  82960. */
  82961. export class Gamepad {
  82962. /**
  82963. * The id of the gamepad
  82964. */
  82965. id: string;
  82966. /**
  82967. * The index of the gamepad
  82968. */
  82969. index: number;
  82970. /**
  82971. * The browser gamepad
  82972. */
  82973. browserGamepad: any;
  82974. /**
  82975. * Specifies what type of gamepad this represents
  82976. */
  82977. type: number;
  82978. private _leftStick;
  82979. private _rightStick;
  82980. /** @hidden */
  82981. _isConnected: boolean;
  82982. private _leftStickAxisX;
  82983. private _leftStickAxisY;
  82984. private _rightStickAxisX;
  82985. private _rightStickAxisY;
  82986. /**
  82987. * Triggered when the left control stick has been changed
  82988. */
  82989. private _onleftstickchanged;
  82990. /**
  82991. * Triggered when the right control stick has been changed
  82992. */
  82993. private _onrightstickchanged;
  82994. /**
  82995. * Represents a gamepad controller
  82996. */
  82997. static GAMEPAD: number;
  82998. /**
  82999. * Represents a generic controller
  83000. */
  83001. static GENERIC: number;
  83002. /**
  83003. * Represents an XBox controller
  83004. */
  83005. static XBOX: number;
  83006. /**
  83007. * Represents a pose-enabled controller
  83008. */
  83009. static POSE_ENABLED: number;
  83010. /**
  83011. * Represents an Dual Shock controller
  83012. */
  83013. static DUALSHOCK: number;
  83014. /**
  83015. * Specifies whether the left control stick should be Y-inverted
  83016. */
  83017. protected _invertLeftStickY: boolean;
  83018. /**
  83019. * Specifies if the gamepad has been connected
  83020. */
  83021. get isConnected(): boolean;
  83022. /**
  83023. * Initializes the gamepad
  83024. * @param id The id of the gamepad
  83025. * @param index The index of the gamepad
  83026. * @param browserGamepad The browser gamepad
  83027. * @param leftStickX The x component of the left joystick
  83028. * @param leftStickY The y component of the left joystick
  83029. * @param rightStickX The x component of the right joystick
  83030. * @param rightStickY The y component of the right joystick
  83031. */
  83032. constructor(
  83033. /**
  83034. * The id of the gamepad
  83035. */
  83036. id: string,
  83037. /**
  83038. * The index of the gamepad
  83039. */
  83040. index: number,
  83041. /**
  83042. * The browser gamepad
  83043. */
  83044. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83045. /**
  83046. * Callback triggered when the left joystick has changed
  83047. * @param callback
  83048. */
  83049. onleftstickchanged(callback: (values: StickValues) => void): void;
  83050. /**
  83051. * Callback triggered when the right joystick has changed
  83052. * @param callback
  83053. */
  83054. onrightstickchanged(callback: (values: StickValues) => void): void;
  83055. /**
  83056. * Gets the left joystick
  83057. */
  83058. get leftStick(): StickValues;
  83059. /**
  83060. * Sets the left joystick values
  83061. */
  83062. set leftStick(newValues: StickValues);
  83063. /**
  83064. * Gets the right joystick
  83065. */
  83066. get rightStick(): StickValues;
  83067. /**
  83068. * Sets the right joystick value
  83069. */
  83070. set rightStick(newValues: StickValues);
  83071. /**
  83072. * Updates the gamepad joystick positions
  83073. */
  83074. update(): void;
  83075. /**
  83076. * Disposes the gamepad
  83077. */
  83078. dispose(): void;
  83079. }
  83080. /**
  83081. * Represents a generic gamepad
  83082. */
  83083. export class GenericPad extends Gamepad {
  83084. private _buttons;
  83085. private _onbuttondown;
  83086. private _onbuttonup;
  83087. /**
  83088. * Observable triggered when a button has been pressed
  83089. */
  83090. onButtonDownObservable: Observable<number>;
  83091. /**
  83092. * Observable triggered when a button has been released
  83093. */
  83094. onButtonUpObservable: Observable<number>;
  83095. /**
  83096. * Callback triggered when a button has been pressed
  83097. * @param callback Called when a button has been pressed
  83098. */
  83099. onbuttondown(callback: (buttonPressed: number) => void): void;
  83100. /**
  83101. * Callback triggered when a button has been released
  83102. * @param callback Called when a button has been released
  83103. */
  83104. onbuttonup(callback: (buttonReleased: number) => void): void;
  83105. /**
  83106. * Initializes the generic gamepad
  83107. * @param id The id of the generic gamepad
  83108. * @param index The index of the generic gamepad
  83109. * @param browserGamepad The browser gamepad
  83110. */
  83111. constructor(id: string, index: number, browserGamepad: any);
  83112. private _setButtonValue;
  83113. /**
  83114. * Updates the generic gamepad
  83115. */
  83116. update(): void;
  83117. /**
  83118. * Disposes the generic gamepad
  83119. */
  83120. dispose(): void;
  83121. }
  83122. }
  83123. declare module BABYLON {
  83124. interface Engine {
  83125. /**
  83126. * Creates a raw texture
  83127. * @param data defines the data to store in the texture
  83128. * @param width defines the width of the texture
  83129. * @param height defines the height of the texture
  83130. * @param format defines the format of the data
  83131. * @param generateMipMaps defines if the engine should generate the mip levels
  83132. * @param invertY defines if data must be stored with Y axis inverted
  83133. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83134. * @param compression defines the compression used (null by default)
  83135. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83136. * @returns the raw texture inside an InternalTexture
  83137. */
  83138. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83139. /**
  83140. * Update a raw texture
  83141. * @param texture defines the texture to update
  83142. * @param data defines the data to store in the texture
  83143. * @param format defines the format of the data
  83144. * @param invertY defines if data must be stored with Y axis inverted
  83145. */
  83146. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83147. /**
  83148. * Update a raw texture
  83149. * @param texture defines the texture to update
  83150. * @param data defines the data to store in the texture
  83151. * @param format defines the format of the data
  83152. * @param invertY defines if data must be stored with Y axis inverted
  83153. * @param compression defines the compression used (null by default)
  83154. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83155. */
  83156. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83157. /**
  83158. * Creates a new raw cube texture
  83159. * @param data defines the array of data to use to create each face
  83160. * @param size defines the size of the textures
  83161. * @param format defines the format of the data
  83162. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83163. * @param generateMipMaps defines if the engine should generate the mip levels
  83164. * @param invertY defines if data must be stored with Y axis inverted
  83165. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83166. * @param compression defines the compression used (null by default)
  83167. * @returns the cube texture as an InternalTexture
  83168. */
  83169. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83170. /**
  83171. * Update a raw cube texture
  83172. * @param texture defines the texture to udpdate
  83173. * @param data defines the data to store
  83174. * @param format defines the data format
  83175. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83176. * @param invertY defines if data must be stored with Y axis inverted
  83177. */
  83178. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83179. /**
  83180. * Update a raw cube texture
  83181. * @param texture defines the texture to udpdate
  83182. * @param data defines the data to store
  83183. * @param format defines the data format
  83184. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83185. * @param invertY defines if data must be stored with Y axis inverted
  83186. * @param compression defines the compression used (null by default)
  83187. */
  83188. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83189. /**
  83190. * Update a raw cube texture
  83191. * @param texture defines the texture to udpdate
  83192. * @param data defines the data to store
  83193. * @param format defines the data format
  83194. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83195. * @param invertY defines if data must be stored with Y axis inverted
  83196. * @param compression defines the compression used (null by default)
  83197. * @param level defines which level of the texture to update
  83198. */
  83199. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83200. /**
  83201. * Creates a new raw cube texture from a specified url
  83202. * @param url defines the url where the data is located
  83203. * @param scene defines the current scene
  83204. * @param size defines the size of the textures
  83205. * @param format defines the format of the data
  83206. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83207. * @param noMipmap defines if the engine should avoid generating the mip levels
  83208. * @param callback defines a callback used to extract texture data from loaded data
  83209. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83210. * @param onLoad defines a callback called when texture is loaded
  83211. * @param onError defines a callback called if there is an error
  83212. * @returns the cube texture as an InternalTexture
  83213. */
  83214. 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;
  83215. /**
  83216. * Creates a new raw cube texture from a specified url
  83217. * @param url defines the url where the data is located
  83218. * @param scene defines the current scene
  83219. * @param size defines the size of the textures
  83220. * @param format defines the format of the data
  83221. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83222. * @param noMipmap defines if the engine should avoid generating the mip levels
  83223. * @param callback defines a callback used to extract texture data from loaded data
  83224. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83225. * @param onLoad defines a callback called when texture is loaded
  83226. * @param onError defines a callback called if there is an error
  83227. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83228. * @param invertY defines if data must be stored with Y axis inverted
  83229. * @returns the cube texture as an InternalTexture
  83230. */
  83231. 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;
  83232. /**
  83233. * Creates a new raw 3D texture
  83234. * @param data defines the data used to create the texture
  83235. * @param width defines the width of the texture
  83236. * @param height defines the height of the texture
  83237. * @param depth defines the depth of the texture
  83238. * @param format defines the format of the texture
  83239. * @param generateMipMaps defines if the engine must generate mip levels
  83240. * @param invertY defines if data must be stored with Y axis inverted
  83241. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83242. * @param compression defines the compressed used (can be null)
  83243. * @param textureType defines the compressed used (can be null)
  83244. * @returns a new raw 3D texture (stored in an InternalTexture)
  83245. */
  83246. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83247. /**
  83248. * Update a raw 3D texture
  83249. * @param texture defines the texture to update
  83250. * @param data defines the data to store
  83251. * @param format defines the data format
  83252. * @param invertY defines if data must be stored with Y axis inverted
  83253. */
  83254. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83255. /**
  83256. * Update a raw 3D texture
  83257. * @param texture defines the texture to update
  83258. * @param data defines the data to store
  83259. * @param format defines the data format
  83260. * @param invertY defines if data must be stored with Y axis inverted
  83261. * @param compression defines the used compression (can be null)
  83262. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83263. */
  83264. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83265. /**
  83266. * Creates a new raw 2D array texture
  83267. * @param data defines the data used to create the texture
  83268. * @param width defines the width of the texture
  83269. * @param height defines the height of the texture
  83270. * @param depth defines the number of layers of the texture
  83271. * @param format defines the format of the texture
  83272. * @param generateMipMaps defines if the engine must generate mip levels
  83273. * @param invertY defines if data must be stored with Y axis inverted
  83274. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83275. * @param compression defines the compressed used (can be null)
  83276. * @param textureType defines the compressed used (can be null)
  83277. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83278. */
  83279. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83280. /**
  83281. * Update a raw 2D array texture
  83282. * @param texture defines the texture to update
  83283. * @param data defines the data to store
  83284. * @param format defines the data format
  83285. * @param invertY defines if data must be stored with Y axis inverted
  83286. */
  83287. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83288. /**
  83289. * Update a raw 2D array texture
  83290. * @param texture defines the texture to update
  83291. * @param data defines the data to store
  83292. * @param format defines the data format
  83293. * @param invertY defines if data must be stored with Y axis inverted
  83294. * @param compression defines the used compression (can be null)
  83295. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83296. */
  83297. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83298. }
  83299. }
  83300. declare module BABYLON {
  83301. /**
  83302. * Raw texture can help creating a texture directly from an array of data.
  83303. * This can be super useful if you either get the data from an uncompressed source or
  83304. * if you wish to create your texture pixel by pixel.
  83305. */
  83306. export class RawTexture extends Texture {
  83307. /**
  83308. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83309. */
  83310. format: number;
  83311. private _engine;
  83312. /**
  83313. * Instantiates a new RawTexture.
  83314. * Raw texture can help creating a texture directly from an array of data.
  83315. * This can be super useful if you either get the data from an uncompressed source or
  83316. * if you wish to create your texture pixel by pixel.
  83317. * @param data define the array of data to use to create the texture
  83318. * @param width define the width of the texture
  83319. * @param height define the height of the texture
  83320. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83321. * @param scene define the scene the texture belongs to
  83322. * @param generateMipMaps define whether mip maps should be generated or not
  83323. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83324. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83325. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83326. */
  83327. constructor(data: ArrayBufferView, width: number, height: number,
  83328. /**
  83329. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83330. */
  83331. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83332. /**
  83333. * Updates the texture underlying data.
  83334. * @param data Define the new data of the texture
  83335. */
  83336. update(data: ArrayBufferView): void;
  83337. /**
  83338. * Creates a luminance texture from some data.
  83339. * @param data Define the texture data
  83340. * @param width Define the width of the texture
  83341. * @param height Define the height of the texture
  83342. * @param scene Define the scene the texture belongs to
  83343. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83344. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83345. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83346. * @returns the luminance texture
  83347. */
  83348. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83349. /**
  83350. * Creates a luminance alpha texture from some data.
  83351. * @param data Define the texture data
  83352. * @param width Define the width of the texture
  83353. * @param height Define the height of the texture
  83354. * @param scene Define the scene the texture belongs to
  83355. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83356. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83357. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83358. * @returns the luminance alpha texture
  83359. */
  83360. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83361. /**
  83362. * Creates an alpha texture from some data.
  83363. * @param data Define the texture data
  83364. * @param width Define the width of the texture
  83365. * @param height Define the height of the texture
  83366. * @param scene Define the scene the texture belongs to
  83367. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83368. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83369. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83370. * @returns the alpha texture
  83371. */
  83372. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83373. /**
  83374. * Creates a RGB texture from some data.
  83375. * @param data Define the texture data
  83376. * @param width Define the width of the texture
  83377. * @param height Define the height of the texture
  83378. * @param scene Define the scene the texture belongs to
  83379. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83380. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83381. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83382. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83383. * @returns the RGB alpha texture
  83384. */
  83385. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83386. /**
  83387. * Creates a RGBA texture from some data.
  83388. * @param data Define the texture data
  83389. * @param width Define the width of the texture
  83390. * @param height Define the height of the texture
  83391. * @param scene Define the scene the texture belongs to
  83392. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83393. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83394. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83395. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83396. * @returns the RGBA texture
  83397. */
  83398. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83399. /**
  83400. * Creates a R texture from some data.
  83401. * @param data Define the texture data
  83402. * @param width Define the width of the texture
  83403. * @param height Define the height of the texture
  83404. * @param scene Define the scene the texture belongs to
  83405. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83406. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83407. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83408. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83409. * @returns the R texture
  83410. */
  83411. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83412. }
  83413. }
  83414. declare module BABYLON {
  83415. /**
  83416. * Interface for the size containing width and height
  83417. */
  83418. export interface ISize {
  83419. /**
  83420. * Width
  83421. */
  83422. width: number;
  83423. /**
  83424. * Heighht
  83425. */
  83426. height: number;
  83427. }
  83428. /**
  83429. * Size containing widht and height
  83430. */
  83431. export class Size implements ISize {
  83432. /**
  83433. * Width
  83434. */
  83435. width: number;
  83436. /**
  83437. * Height
  83438. */
  83439. height: number;
  83440. /**
  83441. * Creates a Size object from the given width and height (floats).
  83442. * @param width width of the new size
  83443. * @param height height of the new size
  83444. */
  83445. constructor(width: number, height: number);
  83446. /**
  83447. * Returns a string with the Size width and height
  83448. * @returns a string with the Size width and height
  83449. */
  83450. toString(): string;
  83451. /**
  83452. * "Size"
  83453. * @returns the string "Size"
  83454. */
  83455. getClassName(): string;
  83456. /**
  83457. * Returns the Size hash code.
  83458. * @returns a hash code for a unique width and height
  83459. */
  83460. getHashCode(): number;
  83461. /**
  83462. * Updates the current size from the given one.
  83463. * @param src the given size
  83464. */
  83465. copyFrom(src: Size): void;
  83466. /**
  83467. * Updates in place the current Size from the given floats.
  83468. * @param width width of the new size
  83469. * @param height height of the new size
  83470. * @returns the updated Size.
  83471. */
  83472. copyFromFloats(width: number, height: number): Size;
  83473. /**
  83474. * Updates in place the current Size from the given floats.
  83475. * @param width width to set
  83476. * @param height height to set
  83477. * @returns the updated Size.
  83478. */
  83479. set(width: number, height: number): Size;
  83480. /**
  83481. * Multiplies the width and height by numbers
  83482. * @param w factor to multiple the width by
  83483. * @param h factor to multiple the height by
  83484. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83485. */
  83486. multiplyByFloats(w: number, h: number): Size;
  83487. /**
  83488. * Clones the size
  83489. * @returns a new Size copied from the given one.
  83490. */
  83491. clone(): Size;
  83492. /**
  83493. * True if the current Size and the given one width and height are strictly equal.
  83494. * @param other the other size to compare against
  83495. * @returns True if the current Size and the given one width and height are strictly equal.
  83496. */
  83497. equals(other: Size): boolean;
  83498. /**
  83499. * The surface of the Size : width * height (float).
  83500. */
  83501. get surface(): number;
  83502. /**
  83503. * Create a new size of zero
  83504. * @returns a new Size set to (0.0, 0.0)
  83505. */
  83506. static Zero(): Size;
  83507. /**
  83508. * Sums the width and height of two sizes
  83509. * @param otherSize size to add to this size
  83510. * @returns a new Size set as the addition result of the current Size and the given one.
  83511. */
  83512. add(otherSize: Size): Size;
  83513. /**
  83514. * Subtracts the width and height of two
  83515. * @param otherSize size to subtract to this size
  83516. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83517. */
  83518. subtract(otherSize: Size): Size;
  83519. /**
  83520. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83521. * @param start starting size to lerp between
  83522. * @param end end size to lerp between
  83523. * @param amount amount to lerp between the start and end values
  83524. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83525. */
  83526. static Lerp(start: Size, end: Size, amount: number): Size;
  83527. }
  83528. }
  83529. declare module BABYLON {
  83530. /**
  83531. * Defines a runtime animation
  83532. */
  83533. export class RuntimeAnimation {
  83534. private _events;
  83535. /**
  83536. * The current frame of the runtime animation
  83537. */
  83538. private _currentFrame;
  83539. /**
  83540. * The animation used by the runtime animation
  83541. */
  83542. private _animation;
  83543. /**
  83544. * The target of the runtime animation
  83545. */
  83546. private _target;
  83547. /**
  83548. * The initiating animatable
  83549. */
  83550. private _host;
  83551. /**
  83552. * The original value of the runtime animation
  83553. */
  83554. private _originalValue;
  83555. /**
  83556. * The original blend value of the runtime animation
  83557. */
  83558. private _originalBlendValue;
  83559. /**
  83560. * The offsets cache of the runtime animation
  83561. */
  83562. private _offsetsCache;
  83563. /**
  83564. * The high limits cache of the runtime animation
  83565. */
  83566. private _highLimitsCache;
  83567. /**
  83568. * Specifies if the runtime animation has been stopped
  83569. */
  83570. private _stopped;
  83571. /**
  83572. * The blending factor of the runtime animation
  83573. */
  83574. private _blendingFactor;
  83575. /**
  83576. * The BabylonJS scene
  83577. */
  83578. private _scene;
  83579. /**
  83580. * The current value of the runtime animation
  83581. */
  83582. private _currentValue;
  83583. /** @hidden */
  83584. _animationState: _IAnimationState;
  83585. /**
  83586. * The active target of the runtime animation
  83587. */
  83588. private _activeTargets;
  83589. private _currentActiveTarget;
  83590. private _directTarget;
  83591. /**
  83592. * The target path of the runtime animation
  83593. */
  83594. private _targetPath;
  83595. /**
  83596. * The weight of the runtime animation
  83597. */
  83598. private _weight;
  83599. /**
  83600. * The ratio offset of the runtime animation
  83601. */
  83602. private _ratioOffset;
  83603. /**
  83604. * The previous delay of the runtime animation
  83605. */
  83606. private _previousDelay;
  83607. /**
  83608. * The previous ratio of the runtime animation
  83609. */
  83610. private _previousRatio;
  83611. private _enableBlending;
  83612. private _keys;
  83613. private _minFrame;
  83614. private _maxFrame;
  83615. private _minValue;
  83616. private _maxValue;
  83617. private _targetIsArray;
  83618. /**
  83619. * Gets the current frame of the runtime animation
  83620. */
  83621. get currentFrame(): number;
  83622. /**
  83623. * Gets the weight of the runtime animation
  83624. */
  83625. get weight(): number;
  83626. /**
  83627. * Gets the current value of the runtime animation
  83628. */
  83629. get currentValue(): any;
  83630. /**
  83631. * Gets the target path of the runtime animation
  83632. */
  83633. get targetPath(): string;
  83634. /**
  83635. * Gets the actual target of the runtime animation
  83636. */
  83637. get target(): any;
  83638. /** @hidden */
  83639. _onLoop: () => void;
  83640. /**
  83641. * Create a new RuntimeAnimation object
  83642. * @param target defines the target of the animation
  83643. * @param animation defines the source animation object
  83644. * @param scene defines the hosting scene
  83645. * @param host defines the initiating Animatable
  83646. */
  83647. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  83648. private _preparePath;
  83649. /**
  83650. * Gets the animation from the runtime animation
  83651. */
  83652. get animation(): Animation;
  83653. /**
  83654. * Resets the runtime animation to the beginning
  83655. * @param restoreOriginal defines whether to restore the target property to the original value
  83656. */
  83657. reset(restoreOriginal?: boolean): void;
  83658. /**
  83659. * Specifies if the runtime animation is stopped
  83660. * @returns Boolean specifying if the runtime animation is stopped
  83661. */
  83662. isStopped(): boolean;
  83663. /**
  83664. * Disposes of the runtime animation
  83665. */
  83666. dispose(): void;
  83667. /**
  83668. * Apply the interpolated value to the target
  83669. * @param currentValue defines the value computed by the animation
  83670. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  83671. */
  83672. setValue(currentValue: any, weight: number): void;
  83673. private _getOriginalValues;
  83674. private _setValue;
  83675. /**
  83676. * Gets the loop pmode of the runtime animation
  83677. * @returns Loop Mode
  83678. */
  83679. private _getCorrectLoopMode;
  83680. /**
  83681. * Move the current animation to a given frame
  83682. * @param frame defines the frame to move to
  83683. */
  83684. goToFrame(frame: number): void;
  83685. /**
  83686. * @hidden Internal use only
  83687. */
  83688. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  83689. /**
  83690. * Execute the current animation
  83691. * @param delay defines the delay to add to the current frame
  83692. * @param from defines the lower bound of the animation range
  83693. * @param to defines the upper bound of the animation range
  83694. * @param loop defines if the current animation must loop
  83695. * @param speedRatio defines the current speed ratio
  83696. * @param weight defines the weight of the animation (default is -1 so no weight)
  83697. * @param onLoop optional callback called when animation loops
  83698. * @returns a boolean indicating if the animation is running
  83699. */
  83700. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  83701. }
  83702. }
  83703. declare module BABYLON {
  83704. /**
  83705. * Class used to store an actual running animation
  83706. */
  83707. export class Animatable {
  83708. /** defines the target object */
  83709. target: any;
  83710. /** defines the starting frame number (default is 0) */
  83711. fromFrame: number;
  83712. /** defines the ending frame number (default is 100) */
  83713. toFrame: number;
  83714. /** defines if the animation must loop (default is false) */
  83715. loopAnimation: boolean;
  83716. /** defines a callback to call when animation ends if it is not looping */
  83717. onAnimationEnd?: (() => void) | null | undefined;
  83718. /** defines a callback to call when animation loops */
  83719. onAnimationLoop?: (() => void) | null | undefined;
  83720. private _localDelayOffset;
  83721. private _pausedDelay;
  83722. private _runtimeAnimations;
  83723. private _paused;
  83724. private _scene;
  83725. private _speedRatio;
  83726. private _weight;
  83727. private _syncRoot;
  83728. /**
  83729. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  83730. * This will only apply for non looping animation (default is true)
  83731. */
  83732. disposeOnEnd: boolean;
  83733. /**
  83734. * Gets a boolean indicating if the animation has started
  83735. */
  83736. animationStarted: boolean;
  83737. /**
  83738. * Observer raised when the animation ends
  83739. */
  83740. onAnimationEndObservable: Observable<Animatable>;
  83741. /**
  83742. * Observer raised when the animation loops
  83743. */
  83744. onAnimationLoopObservable: Observable<Animatable>;
  83745. /**
  83746. * Gets the root Animatable used to synchronize and normalize animations
  83747. */
  83748. get syncRoot(): Nullable<Animatable>;
  83749. /**
  83750. * Gets the current frame of the first RuntimeAnimation
  83751. * Used to synchronize Animatables
  83752. */
  83753. get masterFrame(): number;
  83754. /**
  83755. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  83756. */
  83757. get weight(): number;
  83758. set weight(value: number);
  83759. /**
  83760. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  83761. */
  83762. get speedRatio(): number;
  83763. set speedRatio(value: number);
  83764. /**
  83765. * Creates a new Animatable
  83766. * @param scene defines the hosting scene
  83767. * @param target defines the target object
  83768. * @param fromFrame defines the starting frame number (default is 0)
  83769. * @param toFrame defines the ending frame number (default is 100)
  83770. * @param loopAnimation defines if the animation must loop (default is false)
  83771. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  83772. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  83773. * @param animations defines a group of animation to add to the new Animatable
  83774. * @param onAnimationLoop defines a callback to call when animation loops
  83775. */
  83776. constructor(scene: Scene,
  83777. /** defines the target object */
  83778. target: any,
  83779. /** defines the starting frame number (default is 0) */
  83780. fromFrame?: number,
  83781. /** defines the ending frame number (default is 100) */
  83782. toFrame?: number,
  83783. /** defines if the animation must loop (default is false) */
  83784. loopAnimation?: boolean, speedRatio?: number,
  83785. /** defines a callback to call when animation ends if it is not looping */
  83786. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  83787. /** defines a callback to call when animation loops */
  83788. onAnimationLoop?: (() => void) | null | undefined);
  83789. /**
  83790. * Synchronize and normalize current Animatable with a source Animatable
  83791. * This is useful when using animation weights and when animations are not of the same length
  83792. * @param root defines the root Animatable to synchronize with
  83793. * @returns the current Animatable
  83794. */
  83795. syncWith(root: Animatable): Animatable;
  83796. /**
  83797. * Gets the list of runtime animations
  83798. * @returns an array of RuntimeAnimation
  83799. */
  83800. getAnimations(): RuntimeAnimation[];
  83801. /**
  83802. * Adds more animations to the current animatable
  83803. * @param target defines the target of the animations
  83804. * @param animations defines the new animations to add
  83805. */
  83806. appendAnimations(target: any, animations: Animation[]): void;
  83807. /**
  83808. * Gets the source animation for a specific property
  83809. * @param property defines the propertyu to look for
  83810. * @returns null or the source animation for the given property
  83811. */
  83812. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  83813. /**
  83814. * Gets the runtime animation for a specific property
  83815. * @param property defines the propertyu to look for
  83816. * @returns null or the runtime animation for the given property
  83817. */
  83818. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  83819. /**
  83820. * Resets the animatable to its original state
  83821. */
  83822. reset(): void;
  83823. /**
  83824. * Allows the animatable to blend with current running animations
  83825. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83826. * @param blendingSpeed defines the blending speed to use
  83827. */
  83828. enableBlending(blendingSpeed: number): void;
  83829. /**
  83830. * Disable animation blending
  83831. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83832. */
  83833. disableBlending(): void;
  83834. /**
  83835. * Jump directly to a given frame
  83836. * @param frame defines the frame to jump to
  83837. */
  83838. goToFrame(frame: number): void;
  83839. /**
  83840. * Pause the animation
  83841. */
  83842. pause(): void;
  83843. /**
  83844. * Restart the animation
  83845. */
  83846. restart(): void;
  83847. private _raiseOnAnimationEnd;
  83848. /**
  83849. * Stop and delete the current animation
  83850. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  83851. * @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)
  83852. */
  83853. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  83854. /**
  83855. * Wait asynchronously for the animation to end
  83856. * @returns a promise which will be fullfilled when the animation ends
  83857. */
  83858. waitAsync(): Promise<Animatable>;
  83859. /** @hidden */
  83860. _animate(delay: number): boolean;
  83861. }
  83862. interface Scene {
  83863. /** @hidden */
  83864. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  83865. /** @hidden */
  83866. _processLateAnimationBindingsForMatrices(holder: {
  83867. totalWeight: number;
  83868. animations: RuntimeAnimation[];
  83869. originalValue: Matrix;
  83870. }): any;
  83871. /** @hidden */
  83872. _processLateAnimationBindingsForQuaternions(holder: {
  83873. totalWeight: number;
  83874. animations: RuntimeAnimation[];
  83875. originalValue: Quaternion;
  83876. }, refQuaternion: Quaternion): Quaternion;
  83877. /** @hidden */
  83878. _processLateAnimationBindings(): void;
  83879. /**
  83880. * Will start the animation sequence of a given target
  83881. * @param target defines the target
  83882. * @param from defines from which frame should animation start
  83883. * @param to defines until which frame should animation run.
  83884. * @param weight defines the weight to apply to the animation (1.0 by default)
  83885. * @param loop defines if the animation loops
  83886. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83887. * @param onAnimationEnd defines the function to be executed when the animation ends
  83888. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83889. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83890. * @param onAnimationLoop defines the callback to call when an animation loops
  83891. * @returns the animatable object created for this animation
  83892. */
  83893. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83894. /**
  83895. * Will start the animation sequence of a given target
  83896. * @param target defines the target
  83897. * @param from defines from which frame should animation start
  83898. * @param to defines until which frame should animation run.
  83899. * @param loop defines if the animation loops
  83900. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83901. * @param onAnimationEnd defines the function to be executed when the animation ends
  83902. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83903. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83904. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  83905. * @param onAnimationLoop defines the callback to call when an animation loops
  83906. * @returns the animatable object created for this animation
  83907. */
  83908. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83909. /**
  83910. * Will start the animation sequence of a given target and its hierarchy
  83911. * @param target defines the target
  83912. * @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.
  83913. * @param from defines from which frame should animation start
  83914. * @param to defines until which frame should animation run.
  83915. * @param loop defines if the animation loops
  83916. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83917. * @param onAnimationEnd defines the function to be executed when the animation ends
  83918. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83919. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83920. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83921. * @param onAnimationLoop defines the callback to call when an animation loops
  83922. * @returns the list of created animatables
  83923. */
  83924. 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[];
  83925. /**
  83926. * Begin a new animation on a given node
  83927. * @param target defines the target where the animation will take place
  83928. * @param animations defines the list of animations to start
  83929. * @param from defines the initial value
  83930. * @param to defines the final value
  83931. * @param loop defines if you want animation to loop (off by default)
  83932. * @param speedRatio defines the speed ratio to apply to all animations
  83933. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83934. * @param onAnimationLoop defines the callback to call when an animation loops
  83935. * @returns the list of created animatables
  83936. */
  83937. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  83938. /**
  83939. * Begin a new animation on a given node and its hierarchy
  83940. * @param target defines the root node where the animation will take place
  83941. * @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.
  83942. * @param animations defines the list of animations to start
  83943. * @param from defines the initial value
  83944. * @param to defines the final value
  83945. * @param loop defines if you want animation to loop (off by default)
  83946. * @param speedRatio defines the speed ratio to apply to all animations
  83947. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83948. * @param onAnimationLoop defines the callback to call when an animation loops
  83949. * @returns the list of animatables created for all nodes
  83950. */
  83951. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  83952. /**
  83953. * Gets the animatable associated with a specific target
  83954. * @param target defines the target of the animatable
  83955. * @returns the required animatable if found
  83956. */
  83957. getAnimatableByTarget(target: any): Nullable<Animatable>;
  83958. /**
  83959. * Gets all animatables associated with a given target
  83960. * @param target defines the target to look animatables for
  83961. * @returns an array of Animatables
  83962. */
  83963. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  83964. /**
  83965. * Stops and removes all animations that have been applied to the scene
  83966. */
  83967. stopAllAnimations(): void;
  83968. /**
  83969. * Gets the current delta time used by animation engine
  83970. */
  83971. deltaTime: number;
  83972. }
  83973. interface Bone {
  83974. /**
  83975. * Copy an animation range from another bone
  83976. * @param source defines the source bone
  83977. * @param rangeName defines the range name to copy
  83978. * @param frameOffset defines the frame offset
  83979. * @param rescaleAsRequired defines if rescaling must be applied if required
  83980. * @param skelDimensionsRatio defines the scaling ratio
  83981. * @returns true if operation was successful
  83982. */
  83983. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  83984. }
  83985. }
  83986. declare module BABYLON {
  83987. /**
  83988. * Class used to override all child animations of a given target
  83989. */
  83990. export class AnimationPropertiesOverride {
  83991. /**
  83992. * Gets or sets a value indicating if animation blending must be used
  83993. */
  83994. enableBlending: boolean;
  83995. /**
  83996. * Gets or sets the blending speed to use when enableBlending is true
  83997. */
  83998. blendingSpeed: number;
  83999. /**
  84000. * Gets or sets the default loop mode to use
  84001. */
  84002. loopMode: number;
  84003. }
  84004. }
  84005. declare module BABYLON {
  84006. /**
  84007. * Class used to handle skinning animations
  84008. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84009. */
  84010. export class Skeleton implements IAnimatable {
  84011. /** defines the skeleton name */
  84012. name: string;
  84013. /** defines the skeleton Id */
  84014. id: string;
  84015. /**
  84016. * Defines the list of child bones
  84017. */
  84018. bones: Bone[];
  84019. /**
  84020. * Defines an estimate of the dimension of the skeleton at rest
  84021. */
  84022. dimensionsAtRest: Vector3;
  84023. /**
  84024. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84025. */
  84026. needInitialSkinMatrix: boolean;
  84027. /**
  84028. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84029. */
  84030. overrideMesh: Nullable<AbstractMesh>;
  84031. /**
  84032. * Gets the list of animations attached to this skeleton
  84033. */
  84034. animations: Array<Animation>;
  84035. private _scene;
  84036. private _isDirty;
  84037. private _transformMatrices;
  84038. private _transformMatrixTexture;
  84039. private _meshesWithPoseMatrix;
  84040. private _animatables;
  84041. private _identity;
  84042. private _synchronizedWithMesh;
  84043. private _ranges;
  84044. private _lastAbsoluteTransformsUpdateId;
  84045. private _canUseTextureForBones;
  84046. private _uniqueId;
  84047. /** @hidden */
  84048. _numBonesWithLinkedTransformNode: number;
  84049. /** @hidden */
  84050. _hasWaitingData: Nullable<boolean>;
  84051. /**
  84052. * Specifies if the skeleton should be serialized
  84053. */
  84054. doNotSerialize: boolean;
  84055. private _useTextureToStoreBoneMatrices;
  84056. /**
  84057. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84058. * Please note that this option is not available if the hardware does not support it
  84059. */
  84060. get useTextureToStoreBoneMatrices(): boolean;
  84061. set useTextureToStoreBoneMatrices(value: boolean);
  84062. private _animationPropertiesOverride;
  84063. /**
  84064. * Gets or sets the animation properties override
  84065. */
  84066. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84067. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84068. /**
  84069. * List of inspectable custom properties (used by the Inspector)
  84070. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84071. */
  84072. inspectableCustomProperties: IInspectable[];
  84073. /**
  84074. * An observable triggered before computing the skeleton's matrices
  84075. */
  84076. onBeforeComputeObservable: Observable<Skeleton>;
  84077. /**
  84078. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84079. */
  84080. get isUsingTextureForMatrices(): boolean;
  84081. /**
  84082. * Gets the unique ID of this skeleton
  84083. */
  84084. get uniqueId(): number;
  84085. /**
  84086. * Creates a new skeleton
  84087. * @param name defines the skeleton name
  84088. * @param id defines the skeleton Id
  84089. * @param scene defines the hosting scene
  84090. */
  84091. constructor(
  84092. /** defines the skeleton name */
  84093. name: string,
  84094. /** defines the skeleton Id */
  84095. id: string, scene: Scene);
  84096. /**
  84097. * Gets the current object class name.
  84098. * @return the class name
  84099. */
  84100. getClassName(): string;
  84101. /**
  84102. * Returns an array containing the root bones
  84103. * @returns an array containing the root bones
  84104. */
  84105. getChildren(): Array<Bone>;
  84106. /**
  84107. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84108. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84109. * @returns a Float32Array containing matrices data
  84110. */
  84111. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84112. /**
  84113. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84114. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84115. * @returns a raw texture containing the data
  84116. */
  84117. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84118. /**
  84119. * Gets the current hosting scene
  84120. * @returns a scene object
  84121. */
  84122. getScene(): Scene;
  84123. /**
  84124. * Gets a string representing the current skeleton data
  84125. * @param fullDetails defines a boolean indicating if we want a verbose version
  84126. * @returns a string representing the current skeleton data
  84127. */
  84128. toString(fullDetails?: boolean): string;
  84129. /**
  84130. * Get bone's index searching by name
  84131. * @param name defines bone's name to search for
  84132. * @return the indice of the bone. Returns -1 if not found
  84133. */
  84134. getBoneIndexByName(name: string): number;
  84135. /**
  84136. * Creater a new animation range
  84137. * @param name defines the name of the range
  84138. * @param from defines the start key
  84139. * @param to defines the end key
  84140. */
  84141. createAnimationRange(name: string, from: number, to: number): void;
  84142. /**
  84143. * Delete a specific animation range
  84144. * @param name defines the name of the range
  84145. * @param deleteFrames defines if frames must be removed as well
  84146. */
  84147. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84148. /**
  84149. * Gets a specific animation range
  84150. * @param name defines the name of the range to look for
  84151. * @returns the requested animation range or null if not found
  84152. */
  84153. getAnimationRange(name: string): Nullable<AnimationRange>;
  84154. /**
  84155. * Gets the list of all animation ranges defined on this skeleton
  84156. * @returns an array
  84157. */
  84158. getAnimationRanges(): Nullable<AnimationRange>[];
  84159. /**
  84160. * Copy animation range from a source skeleton.
  84161. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  84162. * @param source defines the source skeleton
  84163. * @param name defines the name of the range to copy
  84164. * @param rescaleAsRequired defines if rescaling must be applied if required
  84165. * @returns true if operation was successful
  84166. */
  84167. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  84168. /**
  84169. * Forces the skeleton to go to rest pose
  84170. */
  84171. returnToRest(): void;
  84172. private _getHighestAnimationFrame;
  84173. /**
  84174. * Begin a specific animation range
  84175. * @param name defines the name of the range to start
  84176. * @param loop defines if looping must be turned on (false by default)
  84177. * @param speedRatio defines the speed ratio to apply (1 by default)
  84178. * @param onAnimationEnd defines a callback which will be called when animation will end
  84179. * @returns a new animatable
  84180. */
  84181. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84182. /** @hidden */
  84183. _markAsDirty(): void;
  84184. /** @hidden */
  84185. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84186. /** @hidden */
  84187. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84188. private _computeTransformMatrices;
  84189. /**
  84190. * Build all resources required to render a skeleton
  84191. */
  84192. prepare(): void;
  84193. /**
  84194. * Gets the list of animatables currently running for this skeleton
  84195. * @returns an array of animatables
  84196. */
  84197. getAnimatables(): IAnimatable[];
  84198. /**
  84199. * Clone the current skeleton
  84200. * @param name defines the name of the new skeleton
  84201. * @param id defines the id of the new skeleton
  84202. * @returns the new skeleton
  84203. */
  84204. clone(name: string, id?: string): Skeleton;
  84205. /**
  84206. * Enable animation blending for this skeleton
  84207. * @param blendingSpeed defines the blending speed to apply
  84208. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84209. */
  84210. enableBlending(blendingSpeed?: number): void;
  84211. /**
  84212. * Releases all resources associated with the current skeleton
  84213. */
  84214. dispose(): void;
  84215. /**
  84216. * Serialize the skeleton in a JSON object
  84217. * @returns a JSON object
  84218. */
  84219. serialize(): any;
  84220. /**
  84221. * Creates a new skeleton from serialized data
  84222. * @param parsedSkeleton defines the serialized data
  84223. * @param scene defines the hosting scene
  84224. * @returns a new skeleton
  84225. */
  84226. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  84227. /**
  84228. * Compute all node absolute transforms
  84229. * @param forceUpdate defines if computation must be done even if cache is up to date
  84230. */
  84231. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  84232. /**
  84233. * Gets the root pose matrix
  84234. * @returns a matrix
  84235. */
  84236. getPoseMatrix(): Nullable<Matrix>;
  84237. /**
  84238. * Sorts bones per internal index
  84239. */
  84240. sortBones(): void;
  84241. private _sortBones;
  84242. }
  84243. }
  84244. declare module BABYLON {
  84245. /**
  84246. * Class used to store bone information
  84247. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84248. */
  84249. export class Bone extends Node {
  84250. /**
  84251. * defines the bone name
  84252. */
  84253. name: string;
  84254. private static _tmpVecs;
  84255. private static _tmpQuat;
  84256. private static _tmpMats;
  84257. /**
  84258. * Gets the list of child bones
  84259. */
  84260. children: Bone[];
  84261. /** Gets the animations associated with this bone */
  84262. animations: Animation[];
  84263. /**
  84264. * Gets or sets bone length
  84265. */
  84266. length: number;
  84267. /**
  84268. * @hidden Internal only
  84269. * Set this value to map this bone to a different index in the transform matrices
  84270. * Set this value to -1 to exclude the bone from the transform matrices
  84271. */
  84272. _index: Nullable<number>;
  84273. private _skeleton;
  84274. private _localMatrix;
  84275. private _restPose;
  84276. private _baseMatrix;
  84277. private _absoluteTransform;
  84278. private _invertedAbsoluteTransform;
  84279. private _parent;
  84280. private _scalingDeterminant;
  84281. private _worldTransform;
  84282. private _localScaling;
  84283. private _localRotation;
  84284. private _localPosition;
  84285. private _needToDecompose;
  84286. private _needToCompose;
  84287. /** @hidden */
  84288. _linkedTransformNode: Nullable<TransformNode>;
  84289. /** @hidden */
  84290. _waitingTransformNodeId: Nullable<string>;
  84291. /** @hidden */
  84292. get _matrix(): Matrix;
  84293. /** @hidden */
  84294. set _matrix(value: Matrix);
  84295. /**
  84296. * Create a new bone
  84297. * @param name defines the bone name
  84298. * @param skeleton defines the parent skeleton
  84299. * @param parentBone defines the parent (can be null if the bone is the root)
  84300. * @param localMatrix defines the local matrix
  84301. * @param restPose defines the rest pose matrix
  84302. * @param baseMatrix defines the base matrix
  84303. * @param index defines index of the bone in the hiearchy
  84304. */
  84305. constructor(
  84306. /**
  84307. * defines the bone name
  84308. */
  84309. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  84310. /**
  84311. * Gets the current object class name.
  84312. * @return the class name
  84313. */
  84314. getClassName(): string;
  84315. /**
  84316. * Gets the parent skeleton
  84317. * @returns a skeleton
  84318. */
  84319. getSkeleton(): Skeleton;
  84320. /**
  84321. * Gets parent bone
  84322. * @returns a bone or null if the bone is the root of the bone hierarchy
  84323. */
  84324. getParent(): Nullable<Bone>;
  84325. /**
  84326. * Returns an array containing the root bones
  84327. * @returns an array containing the root bones
  84328. */
  84329. getChildren(): Array<Bone>;
  84330. /**
  84331. * Gets the node index in matrix array generated for rendering
  84332. * @returns the node index
  84333. */
  84334. getIndex(): number;
  84335. /**
  84336. * Sets the parent bone
  84337. * @param parent defines the parent (can be null if the bone is the root)
  84338. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84339. */
  84340. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  84341. /**
  84342. * Gets the local matrix
  84343. * @returns a matrix
  84344. */
  84345. getLocalMatrix(): Matrix;
  84346. /**
  84347. * Gets the base matrix (initial matrix which remains unchanged)
  84348. * @returns a matrix
  84349. */
  84350. getBaseMatrix(): Matrix;
  84351. /**
  84352. * Gets the rest pose matrix
  84353. * @returns a matrix
  84354. */
  84355. getRestPose(): Matrix;
  84356. /**
  84357. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  84358. */
  84359. getWorldMatrix(): Matrix;
  84360. /**
  84361. * Sets the local matrix to rest pose matrix
  84362. */
  84363. returnToRest(): void;
  84364. /**
  84365. * Gets the inverse of the absolute transform matrix.
  84366. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  84367. * @returns a matrix
  84368. */
  84369. getInvertedAbsoluteTransform(): Matrix;
  84370. /**
  84371. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  84372. * @returns a matrix
  84373. */
  84374. getAbsoluteTransform(): Matrix;
  84375. /**
  84376. * Links with the given transform node.
  84377. * The local matrix of this bone is copied from the transform node every frame.
  84378. * @param transformNode defines the transform node to link to
  84379. */
  84380. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  84381. /**
  84382. * Gets the node used to drive the bone's transformation
  84383. * @returns a transform node or null
  84384. */
  84385. getTransformNode(): Nullable<TransformNode>;
  84386. /** Gets or sets current position (in local space) */
  84387. get position(): Vector3;
  84388. set position(newPosition: Vector3);
  84389. /** Gets or sets current rotation (in local space) */
  84390. get rotation(): Vector3;
  84391. set rotation(newRotation: Vector3);
  84392. /** Gets or sets current rotation quaternion (in local space) */
  84393. get rotationQuaternion(): Quaternion;
  84394. set rotationQuaternion(newRotation: Quaternion);
  84395. /** Gets or sets current scaling (in local space) */
  84396. get scaling(): Vector3;
  84397. set scaling(newScaling: Vector3);
  84398. /**
  84399. * Gets the animation properties override
  84400. */
  84401. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84402. private _decompose;
  84403. private _compose;
  84404. /**
  84405. * Update the base and local matrices
  84406. * @param matrix defines the new base or local matrix
  84407. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84408. * @param updateLocalMatrix defines if the local matrix should be updated
  84409. */
  84410. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  84411. /** @hidden */
  84412. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  84413. /**
  84414. * Flag the bone as dirty (Forcing it to update everything)
  84415. */
  84416. markAsDirty(): void;
  84417. /** @hidden */
  84418. _markAsDirtyAndCompose(): void;
  84419. private _markAsDirtyAndDecompose;
  84420. /**
  84421. * Translate the bone in local or world space
  84422. * @param vec The amount to translate the bone
  84423. * @param space The space that the translation is in
  84424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84425. */
  84426. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84427. /**
  84428. * Set the postion of the bone in local or world space
  84429. * @param position The position to set the bone
  84430. * @param space The space that the position is in
  84431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84432. */
  84433. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84434. /**
  84435. * Set the absolute position of the bone (world space)
  84436. * @param position The position to set the bone
  84437. * @param mesh The mesh that this bone is attached to
  84438. */
  84439. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  84440. /**
  84441. * Scale the bone on the x, y and z axes (in local space)
  84442. * @param x The amount to scale the bone on the x axis
  84443. * @param y The amount to scale the bone on the y axis
  84444. * @param z The amount to scale the bone on the z axis
  84445. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  84446. */
  84447. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  84448. /**
  84449. * Set the bone scaling in local space
  84450. * @param scale defines the scaling vector
  84451. */
  84452. setScale(scale: Vector3): void;
  84453. /**
  84454. * Gets the current scaling in local space
  84455. * @returns the current scaling vector
  84456. */
  84457. getScale(): Vector3;
  84458. /**
  84459. * Gets the current scaling in local space and stores it in a target vector
  84460. * @param result defines the target vector
  84461. */
  84462. getScaleToRef(result: Vector3): void;
  84463. /**
  84464. * Set the yaw, pitch, and roll of the bone in local or world space
  84465. * @param yaw The rotation of the bone on the y axis
  84466. * @param pitch The rotation of the bone on the x axis
  84467. * @param roll The rotation of the bone on the z axis
  84468. * @param space The space that the axes of rotation are in
  84469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84470. */
  84471. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  84472. /**
  84473. * Add a rotation to the bone on an axis in local or world space
  84474. * @param axis The axis to rotate the bone on
  84475. * @param amount The amount to rotate the bone
  84476. * @param space The space that the axis is in
  84477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84478. */
  84479. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  84480. /**
  84481. * Set the rotation of the bone to a particular axis angle in local or world space
  84482. * @param axis The axis to rotate the bone on
  84483. * @param angle The angle that the bone should be rotated to
  84484. * @param space The space that the axis is in
  84485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84486. */
  84487. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  84488. /**
  84489. * Set the euler rotation of the bone in local of world space
  84490. * @param rotation The euler rotation that the bone should be set to
  84491. * @param space The space that the rotation is in
  84492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84493. */
  84494. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84495. /**
  84496. * Set the quaternion rotation of the bone in local of world space
  84497. * @param quat The quaternion rotation that the bone should be set to
  84498. * @param space The space that the rotation is in
  84499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84500. */
  84501. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  84502. /**
  84503. * Set the rotation matrix of the bone in local of world space
  84504. * @param rotMat The rotation matrix that the bone should be set to
  84505. * @param space The space that the rotation is in
  84506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84507. */
  84508. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  84509. private _rotateWithMatrix;
  84510. private _getNegativeRotationToRef;
  84511. /**
  84512. * Get the position of the bone in local or world space
  84513. * @param space The space that the returned position is in
  84514. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84515. * @returns The position of the bone
  84516. */
  84517. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84518. /**
  84519. * Copy the position of the bone to a vector3 in local or world space
  84520. * @param space The space that the returned position is in
  84521. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84522. * @param result The vector3 to copy the position to
  84523. */
  84524. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  84525. /**
  84526. * Get the absolute position of the bone (world space)
  84527. * @param mesh The mesh that this bone is attached to
  84528. * @returns The absolute position of the bone
  84529. */
  84530. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  84531. /**
  84532. * Copy the absolute position of the bone (world space) to the result param
  84533. * @param mesh The mesh that this bone is attached to
  84534. * @param result The vector3 to copy the absolute position to
  84535. */
  84536. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  84537. /**
  84538. * Compute the absolute transforms of this bone and its children
  84539. */
  84540. computeAbsoluteTransforms(): void;
  84541. /**
  84542. * Get the world direction from an axis that is in the local space of the bone
  84543. * @param localAxis The local direction that is used to compute the world direction
  84544. * @param mesh The mesh that this bone is attached to
  84545. * @returns The world direction
  84546. */
  84547. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84548. /**
  84549. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  84550. * @param localAxis The local direction that is used to compute the world direction
  84551. * @param mesh The mesh that this bone is attached to
  84552. * @param result The vector3 that the world direction will be copied to
  84553. */
  84554. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84555. /**
  84556. * Get the euler rotation of the bone in local or world space
  84557. * @param space The space that the rotation should be in
  84558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84559. * @returns The euler rotation
  84560. */
  84561. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84562. /**
  84563. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  84564. * @param space The space that the rotation should be in
  84565. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84566. * @param result The vector3 that the rotation should be copied to
  84567. */
  84568. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84569. /**
  84570. * Get the quaternion rotation of the bone in either local or world space
  84571. * @param space The space that the rotation should be in
  84572. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84573. * @returns The quaternion rotation
  84574. */
  84575. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  84576. /**
  84577. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  84578. * @param space The space that the rotation should be in
  84579. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84580. * @param result The quaternion that the rotation should be copied to
  84581. */
  84582. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  84583. /**
  84584. * Get the rotation matrix of the bone in local or world space
  84585. * @param space The space that the rotation should be in
  84586. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84587. * @returns The rotation matrix
  84588. */
  84589. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  84590. /**
  84591. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  84592. * @param space The space that the rotation should be in
  84593. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84594. * @param result The quaternion that the rotation should be copied to
  84595. */
  84596. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  84597. /**
  84598. * Get the world position of a point that is in the local space of the bone
  84599. * @param position The local position
  84600. * @param mesh The mesh that this bone is attached to
  84601. * @returns The world position
  84602. */
  84603. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84604. /**
  84605. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  84606. * @param position The local position
  84607. * @param mesh The mesh that this bone is attached to
  84608. * @param result The vector3 that the world position should be copied to
  84609. */
  84610. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84611. /**
  84612. * Get the local position of a point that is in world space
  84613. * @param position The world position
  84614. * @param mesh The mesh that this bone is attached to
  84615. * @returns The local position
  84616. */
  84617. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84618. /**
  84619. * Get the local position of a point that is in world space and copy it to the result param
  84620. * @param position The world position
  84621. * @param mesh The mesh that this bone is attached to
  84622. * @param result The vector3 that the local position should be copied to
  84623. */
  84624. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84625. }
  84626. }
  84627. declare module BABYLON {
  84628. /**
  84629. * 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.
  84630. * @see https://doc.babylonjs.com/how_to/transformnode
  84631. */
  84632. export class TransformNode extends Node {
  84633. /**
  84634. * Object will not rotate to face the camera
  84635. */
  84636. static BILLBOARDMODE_NONE: number;
  84637. /**
  84638. * Object will rotate to face the camera but only on the x axis
  84639. */
  84640. static BILLBOARDMODE_X: number;
  84641. /**
  84642. * Object will rotate to face the camera but only on the y axis
  84643. */
  84644. static BILLBOARDMODE_Y: number;
  84645. /**
  84646. * Object will rotate to face the camera but only on the z axis
  84647. */
  84648. static BILLBOARDMODE_Z: number;
  84649. /**
  84650. * Object will rotate to face the camera
  84651. */
  84652. static BILLBOARDMODE_ALL: number;
  84653. /**
  84654. * Object will rotate to face the camera's position instead of orientation
  84655. */
  84656. static BILLBOARDMODE_USE_POSITION: number;
  84657. private _forward;
  84658. private _forwardInverted;
  84659. private _up;
  84660. private _right;
  84661. private _rightInverted;
  84662. private _position;
  84663. private _rotation;
  84664. private _rotationQuaternion;
  84665. protected _scaling: Vector3;
  84666. protected _isDirty: boolean;
  84667. private _transformToBoneReferal;
  84668. private _isAbsoluteSynced;
  84669. private _billboardMode;
  84670. /**
  84671. * Gets or sets the billboard mode. Default is 0.
  84672. *
  84673. * | Value | Type | Description |
  84674. * | --- | --- | --- |
  84675. * | 0 | BILLBOARDMODE_NONE | |
  84676. * | 1 | BILLBOARDMODE_X | |
  84677. * | 2 | BILLBOARDMODE_Y | |
  84678. * | 4 | BILLBOARDMODE_Z | |
  84679. * | 7 | BILLBOARDMODE_ALL | |
  84680. *
  84681. */
  84682. get billboardMode(): number;
  84683. set billboardMode(value: number);
  84684. private _preserveParentRotationForBillboard;
  84685. /**
  84686. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  84687. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  84688. */
  84689. get preserveParentRotationForBillboard(): boolean;
  84690. set preserveParentRotationForBillboard(value: boolean);
  84691. /**
  84692. * 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
  84693. */
  84694. scalingDeterminant: number;
  84695. private _infiniteDistance;
  84696. /**
  84697. * Gets or sets the distance of the object to max, often used by skybox
  84698. */
  84699. get infiniteDistance(): boolean;
  84700. set infiniteDistance(value: boolean);
  84701. /**
  84702. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  84703. * By default the system will update normals to compensate
  84704. */
  84705. ignoreNonUniformScaling: boolean;
  84706. /**
  84707. * 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
  84708. */
  84709. reIntegrateRotationIntoRotationQuaternion: boolean;
  84710. /** @hidden */
  84711. _poseMatrix: Nullable<Matrix>;
  84712. /** @hidden */
  84713. _localMatrix: Matrix;
  84714. private _usePivotMatrix;
  84715. private _absolutePosition;
  84716. private _absoluteScaling;
  84717. private _absoluteRotationQuaternion;
  84718. private _pivotMatrix;
  84719. private _pivotMatrixInverse;
  84720. protected _postMultiplyPivotMatrix: boolean;
  84721. protected _isWorldMatrixFrozen: boolean;
  84722. /** @hidden */
  84723. _indexInSceneTransformNodesArray: number;
  84724. /**
  84725. * An event triggered after the world matrix is updated
  84726. */
  84727. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  84728. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  84729. /**
  84730. * Gets a string identifying the name of the class
  84731. * @returns "TransformNode" string
  84732. */
  84733. getClassName(): string;
  84734. /**
  84735. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  84736. */
  84737. get position(): Vector3;
  84738. set position(newPosition: Vector3);
  84739. /**
  84740. * 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)).
  84741. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  84742. */
  84743. get rotation(): Vector3;
  84744. set rotation(newRotation: Vector3);
  84745. /**
  84746. * 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)).
  84747. */
  84748. get scaling(): Vector3;
  84749. set scaling(newScaling: Vector3);
  84750. /**
  84751. * 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).
  84752. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  84753. */
  84754. get rotationQuaternion(): Nullable<Quaternion>;
  84755. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  84756. /**
  84757. * The forward direction of that transform in world space.
  84758. */
  84759. get forward(): Vector3;
  84760. /**
  84761. * The up direction of that transform in world space.
  84762. */
  84763. get up(): Vector3;
  84764. /**
  84765. * The right direction of that transform in world space.
  84766. */
  84767. get right(): Vector3;
  84768. /**
  84769. * Copies the parameter passed Matrix into the mesh Pose matrix.
  84770. * @param matrix the matrix to copy the pose from
  84771. * @returns this TransformNode.
  84772. */
  84773. updatePoseMatrix(matrix: Matrix): TransformNode;
  84774. /**
  84775. * Returns the mesh Pose matrix.
  84776. * @returns the pose matrix
  84777. */
  84778. getPoseMatrix(): Matrix;
  84779. /** @hidden */
  84780. _isSynchronized(): boolean;
  84781. /** @hidden */
  84782. _initCache(): void;
  84783. /**
  84784. * Flag the transform node as dirty (Forcing it to update everything)
  84785. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  84786. * @returns this transform node
  84787. */
  84788. markAsDirty(property: string): TransformNode;
  84789. /**
  84790. * Returns the current mesh absolute position.
  84791. * Returns a Vector3.
  84792. */
  84793. get absolutePosition(): Vector3;
  84794. /**
  84795. * Returns the current mesh absolute scaling.
  84796. * Returns a Vector3.
  84797. */
  84798. get absoluteScaling(): Vector3;
  84799. /**
  84800. * Returns the current mesh absolute rotation.
  84801. * Returns a Quaternion.
  84802. */
  84803. get absoluteRotationQuaternion(): Quaternion;
  84804. /**
  84805. * Sets a new matrix to apply before all other transformation
  84806. * @param matrix defines the transform matrix
  84807. * @returns the current TransformNode
  84808. */
  84809. setPreTransformMatrix(matrix: Matrix): TransformNode;
  84810. /**
  84811. * Sets a new pivot matrix to the current node
  84812. * @param matrix defines the new pivot matrix to use
  84813. * @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
  84814. * @returns the current TransformNode
  84815. */
  84816. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  84817. /**
  84818. * Returns the mesh pivot matrix.
  84819. * Default : Identity.
  84820. * @returns the matrix
  84821. */
  84822. getPivotMatrix(): Matrix;
  84823. /**
  84824. * Instantiate (when possible) or clone that node with its hierarchy
  84825. * @param newParent defines the new parent to use for the instance (or clone)
  84826. * @param options defines options to configure how copy is done
  84827. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  84828. * @returns an instance (or a clone) of the current node with its hiearchy
  84829. */
  84830. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  84831. doNotInstantiate: boolean;
  84832. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  84833. /**
  84834. * Prevents the World matrix to be computed any longer
  84835. * @param newWorldMatrix defines an optional matrix to use as world matrix
  84836. * @returns the TransformNode.
  84837. */
  84838. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  84839. /**
  84840. * Allows back the World matrix computation.
  84841. * @returns the TransformNode.
  84842. */
  84843. unfreezeWorldMatrix(): this;
  84844. /**
  84845. * True if the World matrix has been frozen.
  84846. */
  84847. get isWorldMatrixFrozen(): boolean;
  84848. /**
  84849. * Retuns the mesh absolute position in the World.
  84850. * @returns a Vector3.
  84851. */
  84852. getAbsolutePosition(): Vector3;
  84853. /**
  84854. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  84855. * @param absolutePosition the absolute position to set
  84856. * @returns the TransformNode.
  84857. */
  84858. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  84859. /**
  84860. * Sets the mesh position in its local space.
  84861. * @param vector3 the position to set in localspace
  84862. * @returns the TransformNode.
  84863. */
  84864. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  84865. /**
  84866. * Returns the mesh position in the local space from the current World matrix values.
  84867. * @returns a new Vector3.
  84868. */
  84869. getPositionExpressedInLocalSpace(): Vector3;
  84870. /**
  84871. * Translates the mesh along the passed Vector3 in its local space.
  84872. * @param vector3 the distance to translate in localspace
  84873. * @returns the TransformNode.
  84874. */
  84875. locallyTranslate(vector3: Vector3): TransformNode;
  84876. private static _lookAtVectorCache;
  84877. /**
  84878. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  84879. * @param targetPoint the position (must be in same space as current mesh) to look at
  84880. * @param yawCor optional yaw (y-axis) correction in radians
  84881. * @param pitchCor optional pitch (x-axis) correction in radians
  84882. * @param rollCor optional roll (z-axis) correction in radians
  84883. * @param space the choosen space of the target
  84884. * @returns the TransformNode.
  84885. */
  84886. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  84887. /**
  84888. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84889. * This Vector3 is expressed in the World space.
  84890. * @param localAxis axis to rotate
  84891. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84892. */
  84893. getDirection(localAxis: Vector3): Vector3;
  84894. /**
  84895. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  84896. * localAxis is expressed in the mesh local space.
  84897. * result is computed in the Wordl space from the mesh World matrix.
  84898. * @param localAxis axis to rotate
  84899. * @param result the resulting transformnode
  84900. * @returns this TransformNode.
  84901. */
  84902. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  84903. /**
  84904. * Sets this transform node rotation to the given local axis.
  84905. * @param localAxis the axis in local space
  84906. * @param yawCor optional yaw (y-axis) correction in radians
  84907. * @param pitchCor optional pitch (x-axis) correction in radians
  84908. * @param rollCor optional roll (z-axis) correction in radians
  84909. * @returns this TransformNode
  84910. */
  84911. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  84912. /**
  84913. * Sets a new pivot point to the current node
  84914. * @param point defines the new pivot point to use
  84915. * @param space defines if the point is in world or local space (local by default)
  84916. * @returns the current TransformNode
  84917. */
  84918. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  84919. /**
  84920. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  84921. * @returns the pivot point
  84922. */
  84923. getPivotPoint(): Vector3;
  84924. /**
  84925. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  84926. * @param result the vector3 to store the result
  84927. * @returns this TransformNode.
  84928. */
  84929. getPivotPointToRef(result: Vector3): TransformNode;
  84930. /**
  84931. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  84932. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  84933. */
  84934. getAbsolutePivotPoint(): Vector3;
  84935. /**
  84936. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  84937. * @param result vector3 to store the result
  84938. * @returns this TransformNode.
  84939. */
  84940. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  84941. /**
  84942. * Defines the passed node as the parent of the current node.
  84943. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  84944. * @see https://doc.babylonjs.com/how_to/parenting
  84945. * @param node the node ot set as the parent
  84946. * @returns this TransformNode.
  84947. */
  84948. setParent(node: Nullable<Node>): TransformNode;
  84949. private _nonUniformScaling;
  84950. /**
  84951. * True if the scaling property of this object is non uniform eg. (1,2,1)
  84952. */
  84953. get nonUniformScaling(): boolean;
  84954. /** @hidden */
  84955. _updateNonUniformScalingState(value: boolean): boolean;
  84956. /**
  84957. * Attach the current TransformNode to another TransformNode associated with a bone
  84958. * @param bone Bone affecting the TransformNode
  84959. * @param affectedTransformNode TransformNode associated with the bone
  84960. * @returns this object
  84961. */
  84962. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  84963. /**
  84964. * Detach the transform node if its associated with a bone
  84965. * @returns this object
  84966. */
  84967. detachFromBone(): TransformNode;
  84968. private static _rotationAxisCache;
  84969. /**
  84970. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  84971. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  84972. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  84973. * The passed axis is also normalized.
  84974. * @param axis the axis to rotate around
  84975. * @param amount the amount to rotate in radians
  84976. * @param space Space to rotate in (Default: local)
  84977. * @returns the TransformNode.
  84978. */
  84979. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  84980. /**
  84981. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  84982. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  84983. * The passed axis is also normalized. .
  84984. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  84985. * @param point the point to rotate around
  84986. * @param axis the axis to rotate around
  84987. * @param amount the amount to rotate in radians
  84988. * @returns the TransformNode
  84989. */
  84990. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  84991. /**
  84992. * Translates the mesh along the axis vector for the passed distance in the given space.
  84993. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  84994. * @param axis the axis to translate in
  84995. * @param distance the distance to translate
  84996. * @param space Space to rotate in (Default: local)
  84997. * @returns the TransformNode.
  84998. */
  84999. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85000. /**
  85001. * Adds a rotation step to the mesh current rotation.
  85002. * x, y, z are Euler angles expressed in radians.
  85003. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85004. * This means this rotation is made in the mesh local space only.
  85005. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85006. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85007. * ```javascript
  85008. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85009. * ```
  85010. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85011. * 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.
  85012. * @param x Rotation to add
  85013. * @param y Rotation to add
  85014. * @param z Rotation to add
  85015. * @returns the TransformNode.
  85016. */
  85017. addRotation(x: number, y: number, z: number): TransformNode;
  85018. /**
  85019. * @hidden
  85020. */
  85021. protected _getEffectiveParent(): Nullable<Node>;
  85022. /**
  85023. * Computes the world matrix of the node
  85024. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85025. * @returns the world matrix
  85026. */
  85027. computeWorldMatrix(force?: boolean): Matrix;
  85028. protected _afterComputeWorldMatrix(): void;
  85029. /**
  85030. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85031. * @param func callback function to add
  85032. *
  85033. * @returns the TransformNode.
  85034. */
  85035. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85036. /**
  85037. * Removes a registered callback function.
  85038. * @param func callback function to remove
  85039. * @returns the TransformNode.
  85040. */
  85041. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85042. /**
  85043. * Gets the position of the current mesh in camera space
  85044. * @param camera defines the camera to use
  85045. * @returns a position
  85046. */
  85047. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85048. /**
  85049. * Returns the distance from the mesh to the active camera
  85050. * @param camera defines the camera to use
  85051. * @returns the distance
  85052. */
  85053. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85054. /**
  85055. * Clone the current transform node
  85056. * @param name Name of the new clone
  85057. * @param newParent New parent for the clone
  85058. * @param doNotCloneChildren Do not clone children hierarchy
  85059. * @returns the new transform node
  85060. */
  85061. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85062. /**
  85063. * Serializes the objects information.
  85064. * @param currentSerializationObject defines the object to serialize in
  85065. * @returns the serialized object
  85066. */
  85067. serialize(currentSerializationObject?: any): any;
  85068. /**
  85069. * Returns a new TransformNode object parsed from the source provided.
  85070. * @param parsedTransformNode is the source.
  85071. * @param scene the scne the object belongs to
  85072. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85073. * @returns a new TransformNode object parsed from the source provided.
  85074. */
  85075. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85076. /**
  85077. * Get all child-transformNodes of this node
  85078. * @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
  85079. * @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
  85080. * @returns an array of TransformNode
  85081. */
  85082. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85083. /**
  85084. * Releases resources associated with this transform node.
  85085. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85086. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85087. */
  85088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85089. /**
  85090. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85091. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85092. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85093. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85094. * @returns the current mesh
  85095. */
  85096. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85097. private _syncAbsoluteScalingAndRotation;
  85098. }
  85099. }
  85100. declare module BABYLON {
  85101. /**
  85102. * Defines the types of pose enabled controllers that are supported
  85103. */
  85104. export enum PoseEnabledControllerType {
  85105. /**
  85106. * HTC Vive
  85107. */
  85108. VIVE = 0,
  85109. /**
  85110. * Oculus Rift
  85111. */
  85112. OCULUS = 1,
  85113. /**
  85114. * Windows mixed reality
  85115. */
  85116. WINDOWS = 2,
  85117. /**
  85118. * Samsung gear VR
  85119. */
  85120. GEAR_VR = 3,
  85121. /**
  85122. * Google Daydream
  85123. */
  85124. DAYDREAM = 4,
  85125. /**
  85126. * Generic
  85127. */
  85128. GENERIC = 5
  85129. }
  85130. /**
  85131. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85132. */
  85133. export interface MutableGamepadButton {
  85134. /**
  85135. * Value of the button/trigger
  85136. */
  85137. value: number;
  85138. /**
  85139. * If the button/trigger is currently touched
  85140. */
  85141. touched: boolean;
  85142. /**
  85143. * If the button/trigger is currently pressed
  85144. */
  85145. pressed: boolean;
  85146. }
  85147. /**
  85148. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  85149. * @hidden
  85150. */
  85151. export interface ExtendedGamepadButton extends GamepadButton {
  85152. /**
  85153. * If the button/trigger is currently pressed
  85154. */
  85155. readonly pressed: boolean;
  85156. /**
  85157. * If the button/trigger is currently touched
  85158. */
  85159. readonly touched: boolean;
  85160. /**
  85161. * Value of the button/trigger
  85162. */
  85163. readonly value: number;
  85164. }
  85165. /** @hidden */
  85166. export interface _GamePadFactory {
  85167. /**
  85168. * Returns wether or not the current gamepad can be created for this type of controller.
  85169. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85170. * @returns true if it can be created, otherwise false
  85171. */
  85172. canCreate(gamepadInfo: any): boolean;
  85173. /**
  85174. * Creates a new instance of the Gamepad.
  85175. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85176. * @returns the new gamepad instance
  85177. */
  85178. create(gamepadInfo: any): Gamepad;
  85179. }
  85180. /**
  85181. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85182. */
  85183. export class PoseEnabledControllerHelper {
  85184. /** @hidden */
  85185. static _ControllerFactories: _GamePadFactory[];
  85186. /** @hidden */
  85187. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  85188. /**
  85189. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85190. * @param vrGamepad the gamepad to initialized
  85191. * @returns a vr controller of the type the gamepad identified as
  85192. */
  85193. static InitiateController(vrGamepad: any): Gamepad;
  85194. }
  85195. /**
  85196. * Defines the PoseEnabledController object that contains state of a vr capable controller
  85197. */
  85198. export class PoseEnabledController extends Gamepad implements PoseControlled {
  85199. /**
  85200. * If the controller is used in a webXR session
  85201. */
  85202. isXR: boolean;
  85203. private _deviceRoomPosition;
  85204. private _deviceRoomRotationQuaternion;
  85205. /**
  85206. * The device position in babylon space
  85207. */
  85208. devicePosition: Vector3;
  85209. /**
  85210. * The device rotation in babylon space
  85211. */
  85212. deviceRotationQuaternion: Quaternion;
  85213. /**
  85214. * The scale factor of the device in babylon space
  85215. */
  85216. deviceScaleFactor: number;
  85217. /**
  85218. * (Likely devicePosition should be used instead) The device position in its room space
  85219. */
  85220. position: Vector3;
  85221. /**
  85222. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  85223. */
  85224. rotationQuaternion: Quaternion;
  85225. /**
  85226. * The type of controller (Eg. Windows mixed reality)
  85227. */
  85228. controllerType: PoseEnabledControllerType;
  85229. protected _calculatedPosition: Vector3;
  85230. private _calculatedRotation;
  85231. /**
  85232. * The raw pose from the device
  85233. */
  85234. rawPose: DevicePose;
  85235. private _trackPosition;
  85236. private _maxRotationDistFromHeadset;
  85237. private _draggedRoomRotation;
  85238. /**
  85239. * @hidden
  85240. */
  85241. _disableTrackPosition(fixedPosition: Vector3): void;
  85242. /**
  85243. * Internal, the mesh attached to the controller
  85244. * @hidden
  85245. */
  85246. _mesh: Nullable<AbstractMesh>;
  85247. private _poseControlledCamera;
  85248. private _leftHandSystemQuaternion;
  85249. /**
  85250. * Internal, matrix used to convert room space to babylon space
  85251. * @hidden
  85252. */
  85253. _deviceToWorld: Matrix;
  85254. /**
  85255. * Node to be used when casting a ray from the controller
  85256. * @hidden
  85257. */
  85258. _pointingPoseNode: Nullable<TransformNode>;
  85259. /**
  85260. * Name of the child mesh that can be used to cast a ray from the controller
  85261. */
  85262. static readonly POINTING_POSE: string;
  85263. /**
  85264. * Creates a new PoseEnabledController from a gamepad
  85265. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  85266. */
  85267. constructor(browserGamepad: any);
  85268. private _workingMatrix;
  85269. /**
  85270. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  85271. */
  85272. update(): void;
  85273. /**
  85274. * Updates only the pose device and mesh without doing any button event checking
  85275. */
  85276. protected _updatePoseAndMesh(): void;
  85277. /**
  85278. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  85279. * @param poseData raw pose fromthe device
  85280. */
  85281. updateFromDevice(poseData: DevicePose): void;
  85282. /**
  85283. * @hidden
  85284. */
  85285. _meshAttachedObservable: Observable<AbstractMesh>;
  85286. /**
  85287. * Attaches a mesh to the controller
  85288. * @param mesh the mesh to be attached
  85289. */
  85290. attachToMesh(mesh: AbstractMesh): void;
  85291. /**
  85292. * Attaches the controllers mesh to a camera
  85293. * @param camera the camera the mesh should be attached to
  85294. */
  85295. attachToPoseControlledCamera(camera: TargetCamera): void;
  85296. /**
  85297. * Disposes of the controller
  85298. */
  85299. dispose(): void;
  85300. /**
  85301. * The mesh that is attached to the controller
  85302. */
  85303. get mesh(): Nullable<AbstractMesh>;
  85304. /**
  85305. * Gets the ray of the controller in the direction the controller is pointing
  85306. * @param length the length the resulting ray should be
  85307. * @returns a ray in the direction the controller is pointing
  85308. */
  85309. getForwardRay(length?: number): Ray;
  85310. }
  85311. }
  85312. declare module BABYLON {
  85313. /**
  85314. * Defines the WebVRController object that represents controllers tracked in 3D space
  85315. */
  85316. export abstract class WebVRController extends PoseEnabledController {
  85317. /**
  85318. * Internal, the default controller model for the controller
  85319. */
  85320. protected _defaultModel: Nullable<AbstractMesh>;
  85321. /**
  85322. * Fired when the trigger state has changed
  85323. */
  85324. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  85325. /**
  85326. * Fired when the main button state has changed
  85327. */
  85328. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85329. /**
  85330. * Fired when the secondary button state has changed
  85331. */
  85332. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85333. /**
  85334. * Fired when the pad state has changed
  85335. */
  85336. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  85337. /**
  85338. * Fired when controllers stick values have changed
  85339. */
  85340. onPadValuesChangedObservable: Observable<StickValues>;
  85341. /**
  85342. * Array of button availible on the controller
  85343. */
  85344. protected _buttons: Array<MutableGamepadButton>;
  85345. private _onButtonStateChange;
  85346. /**
  85347. * Fired when a controller button's state has changed
  85348. * @param callback the callback containing the button that was modified
  85349. */
  85350. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  85351. /**
  85352. * X and Y axis corresponding to the controllers joystick
  85353. */
  85354. pad: StickValues;
  85355. /**
  85356. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  85357. */
  85358. hand: string;
  85359. /**
  85360. * The default controller model for the controller
  85361. */
  85362. get defaultModel(): Nullable<AbstractMesh>;
  85363. /**
  85364. * Creates a new WebVRController from a gamepad
  85365. * @param vrGamepad the gamepad that the WebVRController should be created from
  85366. */
  85367. constructor(vrGamepad: any);
  85368. /**
  85369. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  85370. */
  85371. update(): void;
  85372. /**
  85373. * Function to be called when a button is modified
  85374. */
  85375. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  85376. /**
  85377. * Loads a mesh and attaches it to the controller
  85378. * @param scene the scene the mesh should be added to
  85379. * @param meshLoaded callback for when the mesh has been loaded
  85380. */
  85381. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  85382. private _setButtonValue;
  85383. private _changes;
  85384. private _checkChanges;
  85385. /**
  85386. * Disposes of th webVRCOntroller
  85387. */
  85388. dispose(): void;
  85389. }
  85390. }
  85391. declare module BABYLON {
  85392. /**
  85393. * The HemisphericLight simulates the ambient environment light,
  85394. * so the passed direction is the light reflection direction, not the incoming direction.
  85395. */
  85396. export class HemisphericLight extends Light {
  85397. /**
  85398. * The groundColor is the light in the opposite direction to the one specified during creation.
  85399. * 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.
  85400. */
  85401. groundColor: Color3;
  85402. /**
  85403. * The light reflection direction, not the incoming direction.
  85404. */
  85405. direction: Vector3;
  85406. /**
  85407. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  85408. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  85409. * The HemisphericLight can't cast shadows.
  85410. * Documentation : https://doc.babylonjs.com/babylon101/lights
  85411. * @param name The friendly name of the light
  85412. * @param direction The direction of the light reflection
  85413. * @param scene The scene the light belongs to
  85414. */
  85415. constructor(name: string, direction: Vector3, scene: Scene);
  85416. protected _buildUniformLayout(): void;
  85417. /**
  85418. * Returns the string "HemisphericLight".
  85419. * @return The class name
  85420. */
  85421. getClassName(): string;
  85422. /**
  85423. * Sets the HemisphericLight direction towards the passed target (Vector3).
  85424. * Returns the updated direction.
  85425. * @param target The target the direction should point to
  85426. * @return The computed direction
  85427. */
  85428. setDirectionToTarget(target: Vector3): Vector3;
  85429. /**
  85430. * Returns the shadow generator associated to the light.
  85431. * @returns Always null for hemispheric lights because it does not support shadows.
  85432. */
  85433. getShadowGenerator(): Nullable<IShadowGenerator>;
  85434. /**
  85435. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  85436. * @param effect The effect to update
  85437. * @param lightIndex The index of the light in the effect to update
  85438. * @returns The hemispheric light
  85439. */
  85440. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  85441. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  85442. /**
  85443. * Computes the world matrix of the node
  85444. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85445. * @param useWasUpdatedFlag defines a reserved property
  85446. * @returns the world matrix
  85447. */
  85448. computeWorldMatrix(): Matrix;
  85449. /**
  85450. * Returns the integer 3.
  85451. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  85452. */
  85453. getTypeID(): number;
  85454. /**
  85455. * Prepares the list of defines specific to the light type.
  85456. * @param defines the list of defines
  85457. * @param lightIndex defines the index of the light for the effect
  85458. */
  85459. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  85460. }
  85461. }
  85462. declare module BABYLON {
  85463. /** @hidden */
  85464. export var vrMultiviewToSingleviewPixelShader: {
  85465. name: string;
  85466. shader: string;
  85467. };
  85468. }
  85469. declare module BABYLON {
  85470. /**
  85471. * Renders to multiple views with a single draw call
  85472. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  85473. */
  85474. export class MultiviewRenderTarget extends RenderTargetTexture {
  85475. /**
  85476. * Creates a multiview render target
  85477. * @param scene scene used with the render target
  85478. * @param size the size of the render target (used for each view)
  85479. */
  85480. constructor(scene: Scene, size?: number | {
  85481. width: number;
  85482. height: number;
  85483. } | {
  85484. ratio: number;
  85485. });
  85486. /**
  85487. * @hidden
  85488. * @param faceIndex the face index, if its a cube texture
  85489. */
  85490. _bindFrameBuffer(faceIndex?: number): void;
  85491. /**
  85492. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85493. * @returns the view count
  85494. */
  85495. getViewCount(): number;
  85496. }
  85497. }
  85498. declare module BABYLON {
  85499. /**
  85500. * Represents a camera frustum
  85501. */
  85502. export class Frustum {
  85503. /**
  85504. * Gets the planes representing the frustum
  85505. * @param transform matrix to be applied to the returned planes
  85506. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85507. */
  85508. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85509. /**
  85510. * Gets the near frustum plane transformed by the transform matrix
  85511. * @param transform transformation matrix to be applied to the resulting frustum plane
  85512. * @param frustumPlane the resuling frustum plane
  85513. */
  85514. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85515. /**
  85516. * Gets the far frustum plane transformed by the transform matrix
  85517. * @param transform transformation matrix to be applied to the resulting frustum plane
  85518. * @param frustumPlane the resuling frustum plane
  85519. */
  85520. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85521. /**
  85522. * Gets the left frustum plane transformed by the transform matrix
  85523. * @param transform transformation matrix to be applied to the resulting frustum plane
  85524. * @param frustumPlane the resuling frustum plane
  85525. */
  85526. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85527. /**
  85528. * Gets the right frustum plane transformed by the transform matrix
  85529. * @param transform transformation matrix to be applied to the resulting frustum plane
  85530. * @param frustumPlane the resuling frustum plane
  85531. */
  85532. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85533. /**
  85534. * Gets the top frustum plane transformed by the transform matrix
  85535. * @param transform transformation matrix to be applied to the resulting frustum plane
  85536. * @param frustumPlane the resuling frustum plane
  85537. */
  85538. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85539. /**
  85540. * Gets the bottom frustum plane transformed by the transform matrix
  85541. * @param transform transformation matrix to be applied to the resulting frustum plane
  85542. * @param frustumPlane the resuling frustum plane
  85543. */
  85544. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85545. /**
  85546. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85547. * @param transform transformation matrix to be applied to the resulting frustum planes
  85548. * @param frustumPlanes the resuling frustum planes
  85549. */
  85550. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85551. }
  85552. }
  85553. declare module BABYLON {
  85554. interface Engine {
  85555. /**
  85556. * Creates a new multiview render target
  85557. * @param width defines the width of the texture
  85558. * @param height defines the height of the texture
  85559. * @returns the created multiview texture
  85560. */
  85561. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  85562. /**
  85563. * Binds a multiview framebuffer to be drawn to
  85564. * @param multiviewTexture texture to bind
  85565. */
  85566. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  85567. }
  85568. interface Camera {
  85569. /**
  85570. * @hidden
  85571. * 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)
  85572. */
  85573. _useMultiviewToSingleView: boolean;
  85574. /**
  85575. * @hidden
  85576. * 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)
  85577. */
  85578. _multiviewTexture: Nullable<RenderTargetTexture>;
  85579. /**
  85580. * @hidden
  85581. * ensures the multiview texture of the camera exists and has the specified width/height
  85582. * @param width height to set on the multiview texture
  85583. * @param height width to set on the multiview texture
  85584. */
  85585. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  85586. }
  85587. interface Scene {
  85588. /** @hidden */
  85589. _transformMatrixR: Matrix;
  85590. /** @hidden */
  85591. _multiviewSceneUbo: Nullable<UniformBuffer>;
  85592. /** @hidden */
  85593. _createMultiviewUbo(): void;
  85594. /** @hidden */
  85595. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  85596. /** @hidden */
  85597. _renderMultiviewToSingleView(camera: Camera): void;
  85598. }
  85599. }
  85600. declare module BABYLON {
  85601. /**
  85602. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  85603. * This will not be used for webXR as it supports displaying texture arrays directly
  85604. */
  85605. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  85606. /**
  85607. * Initializes a VRMultiviewToSingleview
  85608. * @param name name of the post process
  85609. * @param camera camera to be applied to
  85610. * @param scaleFactor scaling factor to the size of the output texture
  85611. */
  85612. constructor(name: string, camera: Camera, scaleFactor: number);
  85613. }
  85614. }
  85615. declare module BABYLON {
  85616. /**
  85617. * Interface used to define additional presentation attributes
  85618. */
  85619. export interface IVRPresentationAttributes {
  85620. /**
  85621. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  85622. */
  85623. highRefreshRate: boolean;
  85624. /**
  85625. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  85626. */
  85627. foveationLevel: number;
  85628. }
  85629. interface Engine {
  85630. /** @hidden */
  85631. _vrDisplay: any;
  85632. /** @hidden */
  85633. _vrSupported: boolean;
  85634. /** @hidden */
  85635. _oldSize: Size;
  85636. /** @hidden */
  85637. _oldHardwareScaleFactor: number;
  85638. /** @hidden */
  85639. _vrExclusivePointerMode: boolean;
  85640. /** @hidden */
  85641. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  85642. /** @hidden */
  85643. _onVRDisplayPointerRestricted: () => void;
  85644. /** @hidden */
  85645. _onVRDisplayPointerUnrestricted: () => void;
  85646. /** @hidden */
  85647. _onVrDisplayConnect: Nullable<(display: any) => void>;
  85648. /** @hidden */
  85649. _onVrDisplayDisconnect: Nullable<() => void>;
  85650. /** @hidden */
  85651. _onVrDisplayPresentChange: Nullable<() => void>;
  85652. /**
  85653. * Observable signaled when VR display mode changes
  85654. */
  85655. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85656. /**
  85657. * Observable signaled when VR request present is complete
  85658. */
  85659. onVRRequestPresentComplete: Observable<boolean>;
  85660. /**
  85661. * Observable signaled when VR request present starts
  85662. */
  85663. onVRRequestPresentStart: Observable<Engine>;
  85664. /**
  85665. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85666. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85667. */
  85668. isInVRExclusivePointerMode: boolean;
  85669. /**
  85670. * Gets a boolean indicating if a webVR device was detected
  85671. * @returns true if a webVR device was detected
  85672. */
  85673. isVRDevicePresent(): boolean;
  85674. /**
  85675. * Gets the current webVR device
  85676. * @returns the current webVR device (or null)
  85677. */
  85678. getVRDevice(): any;
  85679. /**
  85680. * Initializes a webVR display and starts listening to display change events
  85681. * The onVRDisplayChangedObservable will be notified upon these changes
  85682. * @returns A promise containing a VRDisplay and if vr is supported
  85683. */
  85684. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85685. /** @hidden */
  85686. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  85687. /**
  85688. * Gets or sets the presentation attributes used to configure VR rendering
  85689. */
  85690. vrPresentationAttributes?: IVRPresentationAttributes;
  85691. /**
  85692. * Call this function to switch to webVR mode
  85693. * Will do nothing if webVR is not supported or if there is no webVR device
  85694. * @param options the webvr options provided to the camera. mainly used for multiview
  85695. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85696. */
  85697. enableVR(options: WebVROptions): void;
  85698. /** @hidden */
  85699. _onVRFullScreenTriggered(): void;
  85700. }
  85701. }
  85702. declare module BABYLON {
  85703. /**
  85704. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  85705. * IMPORTANT!! The data is right-hand data.
  85706. * @export
  85707. * @interface DevicePose
  85708. */
  85709. export interface DevicePose {
  85710. /**
  85711. * The position of the device, values in array are [x,y,z].
  85712. */
  85713. readonly position: Nullable<Float32Array>;
  85714. /**
  85715. * The linearVelocity of the device, values in array are [x,y,z].
  85716. */
  85717. readonly linearVelocity: Nullable<Float32Array>;
  85718. /**
  85719. * The linearAcceleration of the device, values in array are [x,y,z].
  85720. */
  85721. readonly linearAcceleration: Nullable<Float32Array>;
  85722. /**
  85723. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  85724. */
  85725. readonly orientation: Nullable<Float32Array>;
  85726. /**
  85727. * The angularVelocity of the device, values in array are [x,y,z].
  85728. */
  85729. readonly angularVelocity: Nullable<Float32Array>;
  85730. /**
  85731. * The angularAcceleration of the device, values in array are [x,y,z].
  85732. */
  85733. readonly angularAcceleration: Nullable<Float32Array>;
  85734. }
  85735. /**
  85736. * Interface representing a pose controlled object in Babylon.
  85737. * A pose controlled object has both regular pose values as well as pose values
  85738. * from an external device such as a VR head mounted display
  85739. */
  85740. export interface PoseControlled {
  85741. /**
  85742. * The position of the object in babylon space.
  85743. */
  85744. position: Vector3;
  85745. /**
  85746. * The rotation quaternion of the object in babylon space.
  85747. */
  85748. rotationQuaternion: Quaternion;
  85749. /**
  85750. * The position of the device in babylon space.
  85751. */
  85752. devicePosition?: Vector3;
  85753. /**
  85754. * The rotation quaternion of the device in babylon space.
  85755. */
  85756. deviceRotationQuaternion: Quaternion;
  85757. /**
  85758. * The raw pose coming from the device.
  85759. */
  85760. rawPose: Nullable<DevicePose>;
  85761. /**
  85762. * The scale of the device to be used when translating from device space to babylon space.
  85763. */
  85764. deviceScaleFactor: number;
  85765. /**
  85766. * Updates the poseControlled values based on the input device pose.
  85767. * @param poseData the pose data to update the object with
  85768. */
  85769. updateFromDevice(poseData: DevicePose): void;
  85770. }
  85771. /**
  85772. * Set of options to customize the webVRCamera
  85773. */
  85774. export interface WebVROptions {
  85775. /**
  85776. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  85777. */
  85778. trackPosition?: boolean;
  85779. /**
  85780. * Sets the scale of the vrDevice in babylon space. (default: 1)
  85781. */
  85782. positionScale?: number;
  85783. /**
  85784. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  85785. */
  85786. displayName?: string;
  85787. /**
  85788. * Should the native controller meshes be initialized. (default: true)
  85789. */
  85790. controllerMeshes?: boolean;
  85791. /**
  85792. * Creating a default HemiLight only on controllers. (default: true)
  85793. */
  85794. defaultLightingOnControllers?: boolean;
  85795. /**
  85796. * If you don't want to use the default VR button of the helper. (default: false)
  85797. */
  85798. useCustomVRButton?: boolean;
  85799. /**
  85800. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  85801. */
  85802. customVRButton?: HTMLButtonElement;
  85803. /**
  85804. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  85805. */
  85806. rayLength?: number;
  85807. /**
  85808. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  85809. */
  85810. defaultHeight?: number;
  85811. /**
  85812. * If multiview should be used if availible (default: false)
  85813. */
  85814. useMultiview?: boolean;
  85815. }
  85816. /**
  85817. * This represents a WebVR camera.
  85818. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  85819. * @example http://doc.babylonjs.com/how_to/webvr_camera
  85820. */
  85821. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  85822. private webVROptions;
  85823. /**
  85824. * @hidden
  85825. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  85826. */
  85827. _vrDevice: any;
  85828. /**
  85829. * The rawPose of the vrDevice.
  85830. */
  85831. rawPose: Nullable<DevicePose>;
  85832. private _onVREnabled;
  85833. private _specsVersion;
  85834. private _attached;
  85835. private _frameData;
  85836. protected _descendants: Array<Node>;
  85837. private _deviceRoomPosition;
  85838. /** @hidden */
  85839. _deviceRoomRotationQuaternion: Quaternion;
  85840. private _standingMatrix;
  85841. /**
  85842. * Represents device position in babylon space.
  85843. */
  85844. devicePosition: Vector3;
  85845. /**
  85846. * Represents device rotation in babylon space.
  85847. */
  85848. deviceRotationQuaternion: Quaternion;
  85849. /**
  85850. * The scale of the device to be used when translating from device space to babylon space.
  85851. */
  85852. deviceScaleFactor: number;
  85853. private _deviceToWorld;
  85854. private _worldToDevice;
  85855. /**
  85856. * References to the webVR controllers for the vrDevice.
  85857. */
  85858. controllers: Array<WebVRController>;
  85859. /**
  85860. * Emits an event when a controller is attached.
  85861. */
  85862. onControllersAttachedObservable: Observable<WebVRController[]>;
  85863. /**
  85864. * Emits an event when a controller's mesh has been loaded;
  85865. */
  85866. onControllerMeshLoadedObservable: Observable<WebVRController>;
  85867. /**
  85868. * Emits an event when the HMD's pose has been updated.
  85869. */
  85870. onPoseUpdatedFromDeviceObservable: Observable<any>;
  85871. private _poseSet;
  85872. /**
  85873. * If the rig cameras be used as parent instead of this camera.
  85874. */
  85875. rigParenting: boolean;
  85876. private _lightOnControllers;
  85877. private _defaultHeight?;
  85878. /**
  85879. * Instantiates a WebVRFreeCamera.
  85880. * @param name The name of the WebVRFreeCamera
  85881. * @param position The starting anchor position for the camera
  85882. * @param scene The scene the camera belongs to
  85883. * @param webVROptions a set of customizable options for the webVRCamera
  85884. */
  85885. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  85886. /**
  85887. * Gets the device distance from the ground in meters.
  85888. * @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.
  85889. */
  85890. deviceDistanceToRoomGround(): number;
  85891. /**
  85892. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85893. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  85894. */
  85895. useStandingMatrix(callback?: (bool: boolean) => void): void;
  85896. /**
  85897. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85898. * @returns A promise with a boolean set to if the standing matrix is supported.
  85899. */
  85900. useStandingMatrixAsync(): Promise<boolean>;
  85901. /**
  85902. * Disposes the camera
  85903. */
  85904. dispose(): void;
  85905. /**
  85906. * Gets a vrController by name.
  85907. * @param name The name of the controller to retreive
  85908. * @returns the controller matching the name specified or null if not found
  85909. */
  85910. getControllerByName(name: string): Nullable<WebVRController>;
  85911. private _leftController;
  85912. /**
  85913. * The controller corresponding to the users left hand.
  85914. */
  85915. get leftController(): Nullable<WebVRController>;
  85916. private _rightController;
  85917. /**
  85918. * The controller corresponding to the users right hand.
  85919. */
  85920. get rightController(): Nullable<WebVRController>;
  85921. /**
  85922. * Casts a ray forward from the vrCamera's gaze.
  85923. * @param length Length of the ray (default: 100)
  85924. * @returns the ray corresponding to the gaze
  85925. */
  85926. getForwardRay(length?: number): Ray;
  85927. /**
  85928. * @hidden
  85929. * Updates the camera based on device's frame data
  85930. */
  85931. _checkInputs(): void;
  85932. /**
  85933. * Updates the poseControlled values based on the input device pose.
  85934. * @param poseData Pose coming from the device
  85935. */
  85936. updateFromDevice(poseData: DevicePose): void;
  85937. private _htmlElementAttached;
  85938. private _detachIfAttached;
  85939. /**
  85940. * WebVR's attach control will start broadcasting frames to the device.
  85941. * Note that in certain browsers (chrome for example) this function must be called
  85942. * within a user-interaction callback. Example:
  85943. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  85944. *
  85945. * @param element html element to attach the vrDevice to
  85946. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  85947. */
  85948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85949. /**
  85950. * Detaches the camera from the html element and disables VR
  85951. *
  85952. * @param element html element to detach from
  85953. */
  85954. detachControl(element: HTMLElement): void;
  85955. /**
  85956. * @returns the name of this class
  85957. */
  85958. getClassName(): string;
  85959. /**
  85960. * Calls resetPose on the vrDisplay
  85961. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  85962. */
  85963. resetToCurrentRotation(): void;
  85964. /**
  85965. * @hidden
  85966. * Updates the rig cameras (left and right eye)
  85967. */
  85968. _updateRigCameras(): void;
  85969. private _workingVector;
  85970. private _oneVector;
  85971. private _workingMatrix;
  85972. private updateCacheCalled;
  85973. private _correctPositionIfNotTrackPosition;
  85974. /**
  85975. * @hidden
  85976. * Updates the cached values of the camera
  85977. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  85978. */
  85979. _updateCache(ignoreParentClass?: boolean): void;
  85980. /**
  85981. * @hidden
  85982. * Get current device position in babylon world
  85983. */
  85984. _computeDevicePosition(): void;
  85985. /**
  85986. * Updates the current device position and rotation in the babylon world
  85987. */
  85988. update(): void;
  85989. /**
  85990. * @hidden
  85991. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  85992. * @returns an identity matrix
  85993. */
  85994. _getViewMatrix(): Matrix;
  85995. private _tmpMatrix;
  85996. /**
  85997. * This function is called by the two RIG cameras.
  85998. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  85999. * @hidden
  86000. */
  86001. _getWebVRViewMatrix(): Matrix;
  86002. /** @hidden */
  86003. _getWebVRProjectionMatrix(): Matrix;
  86004. private _onGamepadConnectedObserver;
  86005. private _onGamepadDisconnectedObserver;
  86006. private _updateCacheWhenTrackingDisabledObserver;
  86007. /**
  86008. * Initializes the controllers and their meshes
  86009. */
  86010. initControllers(): void;
  86011. }
  86012. }
  86013. declare module BABYLON {
  86014. /**
  86015. * Size options for a post process
  86016. */
  86017. export type PostProcessOptions = {
  86018. width: number;
  86019. height: number;
  86020. };
  86021. /**
  86022. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86023. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86024. */
  86025. export class PostProcess {
  86026. /** Name of the PostProcess. */
  86027. name: string;
  86028. /**
  86029. * Gets or sets the unique id of the post process
  86030. */
  86031. uniqueId: number;
  86032. /**
  86033. * Width of the texture to apply the post process on
  86034. */
  86035. width: number;
  86036. /**
  86037. * Height of the texture to apply the post process on
  86038. */
  86039. height: number;
  86040. /**
  86041. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86042. * @hidden
  86043. */
  86044. _outputTexture: Nullable<InternalTexture>;
  86045. /**
  86046. * Sampling mode used by the shader
  86047. * See https://doc.babylonjs.com/classes/3.1/texture
  86048. */
  86049. renderTargetSamplingMode: number;
  86050. /**
  86051. * Clear color to use when screen clearing
  86052. */
  86053. clearColor: Color4;
  86054. /**
  86055. * If the buffer needs to be cleared before applying the post process. (default: true)
  86056. * Should be set to false if shader will overwrite all previous pixels.
  86057. */
  86058. autoClear: boolean;
  86059. /**
  86060. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86061. */
  86062. alphaMode: number;
  86063. /**
  86064. * Sets the setAlphaBlendConstants of the babylon engine
  86065. */
  86066. alphaConstants: Color4;
  86067. /**
  86068. * Animations to be used for the post processing
  86069. */
  86070. animations: Animation[];
  86071. /**
  86072. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86073. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86074. */
  86075. enablePixelPerfectMode: boolean;
  86076. /**
  86077. * Force the postprocess to be applied without taking in account viewport
  86078. */
  86079. forceFullscreenViewport: boolean;
  86080. /**
  86081. * List of inspectable custom properties (used by the Inspector)
  86082. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86083. */
  86084. inspectableCustomProperties: IInspectable[];
  86085. /**
  86086. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86087. *
  86088. * | Value | Type | Description |
  86089. * | ----- | ----------------------------------- | ----------- |
  86090. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86091. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86092. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86093. *
  86094. */
  86095. scaleMode: number;
  86096. /**
  86097. * Force textures to be a power of two (default: false)
  86098. */
  86099. alwaysForcePOT: boolean;
  86100. private _samples;
  86101. /**
  86102. * Number of sample textures (default: 1)
  86103. */
  86104. get samples(): number;
  86105. set samples(n: number);
  86106. /**
  86107. * Modify the scale of the post process to be the same as the viewport (default: false)
  86108. */
  86109. adaptScaleToCurrentViewport: boolean;
  86110. private _camera;
  86111. private _scene;
  86112. private _engine;
  86113. private _options;
  86114. private _reusable;
  86115. private _textureType;
  86116. /**
  86117. * Smart array of input and output textures for the post process.
  86118. * @hidden
  86119. */
  86120. _textures: SmartArray<InternalTexture>;
  86121. /**
  86122. * The index in _textures that corresponds to the output texture.
  86123. * @hidden
  86124. */
  86125. _currentRenderTextureInd: number;
  86126. private _effect;
  86127. private _samplers;
  86128. private _fragmentUrl;
  86129. private _vertexUrl;
  86130. private _parameters;
  86131. private _scaleRatio;
  86132. protected _indexParameters: any;
  86133. private _shareOutputWithPostProcess;
  86134. private _texelSize;
  86135. private _forcedOutputTexture;
  86136. /**
  86137. * Returns the fragment url or shader name used in the post process.
  86138. * @returns the fragment url or name in the shader store.
  86139. */
  86140. getEffectName(): string;
  86141. /**
  86142. * An event triggered when the postprocess is activated.
  86143. */
  86144. onActivateObservable: Observable<Camera>;
  86145. private _onActivateObserver;
  86146. /**
  86147. * A function that is added to the onActivateObservable
  86148. */
  86149. set onActivate(callback: Nullable<(camera: Camera) => void>);
  86150. /**
  86151. * An event triggered when the postprocess changes its size.
  86152. */
  86153. onSizeChangedObservable: Observable<PostProcess>;
  86154. private _onSizeChangedObserver;
  86155. /**
  86156. * A function that is added to the onSizeChangedObservable
  86157. */
  86158. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  86159. /**
  86160. * An event triggered when the postprocess applies its effect.
  86161. */
  86162. onApplyObservable: Observable<Effect>;
  86163. private _onApplyObserver;
  86164. /**
  86165. * A function that is added to the onApplyObservable
  86166. */
  86167. set onApply(callback: (effect: Effect) => void);
  86168. /**
  86169. * An event triggered before rendering the postprocess
  86170. */
  86171. onBeforeRenderObservable: Observable<Effect>;
  86172. private _onBeforeRenderObserver;
  86173. /**
  86174. * A function that is added to the onBeforeRenderObservable
  86175. */
  86176. set onBeforeRender(callback: (effect: Effect) => void);
  86177. /**
  86178. * An event triggered after rendering the postprocess
  86179. */
  86180. onAfterRenderObservable: Observable<Effect>;
  86181. private _onAfterRenderObserver;
  86182. /**
  86183. * A function that is added to the onAfterRenderObservable
  86184. */
  86185. set onAfterRender(callback: (efect: Effect) => void);
  86186. /**
  86187. * 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
  86188. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  86189. */
  86190. get inputTexture(): InternalTexture;
  86191. set inputTexture(value: InternalTexture);
  86192. /**
  86193. * Gets the camera which post process is applied to.
  86194. * @returns The camera the post process is applied to.
  86195. */
  86196. getCamera(): Camera;
  86197. /**
  86198. * Gets the texel size of the postprocess.
  86199. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  86200. */
  86201. get texelSize(): Vector2;
  86202. /**
  86203. * Creates a new instance PostProcess
  86204. * @param name The name of the PostProcess.
  86205. * @param fragmentUrl The url of the fragment shader to be used.
  86206. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  86207. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  86208. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86209. * @param camera The camera to apply the render pass to.
  86210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86211. * @param engine The engine which the post process will be applied. (default: current engine)
  86212. * @param reusable If the post process can be reused on the same frame. (default: false)
  86213. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  86214. * @param textureType Type of textures used when performing the post process. (default: 0)
  86215. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  86216. * @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
  86217. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  86218. */
  86219. constructor(
  86220. /** Name of the PostProcess. */
  86221. 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);
  86222. /**
  86223. * Gets a string idenfifying the name of the class
  86224. * @returns "PostProcess" string
  86225. */
  86226. getClassName(): string;
  86227. /**
  86228. * Gets the engine which this post process belongs to.
  86229. * @returns The engine the post process was enabled with.
  86230. */
  86231. getEngine(): Engine;
  86232. /**
  86233. * The effect that is created when initializing the post process.
  86234. * @returns The created effect corresponding the the postprocess.
  86235. */
  86236. getEffect(): Effect;
  86237. /**
  86238. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  86239. * @param postProcess The post process to share the output with.
  86240. * @returns This post process.
  86241. */
  86242. shareOutputWith(postProcess: PostProcess): PostProcess;
  86243. /**
  86244. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  86245. * This should be called if the post process that shares output with this post process is disabled/disposed.
  86246. */
  86247. useOwnOutput(): void;
  86248. /**
  86249. * Updates the effect with the current post process compile time values and recompiles the shader.
  86250. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86251. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86252. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86253. * @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
  86254. * @param onCompiled Called when the shader has been compiled.
  86255. * @param onError Called if there is an error when compiling a shader.
  86256. */
  86257. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86258. /**
  86259. * The post process is reusable if it can be used multiple times within one frame.
  86260. * @returns If the post process is reusable
  86261. */
  86262. isReusable(): boolean;
  86263. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  86264. markTextureDirty(): void;
  86265. /**
  86266. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  86267. * 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.
  86268. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  86269. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  86270. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  86271. * @returns The target texture that was bound to be written to.
  86272. */
  86273. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  86274. /**
  86275. * If the post process is supported.
  86276. */
  86277. get isSupported(): boolean;
  86278. /**
  86279. * The aspect ratio of the output texture.
  86280. */
  86281. get aspectRatio(): number;
  86282. /**
  86283. * Get a value indicating if the post-process is ready to be used
  86284. * @returns true if the post-process is ready (shader is compiled)
  86285. */
  86286. isReady(): boolean;
  86287. /**
  86288. * Binds all textures and uniforms to the shader, this will be run on every pass.
  86289. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  86290. */
  86291. apply(): Nullable<Effect>;
  86292. private _disposeTextures;
  86293. /**
  86294. * Disposes the post process.
  86295. * @param camera The camera to dispose the post process on.
  86296. */
  86297. dispose(camera?: Camera): void;
  86298. }
  86299. }
  86300. declare module BABYLON {
  86301. /** @hidden */
  86302. export var kernelBlurVaryingDeclaration: {
  86303. name: string;
  86304. shader: string;
  86305. };
  86306. }
  86307. declare module BABYLON {
  86308. /** @hidden */
  86309. export var kernelBlurFragment: {
  86310. name: string;
  86311. shader: string;
  86312. };
  86313. }
  86314. declare module BABYLON {
  86315. /** @hidden */
  86316. export var kernelBlurFragment2: {
  86317. name: string;
  86318. shader: string;
  86319. };
  86320. }
  86321. declare module BABYLON {
  86322. /** @hidden */
  86323. export var kernelBlurPixelShader: {
  86324. name: string;
  86325. shader: string;
  86326. };
  86327. }
  86328. declare module BABYLON {
  86329. /** @hidden */
  86330. export var kernelBlurVertex: {
  86331. name: string;
  86332. shader: string;
  86333. };
  86334. }
  86335. declare module BABYLON {
  86336. /** @hidden */
  86337. export var kernelBlurVertexShader: {
  86338. name: string;
  86339. shader: string;
  86340. };
  86341. }
  86342. declare module BABYLON {
  86343. /**
  86344. * The Blur Post Process which blurs an image based on a kernel and direction.
  86345. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  86346. */
  86347. export class BlurPostProcess extends PostProcess {
  86348. /** The direction in which to blur the image. */
  86349. direction: Vector2;
  86350. private blockCompilation;
  86351. protected _kernel: number;
  86352. protected _idealKernel: number;
  86353. protected _packedFloat: boolean;
  86354. private _staticDefines;
  86355. /**
  86356. * Sets the length in pixels of the blur sample region
  86357. */
  86358. set kernel(v: number);
  86359. /**
  86360. * Gets the length in pixels of the blur sample region
  86361. */
  86362. get kernel(): number;
  86363. /**
  86364. * Sets wether or not the blur needs to unpack/repack floats
  86365. */
  86366. set packedFloat(v: boolean);
  86367. /**
  86368. * Gets wether or not the blur is unpacking/repacking floats
  86369. */
  86370. get packedFloat(): boolean;
  86371. /**
  86372. * Creates a new instance BlurPostProcess
  86373. * @param name The name of the effect.
  86374. * @param direction The direction in which to blur the image.
  86375. * @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.
  86376. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86377. * @param camera The camera to apply the render pass to.
  86378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86379. * @param engine The engine which the post process will be applied. (default: current engine)
  86380. * @param reusable If the post process can be reused on the same frame. (default: false)
  86381. * @param textureType Type of textures used when performing the post process. (default: 0)
  86382. * @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)
  86383. */
  86384. constructor(name: string,
  86385. /** The direction in which to blur the image. */
  86386. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  86387. /**
  86388. * Updates the effect with the current post process compile time values and recompiles the shader.
  86389. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86390. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86391. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86392. * @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
  86393. * @param onCompiled Called when the shader has been compiled.
  86394. * @param onError Called if there is an error when compiling a shader.
  86395. */
  86396. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86397. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86398. /**
  86399. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  86400. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  86401. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  86402. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  86403. * The gaps between physical kernels are compensated for in the weighting of the samples
  86404. * @param idealKernel Ideal blur kernel.
  86405. * @return Nearest best kernel.
  86406. */
  86407. protected _nearestBestKernel(idealKernel: number): number;
  86408. /**
  86409. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  86410. * @param x The point on the Gaussian distribution to sample.
  86411. * @return the value of the Gaussian function at x.
  86412. */
  86413. protected _gaussianWeight(x: number): number;
  86414. /**
  86415. * Generates a string that can be used as a floating point number in GLSL.
  86416. * @param x Value to print.
  86417. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  86418. * @return GLSL float string.
  86419. */
  86420. protected _glslFloat(x: number, decimalFigures?: number): string;
  86421. }
  86422. }
  86423. declare module BABYLON {
  86424. /**
  86425. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86426. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86427. * You can then easily use it as a reflectionTexture on a flat surface.
  86428. * In case the surface is not a plane, please consider relying on reflection probes.
  86429. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86430. */
  86431. export class MirrorTexture extends RenderTargetTexture {
  86432. private scene;
  86433. /**
  86434. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  86435. * 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.
  86436. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86437. */
  86438. mirrorPlane: Plane;
  86439. /**
  86440. * Define the blur ratio used to blur the reflection if needed.
  86441. */
  86442. set blurRatio(value: number);
  86443. get blurRatio(): number;
  86444. /**
  86445. * Define the adaptive blur kernel used to blur the reflection if needed.
  86446. * This will autocompute the closest best match for the `blurKernel`
  86447. */
  86448. set adaptiveBlurKernel(value: number);
  86449. /**
  86450. * Define the blur kernel used to blur the reflection if needed.
  86451. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86452. */
  86453. set blurKernel(value: number);
  86454. /**
  86455. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  86456. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86457. */
  86458. set blurKernelX(value: number);
  86459. get blurKernelX(): number;
  86460. /**
  86461. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  86462. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86463. */
  86464. set blurKernelY(value: number);
  86465. get blurKernelY(): number;
  86466. private _autoComputeBlurKernel;
  86467. protected _onRatioRescale(): void;
  86468. private _updateGammaSpace;
  86469. private _imageProcessingConfigChangeObserver;
  86470. private _transformMatrix;
  86471. private _mirrorMatrix;
  86472. private _savedViewMatrix;
  86473. private _blurX;
  86474. private _blurY;
  86475. private _adaptiveBlurKernel;
  86476. private _blurKernelX;
  86477. private _blurKernelY;
  86478. private _blurRatio;
  86479. /**
  86480. * Instantiates a Mirror Texture.
  86481. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86482. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86483. * You can then easily use it as a reflectionTexture on a flat surface.
  86484. * In case the surface is not a plane, please consider relying on reflection probes.
  86485. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86486. * @param name
  86487. * @param size
  86488. * @param scene
  86489. * @param generateMipMaps
  86490. * @param type
  86491. * @param samplingMode
  86492. * @param generateDepthBuffer
  86493. */
  86494. constructor(name: string, size: number | {
  86495. width: number;
  86496. height: number;
  86497. } | {
  86498. ratio: number;
  86499. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  86500. private _preparePostProcesses;
  86501. /**
  86502. * Clone the mirror texture.
  86503. * @returns the cloned texture
  86504. */
  86505. clone(): MirrorTexture;
  86506. /**
  86507. * Serialize the texture to a JSON representation you could use in Parse later on
  86508. * @returns the serialized JSON representation
  86509. */
  86510. serialize(): any;
  86511. /**
  86512. * Dispose the texture and release its associated resources.
  86513. */
  86514. dispose(): void;
  86515. }
  86516. }
  86517. declare module BABYLON {
  86518. /**
  86519. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86520. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86521. */
  86522. export class Texture extends BaseTexture {
  86523. /**
  86524. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  86525. */
  86526. static SerializeBuffers: boolean;
  86527. /** @hidden */
  86528. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  86529. /** @hidden */
  86530. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  86531. /** @hidden */
  86532. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  86533. /** nearest is mag = nearest and min = nearest and mip = linear */
  86534. static readonly NEAREST_SAMPLINGMODE: number;
  86535. /** nearest is mag = nearest and min = nearest and mip = linear */
  86536. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  86537. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86538. static readonly BILINEAR_SAMPLINGMODE: number;
  86539. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86540. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  86541. /** Trilinear is mag = linear and min = linear and mip = linear */
  86542. static readonly TRILINEAR_SAMPLINGMODE: number;
  86543. /** Trilinear is mag = linear and min = linear and mip = linear */
  86544. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  86545. /** mag = nearest and min = nearest and mip = nearest */
  86546. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  86547. /** mag = nearest and min = linear and mip = nearest */
  86548. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  86549. /** mag = nearest and min = linear and mip = linear */
  86550. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  86551. /** mag = nearest and min = linear and mip = none */
  86552. static readonly NEAREST_LINEAR: number;
  86553. /** mag = nearest and min = nearest and mip = none */
  86554. static readonly NEAREST_NEAREST: number;
  86555. /** mag = linear and min = nearest and mip = nearest */
  86556. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  86557. /** mag = linear and min = nearest and mip = linear */
  86558. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  86559. /** mag = linear and min = linear and mip = none */
  86560. static readonly LINEAR_LINEAR: number;
  86561. /** mag = linear and min = nearest and mip = none */
  86562. static readonly LINEAR_NEAREST: number;
  86563. /** Explicit coordinates mode */
  86564. static readonly EXPLICIT_MODE: number;
  86565. /** Spherical coordinates mode */
  86566. static readonly SPHERICAL_MODE: number;
  86567. /** Planar coordinates mode */
  86568. static readonly PLANAR_MODE: number;
  86569. /** Cubic coordinates mode */
  86570. static readonly CUBIC_MODE: number;
  86571. /** Projection coordinates mode */
  86572. static readonly PROJECTION_MODE: number;
  86573. /** Inverse Cubic coordinates mode */
  86574. static readonly SKYBOX_MODE: number;
  86575. /** Inverse Cubic coordinates mode */
  86576. static readonly INVCUBIC_MODE: number;
  86577. /** Equirectangular coordinates mode */
  86578. static readonly EQUIRECTANGULAR_MODE: number;
  86579. /** Equirectangular Fixed coordinates mode */
  86580. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  86581. /** Equirectangular Fixed Mirrored coordinates mode */
  86582. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86583. /** Texture is not repeating outside of 0..1 UVs */
  86584. static readonly CLAMP_ADDRESSMODE: number;
  86585. /** Texture is repeating outside of 0..1 UVs */
  86586. static readonly WRAP_ADDRESSMODE: number;
  86587. /** Texture is repeating and mirrored */
  86588. static readonly MIRROR_ADDRESSMODE: number;
  86589. /**
  86590. * 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
  86591. */
  86592. static UseSerializedUrlIfAny: boolean;
  86593. /**
  86594. * Define the url of the texture.
  86595. */
  86596. url: Nullable<string>;
  86597. /**
  86598. * Define an offset on the texture to offset the u coordinates of the UVs
  86599. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86600. */
  86601. uOffset: number;
  86602. /**
  86603. * Define an offset on the texture to offset the v coordinates of the UVs
  86604. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86605. */
  86606. vOffset: number;
  86607. /**
  86608. * Define an offset on the texture to scale the u coordinates of the UVs
  86609. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86610. */
  86611. uScale: number;
  86612. /**
  86613. * Define an offset on the texture to scale the v coordinates of the UVs
  86614. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86615. */
  86616. vScale: number;
  86617. /**
  86618. * Define an offset on the texture to rotate around the u coordinates of the UVs
  86619. * @see http://doc.babylonjs.com/how_to/more_materials
  86620. */
  86621. uAng: number;
  86622. /**
  86623. * Define an offset on the texture to rotate around the v coordinates of the UVs
  86624. * @see http://doc.babylonjs.com/how_to/more_materials
  86625. */
  86626. vAng: number;
  86627. /**
  86628. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  86629. * @see http://doc.babylonjs.com/how_to/more_materials
  86630. */
  86631. wAng: number;
  86632. /**
  86633. * Defines the center of rotation (U)
  86634. */
  86635. uRotationCenter: number;
  86636. /**
  86637. * Defines the center of rotation (V)
  86638. */
  86639. vRotationCenter: number;
  86640. /**
  86641. * Defines the center of rotation (W)
  86642. */
  86643. wRotationCenter: number;
  86644. /**
  86645. * Are mip maps generated for this texture or not.
  86646. */
  86647. get noMipmap(): boolean;
  86648. /**
  86649. * List of inspectable custom properties (used by the Inspector)
  86650. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86651. */
  86652. inspectableCustomProperties: Nullable<IInspectable[]>;
  86653. private _noMipmap;
  86654. /** @hidden */
  86655. _invertY: boolean;
  86656. private _rowGenerationMatrix;
  86657. private _cachedTextureMatrix;
  86658. private _projectionModeMatrix;
  86659. private _t0;
  86660. private _t1;
  86661. private _t2;
  86662. private _cachedUOffset;
  86663. private _cachedVOffset;
  86664. private _cachedUScale;
  86665. private _cachedVScale;
  86666. private _cachedUAng;
  86667. private _cachedVAng;
  86668. private _cachedWAng;
  86669. private _cachedProjectionMatrixId;
  86670. private _cachedCoordinatesMode;
  86671. /** @hidden */
  86672. protected _initialSamplingMode: number;
  86673. /** @hidden */
  86674. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  86675. private _deleteBuffer;
  86676. protected _format: Nullable<number>;
  86677. private _delayedOnLoad;
  86678. private _delayedOnError;
  86679. private _mimeType?;
  86680. /**
  86681. * Observable triggered once the texture has been loaded.
  86682. */
  86683. onLoadObservable: Observable<Texture>;
  86684. protected _isBlocking: boolean;
  86685. /**
  86686. * Is the texture preventing material to render while loading.
  86687. * If false, a default texture will be used instead of the loading one during the preparation step.
  86688. */
  86689. set isBlocking(value: boolean);
  86690. get isBlocking(): boolean;
  86691. /**
  86692. * Get the current sampling mode associated with the texture.
  86693. */
  86694. get samplingMode(): number;
  86695. /**
  86696. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  86697. */
  86698. get invertY(): boolean;
  86699. /**
  86700. * Instantiates a new texture.
  86701. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86702. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86703. * @param url defines the url of the picture to load as a texture
  86704. * @param scene defines the scene or engine the texture will belong to
  86705. * @param noMipmap defines if the texture will require mip maps or not
  86706. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  86707. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86708. * @param onLoad defines a callback triggered when the texture has been loaded
  86709. * @param onError defines a callback triggered when an error occurred during the loading session
  86710. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  86711. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  86712. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86713. * @param mimeType defines an optional mime type information
  86714. */
  86715. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  86716. /**
  86717. * Update the url (and optional buffer) of this texture if url was null during construction.
  86718. * @param url the url of the texture
  86719. * @param buffer the buffer of the texture (defaults to null)
  86720. * @param onLoad callback called when the texture is loaded (defaults to null)
  86721. */
  86722. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  86723. /**
  86724. * Finish the loading sequence of a texture flagged as delayed load.
  86725. * @hidden
  86726. */
  86727. delayLoad(): void;
  86728. private _prepareRowForTextureGeneration;
  86729. /**
  86730. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  86731. * @returns the transform matrix of the texture.
  86732. */
  86733. getTextureMatrix(uBase?: number): Matrix;
  86734. /**
  86735. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  86736. * @returns The reflection texture transform
  86737. */
  86738. getReflectionTextureMatrix(): Matrix;
  86739. /**
  86740. * Clones the texture.
  86741. * @returns the cloned texture
  86742. */
  86743. clone(): Texture;
  86744. /**
  86745. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86746. * @returns The JSON representation of the texture
  86747. */
  86748. serialize(): any;
  86749. /**
  86750. * Get the current class name of the texture useful for serialization or dynamic coding.
  86751. * @returns "Texture"
  86752. */
  86753. getClassName(): string;
  86754. /**
  86755. * Dispose the texture and release its associated resources.
  86756. */
  86757. dispose(): void;
  86758. /**
  86759. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  86760. * @param parsedTexture Define the JSON representation of the texture
  86761. * @param scene Define the scene the parsed texture should be instantiated in
  86762. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  86763. * @returns The parsed texture if successful
  86764. */
  86765. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  86766. /**
  86767. * Creates a texture from its base 64 representation.
  86768. * @param data Define the base64 payload without the data: prefix
  86769. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86770. * @param scene Define the scene the texture should belong to
  86771. * @param noMipmap Forces the texture to not create mip map information if true
  86772. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86773. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86774. * @param onLoad define a callback triggered when the texture has been loaded
  86775. * @param onError define a callback triggered when an error occurred during the loading session
  86776. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86777. * @returns the created texture
  86778. */
  86779. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  86780. /**
  86781. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  86782. * @param data Define the base64 payload without the data: prefix
  86783. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86784. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  86785. * @param scene Define the scene the texture should belong to
  86786. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  86787. * @param noMipmap Forces the texture to not create mip map information if true
  86788. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86789. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86790. * @param onLoad define a callback triggered when the texture has been loaded
  86791. * @param onError define a callback triggered when an error occurred during the loading session
  86792. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86793. * @returns the created texture
  86794. */
  86795. 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;
  86796. }
  86797. }
  86798. declare module BABYLON {
  86799. /**
  86800. * PostProcessManager is used to manage one or more post processes or post process pipelines
  86801. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86802. */
  86803. export class PostProcessManager {
  86804. private _scene;
  86805. private _indexBuffer;
  86806. private _vertexBuffers;
  86807. /**
  86808. * Creates a new instance PostProcess
  86809. * @param scene The scene that the post process is associated with.
  86810. */
  86811. constructor(scene: Scene);
  86812. private _prepareBuffers;
  86813. private _buildIndexBuffer;
  86814. /**
  86815. * Rebuilds the vertex buffers of the manager.
  86816. * @hidden
  86817. */
  86818. _rebuild(): void;
  86819. /**
  86820. * Prepares a frame to be run through a post process.
  86821. * @param sourceTexture The input texture to the post procesess. (default: null)
  86822. * @param postProcesses An array of post processes to be run. (default: null)
  86823. * @returns True if the post processes were able to be run.
  86824. * @hidden
  86825. */
  86826. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  86827. /**
  86828. * Manually render a set of post processes to a texture.
  86829. * @param postProcesses An array of post processes to be run.
  86830. * @param targetTexture The target texture to render to.
  86831. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  86832. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  86833. * @param lodLevel defines which lod of the texture to render to
  86834. */
  86835. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  86836. /**
  86837. * Finalize the result of the output of the postprocesses.
  86838. * @param doNotPresent If true the result will not be displayed to the screen.
  86839. * @param targetTexture The target texture to render to.
  86840. * @param faceIndex The index of the face to bind the target texture to.
  86841. * @param postProcesses The array of post processes to render.
  86842. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  86843. * @hidden
  86844. */
  86845. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  86846. /**
  86847. * Disposes of the post process manager.
  86848. */
  86849. dispose(): void;
  86850. }
  86851. }
  86852. declare module BABYLON {
  86853. /** Interface used by value gradients (color, factor, ...) */
  86854. export interface IValueGradient {
  86855. /**
  86856. * Gets or sets the gradient value (between 0 and 1)
  86857. */
  86858. gradient: number;
  86859. }
  86860. /** Class used to store color4 gradient */
  86861. export class ColorGradient implements IValueGradient {
  86862. /**
  86863. * Gets or sets the gradient value (between 0 and 1)
  86864. */
  86865. gradient: number;
  86866. /**
  86867. * Gets or sets first associated color
  86868. */
  86869. color1: Color4;
  86870. /**
  86871. * Gets or sets second associated color
  86872. */
  86873. color2?: Color4;
  86874. /**
  86875. * Will get a color picked randomly between color1 and color2.
  86876. * If color2 is undefined then color1 will be used
  86877. * @param result defines the target Color4 to store the result in
  86878. */
  86879. getColorToRef(result: Color4): void;
  86880. }
  86881. /** Class used to store color 3 gradient */
  86882. export class Color3Gradient implements IValueGradient {
  86883. /**
  86884. * Gets or sets the gradient value (between 0 and 1)
  86885. */
  86886. gradient: number;
  86887. /**
  86888. * Gets or sets the associated color
  86889. */
  86890. color: Color3;
  86891. }
  86892. /** Class used to store factor gradient */
  86893. export class FactorGradient implements IValueGradient {
  86894. /**
  86895. * Gets or sets the gradient value (between 0 and 1)
  86896. */
  86897. gradient: number;
  86898. /**
  86899. * Gets or sets first associated factor
  86900. */
  86901. factor1: number;
  86902. /**
  86903. * Gets or sets second associated factor
  86904. */
  86905. factor2?: number;
  86906. /**
  86907. * Will get a number picked randomly between factor1 and factor2.
  86908. * If factor2 is undefined then factor1 will be used
  86909. * @returns the picked number
  86910. */
  86911. getFactor(): number;
  86912. }
  86913. /**
  86914. * Helper used to simplify some generic gradient tasks
  86915. */
  86916. export class GradientHelper {
  86917. /**
  86918. * Gets the current gradient from an array of IValueGradient
  86919. * @param ratio defines the current ratio to get
  86920. * @param gradients defines the array of IValueGradient
  86921. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86922. */
  86923. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86924. }
  86925. }
  86926. declare module BABYLON {
  86927. interface ThinEngine {
  86928. /**
  86929. * Creates a dynamic texture
  86930. * @param width defines the width of the texture
  86931. * @param height defines the height of the texture
  86932. * @param generateMipMaps defines if the engine should generate the mip levels
  86933. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86934. * @returns the dynamic texture inside an InternalTexture
  86935. */
  86936. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86937. /**
  86938. * Update the content of a dynamic texture
  86939. * @param texture defines the texture to update
  86940. * @param canvas defines the canvas containing the source
  86941. * @param invertY defines if data must be stored with Y axis inverted
  86942. * @param premulAlpha defines if alpha is stored as premultiplied
  86943. * @param format defines the format of the data
  86944. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86945. */
  86946. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86947. }
  86948. }
  86949. declare module BABYLON {
  86950. /**
  86951. * Helper class used to generate a canvas to manipulate images
  86952. */
  86953. export class CanvasGenerator {
  86954. /**
  86955. * Create a new canvas (or offscreen canvas depending on the context)
  86956. * @param width defines the expected width
  86957. * @param height defines the expected height
  86958. * @return a new canvas or offscreen canvas
  86959. */
  86960. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86961. }
  86962. }
  86963. declare module BABYLON {
  86964. /**
  86965. * A class extending Texture allowing drawing on a texture
  86966. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86967. */
  86968. export class DynamicTexture extends Texture {
  86969. private _generateMipMaps;
  86970. private _canvas;
  86971. private _context;
  86972. private _engine;
  86973. /**
  86974. * Creates a DynamicTexture
  86975. * @param name defines the name of the texture
  86976. * @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
  86977. * @param scene defines the scene where you want the texture
  86978. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  86979. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  86980. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  86981. */
  86982. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  86983. /**
  86984. * Get the current class name of the texture useful for serialization or dynamic coding.
  86985. * @returns "DynamicTexture"
  86986. */
  86987. getClassName(): string;
  86988. /**
  86989. * Gets the current state of canRescale
  86990. */
  86991. get canRescale(): boolean;
  86992. private _recreate;
  86993. /**
  86994. * Scales the texture
  86995. * @param ratio the scale factor to apply to both width and height
  86996. */
  86997. scale(ratio: number): void;
  86998. /**
  86999. * Resizes the texture
  87000. * @param width the new width
  87001. * @param height the new height
  87002. */
  87003. scaleTo(width: number, height: number): void;
  87004. /**
  87005. * Gets the context of the canvas used by the texture
  87006. * @returns the canvas context of the dynamic texture
  87007. */
  87008. getContext(): CanvasRenderingContext2D;
  87009. /**
  87010. * Clears the texture
  87011. */
  87012. clear(): void;
  87013. /**
  87014. * Updates the texture
  87015. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87016. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87017. */
  87018. update(invertY?: boolean, premulAlpha?: boolean): void;
  87019. /**
  87020. * Draws text onto the texture
  87021. * @param text defines the text to be drawn
  87022. * @param x defines the placement of the text from the left
  87023. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87024. * @param font defines the font to be used with font-style, font-size, font-name
  87025. * @param color defines the color used for the text
  87026. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87027. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87028. * @param update defines whether texture is immediately update (default is true)
  87029. */
  87030. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87031. /**
  87032. * Clones the texture
  87033. * @returns the clone of the texture.
  87034. */
  87035. clone(): DynamicTexture;
  87036. /**
  87037. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87038. * @returns a serialized dynamic texture object
  87039. */
  87040. serialize(): any;
  87041. /** @hidden */
  87042. _rebuild(): void;
  87043. }
  87044. }
  87045. declare module BABYLON {
  87046. interface AbstractScene {
  87047. /**
  87048. * The list of procedural textures added to the scene
  87049. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87050. */
  87051. proceduralTextures: Array<ProceduralTexture>;
  87052. }
  87053. /**
  87054. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87055. * in a given scene.
  87056. */
  87057. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87058. /**
  87059. * The component name helpfull to identify the component in the list of scene components.
  87060. */
  87061. readonly name: string;
  87062. /**
  87063. * The scene the component belongs to.
  87064. */
  87065. scene: Scene;
  87066. /**
  87067. * Creates a new instance of the component for the given scene
  87068. * @param scene Defines the scene to register the component in
  87069. */
  87070. constructor(scene: Scene);
  87071. /**
  87072. * Registers the component in a given scene
  87073. */
  87074. register(): void;
  87075. /**
  87076. * Rebuilds the elements related to this component in case of
  87077. * context lost for instance.
  87078. */
  87079. rebuild(): void;
  87080. /**
  87081. * Disposes the component and the associated ressources.
  87082. */
  87083. dispose(): void;
  87084. private _beforeClear;
  87085. }
  87086. }
  87087. declare module BABYLON {
  87088. interface ThinEngine {
  87089. /**
  87090. * Creates a new render target cube texture
  87091. * @param size defines the size of the texture
  87092. * @param options defines the options used to create the texture
  87093. * @returns a new render target cube texture stored in an InternalTexture
  87094. */
  87095. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87096. }
  87097. }
  87098. declare module BABYLON {
  87099. /** @hidden */
  87100. export var proceduralVertexShader: {
  87101. name: string;
  87102. shader: string;
  87103. };
  87104. }
  87105. declare module BABYLON {
  87106. /**
  87107. * 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.
  87108. * This is the base class of any Procedural texture and contains most of the shareable code.
  87109. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87110. */
  87111. export class ProceduralTexture extends Texture {
  87112. isCube: boolean;
  87113. /**
  87114. * Define if the texture is enabled or not (disabled texture will not render)
  87115. */
  87116. isEnabled: boolean;
  87117. /**
  87118. * Define if the texture must be cleared before rendering (default is true)
  87119. */
  87120. autoClear: boolean;
  87121. /**
  87122. * Callback called when the texture is generated
  87123. */
  87124. onGenerated: () => void;
  87125. /**
  87126. * Event raised when the texture is generated
  87127. */
  87128. onGeneratedObservable: Observable<ProceduralTexture>;
  87129. /** @hidden */
  87130. _generateMipMaps: boolean;
  87131. /** @hidden **/
  87132. _effect: Effect;
  87133. /** @hidden */
  87134. _textures: {
  87135. [key: string]: Texture;
  87136. };
  87137. private _size;
  87138. private _currentRefreshId;
  87139. private _frameId;
  87140. private _refreshRate;
  87141. private _vertexBuffers;
  87142. private _indexBuffer;
  87143. private _uniforms;
  87144. private _samplers;
  87145. private _fragment;
  87146. private _floats;
  87147. private _ints;
  87148. private _floatsArrays;
  87149. private _colors3;
  87150. private _colors4;
  87151. private _vectors2;
  87152. private _vectors3;
  87153. private _matrices;
  87154. private _fallbackTexture;
  87155. private _fallbackTextureUsed;
  87156. private _engine;
  87157. private _cachedDefines;
  87158. private _contentUpdateId;
  87159. private _contentData;
  87160. /**
  87161. * Instantiates a new procedural texture.
  87162. * 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.
  87163. * This is the base class of any Procedural texture and contains most of the shareable code.
  87164. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87165. * @param name Define the name of the texture
  87166. * @param size Define the size of the texture to create
  87167. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  87168. * @param scene Define the scene the texture belongs to
  87169. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  87170. * @param generateMipMaps Define if the texture should creates mip maps or not
  87171. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  87172. */
  87173. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  87174. /**
  87175. * The effect that is created when initializing the post process.
  87176. * @returns The created effect corresponding the the postprocess.
  87177. */
  87178. getEffect(): Effect;
  87179. /**
  87180. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  87181. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  87182. */
  87183. getContent(): Nullable<ArrayBufferView>;
  87184. private _createIndexBuffer;
  87185. /** @hidden */
  87186. _rebuild(): void;
  87187. /**
  87188. * Resets the texture in order to recreate its associated resources.
  87189. * This can be called in case of context loss
  87190. */
  87191. reset(): void;
  87192. protected _getDefines(): string;
  87193. /**
  87194. * Is the texture ready to be used ? (rendered at least once)
  87195. * @returns true if ready, otherwise, false.
  87196. */
  87197. isReady(): boolean;
  87198. /**
  87199. * Resets the refresh counter of the texture and start bak from scratch.
  87200. * Could be useful to regenerate the texture if it is setup to render only once.
  87201. */
  87202. resetRefreshCounter(): void;
  87203. /**
  87204. * Set the fragment shader to use in order to render the texture.
  87205. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  87206. */
  87207. setFragment(fragment: any): void;
  87208. /**
  87209. * Define the refresh rate of the texture or the rendering frequency.
  87210. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87211. */
  87212. get refreshRate(): number;
  87213. set refreshRate(value: number);
  87214. /** @hidden */
  87215. _shouldRender(): boolean;
  87216. /**
  87217. * Get the size the texture is rendering at.
  87218. * @returns the size (texture is always squared)
  87219. */
  87220. getRenderSize(): number;
  87221. /**
  87222. * Resize the texture to new value.
  87223. * @param size Define the new size the texture should have
  87224. * @param generateMipMaps Define whether the new texture should create mip maps
  87225. */
  87226. resize(size: number, generateMipMaps: boolean): void;
  87227. private _checkUniform;
  87228. /**
  87229. * Set a texture in the shader program used to render.
  87230. * @param name Define the name of the uniform samplers as defined in the shader
  87231. * @param texture Define the texture to bind to this sampler
  87232. * @return the texture itself allowing "fluent" like uniform updates
  87233. */
  87234. setTexture(name: string, texture: Texture): ProceduralTexture;
  87235. /**
  87236. * Set a float in the shader.
  87237. * @param name Define the name of the uniform as defined in the shader
  87238. * @param value Define the value to give to the uniform
  87239. * @return the texture itself allowing "fluent" like uniform updates
  87240. */
  87241. setFloat(name: string, value: number): ProceduralTexture;
  87242. /**
  87243. * Set a int in the shader.
  87244. * @param name Define the name of the uniform as defined in the shader
  87245. * @param value Define the value to give to the uniform
  87246. * @return the texture itself allowing "fluent" like uniform updates
  87247. */
  87248. setInt(name: string, value: number): ProceduralTexture;
  87249. /**
  87250. * Set an array of floats in the shader.
  87251. * @param name Define the name of the uniform as defined in the shader
  87252. * @param value Define the value to give to the uniform
  87253. * @return the texture itself allowing "fluent" like uniform updates
  87254. */
  87255. setFloats(name: string, value: number[]): ProceduralTexture;
  87256. /**
  87257. * Set a vec3 in the shader from a Color3.
  87258. * @param name Define the name of the uniform as defined in the shader
  87259. * @param value Define the value to give to the uniform
  87260. * @return the texture itself allowing "fluent" like uniform updates
  87261. */
  87262. setColor3(name: string, value: Color3): ProceduralTexture;
  87263. /**
  87264. * Set a vec4 in the shader from a Color4.
  87265. * @param name Define the name of the uniform as defined in the shader
  87266. * @param value Define the value to give to the uniform
  87267. * @return the texture itself allowing "fluent" like uniform updates
  87268. */
  87269. setColor4(name: string, value: Color4): ProceduralTexture;
  87270. /**
  87271. * Set a vec2 in the shader from a Vector2.
  87272. * @param name Define the name of the uniform as defined in the shader
  87273. * @param value Define the value to give to the uniform
  87274. * @return the texture itself allowing "fluent" like uniform updates
  87275. */
  87276. setVector2(name: string, value: Vector2): ProceduralTexture;
  87277. /**
  87278. * Set a vec3 in the shader from a Vector3.
  87279. * @param name Define the name of the uniform as defined in the shader
  87280. * @param value Define the value to give to the uniform
  87281. * @return the texture itself allowing "fluent" like uniform updates
  87282. */
  87283. setVector3(name: string, value: Vector3): ProceduralTexture;
  87284. /**
  87285. * Set a mat4 in the shader from a MAtrix.
  87286. * @param name Define the name of the uniform as defined in the shader
  87287. * @param value Define the value to give to the uniform
  87288. * @return the texture itself allowing "fluent" like uniform updates
  87289. */
  87290. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87291. /**
  87292. * Render the texture to its associated render target.
  87293. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87294. */
  87295. render(useCameraPostProcess?: boolean): void;
  87296. /**
  87297. * Clone the texture.
  87298. * @returns the cloned texture
  87299. */
  87300. clone(): ProceduralTexture;
  87301. /**
  87302. * Dispose the texture and release its asoociated resources.
  87303. */
  87304. dispose(): void;
  87305. }
  87306. }
  87307. declare module BABYLON {
  87308. /**
  87309. * This represents the base class for particle system in Babylon.
  87310. * 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.
  87311. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87312. * @example https://doc.babylonjs.com/babylon101/particles
  87313. */
  87314. export class BaseParticleSystem {
  87315. /**
  87316. * Source color is added to the destination color without alpha affecting the result
  87317. */
  87318. static BLENDMODE_ONEONE: number;
  87319. /**
  87320. * Blend current color and particle color using particle’s alpha
  87321. */
  87322. static BLENDMODE_STANDARD: number;
  87323. /**
  87324. * Add current color and particle color multiplied by particle’s alpha
  87325. */
  87326. static BLENDMODE_ADD: number;
  87327. /**
  87328. * Multiply current color with particle color
  87329. */
  87330. static BLENDMODE_MULTIPLY: number;
  87331. /**
  87332. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87333. */
  87334. static BLENDMODE_MULTIPLYADD: number;
  87335. /**
  87336. * List of animations used by the particle system.
  87337. */
  87338. animations: Animation[];
  87339. /**
  87340. * The id of the Particle system.
  87341. */
  87342. id: string;
  87343. /**
  87344. * The friendly name of the Particle system.
  87345. */
  87346. name: string;
  87347. /**
  87348. * The rendering group used by the Particle system to chose when to render.
  87349. */
  87350. renderingGroupId: number;
  87351. /**
  87352. * The emitter represents the Mesh or position we are attaching the particle system to.
  87353. */
  87354. emitter: Nullable<AbstractMesh | Vector3>;
  87355. /**
  87356. * The maximum number of particles to emit per frame
  87357. */
  87358. emitRate: number;
  87359. /**
  87360. * If you want to launch only a few particles at once, that can be done, as well.
  87361. */
  87362. manualEmitCount: number;
  87363. /**
  87364. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87365. */
  87366. updateSpeed: number;
  87367. /**
  87368. * The amount of time the particle system is running (depends of the overall update speed).
  87369. */
  87370. targetStopDuration: number;
  87371. /**
  87372. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87373. */
  87374. disposeOnStop: boolean;
  87375. /**
  87376. * Minimum power of emitting particles.
  87377. */
  87378. minEmitPower: number;
  87379. /**
  87380. * Maximum power of emitting particles.
  87381. */
  87382. maxEmitPower: number;
  87383. /**
  87384. * Minimum life time of emitting particles.
  87385. */
  87386. minLifeTime: number;
  87387. /**
  87388. * Maximum life time of emitting particles.
  87389. */
  87390. maxLifeTime: number;
  87391. /**
  87392. * Minimum Size of emitting particles.
  87393. */
  87394. minSize: number;
  87395. /**
  87396. * Maximum Size of emitting particles.
  87397. */
  87398. maxSize: number;
  87399. /**
  87400. * Minimum scale of emitting particles on X axis.
  87401. */
  87402. minScaleX: number;
  87403. /**
  87404. * Maximum scale of emitting particles on X axis.
  87405. */
  87406. maxScaleX: number;
  87407. /**
  87408. * Minimum scale of emitting particles on Y axis.
  87409. */
  87410. minScaleY: number;
  87411. /**
  87412. * Maximum scale of emitting particles on Y axis.
  87413. */
  87414. maxScaleY: number;
  87415. /**
  87416. * Gets or sets the minimal initial rotation in radians.
  87417. */
  87418. minInitialRotation: number;
  87419. /**
  87420. * Gets or sets the maximal initial rotation in radians.
  87421. */
  87422. maxInitialRotation: number;
  87423. /**
  87424. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87425. */
  87426. minAngularSpeed: number;
  87427. /**
  87428. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87429. */
  87430. maxAngularSpeed: number;
  87431. /**
  87432. * The texture used to render each particle. (this can be a spritesheet)
  87433. */
  87434. particleTexture: Nullable<Texture>;
  87435. /**
  87436. * The layer mask we are rendering the particles through.
  87437. */
  87438. layerMask: number;
  87439. /**
  87440. * This can help using your own shader to render the particle system.
  87441. * The according effect will be created
  87442. */
  87443. customShader: any;
  87444. /**
  87445. * By default particle system starts as soon as they are created. This prevents the
  87446. * automatic start to happen and let you decide when to start emitting particles.
  87447. */
  87448. preventAutoStart: boolean;
  87449. private _noiseTexture;
  87450. /**
  87451. * Gets or sets a texture used to add random noise to particle positions
  87452. */
  87453. get noiseTexture(): Nullable<ProceduralTexture>;
  87454. set noiseTexture(value: Nullable<ProceduralTexture>);
  87455. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87456. noiseStrength: Vector3;
  87457. /**
  87458. * Callback triggered when the particle animation is ending.
  87459. */
  87460. onAnimationEnd: Nullable<() => void>;
  87461. /**
  87462. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87463. */
  87464. blendMode: number;
  87465. /**
  87466. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87467. * to override the particles.
  87468. */
  87469. forceDepthWrite: boolean;
  87470. /** 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 */
  87471. preWarmCycles: number;
  87472. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87473. preWarmStepOffset: number;
  87474. /**
  87475. * 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)
  87476. */
  87477. spriteCellChangeSpeed: number;
  87478. /**
  87479. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87480. */
  87481. startSpriteCellID: number;
  87482. /**
  87483. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87484. */
  87485. endSpriteCellID: number;
  87486. /**
  87487. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87488. */
  87489. spriteCellWidth: number;
  87490. /**
  87491. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87492. */
  87493. spriteCellHeight: number;
  87494. /**
  87495. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87496. */
  87497. spriteRandomStartCell: boolean;
  87498. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87499. translationPivot: Vector2;
  87500. /** @hidden */
  87501. protected _isAnimationSheetEnabled: boolean;
  87502. /**
  87503. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87504. */
  87505. beginAnimationOnStart: boolean;
  87506. /**
  87507. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87508. */
  87509. beginAnimationFrom: number;
  87510. /**
  87511. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87512. */
  87513. beginAnimationTo: number;
  87514. /**
  87515. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87516. */
  87517. beginAnimationLoop: boolean;
  87518. /**
  87519. * Gets or sets a world offset applied to all particles
  87520. */
  87521. worldOffset: Vector3;
  87522. /**
  87523. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87524. */
  87525. get isAnimationSheetEnabled(): boolean;
  87526. set isAnimationSheetEnabled(value: boolean);
  87527. /**
  87528. * Get hosting scene
  87529. * @returns the scene
  87530. */
  87531. getScene(): Scene;
  87532. /**
  87533. * You can use gravity if you want to give an orientation to your particles.
  87534. */
  87535. gravity: Vector3;
  87536. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87537. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87538. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87539. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87540. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87541. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87542. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87543. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87544. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87545. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87546. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87547. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87548. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87549. /**
  87550. * Defines the delay in milliseconds before starting the system (0 by default)
  87551. */
  87552. startDelay: number;
  87553. /**
  87554. * Gets the current list of drag gradients.
  87555. * You must use addDragGradient and removeDragGradient to udpate this list
  87556. * @returns the list of drag gradients
  87557. */
  87558. getDragGradients(): Nullable<Array<FactorGradient>>;
  87559. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87560. limitVelocityDamping: number;
  87561. /**
  87562. * Gets the current list of limit velocity gradients.
  87563. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87564. * @returns the list of limit velocity gradients
  87565. */
  87566. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87567. /**
  87568. * Gets the current list of color gradients.
  87569. * You must use addColorGradient and removeColorGradient to udpate this list
  87570. * @returns the list of color gradients
  87571. */
  87572. getColorGradients(): Nullable<Array<ColorGradient>>;
  87573. /**
  87574. * Gets the current list of size gradients.
  87575. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87576. * @returns the list of size gradients
  87577. */
  87578. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87579. /**
  87580. * Gets the current list of color remap gradients.
  87581. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87582. * @returns the list of color remap gradients
  87583. */
  87584. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87585. /**
  87586. * Gets the current list of alpha remap gradients.
  87587. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87588. * @returns the list of alpha remap gradients
  87589. */
  87590. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87591. /**
  87592. * Gets the current list of life time gradients.
  87593. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87594. * @returns the list of life time gradients
  87595. */
  87596. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87597. /**
  87598. * Gets the current list of angular speed gradients.
  87599. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87600. * @returns the list of angular speed gradients
  87601. */
  87602. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87603. /**
  87604. * Gets the current list of velocity gradients.
  87605. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87606. * @returns the list of velocity gradients
  87607. */
  87608. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87609. /**
  87610. * Gets the current list of start size gradients.
  87611. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87612. * @returns the list of start size gradients
  87613. */
  87614. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87615. /**
  87616. * Gets the current list of emit rate gradients.
  87617. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87618. * @returns the list of emit rate gradients
  87619. */
  87620. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87621. /**
  87622. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87623. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87624. */
  87625. get direction1(): Vector3;
  87626. set direction1(value: Vector3);
  87627. /**
  87628. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87629. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87630. */
  87631. get direction2(): Vector3;
  87632. set direction2(value: Vector3);
  87633. /**
  87634. * 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.
  87635. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87636. */
  87637. get minEmitBox(): Vector3;
  87638. set minEmitBox(value: Vector3);
  87639. /**
  87640. * 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.
  87641. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87642. */
  87643. get maxEmitBox(): Vector3;
  87644. set maxEmitBox(value: Vector3);
  87645. /**
  87646. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87647. */
  87648. color1: Color4;
  87649. /**
  87650. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87651. */
  87652. color2: Color4;
  87653. /**
  87654. * Color the particle will have at the end of its lifetime
  87655. */
  87656. colorDead: Color4;
  87657. /**
  87658. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87659. */
  87660. textureMask: Color4;
  87661. /**
  87662. * The particle emitter type defines the emitter used by the particle system.
  87663. * It can be for example box, sphere, or cone...
  87664. */
  87665. particleEmitterType: IParticleEmitterType;
  87666. /** @hidden */
  87667. _isSubEmitter: boolean;
  87668. /**
  87669. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87670. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87671. */
  87672. billboardMode: number;
  87673. protected _isBillboardBased: boolean;
  87674. /**
  87675. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87676. */
  87677. get isBillboardBased(): boolean;
  87678. set isBillboardBased(value: boolean);
  87679. /**
  87680. * The scene the particle system belongs to.
  87681. */
  87682. protected _scene: Scene;
  87683. /**
  87684. * Local cache of defines for image processing.
  87685. */
  87686. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87687. /**
  87688. * Default configuration related to image processing available in the standard Material.
  87689. */
  87690. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87691. /**
  87692. * Gets the image processing configuration used either in this material.
  87693. */
  87694. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87695. /**
  87696. * Sets the Default image processing configuration used either in the this material.
  87697. *
  87698. * If sets to null, the scene one is in use.
  87699. */
  87700. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87701. /**
  87702. * Attaches a new image processing configuration to the Standard Material.
  87703. * @param configuration
  87704. */
  87705. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87706. /** @hidden */
  87707. protected _reset(): void;
  87708. /** @hidden */
  87709. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87710. /**
  87711. * Instantiates a particle system.
  87712. * 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.
  87713. * @param name The name of the particle system
  87714. */
  87715. constructor(name: string);
  87716. /**
  87717. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87718. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87719. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87720. * @returns the emitter
  87721. */
  87722. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87723. /**
  87724. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87725. * @param radius The radius of the hemisphere to emit from
  87726. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87727. * @returns the emitter
  87728. */
  87729. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87730. /**
  87731. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87732. * @param radius The radius of the sphere to emit from
  87733. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87734. * @returns the emitter
  87735. */
  87736. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87737. /**
  87738. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87739. * @param radius The radius of the sphere to emit from
  87740. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87741. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87742. * @returns the emitter
  87743. */
  87744. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87745. /**
  87746. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87747. * @param radius The radius of the emission cylinder
  87748. * @param height The height of the emission cylinder
  87749. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87750. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87751. * @returns the emitter
  87752. */
  87753. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87754. /**
  87755. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87756. * @param radius The radius of the cylinder to emit from
  87757. * @param height The height of the emission cylinder
  87758. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87759. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87760. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87761. * @returns the emitter
  87762. */
  87763. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87764. /**
  87765. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87766. * @param radius The radius of the cone to emit from
  87767. * @param angle The base angle of the cone
  87768. * @returns the emitter
  87769. */
  87770. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87771. /**
  87772. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87773. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87774. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87775. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87776. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87777. * @returns the emitter
  87778. */
  87779. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87780. }
  87781. }
  87782. declare module BABYLON {
  87783. /**
  87784. * Type of sub emitter
  87785. */
  87786. export enum SubEmitterType {
  87787. /**
  87788. * Attached to the particle over it's lifetime
  87789. */
  87790. ATTACHED = 0,
  87791. /**
  87792. * Created when the particle dies
  87793. */
  87794. END = 1
  87795. }
  87796. /**
  87797. * Sub emitter class used to emit particles from an existing particle
  87798. */
  87799. export class SubEmitter {
  87800. /**
  87801. * the particle system to be used by the sub emitter
  87802. */
  87803. particleSystem: ParticleSystem;
  87804. /**
  87805. * Type of the submitter (Default: END)
  87806. */
  87807. type: SubEmitterType;
  87808. /**
  87809. * 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)
  87810. * Note: This only is supported when using an emitter of type Mesh
  87811. */
  87812. inheritDirection: boolean;
  87813. /**
  87814. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87815. */
  87816. inheritedVelocityAmount: number;
  87817. /**
  87818. * Creates a sub emitter
  87819. * @param particleSystem the particle system to be used by the sub emitter
  87820. */
  87821. constructor(
  87822. /**
  87823. * the particle system to be used by the sub emitter
  87824. */
  87825. particleSystem: ParticleSystem);
  87826. /**
  87827. * Clones the sub emitter
  87828. * @returns the cloned sub emitter
  87829. */
  87830. clone(): SubEmitter;
  87831. /**
  87832. * Serialize current object to a JSON object
  87833. * @returns the serialized object
  87834. */
  87835. serialize(): any;
  87836. /** @hidden */
  87837. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87838. /**
  87839. * Creates a new SubEmitter from a serialized JSON version
  87840. * @param serializationObject defines the JSON object to read from
  87841. * @param scene defines the hosting scene
  87842. * @param rootUrl defines the rootUrl for data loading
  87843. * @returns a new SubEmitter
  87844. */
  87845. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87846. /** Release associated resources */
  87847. dispose(): void;
  87848. }
  87849. }
  87850. declare module BABYLON {
  87851. /** @hidden */
  87852. export var clipPlaneFragmentDeclaration: {
  87853. name: string;
  87854. shader: string;
  87855. };
  87856. }
  87857. declare module BABYLON {
  87858. /** @hidden */
  87859. export var imageProcessingDeclaration: {
  87860. name: string;
  87861. shader: string;
  87862. };
  87863. }
  87864. declare module BABYLON {
  87865. /** @hidden */
  87866. export var imageProcessingFunctions: {
  87867. name: string;
  87868. shader: string;
  87869. };
  87870. }
  87871. declare module BABYLON {
  87872. /** @hidden */
  87873. export var clipPlaneFragment: {
  87874. name: string;
  87875. shader: string;
  87876. };
  87877. }
  87878. declare module BABYLON {
  87879. /** @hidden */
  87880. export var particlesPixelShader: {
  87881. name: string;
  87882. shader: string;
  87883. };
  87884. }
  87885. declare module BABYLON {
  87886. /** @hidden */
  87887. export var clipPlaneVertexDeclaration: {
  87888. name: string;
  87889. shader: string;
  87890. };
  87891. }
  87892. declare module BABYLON {
  87893. /** @hidden */
  87894. export var clipPlaneVertex: {
  87895. name: string;
  87896. shader: string;
  87897. };
  87898. }
  87899. declare module BABYLON {
  87900. /** @hidden */
  87901. export var particlesVertexShader: {
  87902. name: string;
  87903. shader: string;
  87904. };
  87905. }
  87906. declare module BABYLON {
  87907. /**
  87908. * This represents a particle system in Babylon.
  87909. * 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.
  87910. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87911. * @example https://doc.babylonjs.com/babylon101/particles
  87912. */
  87913. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87914. /**
  87915. * Billboard mode will only apply to Y axis
  87916. */
  87917. static readonly BILLBOARDMODE_Y: number;
  87918. /**
  87919. * Billboard mode will apply to all axes
  87920. */
  87921. static readonly BILLBOARDMODE_ALL: number;
  87922. /**
  87923. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87924. */
  87925. static readonly BILLBOARDMODE_STRETCHED: number;
  87926. /**
  87927. * This function can be defined to provide custom update for active particles.
  87928. * This function will be called instead of regular update (age, position, color, etc.).
  87929. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87930. */
  87931. updateFunction: (particles: Particle[]) => void;
  87932. private _emitterWorldMatrix;
  87933. /**
  87934. * This function can be defined to specify initial direction for every new particle.
  87935. * It by default use the emitterType defined function
  87936. */
  87937. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  87938. /**
  87939. * This function can be defined to specify initial position for every new particle.
  87940. * It by default use the emitterType defined function
  87941. */
  87942. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  87943. /**
  87944. * @hidden
  87945. */
  87946. _inheritedVelocityOffset: Vector3;
  87947. /**
  87948. * An event triggered when the system is disposed
  87949. */
  87950. onDisposeObservable: Observable<ParticleSystem>;
  87951. private _onDisposeObserver;
  87952. /**
  87953. * Sets a callback that will be triggered when the system is disposed
  87954. */
  87955. set onDispose(callback: () => void);
  87956. private _particles;
  87957. private _epsilon;
  87958. private _capacity;
  87959. private _stockParticles;
  87960. private _newPartsExcess;
  87961. private _vertexData;
  87962. private _vertexBuffer;
  87963. private _vertexBuffers;
  87964. private _spriteBuffer;
  87965. private _indexBuffer;
  87966. private _effect;
  87967. private _customEffect;
  87968. private _cachedDefines;
  87969. private _scaledColorStep;
  87970. private _colorDiff;
  87971. private _scaledDirection;
  87972. private _scaledGravity;
  87973. private _currentRenderId;
  87974. private _alive;
  87975. private _useInstancing;
  87976. private _started;
  87977. private _stopped;
  87978. private _actualFrame;
  87979. private _scaledUpdateSpeed;
  87980. private _vertexBufferSize;
  87981. /** @hidden */
  87982. _currentEmitRateGradient: Nullable<FactorGradient>;
  87983. /** @hidden */
  87984. _currentEmitRate1: number;
  87985. /** @hidden */
  87986. _currentEmitRate2: number;
  87987. /** @hidden */
  87988. _currentStartSizeGradient: Nullable<FactorGradient>;
  87989. /** @hidden */
  87990. _currentStartSize1: number;
  87991. /** @hidden */
  87992. _currentStartSize2: number;
  87993. private readonly _rawTextureWidth;
  87994. private _rampGradientsTexture;
  87995. private _useRampGradients;
  87996. /** Gets or sets a boolean indicating that ramp gradients must be used
  87997. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87998. */
  87999. get useRampGradients(): boolean;
  88000. set useRampGradients(value: boolean);
  88001. /**
  88002. * 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.
  88003. * 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: [])
  88004. */
  88005. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88006. private _subEmitters;
  88007. /**
  88008. * @hidden
  88009. * If the particle systems emitter should be disposed when the particle system is disposed
  88010. */
  88011. _disposeEmitterOnDispose: boolean;
  88012. /**
  88013. * The current active Sub-systems, this property is used by the root particle system only.
  88014. */
  88015. activeSubSystems: Array<ParticleSystem>;
  88016. private _rootParticleSystem;
  88017. /**
  88018. * Gets the current list of active particles
  88019. */
  88020. get particles(): Particle[];
  88021. /**
  88022. * Returns the string "ParticleSystem"
  88023. * @returns a string containing the class name
  88024. */
  88025. getClassName(): string;
  88026. /**
  88027. * Instantiates a particle system.
  88028. * 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.
  88029. * @param name The name of the particle system
  88030. * @param capacity The max number of particles alive at the same time
  88031. * @param scene The scene the particle system belongs to
  88032. * @param customEffect a custom effect used to change the way particles are rendered by default
  88033. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88034. * @param epsilon Offset used to render the particles
  88035. */
  88036. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88037. private _addFactorGradient;
  88038. private _removeFactorGradient;
  88039. /**
  88040. * Adds a new life time gradient
  88041. * @param gradient defines the gradient to use (between 0 and 1)
  88042. * @param factor defines the life time factor to affect to the specified gradient
  88043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88044. * @returns the current particle system
  88045. */
  88046. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88047. /**
  88048. * Remove a specific life time gradient
  88049. * @param gradient defines the gradient to remove
  88050. * @returns the current particle system
  88051. */
  88052. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88053. /**
  88054. * Adds a new size gradient
  88055. * @param gradient defines the gradient to use (between 0 and 1)
  88056. * @param factor defines the size factor to affect to the specified gradient
  88057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88058. * @returns the current particle system
  88059. */
  88060. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88061. /**
  88062. * Remove a specific size gradient
  88063. * @param gradient defines the gradient to remove
  88064. * @returns the current particle system
  88065. */
  88066. removeSizeGradient(gradient: number): IParticleSystem;
  88067. /**
  88068. * Adds a new color remap gradient
  88069. * @param gradient defines the gradient to use (between 0 and 1)
  88070. * @param min defines the color remap minimal range
  88071. * @param max defines the color remap maximal range
  88072. * @returns the current particle system
  88073. */
  88074. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88075. /**
  88076. * Remove a specific color remap gradient
  88077. * @param gradient defines the gradient to remove
  88078. * @returns the current particle system
  88079. */
  88080. removeColorRemapGradient(gradient: number): IParticleSystem;
  88081. /**
  88082. * Adds a new alpha remap gradient
  88083. * @param gradient defines the gradient to use (between 0 and 1)
  88084. * @param min defines the alpha remap minimal range
  88085. * @param max defines the alpha remap maximal range
  88086. * @returns the current particle system
  88087. */
  88088. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88089. /**
  88090. * Remove a specific alpha remap gradient
  88091. * @param gradient defines the gradient to remove
  88092. * @returns the current particle system
  88093. */
  88094. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88095. /**
  88096. * Adds a new angular speed gradient
  88097. * @param gradient defines the gradient to use (between 0 and 1)
  88098. * @param factor defines the angular speed to affect to the specified gradient
  88099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88100. * @returns the current particle system
  88101. */
  88102. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88103. /**
  88104. * Remove a specific angular speed gradient
  88105. * @param gradient defines the gradient to remove
  88106. * @returns the current particle system
  88107. */
  88108. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88109. /**
  88110. * Adds a new velocity gradient
  88111. * @param gradient defines the gradient to use (between 0 and 1)
  88112. * @param factor defines the velocity to affect to the specified gradient
  88113. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88114. * @returns the current particle system
  88115. */
  88116. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88117. /**
  88118. * Remove a specific velocity gradient
  88119. * @param gradient defines the gradient to remove
  88120. * @returns the current particle system
  88121. */
  88122. removeVelocityGradient(gradient: number): IParticleSystem;
  88123. /**
  88124. * Adds a new limit velocity gradient
  88125. * @param gradient defines the gradient to use (between 0 and 1)
  88126. * @param factor defines the limit velocity value to affect to the specified gradient
  88127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88128. * @returns the current particle system
  88129. */
  88130. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88131. /**
  88132. * Remove a specific limit velocity gradient
  88133. * @param gradient defines the gradient to remove
  88134. * @returns the current particle system
  88135. */
  88136. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88137. /**
  88138. * Adds a new drag gradient
  88139. * @param gradient defines the gradient to use (between 0 and 1)
  88140. * @param factor defines the drag value to affect to the specified gradient
  88141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88142. * @returns the current particle system
  88143. */
  88144. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88145. /**
  88146. * Remove a specific drag gradient
  88147. * @param gradient defines the gradient to remove
  88148. * @returns the current particle system
  88149. */
  88150. removeDragGradient(gradient: number): IParticleSystem;
  88151. /**
  88152. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88153. * @param gradient defines the gradient to use (between 0 and 1)
  88154. * @param factor defines the emit rate value to affect to the specified gradient
  88155. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88156. * @returns the current particle system
  88157. */
  88158. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88159. /**
  88160. * Remove a specific emit rate gradient
  88161. * @param gradient defines the gradient to remove
  88162. * @returns the current particle system
  88163. */
  88164. removeEmitRateGradient(gradient: number): IParticleSystem;
  88165. /**
  88166. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88167. * @param gradient defines the gradient to use (between 0 and 1)
  88168. * @param factor defines the start size value to affect to the specified gradient
  88169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88170. * @returns the current particle system
  88171. */
  88172. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88173. /**
  88174. * Remove a specific start size gradient
  88175. * @param gradient defines the gradient to remove
  88176. * @returns the current particle system
  88177. */
  88178. removeStartSizeGradient(gradient: number): IParticleSystem;
  88179. private _createRampGradientTexture;
  88180. /**
  88181. * Gets the current list of ramp gradients.
  88182. * You must use addRampGradient and removeRampGradient to udpate this list
  88183. * @returns the list of ramp gradients
  88184. */
  88185. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88186. /**
  88187. * Adds a new ramp gradient used to remap particle colors
  88188. * @param gradient defines the gradient to use (between 0 and 1)
  88189. * @param color defines the color to affect to the specified gradient
  88190. * @returns the current particle system
  88191. */
  88192. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  88193. /**
  88194. * Remove a specific ramp gradient
  88195. * @param gradient defines the gradient to remove
  88196. * @returns the current particle system
  88197. */
  88198. removeRampGradient(gradient: number): ParticleSystem;
  88199. /**
  88200. * Adds a new color gradient
  88201. * @param gradient defines the gradient to use (between 0 and 1)
  88202. * @param color1 defines the color to affect to the specified gradient
  88203. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88204. * @returns this particle system
  88205. */
  88206. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88207. /**
  88208. * Remove a specific color gradient
  88209. * @param gradient defines the gradient to remove
  88210. * @returns this particle system
  88211. */
  88212. removeColorGradient(gradient: number): IParticleSystem;
  88213. private _fetchR;
  88214. protected _reset(): void;
  88215. private _resetEffect;
  88216. private _createVertexBuffers;
  88217. private _createIndexBuffer;
  88218. /**
  88219. * Gets the maximum number of particles active at the same time.
  88220. * @returns The max number of active particles.
  88221. */
  88222. getCapacity(): number;
  88223. /**
  88224. * Gets whether there are still active particles in the system.
  88225. * @returns True if it is alive, otherwise false.
  88226. */
  88227. isAlive(): boolean;
  88228. /**
  88229. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88230. * @returns True if it has been started, otherwise false.
  88231. */
  88232. isStarted(): boolean;
  88233. private _prepareSubEmitterInternalArray;
  88234. /**
  88235. * Starts the particle system and begins to emit
  88236. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  88237. */
  88238. start(delay?: number): void;
  88239. /**
  88240. * Stops the particle system.
  88241. * @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.
  88242. */
  88243. stop(stopSubEmitters?: boolean): void;
  88244. /**
  88245. * Remove all active particles
  88246. */
  88247. reset(): void;
  88248. /**
  88249. * @hidden (for internal use only)
  88250. */
  88251. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88252. /**
  88253. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88254. * Its lifetime will start back at 0.
  88255. */
  88256. recycleParticle: (particle: Particle) => void;
  88257. private _stopSubEmitters;
  88258. private _createParticle;
  88259. private _removeFromRoot;
  88260. private _emitFromParticle;
  88261. private _update;
  88262. /** @hidden */
  88263. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88264. /** @hidden */
  88265. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88266. /** @hidden */
  88267. private _getEffect;
  88268. /**
  88269. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88270. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88271. */
  88272. animate(preWarmOnly?: boolean): void;
  88273. private _appendParticleVertices;
  88274. /**
  88275. * Rebuilds the particle system.
  88276. */
  88277. rebuild(): void;
  88278. /**
  88279. * Is this system ready to be used/rendered
  88280. * @return true if the system is ready
  88281. */
  88282. isReady(): boolean;
  88283. private _render;
  88284. /**
  88285. * Renders the particle system in its current state.
  88286. * @returns the current number of particles
  88287. */
  88288. render(): number;
  88289. /**
  88290. * Disposes the particle system and free the associated resources
  88291. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88292. */
  88293. dispose(disposeTexture?: boolean): void;
  88294. /**
  88295. * Clones the particle system.
  88296. * @param name The name of the cloned object
  88297. * @param newEmitter The new emitter to use
  88298. * @returns the cloned particle system
  88299. */
  88300. clone(name: string, newEmitter: any): ParticleSystem;
  88301. /**
  88302. * Serializes the particle system to a JSON object.
  88303. * @returns the JSON object
  88304. */
  88305. serialize(): any;
  88306. /** @hidden */
  88307. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  88308. /** @hidden */
  88309. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88310. /**
  88311. * Parses a JSON object to create a particle system.
  88312. * @param parsedParticleSystem The JSON object to parse
  88313. * @param scene The scene to create the particle system in
  88314. * @param rootUrl The root url to use to load external dependencies like texture
  88315. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88316. * @returns the Parsed particle system
  88317. */
  88318. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88319. }
  88320. }
  88321. declare module BABYLON {
  88322. /**
  88323. * A particle represents one of the element emitted by a particle system.
  88324. * This is mainly define by its coordinates, direction, velocity and age.
  88325. */
  88326. export class Particle {
  88327. /**
  88328. * The particle system the particle belongs to.
  88329. */
  88330. particleSystem: ParticleSystem;
  88331. private static _Count;
  88332. /**
  88333. * Unique ID of the particle
  88334. */
  88335. id: number;
  88336. /**
  88337. * The world position of the particle in the scene.
  88338. */
  88339. position: Vector3;
  88340. /**
  88341. * The world direction of the particle in the scene.
  88342. */
  88343. direction: Vector3;
  88344. /**
  88345. * The color of the particle.
  88346. */
  88347. color: Color4;
  88348. /**
  88349. * The color change of the particle per step.
  88350. */
  88351. colorStep: Color4;
  88352. /**
  88353. * Defines how long will the life of the particle be.
  88354. */
  88355. lifeTime: number;
  88356. /**
  88357. * The current age of the particle.
  88358. */
  88359. age: number;
  88360. /**
  88361. * The current size of the particle.
  88362. */
  88363. size: number;
  88364. /**
  88365. * The current scale of the particle.
  88366. */
  88367. scale: Vector2;
  88368. /**
  88369. * The current angle of the particle.
  88370. */
  88371. angle: number;
  88372. /**
  88373. * Defines how fast is the angle changing.
  88374. */
  88375. angularSpeed: number;
  88376. /**
  88377. * Defines the cell index used by the particle to be rendered from a sprite.
  88378. */
  88379. cellIndex: number;
  88380. /**
  88381. * The information required to support color remapping
  88382. */
  88383. remapData: Vector4;
  88384. /** @hidden */
  88385. _randomCellOffset?: number;
  88386. /** @hidden */
  88387. _initialDirection: Nullable<Vector3>;
  88388. /** @hidden */
  88389. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88390. /** @hidden */
  88391. _initialStartSpriteCellID: number;
  88392. /** @hidden */
  88393. _initialEndSpriteCellID: number;
  88394. /** @hidden */
  88395. _currentColorGradient: Nullable<ColorGradient>;
  88396. /** @hidden */
  88397. _currentColor1: Color4;
  88398. /** @hidden */
  88399. _currentColor2: Color4;
  88400. /** @hidden */
  88401. _currentSizeGradient: Nullable<FactorGradient>;
  88402. /** @hidden */
  88403. _currentSize1: number;
  88404. /** @hidden */
  88405. _currentSize2: number;
  88406. /** @hidden */
  88407. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88408. /** @hidden */
  88409. _currentAngularSpeed1: number;
  88410. /** @hidden */
  88411. _currentAngularSpeed2: number;
  88412. /** @hidden */
  88413. _currentVelocityGradient: Nullable<FactorGradient>;
  88414. /** @hidden */
  88415. _currentVelocity1: number;
  88416. /** @hidden */
  88417. _currentVelocity2: number;
  88418. /** @hidden */
  88419. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88420. /** @hidden */
  88421. _currentLimitVelocity1: number;
  88422. /** @hidden */
  88423. _currentLimitVelocity2: number;
  88424. /** @hidden */
  88425. _currentDragGradient: Nullable<FactorGradient>;
  88426. /** @hidden */
  88427. _currentDrag1: number;
  88428. /** @hidden */
  88429. _currentDrag2: number;
  88430. /** @hidden */
  88431. _randomNoiseCoordinates1: Vector3;
  88432. /** @hidden */
  88433. _randomNoiseCoordinates2: Vector3;
  88434. /**
  88435. * Creates a new instance Particle
  88436. * @param particleSystem the particle system the particle belongs to
  88437. */
  88438. constructor(
  88439. /**
  88440. * The particle system the particle belongs to.
  88441. */
  88442. particleSystem: ParticleSystem);
  88443. private updateCellInfoFromSystem;
  88444. /**
  88445. * Defines how the sprite cell index is updated for the particle
  88446. */
  88447. updateCellIndex(): void;
  88448. /** @hidden */
  88449. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88450. /** @hidden */
  88451. _inheritParticleInfoToSubEmitters(): void;
  88452. /** @hidden */
  88453. _reset(): void;
  88454. /**
  88455. * Copy the properties of particle to another one.
  88456. * @param other the particle to copy the information to.
  88457. */
  88458. copyTo(other: Particle): void;
  88459. }
  88460. }
  88461. declare module BABYLON {
  88462. /**
  88463. * Particle emitter represents a volume emitting particles.
  88464. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88465. */
  88466. export interface IParticleEmitterType {
  88467. /**
  88468. * Called by the particle System when the direction is computed for the created particle.
  88469. * @param worldMatrix is the world matrix of the particle system
  88470. * @param directionToUpdate is the direction vector to update with the result
  88471. * @param particle is the particle we are computed the direction for
  88472. */
  88473. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88474. /**
  88475. * Called by the particle System when the position is computed for the created particle.
  88476. * @param worldMatrix is the world matrix of the particle system
  88477. * @param positionToUpdate is the position vector to update with the result
  88478. * @param particle is the particle we are computed the position for
  88479. */
  88480. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88481. /**
  88482. * Clones the current emitter and returns a copy of it
  88483. * @returns the new emitter
  88484. */
  88485. clone(): IParticleEmitterType;
  88486. /**
  88487. * Called by the GPUParticleSystem to setup the update shader
  88488. * @param effect defines the update shader
  88489. */
  88490. applyToShader(effect: Effect): void;
  88491. /**
  88492. * Returns a string to use to update the GPU particles update shader
  88493. * @returns the effect defines string
  88494. */
  88495. getEffectDefines(): string;
  88496. /**
  88497. * Returns a string representing the class name
  88498. * @returns a string containing the class name
  88499. */
  88500. getClassName(): string;
  88501. /**
  88502. * Serializes the particle system to a JSON object.
  88503. * @returns the JSON object
  88504. */
  88505. serialize(): any;
  88506. /**
  88507. * Parse properties from a JSON object
  88508. * @param serializationObject defines the JSON object
  88509. */
  88510. parse(serializationObject: any): void;
  88511. }
  88512. }
  88513. declare module BABYLON {
  88514. /**
  88515. * Particle emitter emitting particles from the inside of a box.
  88516. * It emits the particles randomly between 2 given directions.
  88517. */
  88518. export class BoxParticleEmitter implements IParticleEmitterType {
  88519. /**
  88520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88521. */
  88522. direction1: Vector3;
  88523. /**
  88524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88525. */
  88526. direction2: Vector3;
  88527. /**
  88528. * 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.
  88529. */
  88530. minEmitBox: Vector3;
  88531. /**
  88532. * 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.
  88533. */
  88534. maxEmitBox: Vector3;
  88535. /**
  88536. * Creates a new instance BoxParticleEmitter
  88537. */
  88538. constructor();
  88539. /**
  88540. * Called by the particle System when the direction is computed for the created particle.
  88541. * @param worldMatrix is the world matrix of the particle system
  88542. * @param directionToUpdate is the direction vector to update with the result
  88543. * @param particle is the particle we are computed the direction for
  88544. */
  88545. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88546. /**
  88547. * Called by the particle System when the position is computed for the created particle.
  88548. * @param worldMatrix is the world matrix of the particle system
  88549. * @param positionToUpdate is the position vector to update with the result
  88550. * @param particle is the particle we are computed the position for
  88551. */
  88552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88553. /**
  88554. * Clones the current emitter and returns a copy of it
  88555. * @returns the new emitter
  88556. */
  88557. clone(): BoxParticleEmitter;
  88558. /**
  88559. * Called by the GPUParticleSystem to setup the update shader
  88560. * @param effect defines the update shader
  88561. */
  88562. applyToShader(effect: Effect): void;
  88563. /**
  88564. * Returns a string to use to update the GPU particles update shader
  88565. * @returns a string containng the defines string
  88566. */
  88567. getEffectDefines(): string;
  88568. /**
  88569. * Returns the string "BoxParticleEmitter"
  88570. * @returns a string containing the class name
  88571. */
  88572. getClassName(): string;
  88573. /**
  88574. * Serializes the particle system to a JSON object.
  88575. * @returns the JSON object
  88576. */
  88577. serialize(): any;
  88578. /**
  88579. * Parse properties from a JSON object
  88580. * @param serializationObject defines the JSON object
  88581. */
  88582. parse(serializationObject: any): void;
  88583. }
  88584. }
  88585. declare module BABYLON {
  88586. /**
  88587. * Particle emitter emitting particles from the inside of a cone.
  88588. * It emits the particles alongside the cone volume from the base to the particle.
  88589. * The emission direction might be randomized.
  88590. */
  88591. export class ConeParticleEmitter implements IParticleEmitterType {
  88592. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88593. directionRandomizer: number;
  88594. private _radius;
  88595. private _angle;
  88596. private _height;
  88597. /**
  88598. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88599. */
  88600. radiusRange: number;
  88601. /**
  88602. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88603. */
  88604. heightRange: number;
  88605. /**
  88606. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88607. */
  88608. emitFromSpawnPointOnly: boolean;
  88609. /**
  88610. * Gets or sets the radius of the emission cone
  88611. */
  88612. get radius(): number;
  88613. set radius(value: number);
  88614. /**
  88615. * Gets or sets the angle of the emission cone
  88616. */
  88617. get angle(): number;
  88618. set angle(value: number);
  88619. private _buildHeight;
  88620. /**
  88621. * Creates a new instance ConeParticleEmitter
  88622. * @param radius the radius of the emission cone (1 by default)
  88623. * @param angle the cone base angle (PI by default)
  88624. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88625. */
  88626. constructor(radius?: number, angle?: number,
  88627. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88628. directionRandomizer?: number);
  88629. /**
  88630. * Called by the particle System when the direction is computed for the created particle.
  88631. * @param worldMatrix is the world matrix of the particle system
  88632. * @param directionToUpdate is the direction vector to update with the result
  88633. * @param particle is the particle we are computed the direction for
  88634. */
  88635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88636. /**
  88637. * Called by the particle System when the position is computed for the created particle.
  88638. * @param worldMatrix is the world matrix of the particle system
  88639. * @param positionToUpdate is the position vector to update with the result
  88640. * @param particle is the particle we are computed the position for
  88641. */
  88642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88643. /**
  88644. * Clones the current emitter and returns a copy of it
  88645. * @returns the new emitter
  88646. */
  88647. clone(): ConeParticleEmitter;
  88648. /**
  88649. * Called by the GPUParticleSystem to setup the update shader
  88650. * @param effect defines the update shader
  88651. */
  88652. applyToShader(effect: Effect): void;
  88653. /**
  88654. * Returns a string to use to update the GPU particles update shader
  88655. * @returns a string containng the defines string
  88656. */
  88657. getEffectDefines(): string;
  88658. /**
  88659. * Returns the string "ConeParticleEmitter"
  88660. * @returns a string containing the class name
  88661. */
  88662. getClassName(): string;
  88663. /**
  88664. * Serializes the particle system to a JSON object.
  88665. * @returns the JSON object
  88666. */
  88667. serialize(): any;
  88668. /**
  88669. * Parse properties from a JSON object
  88670. * @param serializationObject defines the JSON object
  88671. */
  88672. parse(serializationObject: any): void;
  88673. }
  88674. }
  88675. declare module BABYLON {
  88676. /**
  88677. * Particle emitter emitting particles from the inside of a cylinder.
  88678. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88679. */
  88680. export class CylinderParticleEmitter implements IParticleEmitterType {
  88681. /**
  88682. * The radius of the emission cylinder.
  88683. */
  88684. radius: number;
  88685. /**
  88686. * The height of the emission cylinder.
  88687. */
  88688. height: number;
  88689. /**
  88690. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88691. */
  88692. radiusRange: number;
  88693. /**
  88694. * How much to randomize the particle direction [0-1].
  88695. */
  88696. directionRandomizer: number;
  88697. /**
  88698. * Creates a new instance CylinderParticleEmitter
  88699. * @param radius the radius of the emission cylinder (1 by default)
  88700. * @param height the height of the emission cylinder (1 by default)
  88701. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88702. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88703. */
  88704. constructor(
  88705. /**
  88706. * The radius of the emission cylinder.
  88707. */
  88708. radius?: number,
  88709. /**
  88710. * The height of the emission cylinder.
  88711. */
  88712. height?: number,
  88713. /**
  88714. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88715. */
  88716. radiusRange?: number,
  88717. /**
  88718. * How much to randomize the particle direction [0-1].
  88719. */
  88720. directionRandomizer?: number);
  88721. /**
  88722. * Called by the particle System when the direction is computed for the created particle.
  88723. * @param worldMatrix is the world matrix of the particle system
  88724. * @param directionToUpdate is the direction vector to update with the result
  88725. * @param particle is the particle we are computed the direction for
  88726. */
  88727. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88728. /**
  88729. * Called by the particle System when the position is computed for the created particle.
  88730. * @param worldMatrix is the world matrix of the particle system
  88731. * @param positionToUpdate is the position vector to update with the result
  88732. * @param particle is the particle we are computed the position for
  88733. */
  88734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88735. /**
  88736. * Clones the current emitter and returns a copy of it
  88737. * @returns the new emitter
  88738. */
  88739. clone(): CylinderParticleEmitter;
  88740. /**
  88741. * Called by the GPUParticleSystem to setup the update shader
  88742. * @param effect defines the update shader
  88743. */
  88744. applyToShader(effect: Effect): void;
  88745. /**
  88746. * Returns a string to use to update the GPU particles update shader
  88747. * @returns a string containng the defines string
  88748. */
  88749. getEffectDefines(): string;
  88750. /**
  88751. * Returns the string "CylinderParticleEmitter"
  88752. * @returns a string containing the class name
  88753. */
  88754. getClassName(): string;
  88755. /**
  88756. * Serializes the particle system to a JSON object.
  88757. * @returns the JSON object
  88758. */
  88759. serialize(): any;
  88760. /**
  88761. * Parse properties from a JSON object
  88762. * @param serializationObject defines the JSON object
  88763. */
  88764. parse(serializationObject: any): void;
  88765. }
  88766. /**
  88767. * Particle emitter emitting particles from the inside of a cylinder.
  88768. * It emits the particles randomly between two vectors.
  88769. */
  88770. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88771. /**
  88772. * The min limit of the emission direction.
  88773. */
  88774. direction1: Vector3;
  88775. /**
  88776. * The max limit of the emission direction.
  88777. */
  88778. direction2: Vector3;
  88779. /**
  88780. * Creates a new instance CylinderDirectedParticleEmitter
  88781. * @param radius the radius of the emission cylinder (1 by default)
  88782. * @param height the height of the emission cylinder (1 by default)
  88783. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88784. * @param direction1 the min limit of the emission direction (up vector by default)
  88785. * @param direction2 the max limit of the emission direction (up vector by default)
  88786. */
  88787. constructor(radius?: number, height?: number, radiusRange?: number,
  88788. /**
  88789. * The min limit of the emission direction.
  88790. */
  88791. direction1?: Vector3,
  88792. /**
  88793. * The max limit of the emission direction.
  88794. */
  88795. direction2?: Vector3);
  88796. /**
  88797. * Called by the particle System when the direction is computed for the created particle.
  88798. * @param worldMatrix is the world matrix of the particle system
  88799. * @param directionToUpdate is the direction vector to update with the result
  88800. * @param particle is the particle we are computed the direction for
  88801. */
  88802. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88803. /**
  88804. * Clones the current emitter and returns a copy of it
  88805. * @returns the new emitter
  88806. */
  88807. clone(): CylinderDirectedParticleEmitter;
  88808. /**
  88809. * Called by the GPUParticleSystem to setup the update shader
  88810. * @param effect defines the update shader
  88811. */
  88812. applyToShader(effect: Effect): void;
  88813. /**
  88814. * Returns a string to use to update the GPU particles update shader
  88815. * @returns a string containng the defines string
  88816. */
  88817. getEffectDefines(): string;
  88818. /**
  88819. * Returns the string "CylinderDirectedParticleEmitter"
  88820. * @returns a string containing the class name
  88821. */
  88822. getClassName(): string;
  88823. /**
  88824. * Serializes the particle system to a JSON object.
  88825. * @returns the JSON object
  88826. */
  88827. serialize(): any;
  88828. /**
  88829. * Parse properties from a JSON object
  88830. * @param serializationObject defines the JSON object
  88831. */
  88832. parse(serializationObject: any): void;
  88833. }
  88834. }
  88835. declare module BABYLON {
  88836. /**
  88837. * Particle emitter emitting particles from the inside of a hemisphere.
  88838. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88839. */
  88840. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88841. /**
  88842. * The radius of the emission hemisphere.
  88843. */
  88844. radius: number;
  88845. /**
  88846. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88847. */
  88848. radiusRange: number;
  88849. /**
  88850. * How much to randomize the particle direction [0-1].
  88851. */
  88852. directionRandomizer: number;
  88853. /**
  88854. * Creates a new instance HemisphericParticleEmitter
  88855. * @param radius the radius of the emission hemisphere (1 by default)
  88856. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88857. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88858. */
  88859. constructor(
  88860. /**
  88861. * The radius of the emission hemisphere.
  88862. */
  88863. radius?: number,
  88864. /**
  88865. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88866. */
  88867. radiusRange?: number,
  88868. /**
  88869. * How much to randomize the particle direction [0-1].
  88870. */
  88871. directionRandomizer?: number);
  88872. /**
  88873. * Called by the particle System when the direction is computed for the created particle.
  88874. * @param worldMatrix is the world matrix of the particle system
  88875. * @param directionToUpdate is the direction vector to update with the result
  88876. * @param particle is the particle we are computed the direction for
  88877. */
  88878. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88879. /**
  88880. * Called by the particle System when the position is computed for the created particle.
  88881. * @param worldMatrix is the world matrix of the particle system
  88882. * @param positionToUpdate is the position vector to update with the result
  88883. * @param particle is the particle we are computed the position for
  88884. */
  88885. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88886. /**
  88887. * Clones the current emitter and returns a copy of it
  88888. * @returns the new emitter
  88889. */
  88890. clone(): HemisphericParticleEmitter;
  88891. /**
  88892. * Called by the GPUParticleSystem to setup the update shader
  88893. * @param effect defines the update shader
  88894. */
  88895. applyToShader(effect: Effect): void;
  88896. /**
  88897. * Returns a string to use to update the GPU particles update shader
  88898. * @returns a string containng the defines string
  88899. */
  88900. getEffectDefines(): string;
  88901. /**
  88902. * Returns the string "HemisphericParticleEmitter"
  88903. * @returns a string containing the class name
  88904. */
  88905. getClassName(): string;
  88906. /**
  88907. * Serializes the particle system to a JSON object.
  88908. * @returns the JSON object
  88909. */
  88910. serialize(): any;
  88911. /**
  88912. * Parse properties from a JSON object
  88913. * @param serializationObject defines the JSON object
  88914. */
  88915. parse(serializationObject: any): void;
  88916. }
  88917. }
  88918. declare module BABYLON {
  88919. /**
  88920. * Particle emitter emitting particles from a point.
  88921. * It emits the particles randomly between 2 given directions.
  88922. */
  88923. export class PointParticleEmitter implements IParticleEmitterType {
  88924. /**
  88925. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88926. */
  88927. direction1: Vector3;
  88928. /**
  88929. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88930. */
  88931. direction2: Vector3;
  88932. /**
  88933. * Creates a new instance PointParticleEmitter
  88934. */
  88935. constructor();
  88936. /**
  88937. * Called by the particle System when the direction is computed for the created particle.
  88938. * @param worldMatrix is the world matrix of the particle system
  88939. * @param directionToUpdate is the direction vector to update with the result
  88940. * @param particle is the particle we are computed the direction for
  88941. */
  88942. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88943. /**
  88944. * Called by the particle System when the position is computed for the created particle.
  88945. * @param worldMatrix is the world matrix of the particle system
  88946. * @param positionToUpdate is the position vector to update with the result
  88947. * @param particle is the particle we are computed the position for
  88948. */
  88949. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88950. /**
  88951. * Clones the current emitter and returns a copy of it
  88952. * @returns the new emitter
  88953. */
  88954. clone(): PointParticleEmitter;
  88955. /**
  88956. * Called by the GPUParticleSystem to setup the update shader
  88957. * @param effect defines the update shader
  88958. */
  88959. applyToShader(effect: Effect): void;
  88960. /**
  88961. * Returns a string to use to update the GPU particles update shader
  88962. * @returns a string containng the defines string
  88963. */
  88964. getEffectDefines(): string;
  88965. /**
  88966. * Returns the string "PointParticleEmitter"
  88967. * @returns a string containing the class name
  88968. */
  88969. getClassName(): string;
  88970. /**
  88971. * Serializes the particle system to a JSON object.
  88972. * @returns the JSON object
  88973. */
  88974. serialize(): any;
  88975. /**
  88976. * Parse properties from a JSON object
  88977. * @param serializationObject defines the JSON object
  88978. */
  88979. parse(serializationObject: any): void;
  88980. }
  88981. }
  88982. declare module BABYLON {
  88983. /**
  88984. * Particle emitter emitting particles from the inside of a sphere.
  88985. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88986. */
  88987. export class SphereParticleEmitter implements IParticleEmitterType {
  88988. /**
  88989. * The radius of the emission sphere.
  88990. */
  88991. radius: number;
  88992. /**
  88993. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88994. */
  88995. radiusRange: number;
  88996. /**
  88997. * How much to randomize the particle direction [0-1].
  88998. */
  88999. directionRandomizer: number;
  89000. /**
  89001. * Creates a new instance SphereParticleEmitter
  89002. * @param radius the radius of the emission sphere (1 by default)
  89003. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89004. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89005. */
  89006. constructor(
  89007. /**
  89008. * The radius of the emission sphere.
  89009. */
  89010. radius?: number,
  89011. /**
  89012. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89013. */
  89014. radiusRange?: number,
  89015. /**
  89016. * How much to randomize the particle direction [0-1].
  89017. */
  89018. directionRandomizer?: number);
  89019. /**
  89020. * Called by the particle System when the direction is computed for the created particle.
  89021. * @param worldMatrix is the world matrix of the particle system
  89022. * @param directionToUpdate is the direction vector to update with the result
  89023. * @param particle is the particle we are computed the direction for
  89024. */
  89025. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89026. /**
  89027. * Called by the particle System when the position is computed for the created particle.
  89028. * @param worldMatrix is the world matrix of the particle system
  89029. * @param positionToUpdate is the position vector to update with the result
  89030. * @param particle is the particle we are computed the position for
  89031. */
  89032. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89033. /**
  89034. * Clones the current emitter and returns a copy of it
  89035. * @returns the new emitter
  89036. */
  89037. clone(): SphereParticleEmitter;
  89038. /**
  89039. * Called by the GPUParticleSystem to setup the update shader
  89040. * @param effect defines the update shader
  89041. */
  89042. applyToShader(effect: Effect): void;
  89043. /**
  89044. * Returns a string to use to update the GPU particles update shader
  89045. * @returns a string containng the defines string
  89046. */
  89047. getEffectDefines(): string;
  89048. /**
  89049. * Returns the string "SphereParticleEmitter"
  89050. * @returns a string containing the class name
  89051. */
  89052. getClassName(): string;
  89053. /**
  89054. * Serializes the particle system to a JSON object.
  89055. * @returns the JSON object
  89056. */
  89057. serialize(): any;
  89058. /**
  89059. * Parse properties from a JSON object
  89060. * @param serializationObject defines the JSON object
  89061. */
  89062. parse(serializationObject: any): void;
  89063. }
  89064. /**
  89065. * Particle emitter emitting particles from the inside of a sphere.
  89066. * It emits the particles randomly between two vectors.
  89067. */
  89068. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89069. /**
  89070. * The min limit of the emission direction.
  89071. */
  89072. direction1: Vector3;
  89073. /**
  89074. * The max limit of the emission direction.
  89075. */
  89076. direction2: Vector3;
  89077. /**
  89078. * Creates a new instance SphereDirectedParticleEmitter
  89079. * @param radius the radius of the emission sphere (1 by default)
  89080. * @param direction1 the min limit of the emission direction (up vector by default)
  89081. * @param direction2 the max limit of the emission direction (up vector by default)
  89082. */
  89083. constructor(radius?: number,
  89084. /**
  89085. * The min limit of the emission direction.
  89086. */
  89087. direction1?: Vector3,
  89088. /**
  89089. * The max limit of the emission direction.
  89090. */
  89091. direction2?: Vector3);
  89092. /**
  89093. * Called by the particle System when the direction is computed for the created particle.
  89094. * @param worldMatrix is the world matrix of the particle system
  89095. * @param directionToUpdate is the direction vector to update with the result
  89096. * @param particle is the particle we are computed the direction for
  89097. */
  89098. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89099. /**
  89100. * Clones the current emitter and returns a copy of it
  89101. * @returns the new emitter
  89102. */
  89103. clone(): SphereDirectedParticleEmitter;
  89104. /**
  89105. * Called by the GPUParticleSystem to setup the update shader
  89106. * @param effect defines the update shader
  89107. */
  89108. applyToShader(effect: Effect): void;
  89109. /**
  89110. * Returns a string to use to update the GPU particles update shader
  89111. * @returns a string containng the defines string
  89112. */
  89113. getEffectDefines(): string;
  89114. /**
  89115. * Returns the string "SphereDirectedParticleEmitter"
  89116. * @returns a string containing the class name
  89117. */
  89118. getClassName(): string;
  89119. /**
  89120. * Serializes the particle system to a JSON object.
  89121. * @returns the JSON object
  89122. */
  89123. serialize(): any;
  89124. /**
  89125. * Parse properties from a JSON object
  89126. * @param serializationObject defines the JSON object
  89127. */
  89128. parse(serializationObject: any): void;
  89129. }
  89130. }
  89131. declare module BABYLON {
  89132. /**
  89133. * Interface representing a particle system in Babylon.js.
  89134. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89135. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89136. */
  89137. export interface IParticleSystem {
  89138. /**
  89139. * List of animations used by the particle system.
  89140. */
  89141. animations: Animation[];
  89142. /**
  89143. * The id of the Particle system.
  89144. */
  89145. id: string;
  89146. /**
  89147. * The name of the Particle system.
  89148. */
  89149. name: string;
  89150. /**
  89151. * The emitter represents the Mesh or position we are attaching the particle system to.
  89152. */
  89153. emitter: Nullable<AbstractMesh | Vector3>;
  89154. /**
  89155. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89156. */
  89157. isBillboardBased: boolean;
  89158. /**
  89159. * The rendering group used by the Particle system to chose when to render.
  89160. */
  89161. renderingGroupId: number;
  89162. /**
  89163. * The layer mask we are rendering the particles through.
  89164. */
  89165. layerMask: number;
  89166. /**
  89167. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89168. */
  89169. updateSpeed: number;
  89170. /**
  89171. * The amount of time the particle system is running (depends of the overall update speed).
  89172. */
  89173. targetStopDuration: number;
  89174. /**
  89175. * The texture used to render each particle. (this can be a spritesheet)
  89176. */
  89177. particleTexture: Nullable<Texture>;
  89178. /**
  89179. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89180. */
  89181. blendMode: number;
  89182. /**
  89183. * Minimum life time of emitting particles.
  89184. */
  89185. minLifeTime: number;
  89186. /**
  89187. * Maximum life time of emitting particles.
  89188. */
  89189. maxLifeTime: number;
  89190. /**
  89191. * Minimum Size of emitting particles.
  89192. */
  89193. minSize: number;
  89194. /**
  89195. * Maximum Size of emitting particles.
  89196. */
  89197. maxSize: number;
  89198. /**
  89199. * Minimum scale of emitting particles on X axis.
  89200. */
  89201. minScaleX: number;
  89202. /**
  89203. * Maximum scale of emitting particles on X axis.
  89204. */
  89205. maxScaleX: number;
  89206. /**
  89207. * Minimum scale of emitting particles on Y axis.
  89208. */
  89209. minScaleY: number;
  89210. /**
  89211. * Maximum scale of emitting particles on Y axis.
  89212. */
  89213. maxScaleY: number;
  89214. /**
  89215. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89216. */
  89217. color1: Color4;
  89218. /**
  89219. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89220. */
  89221. color2: Color4;
  89222. /**
  89223. * Color the particle will have at the end of its lifetime.
  89224. */
  89225. colorDead: Color4;
  89226. /**
  89227. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89228. */
  89229. emitRate: number;
  89230. /**
  89231. * You can use gravity if you want to give an orientation to your particles.
  89232. */
  89233. gravity: Vector3;
  89234. /**
  89235. * Minimum power of emitting particles.
  89236. */
  89237. minEmitPower: number;
  89238. /**
  89239. * Maximum power of emitting particles.
  89240. */
  89241. maxEmitPower: number;
  89242. /**
  89243. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89244. */
  89245. minAngularSpeed: number;
  89246. /**
  89247. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89248. */
  89249. maxAngularSpeed: number;
  89250. /**
  89251. * Gets or sets the minimal initial rotation in radians.
  89252. */
  89253. minInitialRotation: number;
  89254. /**
  89255. * Gets or sets the maximal initial rotation in radians.
  89256. */
  89257. maxInitialRotation: number;
  89258. /**
  89259. * The particle emitter type defines the emitter used by the particle system.
  89260. * It can be for example box, sphere, or cone...
  89261. */
  89262. particleEmitterType: Nullable<IParticleEmitterType>;
  89263. /**
  89264. * Defines the delay in milliseconds before starting the system (0 by default)
  89265. */
  89266. startDelay: number;
  89267. /**
  89268. * 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
  89269. */
  89270. preWarmCycles: number;
  89271. /**
  89272. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89273. */
  89274. preWarmStepOffset: number;
  89275. /**
  89276. * 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)
  89277. */
  89278. spriteCellChangeSpeed: number;
  89279. /**
  89280. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89281. */
  89282. startSpriteCellID: number;
  89283. /**
  89284. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89285. */
  89286. endSpriteCellID: number;
  89287. /**
  89288. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89289. */
  89290. spriteCellWidth: number;
  89291. /**
  89292. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89293. */
  89294. spriteCellHeight: number;
  89295. /**
  89296. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89297. */
  89298. spriteRandomStartCell: boolean;
  89299. /**
  89300. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89301. */
  89302. isAnimationSheetEnabled: boolean;
  89303. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89304. translationPivot: Vector2;
  89305. /**
  89306. * Gets or sets a texture used to add random noise to particle positions
  89307. */
  89308. noiseTexture: Nullable<BaseTexture>;
  89309. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89310. noiseStrength: Vector3;
  89311. /**
  89312. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89313. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89314. */
  89315. billboardMode: number;
  89316. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89317. limitVelocityDamping: number;
  89318. /**
  89319. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89320. */
  89321. beginAnimationOnStart: boolean;
  89322. /**
  89323. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89324. */
  89325. beginAnimationFrom: number;
  89326. /**
  89327. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89328. */
  89329. beginAnimationTo: number;
  89330. /**
  89331. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89332. */
  89333. beginAnimationLoop: boolean;
  89334. /**
  89335. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89336. */
  89337. disposeOnStop: boolean;
  89338. /**
  89339. * Gets the maximum number of particles active at the same time.
  89340. * @returns The max number of active particles.
  89341. */
  89342. getCapacity(): number;
  89343. /**
  89344. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89345. * @returns True if it has been started, otherwise false.
  89346. */
  89347. isStarted(): boolean;
  89348. /**
  89349. * Animates the particle system for this frame.
  89350. */
  89351. animate(): void;
  89352. /**
  89353. * Renders the particle system in its current state.
  89354. * @returns the current number of particles
  89355. */
  89356. render(): number;
  89357. /**
  89358. * Dispose the particle system and frees its associated resources.
  89359. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89360. */
  89361. dispose(disposeTexture?: boolean): void;
  89362. /**
  89363. * Clones the particle system.
  89364. * @param name The name of the cloned object
  89365. * @param newEmitter The new emitter to use
  89366. * @returns the cloned particle system
  89367. */
  89368. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89369. /**
  89370. * Serializes the particle system to a JSON object.
  89371. * @returns the JSON object
  89372. */
  89373. serialize(): any;
  89374. /**
  89375. * Rebuild the particle system
  89376. */
  89377. rebuild(): void;
  89378. /**
  89379. * Starts the particle system and begins to emit
  89380. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89381. */
  89382. start(delay?: number): void;
  89383. /**
  89384. * Stops the particle system.
  89385. */
  89386. stop(): void;
  89387. /**
  89388. * Remove all active particles
  89389. */
  89390. reset(): void;
  89391. /**
  89392. * Is this system ready to be used/rendered
  89393. * @return true if the system is ready
  89394. */
  89395. isReady(): boolean;
  89396. /**
  89397. * Adds a new color gradient
  89398. * @param gradient defines the gradient to use (between 0 and 1)
  89399. * @param color1 defines the color to affect to the specified gradient
  89400. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89401. * @returns the current particle system
  89402. */
  89403. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89404. /**
  89405. * Remove a specific color gradient
  89406. * @param gradient defines the gradient to remove
  89407. * @returns the current particle system
  89408. */
  89409. removeColorGradient(gradient: number): IParticleSystem;
  89410. /**
  89411. * Adds a new size gradient
  89412. * @param gradient defines the gradient to use (between 0 and 1)
  89413. * @param factor defines the size factor to affect to the specified gradient
  89414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89415. * @returns the current particle system
  89416. */
  89417. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89418. /**
  89419. * Remove a specific size gradient
  89420. * @param gradient defines the gradient to remove
  89421. * @returns the current particle system
  89422. */
  89423. removeSizeGradient(gradient: number): IParticleSystem;
  89424. /**
  89425. * Gets the current list of color gradients.
  89426. * You must use addColorGradient and removeColorGradient to udpate this list
  89427. * @returns the list of color gradients
  89428. */
  89429. getColorGradients(): Nullable<Array<ColorGradient>>;
  89430. /**
  89431. * Gets the current list of size gradients.
  89432. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89433. * @returns the list of size gradients
  89434. */
  89435. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89436. /**
  89437. * Gets the current list of angular speed gradients.
  89438. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89439. * @returns the list of angular speed gradients
  89440. */
  89441. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89442. /**
  89443. * Adds a new angular speed gradient
  89444. * @param gradient defines the gradient to use (between 0 and 1)
  89445. * @param factor defines the angular speed to affect to the specified gradient
  89446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89447. * @returns the current particle system
  89448. */
  89449. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89450. /**
  89451. * Remove a specific angular speed gradient
  89452. * @param gradient defines the gradient to remove
  89453. * @returns the current particle system
  89454. */
  89455. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89456. /**
  89457. * Gets the current list of velocity gradients.
  89458. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89459. * @returns the list of velocity gradients
  89460. */
  89461. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89462. /**
  89463. * Adds a new velocity gradient
  89464. * @param gradient defines the gradient to use (between 0 and 1)
  89465. * @param factor defines the velocity to affect to the specified gradient
  89466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89467. * @returns the current particle system
  89468. */
  89469. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89470. /**
  89471. * Remove a specific velocity gradient
  89472. * @param gradient defines the gradient to remove
  89473. * @returns the current particle system
  89474. */
  89475. removeVelocityGradient(gradient: number): IParticleSystem;
  89476. /**
  89477. * Gets the current list of limit velocity gradients.
  89478. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89479. * @returns the list of limit velocity gradients
  89480. */
  89481. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89482. /**
  89483. * Adds a new limit velocity gradient
  89484. * @param gradient defines the gradient to use (between 0 and 1)
  89485. * @param factor defines the limit velocity to affect to the specified gradient
  89486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89487. * @returns the current particle system
  89488. */
  89489. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89490. /**
  89491. * Remove a specific limit velocity gradient
  89492. * @param gradient defines the gradient to remove
  89493. * @returns the current particle system
  89494. */
  89495. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89496. /**
  89497. * Adds a new drag gradient
  89498. * @param gradient defines the gradient to use (between 0 and 1)
  89499. * @param factor defines the drag to affect to the specified gradient
  89500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89501. * @returns the current particle system
  89502. */
  89503. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89504. /**
  89505. * Remove a specific drag gradient
  89506. * @param gradient defines the gradient to remove
  89507. * @returns the current particle system
  89508. */
  89509. removeDragGradient(gradient: number): IParticleSystem;
  89510. /**
  89511. * Gets the current list of drag gradients.
  89512. * You must use addDragGradient and removeDragGradient to udpate this list
  89513. * @returns the list of drag gradients
  89514. */
  89515. getDragGradients(): Nullable<Array<FactorGradient>>;
  89516. /**
  89517. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89518. * @param gradient defines the gradient to use (between 0 and 1)
  89519. * @param factor defines the emit rate to affect to the specified gradient
  89520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89521. * @returns the current particle system
  89522. */
  89523. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89524. /**
  89525. * Remove a specific emit rate gradient
  89526. * @param gradient defines the gradient to remove
  89527. * @returns the current particle system
  89528. */
  89529. removeEmitRateGradient(gradient: number): IParticleSystem;
  89530. /**
  89531. * Gets the current list of emit rate gradients.
  89532. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89533. * @returns the list of emit rate gradients
  89534. */
  89535. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89536. /**
  89537. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89538. * @param gradient defines the gradient to use (between 0 and 1)
  89539. * @param factor defines the start size to affect to the specified gradient
  89540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89541. * @returns the current particle system
  89542. */
  89543. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89544. /**
  89545. * Remove a specific start size gradient
  89546. * @param gradient defines the gradient to remove
  89547. * @returns the current particle system
  89548. */
  89549. removeStartSizeGradient(gradient: number): IParticleSystem;
  89550. /**
  89551. * Gets the current list of start size gradients.
  89552. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89553. * @returns the list of start size gradients
  89554. */
  89555. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89556. /**
  89557. * Adds a new life time gradient
  89558. * @param gradient defines the gradient to use (between 0 and 1)
  89559. * @param factor defines the life time factor to affect to the specified gradient
  89560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89561. * @returns the current particle system
  89562. */
  89563. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89564. /**
  89565. * Remove a specific life time gradient
  89566. * @param gradient defines the gradient to remove
  89567. * @returns the current particle system
  89568. */
  89569. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89570. /**
  89571. * Gets the current list of life time gradients.
  89572. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89573. * @returns the list of life time gradients
  89574. */
  89575. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89576. /**
  89577. * Gets the current list of color gradients.
  89578. * You must use addColorGradient and removeColorGradient to udpate this list
  89579. * @returns the list of color gradients
  89580. */
  89581. getColorGradients(): Nullable<Array<ColorGradient>>;
  89582. /**
  89583. * Adds a new ramp gradient used to remap particle colors
  89584. * @param gradient defines the gradient to use (between 0 and 1)
  89585. * @param color defines the color to affect to the specified gradient
  89586. * @returns the current particle system
  89587. */
  89588. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89589. /**
  89590. * Gets the current list of ramp gradients.
  89591. * You must use addRampGradient and removeRampGradient to udpate this list
  89592. * @returns the list of ramp gradients
  89593. */
  89594. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89595. /** Gets or sets a boolean indicating that ramp gradients must be used
  89596. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89597. */
  89598. useRampGradients: boolean;
  89599. /**
  89600. * Adds a new color remap gradient
  89601. * @param gradient defines the gradient to use (between 0 and 1)
  89602. * @param min defines the color remap minimal range
  89603. * @param max defines the color remap maximal range
  89604. * @returns the current particle system
  89605. */
  89606. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89607. /**
  89608. * Gets the current list of color remap gradients.
  89609. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89610. * @returns the list of color remap gradients
  89611. */
  89612. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89613. /**
  89614. * Adds a new alpha remap gradient
  89615. * @param gradient defines the gradient to use (between 0 and 1)
  89616. * @param min defines the alpha remap minimal range
  89617. * @param max defines the alpha remap maximal range
  89618. * @returns the current particle system
  89619. */
  89620. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89621. /**
  89622. * Gets the current list of alpha remap gradients.
  89623. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89624. * @returns the list of alpha remap gradients
  89625. */
  89626. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89627. /**
  89628. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89629. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89630. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89631. * @returns the emitter
  89632. */
  89633. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89634. /**
  89635. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89636. * @param radius The radius of the hemisphere to emit from
  89637. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89638. * @returns the emitter
  89639. */
  89640. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89641. /**
  89642. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89643. * @param radius The radius of the sphere to emit from
  89644. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89645. * @returns the emitter
  89646. */
  89647. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89648. /**
  89649. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89650. * @param radius The radius of the sphere to emit from
  89651. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89652. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89653. * @returns the emitter
  89654. */
  89655. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89656. /**
  89657. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89658. * @param radius The radius of the emission cylinder
  89659. * @param height The height of the emission cylinder
  89660. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89661. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89662. * @returns the emitter
  89663. */
  89664. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89665. /**
  89666. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89667. * @param radius The radius of the cylinder to emit from
  89668. * @param height The height of the emission cylinder
  89669. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89670. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89671. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89672. * @returns the emitter
  89673. */
  89674. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89675. /**
  89676. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89677. * @param radius The radius of the cone to emit from
  89678. * @param angle The base angle of the cone
  89679. * @returns the emitter
  89680. */
  89681. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89682. /**
  89683. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89684. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89685. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89686. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89687. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89688. * @returns the emitter
  89689. */
  89690. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89691. /**
  89692. * Get hosting scene
  89693. * @returns the scene
  89694. */
  89695. getScene(): Scene;
  89696. }
  89697. }
  89698. declare module BABYLON {
  89699. /**
  89700. * Creates an instance based on a source mesh.
  89701. */
  89702. export class InstancedMesh extends AbstractMesh {
  89703. private _sourceMesh;
  89704. private _currentLOD;
  89705. /** @hidden */
  89706. _indexInSourceMeshInstanceArray: number;
  89707. constructor(name: string, source: Mesh);
  89708. /**
  89709. * Returns the string "InstancedMesh".
  89710. */
  89711. getClassName(): string;
  89712. /** Gets the list of lights affecting that mesh */
  89713. get lightSources(): Light[];
  89714. _resyncLightSources(): void;
  89715. _resyncLightSource(light: Light): void;
  89716. _removeLightSource(light: Light, dispose: boolean): void;
  89717. /**
  89718. * If the source mesh receives shadows
  89719. */
  89720. get receiveShadows(): boolean;
  89721. /**
  89722. * The material of the source mesh
  89723. */
  89724. get material(): Nullable<Material>;
  89725. /**
  89726. * Visibility of the source mesh
  89727. */
  89728. get visibility(): number;
  89729. /**
  89730. * Skeleton of the source mesh
  89731. */
  89732. get skeleton(): Nullable<Skeleton>;
  89733. /**
  89734. * Rendering ground id of the source mesh
  89735. */
  89736. get renderingGroupId(): number;
  89737. set renderingGroupId(value: number);
  89738. /**
  89739. * Returns the total number of vertices (integer).
  89740. */
  89741. getTotalVertices(): number;
  89742. /**
  89743. * Returns a positive integer : the total number of indices in this mesh geometry.
  89744. * @returns the numner of indices or zero if the mesh has no geometry.
  89745. */
  89746. getTotalIndices(): number;
  89747. /**
  89748. * The source mesh of the instance
  89749. */
  89750. get sourceMesh(): Mesh;
  89751. /**
  89752. * Is this node ready to be used/rendered
  89753. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89754. * @return {boolean} is it ready
  89755. */
  89756. isReady(completeCheck?: boolean): boolean;
  89757. /**
  89758. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89759. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89760. * @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.
  89761. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89762. */
  89763. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89764. /**
  89765. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89766. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89767. * The `data` are either a numeric array either a Float32Array.
  89768. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89769. * 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).
  89770. * Note that a new underlying VertexBuffer object is created each call.
  89771. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89772. *
  89773. * Possible `kind` values :
  89774. * - VertexBuffer.PositionKind
  89775. * - VertexBuffer.UVKind
  89776. * - VertexBuffer.UV2Kind
  89777. * - VertexBuffer.UV3Kind
  89778. * - VertexBuffer.UV4Kind
  89779. * - VertexBuffer.UV5Kind
  89780. * - VertexBuffer.UV6Kind
  89781. * - VertexBuffer.ColorKind
  89782. * - VertexBuffer.MatricesIndicesKind
  89783. * - VertexBuffer.MatricesIndicesExtraKind
  89784. * - VertexBuffer.MatricesWeightsKind
  89785. * - VertexBuffer.MatricesWeightsExtraKind
  89786. *
  89787. * Returns the Mesh.
  89788. */
  89789. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89790. /**
  89791. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89792. * If the mesh has no geometry, it is simply returned as it is.
  89793. * The `data` are either a numeric array either a Float32Array.
  89794. * No new underlying VertexBuffer object is created.
  89795. * 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.
  89796. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89797. *
  89798. * Possible `kind` values :
  89799. * - VertexBuffer.PositionKind
  89800. * - VertexBuffer.UVKind
  89801. * - VertexBuffer.UV2Kind
  89802. * - VertexBuffer.UV3Kind
  89803. * - VertexBuffer.UV4Kind
  89804. * - VertexBuffer.UV5Kind
  89805. * - VertexBuffer.UV6Kind
  89806. * - VertexBuffer.ColorKind
  89807. * - VertexBuffer.MatricesIndicesKind
  89808. * - VertexBuffer.MatricesIndicesExtraKind
  89809. * - VertexBuffer.MatricesWeightsKind
  89810. * - VertexBuffer.MatricesWeightsExtraKind
  89811. *
  89812. * Returns the Mesh.
  89813. */
  89814. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89815. /**
  89816. * Sets the mesh indices.
  89817. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89818. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89819. * This method creates a new index buffer each call.
  89820. * Returns the Mesh.
  89821. */
  89822. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89823. /**
  89824. * Boolean : True if the mesh owns the requested kind of data.
  89825. */
  89826. isVerticesDataPresent(kind: string): boolean;
  89827. /**
  89828. * Returns an array of indices (IndicesArray).
  89829. */
  89830. getIndices(): Nullable<IndicesArray>;
  89831. get _positions(): Nullable<Vector3[]>;
  89832. /**
  89833. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89834. * This means the mesh underlying bounding box and sphere are recomputed.
  89835. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89836. * @returns the current mesh
  89837. */
  89838. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89839. /** @hidden */
  89840. _preActivate(): InstancedMesh;
  89841. /** @hidden */
  89842. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89843. /** @hidden */
  89844. _postActivate(): void;
  89845. getWorldMatrix(): Matrix;
  89846. get isAnInstance(): boolean;
  89847. /**
  89848. * Returns the current associated LOD AbstractMesh.
  89849. */
  89850. getLOD(camera: Camera): AbstractMesh;
  89851. /** @hidden */
  89852. _syncSubMeshes(): InstancedMesh;
  89853. /** @hidden */
  89854. _generatePointsArray(): boolean;
  89855. /**
  89856. * Creates a new InstancedMesh from the current mesh.
  89857. * - name (string) : the cloned mesh name
  89858. * - newParent (optional Node) : the optional Node to parent the clone to.
  89859. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89860. *
  89861. * Returns the clone.
  89862. */
  89863. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89864. /**
  89865. * Disposes the InstancedMesh.
  89866. * Returns nothing.
  89867. */
  89868. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89869. }
  89870. interface Mesh {
  89871. /**
  89872. * Register a custom buffer that will be instanced
  89873. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89874. * @param kind defines the buffer kind
  89875. * @param stride defines the stride in floats
  89876. */
  89877. registerInstancedBuffer(kind: string, stride: number): void;
  89878. /** @hidden */
  89879. _userInstancedBuffersStorage: {
  89880. data: {
  89881. [key: string]: Float32Array;
  89882. };
  89883. sizes: {
  89884. [key: string]: number;
  89885. };
  89886. vertexBuffers: {
  89887. [key: string]: Nullable<VertexBuffer>;
  89888. };
  89889. strides: {
  89890. [key: string]: number;
  89891. };
  89892. };
  89893. }
  89894. interface AbstractMesh {
  89895. /**
  89896. * Object used to store instanced buffers defined by user
  89897. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89898. */
  89899. instancedBuffers: {
  89900. [key: string]: any;
  89901. };
  89902. }
  89903. }
  89904. declare module BABYLON {
  89905. /**
  89906. * Defines the options associated with the creation of a shader material.
  89907. */
  89908. export interface IShaderMaterialOptions {
  89909. /**
  89910. * Does the material work in alpha blend mode
  89911. */
  89912. needAlphaBlending: boolean;
  89913. /**
  89914. * Does the material work in alpha test mode
  89915. */
  89916. needAlphaTesting: boolean;
  89917. /**
  89918. * The list of attribute names used in the shader
  89919. */
  89920. attributes: string[];
  89921. /**
  89922. * The list of unifrom names used in the shader
  89923. */
  89924. uniforms: string[];
  89925. /**
  89926. * The list of UBO names used in the shader
  89927. */
  89928. uniformBuffers: string[];
  89929. /**
  89930. * The list of sampler names used in the shader
  89931. */
  89932. samplers: string[];
  89933. /**
  89934. * The list of defines used in the shader
  89935. */
  89936. defines: string[];
  89937. }
  89938. /**
  89939. * 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.
  89940. *
  89941. * This returned material effects how the mesh will look based on the code in the shaders.
  89942. *
  89943. * @see http://doc.babylonjs.com/how_to/shader_material
  89944. */
  89945. export class ShaderMaterial extends Material {
  89946. private _shaderPath;
  89947. private _options;
  89948. private _textures;
  89949. private _textureArrays;
  89950. private _floats;
  89951. private _ints;
  89952. private _floatsArrays;
  89953. private _colors3;
  89954. private _colors3Arrays;
  89955. private _colors4;
  89956. private _colors4Arrays;
  89957. private _vectors2;
  89958. private _vectors3;
  89959. private _vectors4;
  89960. private _matrices;
  89961. private _matrixArrays;
  89962. private _matrices3x3;
  89963. private _matrices2x2;
  89964. private _vectors2Arrays;
  89965. private _vectors3Arrays;
  89966. private _vectors4Arrays;
  89967. private _cachedWorldViewMatrix;
  89968. private _cachedWorldViewProjectionMatrix;
  89969. private _renderId;
  89970. private _multiview;
  89971. /**
  89972. * Instantiate a new shader material.
  89973. * 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.
  89974. * This returned material effects how the mesh will look based on the code in the shaders.
  89975. * @see http://doc.babylonjs.com/how_to/shader_material
  89976. * @param name Define the name of the material in the scene
  89977. * @param scene Define the scene the material belongs to
  89978. * @param shaderPath Defines the route to the shader code in one of three ways:
  89979. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89980. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89981. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89982. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89983. * @param options Define the options used to create the shader
  89984. */
  89985. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89986. /**
  89987. * Gets the shader path used to define the shader code
  89988. * It can be modified to trigger a new compilation
  89989. */
  89990. get shaderPath(): any;
  89991. /**
  89992. * Sets the shader path used to define the shader code
  89993. * It can be modified to trigger a new compilation
  89994. */
  89995. set shaderPath(shaderPath: any);
  89996. /**
  89997. * Gets the options used to compile the shader.
  89998. * They can be modified to trigger a new compilation
  89999. */
  90000. get options(): IShaderMaterialOptions;
  90001. /**
  90002. * Gets the current class name of the material e.g. "ShaderMaterial"
  90003. * Mainly use in serialization.
  90004. * @returns the class name
  90005. */
  90006. getClassName(): string;
  90007. /**
  90008. * Specifies if the material will require alpha blending
  90009. * @returns a boolean specifying if alpha blending is needed
  90010. */
  90011. needAlphaBlending(): boolean;
  90012. /**
  90013. * Specifies if this material should be rendered in alpha test mode
  90014. * @returns a boolean specifying if an alpha test is needed.
  90015. */
  90016. needAlphaTesting(): boolean;
  90017. private _checkUniform;
  90018. /**
  90019. * Set a texture in the shader.
  90020. * @param name Define the name of the uniform samplers as defined in the shader
  90021. * @param texture Define the texture to bind to this sampler
  90022. * @return the material itself allowing "fluent" like uniform updates
  90023. */
  90024. setTexture(name: string, texture: Texture): ShaderMaterial;
  90025. /**
  90026. * Set a texture array in the shader.
  90027. * @param name Define the name of the uniform sampler array as defined in the shader
  90028. * @param textures Define the list of textures to bind to this sampler
  90029. * @return the material itself allowing "fluent" like uniform updates
  90030. */
  90031. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90032. /**
  90033. * Set a float in the shader.
  90034. * @param name Define the name of the uniform as defined in the shader
  90035. * @param value Define the value to give to the uniform
  90036. * @return the material itself allowing "fluent" like uniform updates
  90037. */
  90038. setFloat(name: string, value: number): ShaderMaterial;
  90039. /**
  90040. * Set a int in the shader.
  90041. * @param name Define the name of the uniform as defined in the shader
  90042. * @param value Define the value to give to the uniform
  90043. * @return the material itself allowing "fluent" like uniform updates
  90044. */
  90045. setInt(name: string, value: number): ShaderMaterial;
  90046. /**
  90047. * Set an array of floats in the shader.
  90048. * @param name Define the name of the uniform as defined in the shader
  90049. * @param value Define the value to give to the uniform
  90050. * @return the material itself allowing "fluent" like uniform updates
  90051. */
  90052. setFloats(name: string, value: number[]): ShaderMaterial;
  90053. /**
  90054. * Set a vec3 in the shader from a Color3.
  90055. * @param name Define the name of the uniform as defined in the shader
  90056. * @param value Define the value to give to the uniform
  90057. * @return the material itself allowing "fluent" like uniform updates
  90058. */
  90059. setColor3(name: string, value: Color3): ShaderMaterial;
  90060. /**
  90061. * Set a vec3 array in the shader from a Color3 array.
  90062. * @param name Define the name of the uniform as defined in the shader
  90063. * @param value Define the value to give to the uniform
  90064. * @return the material itself allowing "fluent" like uniform updates
  90065. */
  90066. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90067. /**
  90068. * Set a vec4 in the shader from a Color4.
  90069. * @param name Define the name of the uniform as defined in the shader
  90070. * @param value Define the value to give to the uniform
  90071. * @return the material itself allowing "fluent" like uniform updates
  90072. */
  90073. setColor4(name: string, value: Color4): ShaderMaterial;
  90074. /**
  90075. * Set a vec4 array in the shader from a Color4 array.
  90076. * @param name Define the name of the uniform as defined in the shader
  90077. * @param value Define the value to give to the uniform
  90078. * @return the material itself allowing "fluent" like uniform updates
  90079. */
  90080. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90081. /**
  90082. * Set a vec2 in the shader from a Vector2.
  90083. * @param name Define the name of the uniform as defined in the shader
  90084. * @param value Define the value to give to the uniform
  90085. * @return the material itself allowing "fluent" like uniform updates
  90086. */
  90087. setVector2(name: string, value: Vector2): ShaderMaterial;
  90088. /**
  90089. * Set a vec3 in the shader from a Vector3.
  90090. * @param name Define the name of the uniform as defined in the shader
  90091. * @param value Define the value to give to the uniform
  90092. * @return the material itself allowing "fluent" like uniform updates
  90093. */
  90094. setVector3(name: string, value: Vector3): ShaderMaterial;
  90095. /**
  90096. * Set a vec4 in the shader from a Vector4.
  90097. * @param name Define the name of the uniform as defined in the shader
  90098. * @param value Define the value to give to the uniform
  90099. * @return the material itself allowing "fluent" like uniform updates
  90100. */
  90101. setVector4(name: string, value: Vector4): ShaderMaterial;
  90102. /**
  90103. * Set a mat4 in the shader from a Matrix.
  90104. * @param name Define the name of the uniform as defined in the shader
  90105. * @param value Define the value to give to the uniform
  90106. * @return the material itself allowing "fluent" like uniform updates
  90107. */
  90108. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90109. /**
  90110. * Set a float32Array in the shader from a matrix array.
  90111. * @param name Define the name of the uniform as defined in the shader
  90112. * @param value Define the value to give to the uniform
  90113. * @return the material itself allowing "fluent" like uniform updates
  90114. */
  90115. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90116. /**
  90117. * Set a mat3 in the shader from a Float32Array.
  90118. * @param name Define the name of the uniform as defined in the shader
  90119. * @param value Define the value to give to the uniform
  90120. * @return the material itself allowing "fluent" like uniform updates
  90121. */
  90122. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90123. /**
  90124. * Set a mat2 in the shader from a Float32Array.
  90125. * @param name Define the name of the uniform as defined in the shader
  90126. * @param value Define the value to give to the uniform
  90127. * @return the material itself allowing "fluent" like uniform updates
  90128. */
  90129. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90130. /**
  90131. * Set a vec2 array in the shader from a number array.
  90132. * @param name Define the name of the uniform as defined in the shader
  90133. * @param value Define the value to give to the uniform
  90134. * @return the material itself allowing "fluent" like uniform updates
  90135. */
  90136. setArray2(name: string, value: number[]): ShaderMaterial;
  90137. /**
  90138. * Set a vec3 array in the shader from a number array.
  90139. * @param name Define the name of the uniform as defined in the shader
  90140. * @param value Define the value to give to the uniform
  90141. * @return the material itself allowing "fluent" like uniform updates
  90142. */
  90143. setArray3(name: string, value: number[]): ShaderMaterial;
  90144. /**
  90145. * Set a vec4 array in the shader from a number array.
  90146. * @param name Define the name of the uniform as defined in the shader
  90147. * @param value Define the value to give to the uniform
  90148. * @return the material itself allowing "fluent" like uniform updates
  90149. */
  90150. setArray4(name: string, value: number[]): ShaderMaterial;
  90151. private _checkCache;
  90152. /**
  90153. * Specifies that the submesh is ready to be used
  90154. * @param mesh defines the mesh to check
  90155. * @param subMesh defines which submesh to check
  90156. * @param useInstances specifies that instances should be used
  90157. * @returns a boolean indicating that the submesh is ready or not
  90158. */
  90159. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90160. /**
  90161. * Checks if the material is ready to render the requested mesh
  90162. * @param mesh Define the mesh to render
  90163. * @param useInstances Define whether or not the material is used with instances
  90164. * @returns true if ready, otherwise false
  90165. */
  90166. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90167. /**
  90168. * Binds the world matrix to the material
  90169. * @param world defines the world transformation matrix
  90170. */
  90171. bindOnlyWorldMatrix(world: Matrix): void;
  90172. /**
  90173. * Binds the material to the mesh
  90174. * @param world defines the world transformation matrix
  90175. * @param mesh defines the mesh to bind the material to
  90176. */
  90177. bind(world: Matrix, mesh?: Mesh): void;
  90178. /**
  90179. * Gets the active textures from the material
  90180. * @returns an array of textures
  90181. */
  90182. getActiveTextures(): BaseTexture[];
  90183. /**
  90184. * Specifies if the material uses a texture
  90185. * @param texture defines the texture to check against the material
  90186. * @returns a boolean specifying if the material uses the texture
  90187. */
  90188. hasTexture(texture: BaseTexture): boolean;
  90189. /**
  90190. * Makes a duplicate of the material, and gives it a new name
  90191. * @param name defines the new name for the duplicated material
  90192. * @returns the cloned material
  90193. */
  90194. clone(name: string): ShaderMaterial;
  90195. /**
  90196. * Disposes the material
  90197. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90198. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90199. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90200. */
  90201. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90202. /**
  90203. * Serializes this material in a JSON representation
  90204. * @returns the serialized material object
  90205. */
  90206. serialize(): any;
  90207. /**
  90208. * Creates a shader material from parsed shader material data
  90209. * @param source defines the JSON represnetation of the material
  90210. * @param scene defines the hosting scene
  90211. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90212. * @returns a new material
  90213. */
  90214. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90215. }
  90216. }
  90217. declare module BABYLON {
  90218. /** @hidden */
  90219. export var colorPixelShader: {
  90220. name: string;
  90221. shader: string;
  90222. };
  90223. }
  90224. declare module BABYLON {
  90225. /** @hidden */
  90226. export var colorVertexShader: {
  90227. name: string;
  90228. shader: string;
  90229. };
  90230. }
  90231. declare module BABYLON {
  90232. /**
  90233. * Line mesh
  90234. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90235. */
  90236. export class LinesMesh extends Mesh {
  90237. /**
  90238. * If vertex color should be applied to the mesh
  90239. */
  90240. readonly useVertexColor?: boolean | undefined;
  90241. /**
  90242. * If vertex alpha should be applied to the mesh
  90243. */
  90244. readonly useVertexAlpha?: boolean | undefined;
  90245. /**
  90246. * Color of the line (Default: White)
  90247. */
  90248. color: Color3;
  90249. /**
  90250. * Alpha of the line (Default: 1)
  90251. */
  90252. alpha: number;
  90253. /**
  90254. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90255. * This margin is expressed in world space coordinates, so its value may vary.
  90256. * Default value is 0.1
  90257. */
  90258. intersectionThreshold: number;
  90259. private _colorShader;
  90260. private color4;
  90261. /**
  90262. * Creates a new LinesMesh
  90263. * @param name defines the name
  90264. * @param scene defines the hosting scene
  90265. * @param parent defines the parent mesh if any
  90266. * @param source defines the optional source LinesMesh used to clone data from
  90267. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90268. * When false, achieved by calling a clone(), also passing False.
  90269. * This will make creation of children, recursive.
  90270. * @param useVertexColor defines if this LinesMesh supports vertex color
  90271. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90272. */
  90273. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90274. /**
  90275. * If vertex color should be applied to the mesh
  90276. */
  90277. useVertexColor?: boolean | undefined,
  90278. /**
  90279. * If vertex alpha should be applied to the mesh
  90280. */
  90281. useVertexAlpha?: boolean | undefined);
  90282. private _addClipPlaneDefine;
  90283. private _removeClipPlaneDefine;
  90284. isReady(): boolean;
  90285. /**
  90286. * Returns the string "LineMesh"
  90287. */
  90288. getClassName(): string;
  90289. /**
  90290. * @hidden
  90291. */
  90292. get material(): Material;
  90293. /**
  90294. * @hidden
  90295. */
  90296. set material(value: Material);
  90297. /**
  90298. * @hidden
  90299. */
  90300. get checkCollisions(): boolean;
  90301. /** @hidden */
  90302. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90303. /** @hidden */
  90304. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90305. /**
  90306. * Disposes of the line mesh
  90307. * @param doNotRecurse If children should be disposed
  90308. */
  90309. dispose(doNotRecurse?: boolean): void;
  90310. /**
  90311. * Returns a new LineMesh object cloned from the current one.
  90312. */
  90313. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90314. /**
  90315. * Creates a new InstancedLinesMesh object from the mesh model.
  90316. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90317. * @param name defines the name of the new instance
  90318. * @returns a new InstancedLinesMesh
  90319. */
  90320. createInstance(name: string): InstancedLinesMesh;
  90321. }
  90322. /**
  90323. * Creates an instance based on a source LinesMesh
  90324. */
  90325. export class InstancedLinesMesh extends InstancedMesh {
  90326. /**
  90327. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90328. * This margin is expressed in world space coordinates, so its value may vary.
  90329. * Initilized with the intersectionThreshold value of the source LinesMesh
  90330. */
  90331. intersectionThreshold: number;
  90332. constructor(name: string, source: LinesMesh);
  90333. /**
  90334. * Returns the string "InstancedLinesMesh".
  90335. */
  90336. getClassName(): string;
  90337. }
  90338. }
  90339. declare module BABYLON {
  90340. /** @hidden */
  90341. export var linePixelShader: {
  90342. name: string;
  90343. shader: string;
  90344. };
  90345. }
  90346. declare module BABYLON {
  90347. /** @hidden */
  90348. export var lineVertexShader: {
  90349. name: string;
  90350. shader: string;
  90351. };
  90352. }
  90353. declare module BABYLON {
  90354. interface AbstractMesh {
  90355. /**
  90356. * Gets the edgesRenderer associated with the mesh
  90357. */
  90358. edgesRenderer: Nullable<EdgesRenderer>;
  90359. }
  90360. interface LinesMesh {
  90361. /**
  90362. * Enables the edge rendering mode on the mesh.
  90363. * This mode makes the mesh edges visible
  90364. * @param epsilon defines the maximal distance between two angles to detect a face
  90365. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90366. * @returns the currentAbstractMesh
  90367. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90368. */
  90369. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90370. }
  90371. interface InstancedLinesMesh {
  90372. /**
  90373. * Enables the edge rendering mode on the mesh.
  90374. * This mode makes the mesh edges visible
  90375. * @param epsilon defines the maximal distance between two angles to detect a face
  90376. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90377. * @returns the current InstancedLinesMesh
  90378. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90379. */
  90380. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90381. }
  90382. /**
  90383. * Defines the minimum contract an Edges renderer should follow.
  90384. */
  90385. export interface IEdgesRenderer extends IDisposable {
  90386. /**
  90387. * Gets or sets a boolean indicating if the edgesRenderer is active
  90388. */
  90389. isEnabled: boolean;
  90390. /**
  90391. * Renders the edges of the attached mesh,
  90392. */
  90393. render(): void;
  90394. /**
  90395. * Checks wether or not the edges renderer is ready to render.
  90396. * @return true if ready, otherwise false.
  90397. */
  90398. isReady(): boolean;
  90399. }
  90400. /**
  90401. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90402. */
  90403. export class EdgesRenderer implements IEdgesRenderer {
  90404. /**
  90405. * Define the size of the edges with an orthographic camera
  90406. */
  90407. edgesWidthScalerForOrthographic: number;
  90408. /**
  90409. * Define the size of the edges with a perspective camera
  90410. */
  90411. edgesWidthScalerForPerspective: number;
  90412. protected _source: AbstractMesh;
  90413. protected _linesPositions: number[];
  90414. protected _linesNormals: number[];
  90415. protected _linesIndices: number[];
  90416. protected _epsilon: number;
  90417. protected _indicesCount: number;
  90418. protected _lineShader: ShaderMaterial;
  90419. protected _ib: DataBuffer;
  90420. protected _buffers: {
  90421. [key: string]: Nullable<VertexBuffer>;
  90422. };
  90423. protected _checkVerticesInsteadOfIndices: boolean;
  90424. private _meshRebuildObserver;
  90425. private _meshDisposeObserver;
  90426. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90427. isEnabled: boolean;
  90428. /**
  90429. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90430. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90431. * @param source Mesh used to create edges
  90432. * @param epsilon sum of angles in adjacency to check for edge
  90433. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90434. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90435. */
  90436. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90437. protected _prepareRessources(): void;
  90438. /** @hidden */
  90439. _rebuild(): void;
  90440. /**
  90441. * Releases the required resources for the edges renderer
  90442. */
  90443. dispose(): void;
  90444. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90445. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90446. /**
  90447. * Checks if the pair of p0 and p1 is en edge
  90448. * @param faceIndex
  90449. * @param edge
  90450. * @param faceNormals
  90451. * @param p0
  90452. * @param p1
  90453. * @private
  90454. */
  90455. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90456. /**
  90457. * push line into the position, normal and index buffer
  90458. * @protected
  90459. */
  90460. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90461. /**
  90462. * Generates lines edges from adjacencjes
  90463. * @private
  90464. */
  90465. _generateEdgesLines(): void;
  90466. /**
  90467. * Checks wether or not the edges renderer is ready to render.
  90468. * @return true if ready, otherwise false.
  90469. */
  90470. isReady(): boolean;
  90471. /**
  90472. * Renders the edges of the attached mesh,
  90473. */
  90474. render(): void;
  90475. }
  90476. /**
  90477. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90478. */
  90479. export class LineEdgesRenderer extends EdgesRenderer {
  90480. /**
  90481. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90482. * @param source LineMesh used to generate edges
  90483. * @param epsilon not important (specified angle for edge detection)
  90484. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90485. */
  90486. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90487. /**
  90488. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90489. */
  90490. _generateEdgesLines(): void;
  90491. }
  90492. }
  90493. declare module BABYLON {
  90494. /**
  90495. * This represents the object necessary to create a rendering group.
  90496. * This is exclusively used and created by the rendering manager.
  90497. * To modify the behavior, you use the available helpers in your scene or meshes.
  90498. * @hidden
  90499. */
  90500. export class RenderingGroup {
  90501. index: number;
  90502. private static _zeroVector;
  90503. private _scene;
  90504. private _opaqueSubMeshes;
  90505. private _transparentSubMeshes;
  90506. private _alphaTestSubMeshes;
  90507. private _depthOnlySubMeshes;
  90508. private _particleSystems;
  90509. private _spriteManagers;
  90510. private _opaqueSortCompareFn;
  90511. private _alphaTestSortCompareFn;
  90512. private _transparentSortCompareFn;
  90513. private _renderOpaque;
  90514. private _renderAlphaTest;
  90515. private _renderTransparent;
  90516. /** @hidden */
  90517. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90518. onBeforeTransparentRendering: () => void;
  90519. /**
  90520. * Set the opaque sort comparison function.
  90521. * If null the sub meshes will be render in the order they were created
  90522. */
  90523. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90524. /**
  90525. * Set the alpha test sort comparison function.
  90526. * If null the sub meshes will be render in the order they were created
  90527. */
  90528. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90529. /**
  90530. * Set the transparent sort comparison function.
  90531. * If null the sub meshes will be render in the order they were created
  90532. */
  90533. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90534. /**
  90535. * Creates a new rendering group.
  90536. * @param index The rendering group index
  90537. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90538. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90539. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90540. */
  90541. 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>);
  90542. /**
  90543. * Render all the sub meshes contained in the group.
  90544. * @param customRenderFunction Used to override the default render behaviour of the group.
  90545. * @returns true if rendered some submeshes.
  90546. */
  90547. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90548. /**
  90549. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90550. * @param subMeshes The submeshes to render
  90551. */
  90552. private renderOpaqueSorted;
  90553. /**
  90554. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90555. * @param subMeshes The submeshes to render
  90556. */
  90557. private renderAlphaTestSorted;
  90558. /**
  90559. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90560. * @param subMeshes The submeshes to render
  90561. */
  90562. private renderTransparentSorted;
  90563. /**
  90564. * Renders the submeshes in a specified order.
  90565. * @param subMeshes The submeshes to sort before render
  90566. * @param sortCompareFn The comparison function use to sort
  90567. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90568. * @param transparent Specifies to activate blending if true
  90569. */
  90570. private static renderSorted;
  90571. /**
  90572. * Renders the submeshes in the order they were dispatched (no sort applied).
  90573. * @param subMeshes The submeshes to render
  90574. */
  90575. private static renderUnsorted;
  90576. /**
  90577. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90578. * are rendered back to front if in the same alpha index.
  90579. *
  90580. * @param a The first submesh
  90581. * @param b The second submesh
  90582. * @returns The result of the comparison
  90583. */
  90584. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90585. /**
  90586. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90587. * are rendered back to front.
  90588. *
  90589. * @param a The first submesh
  90590. * @param b The second submesh
  90591. * @returns The result of the comparison
  90592. */
  90593. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90594. /**
  90595. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90596. * are rendered front to back (prevent overdraw).
  90597. *
  90598. * @param a The first submesh
  90599. * @param b The second submesh
  90600. * @returns The result of the comparison
  90601. */
  90602. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90603. /**
  90604. * Resets the different lists of submeshes to prepare a new frame.
  90605. */
  90606. prepare(): void;
  90607. dispose(): void;
  90608. /**
  90609. * Inserts the submesh in its correct queue depending on its material.
  90610. * @param subMesh The submesh to dispatch
  90611. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90612. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90613. */
  90614. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90615. dispatchSprites(spriteManager: ISpriteManager): void;
  90616. dispatchParticles(particleSystem: IParticleSystem): void;
  90617. private _renderParticles;
  90618. private _renderSprites;
  90619. }
  90620. }
  90621. declare module BABYLON {
  90622. /**
  90623. * Interface describing the different options available in the rendering manager
  90624. * regarding Auto Clear between groups.
  90625. */
  90626. export interface IRenderingManagerAutoClearSetup {
  90627. /**
  90628. * Defines whether or not autoclear is enable.
  90629. */
  90630. autoClear: boolean;
  90631. /**
  90632. * Defines whether or not to autoclear the depth buffer.
  90633. */
  90634. depth: boolean;
  90635. /**
  90636. * Defines whether or not to autoclear the stencil buffer.
  90637. */
  90638. stencil: boolean;
  90639. }
  90640. /**
  90641. * This class is used by the onRenderingGroupObservable
  90642. */
  90643. export class RenderingGroupInfo {
  90644. /**
  90645. * The Scene that being rendered
  90646. */
  90647. scene: Scene;
  90648. /**
  90649. * The camera currently used for the rendering pass
  90650. */
  90651. camera: Nullable<Camera>;
  90652. /**
  90653. * The ID of the renderingGroup being processed
  90654. */
  90655. renderingGroupId: number;
  90656. }
  90657. /**
  90658. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90659. * It is enable to manage the different groups as well as the different necessary sort functions.
  90660. * This should not be used directly aside of the few static configurations
  90661. */
  90662. export class RenderingManager {
  90663. /**
  90664. * The max id used for rendering groups (not included)
  90665. */
  90666. static MAX_RENDERINGGROUPS: number;
  90667. /**
  90668. * The min id used for rendering groups (included)
  90669. */
  90670. static MIN_RENDERINGGROUPS: number;
  90671. /**
  90672. * Used to globally prevent autoclearing scenes.
  90673. */
  90674. static AUTOCLEAR: boolean;
  90675. /**
  90676. * @hidden
  90677. */
  90678. _useSceneAutoClearSetup: boolean;
  90679. private _scene;
  90680. private _renderingGroups;
  90681. private _depthStencilBufferAlreadyCleaned;
  90682. private _autoClearDepthStencil;
  90683. private _customOpaqueSortCompareFn;
  90684. private _customAlphaTestSortCompareFn;
  90685. private _customTransparentSortCompareFn;
  90686. private _renderingGroupInfo;
  90687. /**
  90688. * Instantiates a new rendering group for a particular scene
  90689. * @param scene Defines the scene the groups belongs to
  90690. */
  90691. constructor(scene: Scene);
  90692. private _clearDepthStencilBuffer;
  90693. /**
  90694. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90695. * @hidden
  90696. */
  90697. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90698. /**
  90699. * Resets the different information of the group to prepare a new frame
  90700. * @hidden
  90701. */
  90702. reset(): void;
  90703. /**
  90704. * Dispose and release the group and its associated resources.
  90705. * @hidden
  90706. */
  90707. dispose(): void;
  90708. /**
  90709. * Clear the info related to rendering groups preventing retention points during dispose.
  90710. */
  90711. freeRenderingGroups(): void;
  90712. private _prepareRenderingGroup;
  90713. /**
  90714. * Add a sprite manager to the rendering manager in order to render it this frame.
  90715. * @param spriteManager Define the sprite manager to render
  90716. */
  90717. dispatchSprites(spriteManager: ISpriteManager): void;
  90718. /**
  90719. * Add a particle system to the rendering manager in order to render it this frame.
  90720. * @param particleSystem Define the particle system to render
  90721. */
  90722. dispatchParticles(particleSystem: IParticleSystem): void;
  90723. /**
  90724. * Add a submesh to the manager in order to render it this frame
  90725. * @param subMesh The submesh to dispatch
  90726. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90727. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90728. */
  90729. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90730. /**
  90731. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90732. * This allowed control for front to back rendering or reversly depending of the special needs.
  90733. *
  90734. * @param renderingGroupId The rendering group id corresponding to its index
  90735. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90736. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90737. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90738. */
  90739. 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;
  90740. /**
  90741. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90742. *
  90743. * @param renderingGroupId The rendering group id corresponding to its index
  90744. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90745. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90746. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90747. */
  90748. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90749. /**
  90750. * Gets the current auto clear configuration for one rendering group of the rendering
  90751. * manager.
  90752. * @param index the rendering group index to get the information for
  90753. * @returns The auto clear setup for the requested rendering group
  90754. */
  90755. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90756. }
  90757. }
  90758. declare module BABYLON {
  90759. /**
  90760. * This Helps creating a texture that will be created from a camera in your scene.
  90761. * It is basically a dynamic texture that could be used to create special effects for instance.
  90762. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  90763. */
  90764. export class RenderTargetTexture extends Texture {
  90765. isCube: boolean;
  90766. /**
  90767. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  90768. */
  90769. static readonly REFRESHRATE_RENDER_ONCE: number;
  90770. /**
  90771. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  90772. */
  90773. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  90774. /**
  90775. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  90776. * the central point of your effect and can save a lot of performances.
  90777. */
  90778. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  90779. /**
  90780. * Use this predicate to dynamically define the list of mesh you want to render.
  90781. * If set, the renderList property will be overwritten.
  90782. */
  90783. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  90784. private _renderList;
  90785. /**
  90786. * Use this list to define the list of mesh you want to render.
  90787. */
  90788. get renderList(): Nullable<Array<AbstractMesh>>;
  90789. set renderList(value: Nullable<Array<AbstractMesh>>);
  90790. private _hookArray;
  90791. /**
  90792. * Define if particles should be rendered in your texture.
  90793. */
  90794. renderParticles: boolean;
  90795. /**
  90796. * Define if sprites should be rendered in your texture.
  90797. */
  90798. renderSprites: boolean;
  90799. /**
  90800. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  90801. */
  90802. coordinatesMode: number;
  90803. /**
  90804. * Define the camera used to render the texture.
  90805. */
  90806. activeCamera: Nullable<Camera>;
  90807. /**
  90808. * Override the render function of the texture with your own one.
  90809. */
  90810. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  90811. /**
  90812. * Define if camera post processes should be use while rendering the texture.
  90813. */
  90814. useCameraPostProcesses: boolean;
  90815. /**
  90816. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  90817. */
  90818. ignoreCameraViewport: boolean;
  90819. private _postProcessManager;
  90820. private _postProcesses;
  90821. private _resizeObserver;
  90822. /**
  90823. * An event triggered when the texture is unbind.
  90824. */
  90825. onBeforeBindObservable: Observable<RenderTargetTexture>;
  90826. /**
  90827. * An event triggered when the texture is unbind.
  90828. */
  90829. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  90830. private _onAfterUnbindObserver;
  90831. /**
  90832. * Set a after unbind callback in the texture.
  90833. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  90834. */
  90835. set onAfterUnbind(callback: () => void);
  90836. /**
  90837. * An event triggered before rendering the texture
  90838. */
  90839. onBeforeRenderObservable: Observable<number>;
  90840. private _onBeforeRenderObserver;
  90841. /**
  90842. * Set a before render callback in the texture.
  90843. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  90844. */
  90845. set onBeforeRender(callback: (faceIndex: number) => void);
  90846. /**
  90847. * An event triggered after rendering the texture
  90848. */
  90849. onAfterRenderObservable: Observable<number>;
  90850. private _onAfterRenderObserver;
  90851. /**
  90852. * Set a after render callback in the texture.
  90853. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  90854. */
  90855. set onAfterRender(callback: (faceIndex: number) => void);
  90856. /**
  90857. * An event triggered after the texture clear
  90858. */
  90859. onClearObservable: Observable<Engine>;
  90860. private _onClearObserver;
  90861. /**
  90862. * Set a clear callback in the texture.
  90863. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  90864. */
  90865. set onClear(callback: (Engine: Engine) => void);
  90866. /**
  90867. * An event triggered when the texture is resized.
  90868. */
  90869. onResizeObservable: Observable<RenderTargetTexture>;
  90870. /**
  90871. * Define the clear color of the Render Target if it should be different from the scene.
  90872. */
  90873. clearColor: Color4;
  90874. protected _size: number | {
  90875. width: number;
  90876. height: number;
  90877. };
  90878. protected _initialSizeParameter: number | {
  90879. width: number;
  90880. height: number;
  90881. } | {
  90882. ratio: number;
  90883. };
  90884. protected _sizeRatio: Nullable<number>;
  90885. /** @hidden */
  90886. _generateMipMaps: boolean;
  90887. protected _renderingManager: RenderingManager;
  90888. /** @hidden */
  90889. _waitingRenderList: string[];
  90890. protected _doNotChangeAspectRatio: boolean;
  90891. protected _currentRefreshId: number;
  90892. protected _refreshRate: number;
  90893. protected _textureMatrix: Matrix;
  90894. protected _samples: number;
  90895. protected _renderTargetOptions: RenderTargetCreationOptions;
  90896. /**
  90897. * Gets render target creation options that were used.
  90898. */
  90899. get renderTargetOptions(): RenderTargetCreationOptions;
  90900. protected _engine: Engine;
  90901. protected _onRatioRescale(): void;
  90902. /**
  90903. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  90904. * It must define where the camera used to render the texture is set
  90905. */
  90906. boundingBoxPosition: Vector3;
  90907. private _boundingBoxSize;
  90908. /**
  90909. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  90910. * When defined, the cubemap will switch to local mode
  90911. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  90912. * @example https://www.babylonjs-playground.com/#RNASML
  90913. */
  90914. set boundingBoxSize(value: Vector3);
  90915. get boundingBoxSize(): Vector3;
  90916. /**
  90917. * In case the RTT has been created with a depth texture, get the associated
  90918. * depth texture.
  90919. * Otherwise, return null.
  90920. */
  90921. depthStencilTexture: Nullable<InternalTexture>;
  90922. /**
  90923. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  90924. * or used a shadow, depth texture...
  90925. * @param name The friendly name of the texture
  90926. * @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)
  90927. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  90928. * @param generateMipMaps True if mip maps need to be generated after render.
  90929. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  90930. * @param type The type of the buffer in the RTT (int, half float, float...)
  90931. * @param isCube True if a cube texture needs to be created
  90932. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  90933. * @param generateDepthBuffer True to generate a depth buffer
  90934. * @param generateStencilBuffer True to generate a stencil buffer
  90935. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  90936. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  90937. * @param delayAllocation if the texture allocation should be delayed (default: false)
  90938. */
  90939. constructor(name: string, size: number | {
  90940. width: number;
  90941. height: number;
  90942. } | {
  90943. ratio: number;
  90944. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  90945. /**
  90946. * Creates a depth stencil texture.
  90947. * This is only available in WebGL 2 or with the depth texture extension available.
  90948. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  90949. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  90950. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  90951. */
  90952. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  90953. private _processSizeParameter;
  90954. /**
  90955. * Define the number of samples to use in case of MSAA.
  90956. * It defaults to one meaning no MSAA has been enabled.
  90957. */
  90958. get samples(): number;
  90959. set samples(value: number);
  90960. /**
  90961. * Resets the refresh counter of the texture and start bak from scratch.
  90962. * Could be useful to regenerate the texture if it is setup to render only once.
  90963. */
  90964. resetRefreshCounter(): void;
  90965. /**
  90966. * Define the refresh rate of the texture or the rendering frequency.
  90967. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90968. */
  90969. get refreshRate(): number;
  90970. set refreshRate(value: number);
  90971. /**
  90972. * Adds a post process to the render target rendering passes.
  90973. * @param postProcess define the post process to add
  90974. */
  90975. addPostProcess(postProcess: PostProcess): void;
  90976. /**
  90977. * Clear all the post processes attached to the render target
  90978. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  90979. */
  90980. clearPostProcesses(dispose?: boolean): void;
  90981. /**
  90982. * Remove one of the post process from the list of attached post processes to the texture
  90983. * @param postProcess define the post process to remove from the list
  90984. */
  90985. removePostProcess(postProcess: PostProcess): void;
  90986. /** @hidden */
  90987. _shouldRender(): boolean;
  90988. /**
  90989. * Gets the actual render size of the texture.
  90990. * @returns the width of the render size
  90991. */
  90992. getRenderSize(): number;
  90993. /**
  90994. * Gets the actual render width of the texture.
  90995. * @returns the width of the render size
  90996. */
  90997. getRenderWidth(): number;
  90998. /**
  90999. * Gets the actual render height of the texture.
  91000. * @returns the height of the render size
  91001. */
  91002. getRenderHeight(): number;
  91003. /**
  91004. * Get if the texture can be rescaled or not.
  91005. */
  91006. get canRescale(): boolean;
  91007. /**
  91008. * Resize the texture using a ratio.
  91009. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91010. */
  91011. scale(ratio: number): void;
  91012. /**
  91013. * Get the texture reflection matrix used to rotate/transform the reflection.
  91014. * @returns the reflection matrix
  91015. */
  91016. getReflectionTextureMatrix(): Matrix;
  91017. /**
  91018. * Resize the texture to a new desired size.
  91019. * Be carrefull as it will recreate all the data in the new texture.
  91020. * @param size Define the new size. It can be:
  91021. * - a number for squared texture,
  91022. * - an object containing { width: number, height: number }
  91023. * - or an object containing a ratio { ratio: number }
  91024. */
  91025. resize(size: number | {
  91026. width: number;
  91027. height: number;
  91028. } | {
  91029. ratio: number;
  91030. }): void;
  91031. /**
  91032. * Renders all the objects from the render list into the texture.
  91033. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91034. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91035. */
  91036. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91037. private _bestReflectionRenderTargetDimension;
  91038. /**
  91039. * @hidden
  91040. * @param faceIndex face index to bind to if this is a cubetexture
  91041. */
  91042. _bindFrameBuffer(faceIndex?: number): void;
  91043. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91044. private renderToTarget;
  91045. /**
  91046. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91047. * This allowed control for front to back rendering or reversly depending of the special needs.
  91048. *
  91049. * @param renderingGroupId The rendering group id corresponding to its index
  91050. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91051. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91052. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91053. */
  91054. 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;
  91055. /**
  91056. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91057. *
  91058. * @param renderingGroupId The rendering group id corresponding to its index
  91059. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91060. */
  91061. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91062. /**
  91063. * Clones the texture.
  91064. * @returns the cloned texture
  91065. */
  91066. clone(): RenderTargetTexture;
  91067. /**
  91068. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91069. * @returns The JSON representation of the texture
  91070. */
  91071. serialize(): any;
  91072. /**
  91073. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91074. */
  91075. disposeFramebufferObjects(): void;
  91076. /**
  91077. * Dispose the texture and release its associated resources.
  91078. */
  91079. dispose(): void;
  91080. /** @hidden */
  91081. _rebuild(): void;
  91082. /**
  91083. * Clear the info related to rendering groups preventing retention point in material dispose.
  91084. */
  91085. freeRenderingGroups(): void;
  91086. /**
  91087. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91088. * @returns the view count
  91089. */
  91090. getViewCount(): number;
  91091. }
  91092. }
  91093. declare module BABYLON {
  91094. /**
  91095. * Options for compiling materials.
  91096. */
  91097. export interface IMaterialCompilationOptions {
  91098. /**
  91099. * Defines whether clip planes are enabled.
  91100. */
  91101. clipPlane: boolean;
  91102. /**
  91103. * Defines whether instances are enabled.
  91104. */
  91105. useInstances: boolean;
  91106. }
  91107. /**
  91108. * Base class for the main features of a material in Babylon.js
  91109. */
  91110. export class Material implements IAnimatable {
  91111. /**
  91112. * Returns the triangle fill mode
  91113. */
  91114. static readonly TriangleFillMode: number;
  91115. /**
  91116. * Returns the wireframe mode
  91117. */
  91118. static readonly WireFrameFillMode: number;
  91119. /**
  91120. * Returns the point fill mode
  91121. */
  91122. static readonly PointFillMode: number;
  91123. /**
  91124. * Returns the point list draw mode
  91125. */
  91126. static readonly PointListDrawMode: number;
  91127. /**
  91128. * Returns the line list draw mode
  91129. */
  91130. static readonly LineListDrawMode: number;
  91131. /**
  91132. * Returns the line loop draw mode
  91133. */
  91134. static readonly LineLoopDrawMode: number;
  91135. /**
  91136. * Returns the line strip draw mode
  91137. */
  91138. static readonly LineStripDrawMode: number;
  91139. /**
  91140. * Returns the triangle strip draw mode
  91141. */
  91142. static readonly TriangleStripDrawMode: number;
  91143. /**
  91144. * Returns the triangle fan draw mode
  91145. */
  91146. static readonly TriangleFanDrawMode: number;
  91147. /**
  91148. * Stores the clock-wise side orientation
  91149. */
  91150. static readonly ClockWiseSideOrientation: number;
  91151. /**
  91152. * Stores the counter clock-wise side orientation
  91153. */
  91154. static readonly CounterClockWiseSideOrientation: number;
  91155. /**
  91156. * The dirty texture flag value
  91157. */
  91158. static readonly TextureDirtyFlag: number;
  91159. /**
  91160. * The dirty light flag value
  91161. */
  91162. static readonly LightDirtyFlag: number;
  91163. /**
  91164. * The dirty fresnel flag value
  91165. */
  91166. static readonly FresnelDirtyFlag: number;
  91167. /**
  91168. * The dirty attribute flag value
  91169. */
  91170. static readonly AttributesDirtyFlag: number;
  91171. /**
  91172. * The dirty misc flag value
  91173. */
  91174. static readonly MiscDirtyFlag: number;
  91175. /**
  91176. * The all dirty flag value
  91177. */
  91178. static readonly AllDirtyFlag: number;
  91179. /**
  91180. * The ID of the material
  91181. */
  91182. id: string;
  91183. /**
  91184. * Gets or sets the unique id of the material
  91185. */
  91186. uniqueId: number;
  91187. /**
  91188. * The name of the material
  91189. */
  91190. name: string;
  91191. /**
  91192. * Gets or sets user defined metadata
  91193. */
  91194. metadata: any;
  91195. /**
  91196. * For internal use only. Please do not use.
  91197. */
  91198. reservedDataStore: any;
  91199. /**
  91200. * Specifies if the ready state should be checked on each call
  91201. */
  91202. checkReadyOnEveryCall: boolean;
  91203. /**
  91204. * Specifies if the ready state should be checked once
  91205. */
  91206. checkReadyOnlyOnce: boolean;
  91207. /**
  91208. * The state of the material
  91209. */
  91210. state: string;
  91211. /**
  91212. * The alpha value of the material
  91213. */
  91214. protected _alpha: number;
  91215. /**
  91216. * List of inspectable custom properties (used by the Inspector)
  91217. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91218. */
  91219. inspectableCustomProperties: IInspectable[];
  91220. /**
  91221. * Sets the alpha value of the material
  91222. */
  91223. set alpha(value: number);
  91224. /**
  91225. * Gets the alpha value of the material
  91226. */
  91227. get alpha(): number;
  91228. /**
  91229. * Specifies if back face culling is enabled
  91230. */
  91231. protected _backFaceCulling: boolean;
  91232. /**
  91233. * Sets the back-face culling state
  91234. */
  91235. set backFaceCulling(value: boolean);
  91236. /**
  91237. * Gets the back-face culling state
  91238. */
  91239. get backFaceCulling(): boolean;
  91240. /**
  91241. * Stores the value for side orientation
  91242. */
  91243. sideOrientation: number;
  91244. /**
  91245. * Callback triggered when the material is compiled
  91246. */
  91247. onCompiled: Nullable<(effect: Effect) => void>;
  91248. /**
  91249. * Callback triggered when an error occurs
  91250. */
  91251. onError: Nullable<(effect: Effect, errors: string) => void>;
  91252. /**
  91253. * Callback triggered to get the render target textures
  91254. */
  91255. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  91256. /**
  91257. * Gets a boolean indicating that current material needs to register RTT
  91258. */
  91259. get hasRenderTargetTextures(): boolean;
  91260. /**
  91261. * Specifies if the material should be serialized
  91262. */
  91263. doNotSerialize: boolean;
  91264. /**
  91265. * @hidden
  91266. */
  91267. _storeEffectOnSubMeshes: boolean;
  91268. /**
  91269. * Stores the animations for the material
  91270. */
  91271. animations: Nullable<Array<Animation>>;
  91272. /**
  91273. * An event triggered when the material is disposed
  91274. */
  91275. onDisposeObservable: Observable<Material>;
  91276. /**
  91277. * An observer which watches for dispose events
  91278. */
  91279. private _onDisposeObserver;
  91280. private _onUnBindObservable;
  91281. /**
  91282. * Called during a dispose event
  91283. */
  91284. set onDispose(callback: () => void);
  91285. private _onBindObservable;
  91286. /**
  91287. * An event triggered when the material is bound
  91288. */
  91289. get onBindObservable(): Observable<AbstractMesh>;
  91290. /**
  91291. * An observer which watches for bind events
  91292. */
  91293. private _onBindObserver;
  91294. /**
  91295. * Called during a bind event
  91296. */
  91297. set onBind(callback: (Mesh: AbstractMesh) => void);
  91298. /**
  91299. * An event triggered when the material is unbound
  91300. */
  91301. get onUnBindObservable(): Observable<Material>;
  91302. /**
  91303. * Stores the value of the alpha mode
  91304. */
  91305. private _alphaMode;
  91306. /**
  91307. * Sets the value of the alpha mode.
  91308. *
  91309. * | Value | Type | Description |
  91310. * | --- | --- | --- |
  91311. * | 0 | ALPHA_DISABLE | |
  91312. * | 1 | ALPHA_ADD | |
  91313. * | 2 | ALPHA_COMBINE | |
  91314. * | 3 | ALPHA_SUBTRACT | |
  91315. * | 4 | ALPHA_MULTIPLY | |
  91316. * | 5 | ALPHA_MAXIMIZED | |
  91317. * | 6 | ALPHA_ONEONE | |
  91318. * | 7 | ALPHA_PREMULTIPLIED | |
  91319. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  91320. * | 9 | ALPHA_INTERPOLATE | |
  91321. * | 10 | ALPHA_SCREENMODE | |
  91322. *
  91323. */
  91324. set alphaMode(value: number);
  91325. /**
  91326. * Gets the value of the alpha mode
  91327. */
  91328. get alphaMode(): number;
  91329. /**
  91330. * Stores the state of the need depth pre-pass value
  91331. */
  91332. private _needDepthPrePass;
  91333. /**
  91334. * Sets the need depth pre-pass value
  91335. */
  91336. set needDepthPrePass(value: boolean);
  91337. /**
  91338. * Gets the depth pre-pass value
  91339. */
  91340. get needDepthPrePass(): boolean;
  91341. /**
  91342. * Specifies if depth writing should be disabled
  91343. */
  91344. disableDepthWrite: boolean;
  91345. /**
  91346. * Specifies if depth writing should be forced
  91347. */
  91348. forceDepthWrite: boolean;
  91349. /**
  91350. * Specifies the depth function that should be used. 0 means the default engine function
  91351. */
  91352. depthFunction: number;
  91353. /**
  91354. * Specifies if there should be a separate pass for culling
  91355. */
  91356. separateCullingPass: boolean;
  91357. /**
  91358. * Stores the state specifing if fog should be enabled
  91359. */
  91360. private _fogEnabled;
  91361. /**
  91362. * Sets the state for enabling fog
  91363. */
  91364. set fogEnabled(value: boolean);
  91365. /**
  91366. * Gets the value of the fog enabled state
  91367. */
  91368. get fogEnabled(): boolean;
  91369. /**
  91370. * Stores the size of points
  91371. */
  91372. pointSize: number;
  91373. /**
  91374. * Stores the z offset value
  91375. */
  91376. zOffset: number;
  91377. /**
  91378. * Gets a value specifying if wireframe mode is enabled
  91379. */
  91380. get wireframe(): boolean;
  91381. /**
  91382. * Sets the state of wireframe mode
  91383. */
  91384. set wireframe(value: boolean);
  91385. /**
  91386. * Gets the value specifying if point clouds are enabled
  91387. */
  91388. get pointsCloud(): boolean;
  91389. /**
  91390. * Sets the state of point cloud mode
  91391. */
  91392. set pointsCloud(value: boolean);
  91393. /**
  91394. * Gets the material fill mode
  91395. */
  91396. get fillMode(): number;
  91397. /**
  91398. * Sets the material fill mode
  91399. */
  91400. set fillMode(value: number);
  91401. /**
  91402. * @hidden
  91403. * Stores the effects for the material
  91404. */
  91405. _effect: Nullable<Effect>;
  91406. /**
  91407. * @hidden
  91408. * Specifies if the material was previously ready
  91409. */
  91410. _wasPreviouslyReady: boolean;
  91411. /**
  91412. * Specifies if uniform buffers should be used
  91413. */
  91414. private _useUBO;
  91415. /**
  91416. * Stores a reference to the scene
  91417. */
  91418. private _scene;
  91419. /**
  91420. * Stores the fill mode state
  91421. */
  91422. private _fillMode;
  91423. /**
  91424. * Specifies if the depth write state should be cached
  91425. */
  91426. private _cachedDepthWriteState;
  91427. /**
  91428. * Specifies if the depth function state should be cached
  91429. */
  91430. private _cachedDepthFunctionState;
  91431. /**
  91432. * Stores the uniform buffer
  91433. */
  91434. protected _uniformBuffer: UniformBuffer;
  91435. /** @hidden */
  91436. _indexInSceneMaterialArray: number;
  91437. /** @hidden */
  91438. meshMap: Nullable<{
  91439. [id: string]: AbstractMesh | undefined;
  91440. }>;
  91441. /**
  91442. * Creates a material instance
  91443. * @param name defines the name of the material
  91444. * @param scene defines the scene to reference
  91445. * @param doNotAdd specifies if the material should be added to the scene
  91446. */
  91447. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  91448. /**
  91449. * Returns a string representation of the current material
  91450. * @param fullDetails defines a boolean indicating which levels of logging is desired
  91451. * @returns a string with material information
  91452. */
  91453. toString(fullDetails?: boolean): string;
  91454. /**
  91455. * Gets the class name of the material
  91456. * @returns a string with the class name of the material
  91457. */
  91458. getClassName(): string;
  91459. /**
  91460. * Specifies if updates for the material been locked
  91461. */
  91462. get isFrozen(): boolean;
  91463. /**
  91464. * Locks updates for the material
  91465. */
  91466. freeze(): void;
  91467. /**
  91468. * Unlocks updates for the material
  91469. */
  91470. unfreeze(): void;
  91471. /**
  91472. * Specifies if the material is ready to be used
  91473. * @param mesh defines the mesh to check
  91474. * @param useInstances specifies if instances should be used
  91475. * @returns a boolean indicating if the material is ready to be used
  91476. */
  91477. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91478. /**
  91479. * Specifies that the submesh is ready to be used
  91480. * @param mesh defines the mesh to check
  91481. * @param subMesh defines which submesh to check
  91482. * @param useInstances specifies that instances should be used
  91483. * @returns a boolean indicating that the submesh is ready or not
  91484. */
  91485. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91486. /**
  91487. * Returns the material effect
  91488. * @returns the effect associated with the material
  91489. */
  91490. getEffect(): Nullable<Effect>;
  91491. /**
  91492. * Returns the current scene
  91493. * @returns a Scene
  91494. */
  91495. getScene(): Scene;
  91496. /**
  91497. * Specifies if the material will require alpha blending
  91498. * @returns a boolean specifying if alpha blending is needed
  91499. */
  91500. needAlphaBlending(): boolean;
  91501. /**
  91502. * Specifies if the mesh will require alpha blending
  91503. * @param mesh defines the mesh to check
  91504. * @returns a boolean specifying if alpha blending is needed for the mesh
  91505. */
  91506. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  91507. /**
  91508. * Specifies if this material should be rendered in alpha test mode
  91509. * @returns a boolean specifying if an alpha test is needed.
  91510. */
  91511. needAlphaTesting(): boolean;
  91512. /**
  91513. * Gets the texture used for the alpha test
  91514. * @returns the texture to use for alpha testing
  91515. */
  91516. getAlphaTestTexture(): Nullable<BaseTexture>;
  91517. /**
  91518. * Marks the material to indicate that it needs to be re-calculated
  91519. */
  91520. markDirty(): void;
  91521. /** @hidden */
  91522. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  91523. /**
  91524. * Binds the material to the mesh
  91525. * @param world defines the world transformation matrix
  91526. * @param mesh defines the mesh to bind the material to
  91527. */
  91528. bind(world: Matrix, mesh?: Mesh): void;
  91529. /**
  91530. * Binds the submesh to the material
  91531. * @param world defines the world transformation matrix
  91532. * @param mesh defines the mesh containing the submesh
  91533. * @param subMesh defines the submesh to bind the material to
  91534. */
  91535. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91536. /**
  91537. * Binds the world matrix to the material
  91538. * @param world defines the world transformation matrix
  91539. */
  91540. bindOnlyWorldMatrix(world: Matrix): void;
  91541. /**
  91542. * Binds the scene's uniform buffer to the effect.
  91543. * @param effect defines the effect to bind to the scene uniform buffer
  91544. * @param sceneUbo defines the uniform buffer storing scene data
  91545. */
  91546. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  91547. /**
  91548. * Binds the view matrix to the effect
  91549. * @param effect defines the effect to bind the view matrix to
  91550. */
  91551. bindView(effect: Effect): void;
  91552. /**
  91553. * Binds the view projection matrix to the effect
  91554. * @param effect defines the effect to bind the view projection matrix to
  91555. */
  91556. bindViewProjection(effect: Effect): void;
  91557. /**
  91558. * Specifies if material alpha testing should be turned on for the mesh
  91559. * @param mesh defines the mesh to check
  91560. */
  91561. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  91562. /**
  91563. * Processes to execute after binding the material to a mesh
  91564. * @param mesh defines the rendered mesh
  91565. */
  91566. protected _afterBind(mesh?: Mesh): void;
  91567. /**
  91568. * Unbinds the material from the mesh
  91569. */
  91570. unbind(): void;
  91571. /**
  91572. * Gets the active textures from the material
  91573. * @returns an array of textures
  91574. */
  91575. getActiveTextures(): BaseTexture[];
  91576. /**
  91577. * Specifies if the material uses a texture
  91578. * @param texture defines the texture to check against the material
  91579. * @returns a boolean specifying if the material uses the texture
  91580. */
  91581. hasTexture(texture: BaseTexture): boolean;
  91582. /**
  91583. * Makes a duplicate of the material, and gives it a new name
  91584. * @param name defines the new name for the duplicated material
  91585. * @returns the cloned material
  91586. */
  91587. clone(name: string): Nullable<Material>;
  91588. /**
  91589. * Gets the meshes bound to the material
  91590. * @returns an array of meshes bound to the material
  91591. */
  91592. getBindedMeshes(): AbstractMesh[];
  91593. /**
  91594. * Force shader compilation
  91595. * @param mesh defines the mesh associated with this material
  91596. * @param onCompiled defines a function to execute once the material is compiled
  91597. * @param options defines the options to configure the compilation
  91598. * @param onError defines a function to execute if the material fails compiling
  91599. */
  91600. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  91601. /**
  91602. * Force shader compilation
  91603. * @param mesh defines the mesh that will use this material
  91604. * @param options defines additional options for compiling the shaders
  91605. * @returns a promise that resolves when the compilation completes
  91606. */
  91607. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  91608. private static readonly _AllDirtyCallBack;
  91609. private static readonly _ImageProcessingDirtyCallBack;
  91610. private static readonly _TextureDirtyCallBack;
  91611. private static readonly _FresnelDirtyCallBack;
  91612. private static readonly _MiscDirtyCallBack;
  91613. private static readonly _LightsDirtyCallBack;
  91614. private static readonly _AttributeDirtyCallBack;
  91615. private static _FresnelAndMiscDirtyCallBack;
  91616. private static _TextureAndMiscDirtyCallBack;
  91617. private static readonly _DirtyCallbackArray;
  91618. private static readonly _RunDirtyCallBacks;
  91619. /**
  91620. * Marks a define in the material to indicate that it needs to be re-computed
  91621. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  91622. */
  91623. markAsDirty(flag: number): void;
  91624. /**
  91625. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  91626. * @param func defines a function which checks material defines against the submeshes
  91627. */
  91628. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  91629. /**
  91630. * Indicates that we need to re-calculated for all submeshes
  91631. */
  91632. protected _markAllSubMeshesAsAllDirty(): void;
  91633. /**
  91634. * Indicates that image processing needs to be re-calculated for all submeshes
  91635. */
  91636. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  91637. /**
  91638. * Indicates that textures need to be re-calculated for all submeshes
  91639. */
  91640. protected _markAllSubMeshesAsTexturesDirty(): void;
  91641. /**
  91642. * Indicates that fresnel needs to be re-calculated for all submeshes
  91643. */
  91644. protected _markAllSubMeshesAsFresnelDirty(): void;
  91645. /**
  91646. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  91647. */
  91648. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  91649. /**
  91650. * Indicates that lights need to be re-calculated for all submeshes
  91651. */
  91652. protected _markAllSubMeshesAsLightsDirty(): void;
  91653. /**
  91654. * Indicates that attributes need to be re-calculated for all submeshes
  91655. */
  91656. protected _markAllSubMeshesAsAttributesDirty(): void;
  91657. /**
  91658. * Indicates that misc needs to be re-calculated for all submeshes
  91659. */
  91660. protected _markAllSubMeshesAsMiscDirty(): void;
  91661. /**
  91662. * Indicates that textures and misc need to be re-calculated for all submeshes
  91663. */
  91664. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  91665. /**
  91666. * Disposes the material
  91667. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91668. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91669. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91670. */
  91671. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91672. /** @hidden */
  91673. private releaseVertexArrayObject;
  91674. /**
  91675. * Serializes this material
  91676. * @returns the serialized material object
  91677. */
  91678. serialize(): any;
  91679. /**
  91680. * Creates a material from parsed material data
  91681. * @param parsedMaterial defines parsed material data
  91682. * @param scene defines the hosting scene
  91683. * @param rootUrl defines the root URL to use to load textures
  91684. * @returns a new material
  91685. */
  91686. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  91687. }
  91688. }
  91689. declare module BABYLON {
  91690. /**
  91691. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91692. * separate meshes. This can be use to improve performances.
  91693. * @see http://doc.babylonjs.com/how_to/multi_materials
  91694. */
  91695. export class MultiMaterial extends Material {
  91696. private _subMaterials;
  91697. /**
  91698. * Gets or Sets the list of Materials used within the multi material.
  91699. * They need to be ordered according to the submeshes order in the associated mesh
  91700. */
  91701. get subMaterials(): Nullable<Material>[];
  91702. set subMaterials(value: Nullable<Material>[]);
  91703. /**
  91704. * Function used to align with Node.getChildren()
  91705. * @returns the list of Materials used within the multi material
  91706. */
  91707. getChildren(): Nullable<Material>[];
  91708. /**
  91709. * Instantiates a new Multi Material
  91710. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91711. * separate meshes. This can be use to improve performances.
  91712. * @see http://doc.babylonjs.com/how_to/multi_materials
  91713. * @param name Define the name in the scene
  91714. * @param scene Define the scene the material belongs to
  91715. */
  91716. constructor(name: string, scene: Scene);
  91717. private _hookArray;
  91718. /**
  91719. * Get one of the submaterial by its index in the submaterials array
  91720. * @param index The index to look the sub material at
  91721. * @returns The Material if the index has been defined
  91722. */
  91723. getSubMaterial(index: number): Nullable<Material>;
  91724. /**
  91725. * Get the list of active textures for the whole sub materials list.
  91726. * @returns All the textures that will be used during the rendering
  91727. */
  91728. getActiveTextures(): BaseTexture[];
  91729. /**
  91730. * Gets the current class name of the material e.g. "MultiMaterial"
  91731. * Mainly use in serialization.
  91732. * @returns the class name
  91733. */
  91734. getClassName(): string;
  91735. /**
  91736. * Checks if the material is ready to render the requested sub mesh
  91737. * @param mesh Define the mesh the submesh belongs to
  91738. * @param subMesh Define the sub mesh to look readyness for
  91739. * @param useInstances Define whether or not the material is used with instances
  91740. * @returns true if ready, otherwise false
  91741. */
  91742. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91743. /**
  91744. * Clones the current material and its related sub materials
  91745. * @param name Define the name of the newly cloned material
  91746. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  91747. * @returns the cloned material
  91748. */
  91749. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  91750. /**
  91751. * Serializes the materials into a JSON representation.
  91752. * @returns the JSON representation
  91753. */
  91754. serialize(): any;
  91755. /**
  91756. * Dispose the material and release its associated resources
  91757. * @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)
  91758. * @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)
  91759. * @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)
  91760. */
  91761. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  91762. /**
  91763. * Creates a MultiMaterial from parsed MultiMaterial data.
  91764. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  91765. * @param scene defines the hosting scene
  91766. * @returns a new MultiMaterial
  91767. */
  91768. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  91769. }
  91770. }
  91771. declare module BABYLON {
  91772. /**
  91773. * Base class for submeshes
  91774. */
  91775. export class BaseSubMesh {
  91776. /** @hidden */
  91777. _materialDefines: Nullable<MaterialDefines>;
  91778. /** @hidden */
  91779. _materialEffect: Nullable<Effect>;
  91780. /**
  91781. * Gets material defines used by the effect associated to the sub mesh
  91782. */
  91783. get materialDefines(): Nullable<MaterialDefines>;
  91784. /**
  91785. * Sets material defines used by the effect associated to the sub mesh
  91786. */
  91787. set materialDefines(defines: Nullable<MaterialDefines>);
  91788. /**
  91789. * Gets associated effect
  91790. */
  91791. get effect(): Nullable<Effect>;
  91792. /**
  91793. * Sets associated effect (effect used to render this submesh)
  91794. * @param effect defines the effect to associate with
  91795. * @param defines defines the set of defines used to compile this effect
  91796. */
  91797. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  91798. }
  91799. /**
  91800. * Defines a subdivision inside a mesh
  91801. */
  91802. export class SubMesh extends BaseSubMesh implements ICullable {
  91803. /** the material index to use */
  91804. materialIndex: number;
  91805. /** vertex index start */
  91806. verticesStart: number;
  91807. /** vertices count */
  91808. verticesCount: number;
  91809. /** index start */
  91810. indexStart: number;
  91811. /** indices count */
  91812. indexCount: number;
  91813. /** @hidden */
  91814. _linesIndexCount: number;
  91815. private _mesh;
  91816. private _renderingMesh;
  91817. private _boundingInfo;
  91818. private _linesIndexBuffer;
  91819. /** @hidden */
  91820. _lastColliderWorldVertices: Nullable<Vector3[]>;
  91821. /** @hidden */
  91822. _trianglePlanes: Plane[];
  91823. /** @hidden */
  91824. _lastColliderTransformMatrix: Nullable<Matrix>;
  91825. /** @hidden */
  91826. _renderId: number;
  91827. /** @hidden */
  91828. _alphaIndex: number;
  91829. /** @hidden */
  91830. _distanceToCamera: number;
  91831. /** @hidden */
  91832. _id: number;
  91833. private _currentMaterial;
  91834. /**
  91835. * Add a new submesh to a mesh
  91836. * @param materialIndex defines the material index to use
  91837. * @param verticesStart defines vertex index start
  91838. * @param verticesCount defines vertices count
  91839. * @param indexStart defines index start
  91840. * @param indexCount defines indices count
  91841. * @param mesh defines the parent mesh
  91842. * @param renderingMesh defines an optional rendering mesh
  91843. * @param createBoundingBox defines if bounding box should be created for this submesh
  91844. * @returns the new submesh
  91845. */
  91846. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  91847. /**
  91848. * Creates a new submesh
  91849. * @param materialIndex defines the material index to use
  91850. * @param verticesStart defines vertex index start
  91851. * @param verticesCount defines vertices count
  91852. * @param indexStart defines index start
  91853. * @param indexCount defines indices count
  91854. * @param mesh defines the parent mesh
  91855. * @param renderingMesh defines an optional rendering mesh
  91856. * @param createBoundingBox defines if bounding box should be created for this submesh
  91857. */
  91858. constructor(
  91859. /** the material index to use */
  91860. materialIndex: number,
  91861. /** vertex index start */
  91862. verticesStart: number,
  91863. /** vertices count */
  91864. verticesCount: number,
  91865. /** index start */
  91866. indexStart: number,
  91867. /** indices count */
  91868. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  91869. /**
  91870. * Returns true if this submesh covers the entire parent mesh
  91871. * @ignorenaming
  91872. */
  91873. get IsGlobal(): boolean;
  91874. /**
  91875. * Returns the submesh BoudingInfo object
  91876. * @returns current bounding info (or mesh's one if the submesh is global)
  91877. */
  91878. getBoundingInfo(): BoundingInfo;
  91879. /**
  91880. * Sets the submesh BoundingInfo
  91881. * @param boundingInfo defines the new bounding info to use
  91882. * @returns the SubMesh
  91883. */
  91884. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  91885. /**
  91886. * Returns the mesh of the current submesh
  91887. * @return the parent mesh
  91888. */
  91889. getMesh(): AbstractMesh;
  91890. /**
  91891. * Returns the rendering mesh of the submesh
  91892. * @returns the rendering mesh (could be different from parent mesh)
  91893. */
  91894. getRenderingMesh(): Mesh;
  91895. /**
  91896. * Returns the submesh material
  91897. * @returns null or the current material
  91898. */
  91899. getMaterial(): Nullable<Material>;
  91900. /**
  91901. * Sets a new updated BoundingInfo object to the submesh
  91902. * @param data defines an optional position array to use to determine the bounding info
  91903. * @returns the SubMesh
  91904. */
  91905. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  91906. /** @hidden */
  91907. _checkCollision(collider: Collider): boolean;
  91908. /**
  91909. * Updates the submesh BoundingInfo
  91910. * @param world defines the world matrix to use to update the bounding info
  91911. * @returns the submesh
  91912. */
  91913. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  91914. /**
  91915. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  91916. * @param frustumPlanes defines the frustum planes
  91917. * @returns true if the submesh is intersecting with the frustum
  91918. */
  91919. isInFrustum(frustumPlanes: Plane[]): boolean;
  91920. /**
  91921. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  91922. * @param frustumPlanes defines the frustum planes
  91923. * @returns true if the submesh is inside the frustum
  91924. */
  91925. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91926. /**
  91927. * Renders the submesh
  91928. * @param enableAlphaMode defines if alpha needs to be used
  91929. * @returns the submesh
  91930. */
  91931. render(enableAlphaMode: boolean): SubMesh;
  91932. /**
  91933. * @hidden
  91934. */
  91935. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  91936. /**
  91937. * Checks if the submesh intersects with a ray
  91938. * @param ray defines the ray to test
  91939. * @returns true is the passed ray intersects the submesh bounding box
  91940. */
  91941. canIntersects(ray: Ray): boolean;
  91942. /**
  91943. * Intersects current submesh with a ray
  91944. * @param ray defines the ray to test
  91945. * @param positions defines mesh's positions array
  91946. * @param indices defines mesh's indices array
  91947. * @param fastCheck defines if only bounding info should be used
  91948. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91949. * @returns intersection info or null if no intersection
  91950. */
  91951. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  91952. /** @hidden */
  91953. private _intersectLines;
  91954. /** @hidden */
  91955. private _intersectUnIndexedLines;
  91956. /** @hidden */
  91957. private _intersectTriangles;
  91958. /** @hidden */
  91959. private _intersectUnIndexedTriangles;
  91960. /** @hidden */
  91961. _rebuild(): void;
  91962. /**
  91963. * Creates a new submesh from the passed mesh
  91964. * @param newMesh defines the new hosting mesh
  91965. * @param newRenderingMesh defines an optional rendering mesh
  91966. * @returns the new submesh
  91967. */
  91968. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  91969. /**
  91970. * Release associated resources
  91971. */
  91972. dispose(): void;
  91973. /**
  91974. * Gets the class name
  91975. * @returns the string "SubMesh".
  91976. */
  91977. getClassName(): string;
  91978. /**
  91979. * Creates a new submesh from indices data
  91980. * @param materialIndex the index of the main mesh material
  91981. * @param startIndex the index where to start the copy in the mesh indices array
  91982. * @param indexCount the number of indices to copy then from the startIndex
  91983. * @param mesh the main mesh to create the submesh from
  91984. * @param renderingMesh the optional rendering mesh
  91985. * @returns a new submesh
  91986. */
  91987. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  91988. }
  91989. }
  91990. declare module BABYLON {
  91991. /**
  91992. * Class used to represent data loading progression
  91993. */
  91994. export class SceneLoaderFlags {
  91995. private static _ForceFullSceneLoadingForIncremental;
  91996. private static _ShowLoadingScreen;
  91997. private static _CleanBoneMatrixWeights;
  91998. private static _loggingLevel;
  91999. /**
  92000. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  92001. */
  92002. static get ForceFullSceneLoadingForIncremental(): boolean;
  92003. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92004. /**
  92005. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92006. */
  92007. static get ShowLoadingScreen(): boolean;
  92008. static set ShowLoadingScreen(value: boolean);
  92009. /**
  92010. * Defines the current logging level (while loading the scene)
  92011. * @ignorenaming
  92012. */
  92013. static get loggingLevel(): number;
  92014. static set loggingLevel(value: number);
  92015. /**
  92016. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92017. */
  92018. static get CleanBoneMatrixWeights(): boolean;
  92019. static set CleanBoneMatrixWeights(value: boolean);
  92020. }
  92021. }
  92022. declare module BABYLON {
  92023. /**
  92024. * Class used to store geometry data (vertex buffers + index buffer)
  92025. */
  92026. export class Geometry implements IGetSetVerticesData {
  92027. /**
  92028. * Gets or sets the ID of the geometry
  92029. */
  92030. id: string;
  92031. /**
  92032. * Gets or sets the unique ID of the geometry
  92033. */
  92034. uniqueId: number;
  92035. /**
  92036. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92037. */
  92038. delayLoadState: number;
  92039. /**
  92040. * Gets the file containing the data to load when running in delay load state
  92041. */
  92042. delayLoadingFile: Nullable<string>;
  92043. /**
  92044. * Callback called when the geometry is updated
  92045. */
  92046. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92047. private _scene;
  92048. private _engine;
  92049. private _meshes;
  92050. private _totalVertices;
  92051. /** @hidden */
  92052. _indices: IndicesArray;
  92053. /** @hidden */
  92054. _vertexBuffers: {
  92055. [key: string]: VertexBuffer;
  92056. };
  92057. private _isDisposed;
  92058. private _extend;
  92059. private _boundingBias;
  92060. /** @hidden */
  92061. _delayInfo: Array<string>;
  92062. private _indexBuffer;
  92063. private _indexBufferIsUpdatable;
  92064. /** @hidden */
  92065. _boundingInfo: Nullable<BoundingInfo>;
  92066. /** @hidden */
  92067. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92068. /** @hidden */
  92069. _softwareSkinningFrameId: number;
  92070. private _vertexArrayObjects;
  92071. private _updatable;
  92072. /** @hidden */
  92073. _positions: Nullable<Vector3[]>;
  92074. /**
  92075. * 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
  92076. */
  92077. get boundingBias(): Vector2;
  92078. /**
  92079. * 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
  92080. */
  92081. set boundingBias(value: Vector2);
  92082. /**
  92083. * Static function used to attach a new empty geometry to a mesh
  92084. * @param mesh defines the mesh to attach the geometry to
  92085. * @returns the new Geometry
  92086. */
  92087. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92088. /**
  92089. * Creates a new geometry
  92090. * @param id defines the unique ID
  92091. * @param scene defines the hosting scene
  92092. * @param vertexData defines the VertexData used to get geometry data
  92093. * @param updatable defines if geometry must be updatable (false by default)
  92094. * @param mesh defines the mesh that will be associated with the geometry
  92095. */
  92096. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92097. /**
  92098. * Gets the current extend of the geometry
  92099. */
  92100. get extend(): {
  92101. minimum: Vector3;
  92102. maximum: Vector3;
  92103. };
  92104. /**
  92105. * Gets the hosting scene
  92106. * @returns the hosting Scene
  92107. */
  92108. getScene(): Scene;
  92109. /**
  92110. * Gets the hosting engine
  92111. * @returns the hosting Engine
  92112. */
  92113. getEngine(): Engine;
  92114. /**
  92115. * Defines if the geometry is ready to use
  92116. * @returns true if the geometry is ready to be used
  92117. */
  92118. isReady(): boolean;
  92119. /**
  92120. * Gets a value indicating that the geometry should not be serialized
  92121. */
  92122. get doNotSerialize(): boolean;
  92123. /** @hidden */
  92124. _rebuild(): void;
  92125. /**
  92126. * Affects all geometry data in one call
  92127. * @param vertexData defines the geometry data
  92128. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92129. */
  92130. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92131. /**
  92132. * Set specific vertex data
  92133. * @param kind defines the data kind (Position, normal, etc...)
  92134. * @param data defines the vertex data to use
  92135. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92136. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92137. */
  92138. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  92139. /**
  92140. * Removes a specific vertex data
  92141. * @param kind defines the data kind (Position, normal, etc...)
  92142. */
  92143. removeVerticesData(kind: string): void;
  92144. /**
  92145. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  92146. * @param buffer defines the vertex buffer to use
  92147. * @param totalVertices defines the total number of vertices for position kind (could be null)
  92148. */
  92149. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  92150. /**
  92151. * Update a specific vertex buffer
  92152. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  92153. * It will do nothing if the buffer is not updatable
  92154. * @param kind defines the data kind (Position, normal, etc...)
  92155. * @param data defines the data to use
  92156. * @param offset defines the offset in the target buffer where to store the data
  92157. * @param useBytes set to true if the offset is in bytes
  92158. */
  92159. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  92160. /**
  92161. * Update a specific vertex buffer
  92162. * This function will create a new buffer if the current one is not updatable
  92163. * @param kind defines the data kind (Position, normal, etc...)
  92164. * @param data defines the data to use
  92165. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  92166. */
  92167. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  92168. private _updateBoundingInfo;
  92169. /** @hidden */
  92170. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  92171. /**
  92172. * Gets total number of vertices
  92173. * @returns the total number of vertices
  92174. */
  92175. getTotalVertices(): number;
  92176. /**
  92177. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92178. * @param kind defines the data kind (Position, normal, etc...)
  92179. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92180. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92181. * @returns a float array containing vertex data
  92182. */
  92183. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92184. /**
  92185. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  92186. * @param kind defines the data kind (Position, normal, etc...)
  92187. * @returns true if the vertex buffer with the specified kind is updatable
  92188. */
  92189. isVertexBufferUpdatable(kind: string): boolean;
  92190. /**
  92191. * Gets a specific vertex buffer
  92192. * @param kind defines the data kind (Position, normal, etc...)
  92193. * @returns a VertexBuffer
  92194. */
  92195. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92196. /**
  92197. * Returns all vertex buffers
  92198. * @return an object holding all vertex buffers indexed by kind
  92199. */
  92200. getVertexBuffers(): Nullable<{
  92201. [key: string]: VertexBuffer;
  92202. }>;
  92203. /**
  92204. * Gets a boolean indicating if specific vertex buffer is present
  92205. * @param kind defines the data kind (Position, normal, etc...)
  92206. * @returns true if data is present
  92207. */
  92208. isVerticesDataPresent(kind: string): boolean;
  92209. /**
  92210. * Gets a list of all attached data kinds (Position, normal, etc...)
  92211. * @returns a list of string containing all kinds
  92212. */
  92213. getVerticesDataKinds(): string[];
  92214. /**
  92215. * Update index buffer
  92216. * @param indices defines the indices to store in the index buffer
  92217. * @param offset defines the offset in the target buffer where to store the data
  92218. * @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)
  92219. */
  92220. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  92221. /**
  92222. * Creates a new index buffer
  92223. * @param indices defines the indices to store in the index buffer
  92224. * @param totalVertices defines the total number of vertices (could be null)
  92225. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92226. */
  92227. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  92228. /**
  92229. * Return the total number of indices
  92230. * @returns the total number of indices
  92231. */
  92232. getTotalIndices(): number;
  92233. /**
  92234. * Gets the index buffer array
  92235. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92236. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92237. * @returns the index buffer array
  92238. */
  92239. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92240. /**
  92241. * Gets the index buffer
  92242. * @return the index buffer
  92243. */
  92244. getIndexBuffer(): Nullable<DataBuffer>;
  92245. /** @hidden */
  92246. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  92247. /**
  92248. * Release the associated resources for a specific mesh
  92249. * @param mesh defines the source mesh
  92250. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  92251. */
  92252. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  92253. /**
  92254. * Apply current geometry to a given mesh
  92255. * @param mesh defines the mesh to apply geometry to
  92256. */
  92257. applyToMesh(mesh: Mesh): void;
  92258. private _updateExtend;
  92259. private _applyToMesh;
  92260. private notifyUpdate;
  92261. /**
  92262. * Load the geometry if it was flagged as delay loaded
  92263. * @param scene defines the hosting scene
  92264. * @param onLoaded defines a callback called when the geometry is loaded
  92265. */
  92266. load(scene: Scene, onLoaded?: () => void): void;
  92267. private _queueLoad;
  92268. /**
  92269. * Invert the geometry to move from a right handed system to a left handed one.
  92270. */
  92271. toLeftHanded(): void;
  92272. /** @hidden */
  92273. _resetPointsArrayCache(): void;
  92274. /** @hidden */
  92275. _generatePointsArray(): boolean;
  92276. /**
  92277. * Gets a value indicating if the geometry is disposed
  92278. * @returns true if the geometry was disposed
  92279. */
  92280. isDisposed(): boolean;
  92281. private _disposeVertexArrayObjects;
  92282. /**
  92283. * Free all associated resources
  92284. */
  92285. dispose(): void;
  92286. /**
  92287. * Clone the current geometry into a new geometry
  92288. * @param id defines the unique ID of the new geometry
  92289. * @returns a new geometry object
  92290. */
  92291. copy(id: string): Geometry;
  92292. /**
  92293. * Serialize the current geometry info (and not the vertices data) into a JSON object
  92294. * @return a JSON representation of the current geometry data (without the vertices data)
  92295. */
  92296. serialize(): any;
  92297. private toNumberArray;
  92298. /**
  92299. * Serialize all vertices data into a JSON oject
  92300. * @returns a JSON representation of the current geometry data
  92301. */
  92302. serializeVerticeData(): any;
  92303. /**
  92304. * Extracts a clone of a mesh geometry
  92305. * @param mesh defines the source mesh
  92306. * @param id defines the unique ID of the new geometry object
  92307. * @returns the new geometry object
  92308. */
  92309. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  92310. /**
  92311. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  92312. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92313. * Be aware Math.random() could cause collisions, but:
  92314. * "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"
  92315. * @returns a string containing a new GUID
  92316. */
  92317. static RandomId(): string;
  92318. /** @hidden */
  92319. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  92320. private static _CleanMatricesWeights;
  92321. /**
  92322. * Create a new geometry from persisted data (Using .babylon file format)
  92323. * @param parsedVertexData defines the persisted data
  92324. * @param scene defines the hosting scene
  92325. * @param rootUrl defines the root url to use to load assets (like delayed data)
  92326. * @returns the new geometry object
  92327. */
  92328. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  92329. }
  92330. }
  92331. declare module BABYLON {
  92332. /**
  92333. * Define an interface for all classes that will get and set the data on vertices
  92334. */
  92335. export interface IGetSetVerticesData {
  92336. /**
  92337. * Gets a boolean indicating if specific vertex data is present
  92338. * @param kind defines the vertex data kind to use
  92339. * @returns true is data kind is present
  92340. */
  92341. isVerticesDataPresent(kind: string): boolean;
  92342. /**
  92343. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92344. * @param kind defines the data kind (Position, normal, etc...)
  92345. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92346. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92347. * @returns a float array containing vertex data
  92348. */
  92349. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92350. /**
  92351. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92352. * @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.
  92353. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92354. * @returns the indices array or an empty array if the mesh has no geometry
  92355. */
  92356. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92357. /**
  92358. * Set specific vertex data
  92359. * @param kind defines the data kind (Position, normal, etc...)
  92360. * @param data defines the vertex data to use
  92361. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92362. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92363. */
  92364. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  92365. /**
  92366. * Update a specific associated vertex buffer
  92367. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92368. * - VertexBuffer.PositionKind
  92369. * - VertexBuffer.UVKind
  92370. * - VertexBuffer.UV2Kind
  92371. * - VertexBuffer.UV3Kind
  92372. * - VertexBuffer.UV4Kind
  92373. * - VertexBuffer.UV5Kind
  92374. * - VertexBuffer.UV6Kind
  92375. * - VertexBuffer.ColorKind
  92376. * - VertexBuffer.MatricesIndicesKind
  92377. * - VertexBuffer.MatricesIndicesExtraKind
  92378. * - VertexBuffer.MatricesWeightsKind
  92379. * - VertexBuffer.MatricesWeightsExtraKind
  92380. * @param data defines the data source
  92381. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92382. * @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)
  92383. */
  92384. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  92385. /**
  92386. * Creates a new index buffer
  92387. * @param indices defines the indices to store in the index buffer
  92388. * @param totalVertices defines the total number of vertices (could be null)
  92389. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92390. */
  92391. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  92392. }
  92393. /**
  92394. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  92395. */
  92396. export class VertexData {
  92397. /**
  92398. * Mesh side orientation : usually the external or front surface
  92399. */
  92400. static readonly FRONTSIDE: number;
  92401. /**
  92402. * Mesh side orientation : usually the internal or back surface
  92403. */
  92404. static readonly BACKSIDE: number;
  92405. /**
  92406. * Mesh side orientation : both internal and external or front and back surfaces
  92407. */
  92408. static readonly DOUBLESIDE: number;
  92409. /**
  92410. * Mesh side orientation : by default, `FRONTSIDE`
  92411. */
  92412. static readonly DEFAULTSIDE: number;
  92413. /**
  92414. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  92415. */
  92416. positions: Nullable<FloatArray>;
  92417. /**
  92418. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  92419. */
  92420. normals: Nullable<FloatArray>;
  92421. /**
  92422. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  92423. */
  92424. tangents: Nullable<FloatArray>;
  92425. /**
  92426. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92427. */
  92428. uvs: Nullable<FloatArray>;
  92429. /**
  92430. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92431. */
  92432. uvs2: Nullable<FloatArray>;
  92433. /**
  92434. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92435. */
  92436. uvs3: Nullable<FloatArray>;
  92437. /**
  92438. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92439. */
  92440. uvs4: Nullable<FloatArray>;
  92441. /**
  92442. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92443. */
  92444. uvs5: Nullable<FloatArray>;
  92445. /**
  92446. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92447. */
  92448. uvs6: Nullable<FloatArray>;
  92449. /**
  92450. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  92451. */
  92452. colors: Nullable<FloatArray>;
  92453. /**
  92454. * 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).
  92455. */
  92456. matricesIndices: Nullable<FloatArray>;
  92457. /**
  92458. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  92459. */
  92460. matricesWeights: Nullable<FloatArray>;
  92461. /**
  92462. * An array extending the number of possible indices
  92463. */
  92464. matricesIndicesExtra: Nullable<FloatArray>;
  92465. /**
  92466. * An array extending the number of possible weights when the number of indices is extended
  92467. */
  92468. matricesWeightsExtra: Nullable<FloatArray>;
  92469. /**
  92470. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  92471. */
  92472. indices: Nullable<IndicesArray>;
  92473. /**
  92474. * Uses the passed data array to set the set the values for the specified kind of data
  92475. * @param data a linear array of floating numbers
  92476. * @param kind the type of data that is being set, eg positions, colors etc
  92477. */
  92478. set(data: FloatArray, kind: string): void;
  92479. /**
  92480. * Associates the vertexData to the passed Mesh.
  92481. * Sets it as updatable or not (default `false`)
  92482. * @param mesh the mesh the vertexData is applied to
  92483. * @param updatable when used and having the value true allows new data to update the vertexData
  92484. * @returns the VertexData
  92485. */
  92486. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  92487. /**
  92488. * Associates the vertexData to the passed Geometry.
  92489. * Sets it as updatable or not (default `false`)
  92490. * @param geometry the geometry the vertexData is applied to
  92491. * @param updatable when used and having the value true allows new data to update the vertexData
  92492. * @returns VertexData
  92493. */
  92494. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  92495. /**
  92496. * Updates the associated mesh
  92497. * @param mesh the mesh to be updated
  92498. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92499. * @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
  92500. * @returns VertexData
  92501. */
  92502. updateMesh(mesh: Mesh): VertexData;
  92503. /**
  92504. * Updates the associated geometry
  92505. * @param geometry the geometry to be updated
  92506. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92507. * @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
  92508. * @returns VertexData.
  92509. */
  92510. updateGeometry(geometry: Geometry): VertexData;
  92511. private _applyTo;
  92512. private _update;
  92513. /**
  92514. * Transforms each position and each normal of the vertexData according to the passed Matrix
  92515. * @param matrix the transforming matrix
  92516. * @returns the VertexData
  92517. */
  92518. transform(matrix: Matrix): VertexData;
  92519. /**
  92520. * Merges the passed VertexData into the current one
  92521. * @param other the VertexData to be merged into the current one
  92522. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  92523. * @returns the modified VertexData
  92524. */
  92525. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  92526. private _mergeElement;
  92527. private _validate;
  92528. /**
  92529. * Serializes the VertexData
  92530. * @returns a serialized object
  92531. */
  92532. serialize(): any;
  92533. /**
  92534. * Extracts the vertexData from a mesh
  92535. * @param mesh the mesh from which to extract the VertexData
  92536. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  92537. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92538. * @returns the object VertexData associated to the passed mesh
  92539. */
  92540. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92541. /**
  92542. * Extracts the vertexData from the geometry
  92543. * @param geometry the geometry from which to extract the VertexData
  92544. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  92545. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92546. * @returns the object VertexData associated to the passed mesh
  92547. */
  92548. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92549. private static _ExtractFrom;
  92550. /**
  92551. * Creates the VertexData for a Ribbon
  92552. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  92553. * * pathArray array of paths, each of which an array of successive Vector3
  92554. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  92555. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  92556. * * 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
  92557. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92558. * * 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)
  92559. * * 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)
  92560. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  92561. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  92562. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  92563. * @returns the VertexData of the ribbon
  92564. */
  92565. static CreateRibbon(options: {
  92566. pathArray: Vector3[][];
  92567. closeArray?: boolean;
  92568. closePath?: boolean;
  92569. offset?: number;
  92570. sideOrientation?: number;
  92571. frontUVs?: Vector4;
  92572. backUVs?: Vector4;
  92573. invertUV?: boolean;
  92574. uvs?: Vector2[];
  92575. colors?: Color4[];
  92576. }): VertexData;
  92577. /**
  92578. * Creates the VertexData for a box
  92579. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92580. * * size sets the width, height and depth of the box to the value of size, optional default 1
  92581. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  92582. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  92583. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  92584. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92585. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92587. * * 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)
  92588. * * 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)
  92589. * @returns the VertexData of the box
  92590. */
  92591. static CreateBox(options: {
  92592. size?: number;
  92593. width?: number;
  92594. height?: number;
  92595. depth?: number;
  92596. faceUV?: Vector4[];
  92597. faceColors?: Color4[];
  92598. sideOrientation?: number;
  92599. frontUVs?: Vector4;
  92600. backUVs?: Vector4;
  92601. }): VertexData;
  92602. /**
  92603. * Creates the VertexData for a tiled box
  92604. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92605. * * faceTiles sets the pattern, tile size and number of tiles for a face
  92606. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92607. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92608. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92609. * @returns the VertexData of the box
  92610. */
  92611. static CreateTiledBox(options: {
  92612. pattern?: number;
  92613. width?: number;
  92614. height?: number;
  92615. depth?: number;
  92616. tileSize?: number;
  92617. tileWidth?: number;
  92618. tileHeight?: number;
  92619. alignHorizontal?: number;
  92620. alignVertical?: number;
  92621. faceUV?: Vector4[];
  92622. faceColors?: Color4[];
  92623. sideOrientation?: number;
  92624. }): VertexData;
  92625. /**
  92626. * Creates the VertexData for a tiled plane
  92627. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92628. * * pattern a limited pattern arrangement depending on the number
  92629. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  92630. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  92631. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  92632. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92633. * * 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)
  92634. * * 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)
  92635. * @returns the VertexData of the tiled plane
  92636. */
  92637. static CreateTiledPlane(options: {
  92638. pattern?: number;
  92639. tileSize?: number;
  92640. tileWidth?: number;
  92641. tileHeight?: number;
  92642. size?: number;
  92643. width?: number;
  92644. height?: number;
  92645. alignHorizontal?: number;
  92646. alignVertical?: number;
  92647. sideOrientation?: number;
  92648. frontUVs?: Vector4;
  92649. backUVs?: Vector4;
  92650. }): VertexData;
  92651. /**
  92652. * Creates the VertexData for an ellipsoid, defaults to a sphere
  92653. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92654. * * segments sets the number of horizontal strips optional, default 32
  92655. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  92656. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  92657. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  92658. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  92659. * * 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
  92660. * * 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
  92661. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92662. * * 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)
  92663. * * 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)
  92664. * @returns the VertexData of the ellipsoid
  92665. */
  92666. static CreateSphere(options: {
  92667. segments?: number;
  92668. diameter?: number;
  92669. diameterX?: number;
  92670. diameterY?: number;
  92671. diameterZ?: number;
  92672. arc?: number;
  92673. slice?: number;
  92674. sideOrientation?: number;
  92675. frontUVs?: Vector4;
  92676. backUVs?: Vector4;
  92677. }): VertexData;
  92678. /**
  92679. * Creates the VertexData for a cylinder, cone or prism
  92680. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92681. * * height sets the height (y direction) of the cylinder, optional, default 2
  92682. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  92683. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  92684. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  92685. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92686. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  92687. * * 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
  92688. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92689. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92690. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  92691. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  92692. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92693. * * 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)
  92694. * * 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)
  92695. * @returns the VertexData of the cylinder, cone or prism
  92696. */
  92697. static CreateCylinder(options: {
  92698. height?: number;
  92699. diameterTop?: number;
  92700. diameterBottom?: number;
  92701. diameter?: number;
  92702. tessellation?: number;
  92703. subdivisions?: number;
  92704. arc?: number;
  92705. faceColors?: Color4[];
  92706. faceUV?: Vector4[];
  92707. hasRings?: boolean;
  92708. enclose?: boolean;
  92709. sideOrientation?: number;
  92710. frontUVs?: Vector4;
  92711. backUVs?: Vector4;
  92712. }): VertexData;
  92713. /**
  92714. * Creates the VertexData for a torus
  92715. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92716. * * diameter the diameter of the torus, optional default 1
  92717. * * thickness the diameter of the tube forming the torus, optional default 0.5
  92718. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92720. * * 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)
  92721. * * 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)
  92722. * @returns the VertexData of the torus
  92723. */
  92724. static CreateTorus(options: {
  92725. diameter?: number;
  92726. thickness?: number;
  92727. tessellation?: number;
  92728. sideOrientation?: number;
  92729. frontUVs?: Vector4;
  92730. backUVs?: Vector4;
  92731. }): VertexData;
  92732. /**
  92733. * Creates the VertexData of the LineSystem
  92734. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  92735. * - lines an array of lines, each line being an array of successive Vector3
  92736. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  92737. * @returns the VertexData of the LineSystem
  92738. */
  92739. static CreateLineSystem(options: {
  92740. lines: Vector3[][];
  92741. colors?: Nullable<Color4[][]>;
  92742. }): VertexData;
  92743. /**
  92744. * Create the VertexData for a DashedLines
  92745. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  92746. * - points an array successive Vector3
  92747. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  92748. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  92749. * - dashNb the intended total number of dashes, optional, default 200
  92750. * @returns the VertexData for the DashedLines
  92751. */
  92752. static CreateDashedLines(options: {
  92753. points: Vector3[];
  92754. dashSize?: number;
  92755. gapSize?: number;
  92756. dashNb?: number;
  92757. }): VertexData;
  92758. /**
  92759. * Creates the VertexData for a Ground
  92760. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92761. * - width the width (x direction) of the ground, optional, default 1
  92762. * - height the height (z direction) of the ground, optional, default 1
  92763. * - subdivisions the number of subdivisions per side, optional, default 1
  92764. * @returns the VertexData of the Ground
  92765. */
  92766. static CreateGround(options: {
  92767. width?: number;
  92768. height?: number;
  92769. subdivisions?: number;
  92770. subdivisionsX?: number;
  92771. subdivisionsY?: number;
  92772. }): VertexData;
  92773. /**
  92774. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  92775. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92776. * * xmin the ground minimum X coordinate, optional, default -1
  92777. * * zmin the ground minimum Z coordinate, optional, default -1
  92778. * * xmax the ground maximum X coordinate, optional, default 1
  92779. * * zmax the ground maximum Z coordinate, optional, default 1
  92780. * * 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}
  92781. * * 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}
  92782. * @returns the VertexData of the TiledGround
  92783. */
  92784. static CreateTiledGround(options: {
  92785. xmin: number;
  92786. zmin: number;
  92787. xmax: number;
  92788. zmax: number;
  92789. subdivisions?: {
  92790. w: number;
  92791. h: number;
  92792. };
  92793. precision?: {
  92794. w: number;
  92795. h: number;
  92796. };
  92797. }): VertexData;
  92798. /**
  92799. * Creates the VertexData of the Ground designed from a heightmap
  92800. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  92801. * * width the width (x direction) of the ground
  92802. * * height the height (z direction) of the ground
  92803. * * subdivisions the number of subdivisions per side
  92804. * * minHeight the minimum altitude on the ground, optional, default 0
  92805. * * maxHeight the maximum altitude on the ground, optional default 1
  92806. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  92807. * * buffer the array holding the image color data
  92808. * * bufferWidth the width of image
  92809. * * bufferHeight the height of image
  92810. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  92811. * @returns the VertexData of the Ground designed from a heightmap
  92812. */
  92813. static CreateGroundFromHeightMap(options: {
  92814. width: number;
  92815. height: number;
  92816. subdivisions: number;
  92817. minHeight: number;
  92818. maxHeight: number;
  92819. colorFilter: Color3;
  92820. buffer: Uint8Array;
  92821. bufferWidth: number;
  92822. bufferHeight: number;
  92823. alphaFilter: number;
  92824. }): VertexData;
  92825. /**
  92826. * Creates the VertexData for a Plane
  92827. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  92828. * * size sets the width and height of the plane to the value of size, optional default 1
  92829. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  92830. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  92831. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92832. * * 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)
  92833. * * 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)
  92834. * @returns the VertexData of the box
  92835. */
  92836. static CreatePlane(options: {
  92837. size?: number;
  92838. width?: number;
  92839. height?: number;
  92840. sideOrientation?: number;
  92841. frontUVs?: Vector4;
  92842. backUVs?: Vector4;
  92843. }): VertexData;
  92844. /**
  92845. * Creates the VertexData of the Disc or regular Polygon
  92846. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  92847. * * radius the radius of the disc, optional default 0.5
  92848. * * tessellation the number of polygon sides, optional, default 64
  92849. * * 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
  92850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92851. * * 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)
  92852. * * 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)
  92853. * @returns the VertexData of the box
  92854. */
  92855. static CreateDisc(options: {
  92856. radius?: number;
  92857. tessellation?: number;
  92858. arc?: number;
  92859. sideOrientation?: number;
  92860. frontUVs?: Vector4;
  92861. backUVs?: Vector4;
  92862. }): VertexData;
  92863. /**
  92864. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  92865. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  92866. * @param polygon a mesh built from polygonTriangulation.build()
  92867. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92868. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92869. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92870. * @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)
  92871. * @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)
  92872. * @returns the VertexData of the Polygon
  92873. */
  92874. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  92875. /**
  92876. * Creates the VertexData of the IcoSphere
  92877. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  92878. * * radius the radius of the IcoSphere, optional default 1
  92879. * * radiusX allows stretching in the x direction, optional, default radius
  92880. * * radiusY allows stretching in the y direction, optional, default radius
  92881. * * radiusZ allows stretching in the z direction, optional, default radius
  92882. * * flat when true creates a flat shaded mesh, optional, default true
  92883. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92885. * * 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)
  92886. * * 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)
  92887. * @returns the VertexData of the IcoSphere
  92888. */
  92889. static CreateIcoSphere(options: {
  92890. radius?: number;
  92891. radiusX?: number;
  92892. radiusY?: number;
  92893. radiusZ?: number;
  92894. flat?: boolean;
  92895. subdivisions?: number;
  92896. sideOrientation?: number;
  92897. frontUVs?: Vector4;
  92898. backUVs?: Vector4;
  92899. }): VertexData;
  92900. /**
  92901. * Creates the VertexData for a Polyhedron
  92902. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  92903. * * type provided types are:
  92904. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  92905. * * 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)
  92906. * * size the size of the IcoSphere, optional default 1
  92907. * * sizeX allows stretching in the x direction, optional, default size
  92908. * * sizeY allows stretching in the y direction, optional, default size
  92909. * * sizeZ allows stretching in the z direction, optional, default size
  92910. * * 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
  92911. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92912. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92913. * * flat when true creates a flat shaded mesh, optional, default true
  92914. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92915. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92916. * * 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)
  92917. * * 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)
  92918. * @returns the VertexData of the Polyhedron
  92919. */
  92920. static CreatePolyhedron(options: {
  92921. type?: number;
  92922. size?: number;
  92923. sizeX?: number;
  92924. sizeY?: number;
  92925. sizeZ?: number;
  92926. custom?: any;
  92927. faceUV?: Vector4[];
  92928. faceColors?: Color4[];
  92929. flat?: boolean;
  92930. sideOrientation?: number;
  92931. frontUVs?: Vector4;
  92932. backUVs?: Vector4;
  92933. }): VertexData;
  92934. /**
  92935. * Creates the VertexData for a TorusKnot
  92936. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  92937. * * radius the radius of the torus knot, optional, default 2
  92938. * * tube the thickness of the tube, optional, default 0.5
  92939. * * radialSegments the number of sides on each tube segments, optional, default 32
  92940. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  92941. * * p the number of windings around the z axis, optional, default 2
  92942. * * q the number of windings around the x axis, optional, default 3
  92943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92944. * * 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)
  92945. * * 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)
  92946. * @returns the VertexData of the Torus Knot
  92947. */
  92948. static CreateTorusKnot(options: {
  92949. radius?: number;
  92950. tube?: number;
  92951. radialSegments?: number;
  92952. tubularSegments?: number;
  92953. p?: number;
  92954. q?: number;
  92955. sideOrientation?: number;
  92956. frontUVs?: Vector4;
  92957. backUVs?: Vector4;
  92958. }): VertexData;
  92959. /**
  92960. * Compute normals for given positions and indices
  92961. * @param positions an array of vertex positions, [...., x, y, z, ......]
  92962. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  92963. * @param normals an array of vertex normals, [...., x, y, z, ......]
  92964. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  92965. * * facetNormals : optional array of facet normals (vector3)
  92966. * * facetPositions : optional array of facet positions (vector3)
  92967. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  92968. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  92969. * * bInfo : optional bounding info, required for facetPartitioning computation
  92970. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  92971. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  92972. * * useRightHandedSystem: optional boolean to for right handed system computation
  92973. * * depthSort : optional boolean to enable the facet depth sort computation
  92974. * * distanceTo : optional Vector3 to compute the facet depth from this location
  92975. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  92976. */
  92977. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  92978. facetNormals?: any;
  92979. facetPositions?: any;
  92980. facetPartitioning?: any;
  92981. ratio?: number;
  92982. bInfo?: any;
  92983. bbSize?: Vector3;
  92984. subDiv?: any;
  92985. useRightHandedSystem?: boolean;
  92986. depthSort?: boolean;
  92987. distanceTo?: Vector3;
  92988. depthSortedFacets?: any;
  92989. }): void;
  92990. /** @hidden */
  92991. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  92992. /**
  92993. * Applies VertexData created from the imported parameters to the geometry
  92994. * @param parsedVertexData the parsed data from an imported file
  92995. * @param geometry the geometry to apply the VertexData to
  92996. */
  92997. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  92998. }
  92999. }
  93000. declare module BABYLON {
  93001. /**
  93002. * Defines a target to use with MorphTargetManager
  93003. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93004. */
  93005. export class MorphTarget implements IAnimatable {
  93006. /** defines the name of the target */
  93007. name: string;
  93008. /**
  93009. * Gets or sets the list of animations
  93010. */
  93011. animations: Animation[];
  93012. private _scene;
  93013. private _positions;
  93014. private _normals;
  93015. private _tangents;
  93016. private _uvs;
  93017. private _influence;
  93018. private _uniqueId;
  93019. /**
  93020. * Observable raised when the influence changes
  93021. */
  93022. onInfluenceChanged: Observable<boolean>;
  93023. /** @hidden */
  93024. _onDataLayoutChanged: Observable<void>;
  93025. /**
  93026. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93027. */
  93028. get influence(): number;
  93029. set influence(influence: number);
  93030. /**
  93031. * Gets or sets the id of the morph Target
  93032. */
  93033. id: string;
  93034. private _animationPropertiesOverride;
  93035. /**
  93036. * Gets or sets the animation properties override
  93037. */
  93038. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93039. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93040. /**
  93041. * Creates a new MorphTarget
  93042. * @param name defines the name of the target
  93043. * @param influence defines the influence to use
  93044. * @param scene defines the scene the morphtarget belongs to
  93045. */
  93046. constructor(
  93047. /** defines the name of the target */
  93048. name: string, influence?: number, scene?: Nullable<Scene>);
  93049. /**
  93050. * Gets the unique ID of this manager
  93051. */
  93052. get uniqueId(): number;
  93053. /**
  93054. * Gets a boolean defining if the target contains position data
  93055. */
  93056. get hasPositions(): boolean;
  93057. /**
  93058. * Gets a boolean defining if the target contains normal data
  93059. */
  93060. get hasNormals(): boolean;
  93061. /**
  93062. * Gets a boolean defining if the target contains tangent data
  93063. */
  93064. get hasTangents(): boolean;
  93065. /**
  93066. * Gets a boolean defining if the target contains texture coordinates data
  93067. */
  93068. get hasUVs(): boolean;
  93069. /**
  93070. * Affects position data to this target
  93071. * @param data defines the position data to use
  93072. */
  93073. setPositions(data: Nullable<FloatArray>): void;
  93074. /**
  93075. * Gets the position data stored in this target
  93076. * @returns a FloatArray containing the position data (or null if not present)
  93077. */
  93078. getPositions(): Nullable<FloatArray>;
  93079. /**
  93080. * Affects normal data to this target
  93081. * @param data defines the normal data to use
  93082. */
  93083. setNormals(data: Nullable<FloatArray>): void;
  93084. /**
  93085. * Gets the normal data stored in this target
  93086. * @returns a FloatArray containing the normal data (or null if not present)
  93087. */
  93088. getNormals(): Nullable<FloatArray>;
  93089. /**
  93090. * Affects tangent data to this target
  93091. * @param data defines the tangent data to use
  93092. */
  93093. setTangents(data: Nullable<FloatArray>): void;
  93094. /**
  93095. * Gets the tangent data stored in this target
  93096. * @returns a FloatArray containing the tangent data (or null if not present)
  93097. */
  93098. getTangents(): Nullable<FloatArray>;
  93099. /**
  93100. * Affects texture coordinates data to this target
  93101. * @param data defines the texture coordinates data to use
  93102. */
  93103. setUVs(data: Nullable<FloatArray>): void;
  93104. /**
  93105. * Gets the texture coordinates data stored in this target
  93106. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93107. */
  93108. getUVs(): Nullable<FloatArray>;
  93109. /**
  93110. * Clone the current target
  93111. * @returns a new MorphTarget
  93112. */
  93113. clone(): MorphTarget;
  93114. /**
  93115. * Serializes the current target into a Serialization object
  93116. * @returns the serialized object
  93117. */
  93118. serialize(): any;
  93119. /**
  93120. * Returns the string "MorphTarget"
  93121. * @returns "MorphTarget"
  93122. */
  93123. getClassName(): string;
  93124. /**
  93125. * Creates a new target from serialized data
  93126. * @param serializationObject defines the serialized data to use
  93127. * @returns a new MorphTarget
  93128. */
  93129. static Parse(serializationObject: any): MorphTarget;
  93130. /**
  93131. * Creates a MorphTarget from mesh data
  93132. * @param mesh defines the source mesh
  93133. * @param name defines the name to use for the new target
  93134. * @param influence defines the influence to attach to the target
  93135. * @returns a new MorphTarget
  93136. */
  93137. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93138. }
  93139. }
  93140. declare module BABYLON {
  93141. /**
  93142. * This class is used to deform meshes using morphing between different targets
  93143. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93144. */
  93145. export class MorphTargetManager {
  93146. private _targets;
  93147. private _targetInfluenceChangedObservers;
  93148. private _targetDataLayoutChangedObservers;
  93149. private _activeTargets;
  93150. private _scene;
  93151. private _influences;
  93152. private _supportsNormals;
  93153. private _supportsTangents;
  93154. private _supportsUVs;
  93155. private _vertexCount;
  93156. private _uniqueId;
  93157. private _tempInfluences;
  93158. /**
  93159. * Gets or sets a boolean indicating if normals must be morphed
  93160. */
  93161. enableNormalMorphing: boolean;
  93162. /**
  93163. * Gets or sets a boolean indicating if tangents must be morphed
  93164. */
  93165. enableTangentMorphing: boolean;
  93166. /**
  93167. * Gets or sets a boolean indicating if UV must be morphed
  93168. */
  93169. enableUVMorphing: boolean;
  93170. /**
  93171. * Creates a new MorphTargetManager
  93172. * @param scene defines the current scene
  93173. */
  93174. constructor(scene?: Nullable<Scene>);
  93175. /**
  93176. * Gets the unique ID of this manager
  93177. */
  93178. get uniqueId(): number;
  93179. /**
  93180. * Gets the number of vertices handled by this manager
  93181. */
  93182. get vertexCount(): number;
  93183. /**
  93184. * Gets a boolean indicating if this manager supports morphing of normals
  93185. */
  93186. get supportsNormals(): boolean;
  93187. /**
  93188. * Gets a boolean indicating if this manager supports morphing of tangents
  93189. */
  93190. get supportsTangents(): boolean;
  93191. /**
  93192. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  93193. */
  93194. get supportsUVs(): boolean;
  93195. /**
  93196. * Gets the number of targets stored in this manager
  93197. */
  93198. get numTargets(): number;
  93199. /**
  93200. * Gets the number of influencers (ie. the number of targets with influences > 0)
  93201. */
  93202. get numInfluencers(): number;
  93203. /**
  93204. * Gets the list of influences (one per target)
  93205. */
  93206. get influences(): Float32Array;
  93207. /**
  93208. * Gets the active target at specified index. An active target is a target with an influence > 0
  93209. * @param index defines the index to check
  93210. * @returns the requested target
  93211. */
  93212. getActiveTarget(index: number): MorphTarget;
  93213. /**
  93214. * Gets the target at specified index
  93215. * @param index defines the index to check
  93216. * @returns the requested target
  93217. */
  93218. getTarget(index: number): MorphTarget;
  93219. /**
  93220. * Add a new target to this manager
  93221. * @param target defines the target to add
  93222. */
  93223. addTarget(target: MorphTarget): void;
  93224. /**
  93225. * Removes a target from the manager
  93226. * @param target defines the target to remove
  93227. */
  93228. removeTarget(target: MorphTarget): void;
  93229. /**
  93230. * Clone the current manager
  93231. * @returns a new MorphTargetManager
  93232. */
  93233. clone(): MorphTargetManager;
  93234. /**
  93235. * Serializes the current manager into a Serialization object
  93236. * @returns the serialized object
  93237. */
  93238. serialize(): any;
  93239. private _syncActiveTargets;
  93240. /**
  93241. * Syncrhonize the targets with all the meshes using this morph target manager
  93242. */
  93243. synchronize(): void;
  93244. /**
  93245. * Creates a new MorphTargetManager from serialized data
  93246. * @param serializationObject defines the serialized data
  93247. * @param scene defines the hosting scene
  93248. * @returns the new MorphTargetManager
  93249. */
  93250. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  93251. }
  93252. }
  93253. declare module BABYLON {
  93254. /**
  93255. * Class used to represent a specific level of detail of a mesh
  93256. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93257. */
  93258. export class MeshLODLevel {
  93259. /** Defines the distance where this level should start being displayed */
  93260. distance: number;
  93261. /** Defines the mesh to use to render this level */
  93262. mesh: Nullable<Mesh>;
  93263. /**
  93264. * Creates a new LOD level
  93265. * @param distance defines the distance where this level should star being displayed
  93266. * @param mesh defines the mesh to use to render this level
  93267. */
  93268. constructor(
  93269. /** Defines the distance where this level should start being displayed */
  93270. distance: number,
  93271. /** Defines the mesh to use to render this level */
  93272. mesh: Nullable<Mesh>);
  93273. }
  93274. }
  93275. declare module BABYLON {
  93276. /**
  93277. * Mesh representing the gorund
  93278. */
  93279. export class GroundMesh extends Mesh {
  93280. /** If octree should be generated */
  93281. generateOctree: boolean;
  93282. private _heightQuads;
  93283. /** @hidden */
  93284. _subdivisionsX: number;
  93285. /** @hidden */
  93286. _subdivisionsY: number;
  93287. /** @hidden */
  93288. _width: number;
  93289. /** @hidden */
  93290. _height: number;
  93291. /** @hidden */
  93292. _minX: number;
  93293. /** @hidden */
  93294. _maxX: number;
  93295. /** @hidden */
  93296. _minZ: number;
  93297. /** @hidden */
  93298. _maxZ: number;
  93299. constructor(name: string, scene: Scene);
  93300. /**
  93301. * "GroundMesh"
  93302. * @returns "GroundMesh"
  93303. */
  93304. getClassName(): string;
  93305. /**
  93306. * The minimum of x and y subdivisions
  93307. */
  93308. get subdivisions(): number;
  93309. /**
  93310. * X subdivisions
  93311. */
  93312. get subdivisionsX(): number;
  93313. /**
  93314. * Y subdivisions
  93315. */
  93316. get subdivisionsY(): number;
  93317. /**
  93318. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  93319. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  93320. * @param chunksCount the number of subdivisions for x and y
  93321. * @param octreeBlocksSize (Default: 32)
  93322. */
  93323. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  93324. /**
  93325. * Returns a height (y) value in the Worl system :
  93326. * the ground altitude at the coordinates (x, z) expressed in the World system.
  93327. * @param x x coordinate
  93328. * @param z z coordinate
  93329. * @returns the ground y position if (x, z) are outside the ground surface.
  93330. */
  93331. getHeightAtCoordinates(x: number, z: number): number;
  93332. /**
  93333. * Returns a normalized vector (Vector3) orthogonal to the ground
  93334. * at the ground coordinates (x, z) expressed in the World system.
  93335. * @param x x coordinate
  93336. * @param z z coordinate
  93337. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  93338. */
  93339. getNormalAtCoordinates(x: number, z: number): Vector3;
  93340. /**
  93341. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  93342. * at the ground coordinates (x, z) expressed in the World system.
  93343. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  93344. * @param x x coordinate
  93345. * @param z z coordinate
  93346. * @param ref vector to store the result
  93347. * @returns the GroundMesh.
  93348. */
  93349. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  93350. /**
  93351. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  93352. * if the ground has been updated.
  93353. * This can be used in the render loop.
  93354. * @returns the GroundMesh.
  93355. */
  93356. updateCoordinateHeights(): GroundMesh;
  93357. private _getFacetAt;
  93358. private _initHeightQuads;
  93359. private _computeHeightQuads;
  93360. /**
  93361. * Serializes this ground mesh
  93362. * @param serializationObject object to write serialization to
  93363. */
  93364. serialize(serializationObject: any): void;
  93365. /**
  93366. * Parses a serialized ground mesh
  93367. * @param parsedMesh the serialized mesh
  93368. * @param scene the scene to create the ground mesh in
  93369. * @returns the created ground mesh
  93370. */
  93371. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  93372. }
  93373. }
  93374. declare module BABYLON {
  93375. /**
  93376. * Interface for Physics-Joint data
  93377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93378. */
  93379. export interface PhysicsJointData {
  93380. /**
  93381. * The main pivot of the joint
  93382. */
  93383. mainPivot?: Vector3;
  93384. /**
  93385. * The connected pivot of the joint
  93386. */
  93387. connectedPivot?: Vector3;
  93388. /**
  93389. * The main axis of the joint
  93390. */
  93391. mainAxis?: Vector3;
  93392. /**
  93393. * The connected axis of the joint
  93394. */
  93395. connectedAxis?: Vector3;
  93396. /**
  93397. * The collision of the joint
  93398. */
  93399. collision?: boolean;
  93400. /**
  93401. * Native Oimo/Cannon/Energy data
  93402. */
  93403. nativeParams?: any;
  93404. }
  93405. /**
  93406. * This is a holder class for the physics joint created by the physics plugin
  93407. * It holds a set of functions to control the underlying joint
  93408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93409. */
  93410. export class PhysicsJoint {
  93411. /**
  93412. * The type of the physics joint
  93413. */
  93414. type: number;
  93415. /**
  93416. * The data for the physics joint
  93417. */
  93418. jointData: PhysicsJointData;
  93419. private _physicsJoint;
  93420. protected _physicsPlugin: IPhysicsEnginePlugin;
  93421. /**
  93422. * Initializes the physics joint
  93423. * @param type The type of the physics joint
  93424. * @param jointData The data for the physics joint
  93425. */
  93426. constructor(
  93427. /**
  93428. * The type of the physics joint
  93429. */
  93430. type: number,
  93431. /**
  93432. * The data for the physics joint
  93433. */
  93434. jointData: PhysicsJointData);
  93435. /**
  93436. * Gets the physics joint
  93437. */
  93438. get physicsJoint(): any;
  93439. /**
  93440. * Sets the physics joint
  93441. */
  93442. set physicsJoint(newJoint: any);
  93443. /**
  93444. * Sets the physics plugin
  93445. */
  93446. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  93447. /**
  93448. * Execute a function that is physics-plugin specific.
  93449. * @param {Function} func the function that will be executed.
  93450. * It accepts two parameters: the physics world and the physics joint
  93451. */
  93452. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  93453. /**
  93454. * Distance-Joint type
  93455. */
  93456. static DistanceJoint: number;
  93457. /**
  93458. * Hinge-Joint type
  93459. */
  93460. static HingeJoint: number;
  93461. /**
  93462. * Ball-and-Socket joint type
  93463. */
  93464. static BallAndSocketJoint: number;
  93465. /**
  93466. * Wheel-Joint type
  93467. */
  93468. static WheelJoint: number;
  93469. /**
  93470. * Slider-Joint type
  93471. */
  93472. static SliderJoint: number;
  93473. /**
  93474. * Prismatic-Joint type
  93475. */
  93476. static PrismaticJoint: number;
  93477. /**
  93478. * Universal-Joint type
  93479. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  93480. */
  93481. static UniversalJoint: number;
  93482. /**
  93483. * Hinge-Joint 2 type
  93484. */
  93485. static Hinge2Joint: number;
  93486. /**
  93487. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  93488. */
  93489. static PointToPointJoint: number;
  93490. /**
  93491. * Spring-Joint type
  93492. */
  93493. static SpringJoint: number;
  93494. /**
  93495. * Lock-Joint type
  93496. */
  93497. static LockJoint: number;
  93498. }
  93499. /**
  93500. * A class representing a physics distance joint
  93501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93502. */
  93503. export class DistanceJoint extends PhysicsJoint {
  93504. /**
  93505. *
  93506. * @param jointData The data for the Distance-Joint
  93507. */
  93508. constructor(jointData: DistanceJointData);
  93509. /**
  93510. * Update the predefined distance.
  93511. * @param maxDistance The maximum preferred distance
  93512. * @param minDistance The minimum preferred distance
  93513. */
  93514. updateDistance(maxDistance: number, minDistance?: number): void;
  93515. }
  93516. /**
  93517. * Represents a Motor-Enabled Joint
  93518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93519. */
  93520. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  93521. /**
  93522. * Initializes the Motor-Enabled Joint
  93523. * @param type The type of the joint
  93524. * @param jointData The physica joint data for the joint
  93525. */
  93526. constructor(type: number, jointData: PhysicsJointData);
  93527. /**
  93528. * Set the motor values.
  93529. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93530. * @param force the force to apply
  93531. * @param maxForce max force for this motor.
  93532. */
  93533. setMotor(force?: number, maxForce?: number): void;
  93534. /**
  93535. * Set the motor's limits.
  93536. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93537. * @param upperLimit The upper limit of the motor
  93538. * @param lowerLimit The lower limit of the motor
  93539. */
  93540. setLimit(upperLimit: number, lowerLimit?: number): void;
  93541. }
  93542. /**
  93543. * This class represents a single physics Hinge-Joint
  93544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93545. */
  93546. export class HingeJoint extends MotorEnabledJoint {
  93547. /**
  93548. * Initializes the Hinge-Joint
  93549. * @param jointData The joint data for the Hinge-Joint
  93550. */
  93551. constructor(jointData: PhysicsJointData);
  93552. /**
  93553. * Set the motor values.
  93554. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93555. * @param {number} force the force to apply
  93556. * @param {number} maxForce max force for this motor.
  93557. */
  93558. setMotor(force?: number, maxForce?: number): void;
  93559. /**
  93560. * Set the motor's limits.
  93561. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93562. * @param upperLimit The upper limit of the motor
  93563. * @param lowerLimit The lower limit of the motor
  93564. */
  93565. setLimit(upperLimit: number, lowerLimit?: number): void;
  93566. }
  93567. /**
  93568. * This class represents a dual hinge physics joint (same as wheel joint)
  93569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93570. */
  93571. export class Hinge2Joint extends MotorEnabledJoint {
  93572. /**
  93573. * Initializes the Hinge2-Joint
  93574. * @param jointData The joint data for the Hinge2-Joint
  93575. */
  93576. constructor(jointData: PhysicsJointData);
  93577. /**
  93578. * Set the motor values.
  93579. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93580. * @param {number} targetSpeed the speed the motor is to reach
  93581. * @param {number} maxForce max force for this motor.
  93582. * @param {motorIndex} the motor's index, 0 or 1.
  93583. */
  93584. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  93585. /**
  93586. * Set the motor limits.
  93587. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93588. * @param {number} upperLimit the upper limit
  93589. * @param {number} lowerLimit lower limit
  93590. * @param {motorIndex} the motor's index, 0 or 1.
  93591. */
  93592. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93593. }
  93594. /**
  93595. * Interface for a motor enabled joint
  93596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93597. */
  93598. export interface IMotorEnabledJoint {
  93599. /**
  93600. * Physics joint
  93601. */
  93602. physicsJoint: any;
  93603. /**
  93604. * Sets the motor of the motor-enabled joint
  93605. * @param force The force of the motor
  93606. * @param maxForce The maximum force of the motor
  93607. * @param motorIndex The index of the motor
  93608. */
  93609. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  93610. /**
  93611. * Sets the limit of the motor
  93612. * @param upperLimit The upper limit of the motor
  93613. * @param lowerLimit The lower limit of the motor
  93614. * @param motorIndex The index of the motor
  93615. */
  93616. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93617. }
  93618. /**
  93619. * Joint data for a Distance-Joint
  93620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93621. */
  93622. export interface DistanceJointData extends PhysicsJointData {
  93623. /**
  93624. * Max distance the 2 joint objects can be apart
  93625. */
  93626. maxDistance: number;
  93627. }
  93628. /**
  93629. * Joint data from a spring joint
  93630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93631. */
  93632. export interface SpringJointData extends PhysicsJointData {
  93633. /**
  93634. * Length of the spring
  93635. */
  93636. length: number;
  93637. /**
  93638. * Stiffness of the spring
  93639. */
  93640. stiffness: number;
  93641. /**
  93642. * Damping of the spring
  93643. */
  93644. damping: number;
  93645. /** this callback will be called when applying the force to the impostors. */
  93646. forceApplicationCallback: () => void;
  93647. }
  93648. }
  93649. declare module BABYLON {
  93650. /**
  93651. * Holds the data for the raycast result
  93652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93653. */
  93654. export class PhysicsRaycastResult {
  93655. private _hasHit;
  93656. private _hitDistance;
  93657. private _hitNormalWorld;
  93658. private _hitPointWorld;
  93659. private _rayFromWorld;
  93660. private _rayToWorld;
  93661. /**
  93662. * Gets if there was a hit
  93663. */
  93664. get hasHit(): boolean;
  93665. /**
  93666. * Gets the distance from the hit
  93667. */
  93668. get hitDistance(): number;
  93669. /**
  93670. * Gets the hit normal/direction in the world
  93671. */
  93672. get hitNormalWorld(): Vector3;
  93673. /**
  93674. * Gets the hit point in the world
  93675. */
  93676. get hitPointWorld(): Vector3;
  93677. /**
  93678. * Gets the ray "start point" of the ray in the world
  93679. */
  93680. get rayFromWorld(): Vector3;
  93681. /**
  93682. * Gets the ray "end point" of the ray in the world
  93683. */
  93684. get rayToWorld(): Vector3;
  93685. /**
  93686. * Sets the hit data (normal & point in world space)
  93687. * @param hitNormalWorld defines the normal in world space
  93688. * @param hitPointWorld defines the point in world space
  93689. */
  93690. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  93691. /**
  93692. * Sets the distance from the start point to the hit point
  93693. * @param distance
  93694. */
  93695. setHitDistance(distance: number): void;
  93696. /**
  93697. * Calculates the distance manually
  93698. */
  93699. calculateHitDistance(): void;
  93700. /**
  93701. * Resets all the values to default
  93702. * @param from The from point on world space
  93703. * @param to The to point on world space
  93704. */
  93705. reset(from?: Vector3, to?: Vector3): void;
  93706. }
  93707. /**
  93708. * Interface for the size containing width and height
  93709. */
  93710. interface IXYZ {
  93711. /**
  93712. * X
  93713. */
  93714. x: number;
  93715. /**
  93716. * Y
  93717. */
  93718. y: number;
  93719. /**
  93720. * Z
  93721. */
  93722. z: number;
  93723. }
  93724. }
  93725. declare module BABYLON {
  93726. /**
  93727. * Interface used to describe a physics joint
  93728. */
  93729. export interface PhysicsImpostorJoint {
  93730. /** Defines the main impostor to which the joint is linked */
  93731. mainImpostor: PhysicsImpostor;
  93732. /** Defines the impostor that is connected to the main impostor using this joint */
  93733. connectedImpostor: PhysicsImpostor;
  93734. /** Defines the joint itself */
  93735. joint: PhysicsJoint;
  93736. }
  93737. /** @hidden */
  93738. export interface IPhysicsEnginePlugin {
  93739. world: any;
  93740. name: string;
  93741. setGravity(gravity: Vector3): void;
  93742. setTimeStep(timeStep: number): void;
  93743. getTimeStep(): number;
  93744. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  93745. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93746. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93747. generatePhysicsBody(impostor: PhysicsImpostor): void;
  93748. removePhysicsBody(impostor: PhysicsImpostor): void;
  93749. generateJoint(joint: PhysicsImpostorJoint): void;
  93750. removeJoint(joint: PhysicsImpostorJoint): void;
  93751. isSupported(): boolean;
  93752. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  93753. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  93754. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93755. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93756. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93757. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93758. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  93759. getBodyMass(impostor: PhysicsImpostor): number;
  93760. getBodyFriction(impostor: PhysicsImpostor): number;
  93761. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  93762. getBodyRestitution(impostor: PhysicsImpostor): number;
  93763. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  93764. getBodyPressure?(impostor: PhysicsImpostor): number;
  93765. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  93766. getBodyStiffness?(impostor: PhysicsImpostor): number;
  93767. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  93768. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  93769. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  93770. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  93771. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  93772. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93773. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93774. sleepBody(impostor: PhysicsImpostor): void;
  93775. wakeUpBody(impostor: PhysicsImpostor): void;
  93776. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93777. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  93778. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  93779. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93780. getRadius(impostor: PhysicsImpostor): number;
  93781. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  93782. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  93783. dispose(): void;
  93784. }
  93785. /**
  93786. * Interface used to define a physics engine
  93787. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  93788. */
  93789. export interface IPhysicsEngine {
  93790. /**
  93791. * Gets the gravity vector used by the simulation
  93792. */
  93793. gravity: Vector3;
  93794. /**
  93795. * Sets the gravity vector used by the simulation
  93796. * @param gravity defines the gravity vector to use
  93797. */
  93798. setGravity(gravity: Vector3): void;
  93799. /**
  93800. * Set the time step of the physics engine.
  93801. * Default is 1/60.
  93802. * To slow it down, enter 1/600 for example.
  93803. * To speed it up, 1/30
  93804. * @param newTimeStep the new timestep to apply to this world.
  93805. */
  93806. setTimeStep(newTimeStep: number): void;
  93807. /**
  93808. * Get the time step of the physics engine.
  93809. * @returns the current time step
  93810. */
  93811. getTimeStep(): number;
  93812. /**
  93813. * Set the sub time step of the physics engine.
  93814. * Default is 0 meaning there is no sub steps
  93815. * To increase physics resolution precision, set a small value (like 1 ms)
  93816. * @param subTimeStep defines the new sub timestep used for physics resolution.
  93817. */
  93818. setSubTimeStep(subTimeStep: number): void;
  93819. /**
  93820. * Get the sub time step of the physics engine.
  93821. * @returns the current sub time step
  93822. */
  93823. getSubTimeStep(): number;
  93824. /**
  93825. * Release all resources
  93826. */
  93827. dispose(): void;
  93828. /**
  93829. * Gets the name of the current physics plugin
  93830. * @returns the name of the plugin
  93831. */
  93832. getPhysicsPluginName(): string;
  93833. /**
  93834. * Adding a new impostor for the impostor tracking.
  93835. * This will be done by the impostor itself.
  93836. * @param impostor the impostor to add
  93837. */
  93838. addImpostor(impostor: PhysicsImpostor): void;
  93839. /**
  93840. * Remove an impostor from the engine.
  93841. * This impostor and its mesh will not longer be updated by the physics engine.
  93842. * @param impostor the impostor to remove
  93843. */
  93844. removeImpostor(impostor: PhysicsImpostor): void;
  93845. /**
  93846. * Add a joint to the physics engine
  93847. * @param mainImpostor defines the main impostor to which the joint is added.
  93848. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  93849. * @param joint defines the joint that will connect both impostors.
  93850. */
  93851. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93852. /**
  93853. * Removes a joint from the simulation
  93854. * @param mainImpostor defines the impostor used with the joint
  93855. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  93856. * @param joint defines the joint to remove
  93857. */
  93858. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93859. /**
  93860. * Gets the current plugin used to run the simulation
  93861. * @returns current plugin
  93862. */
  93863. getPhysicsPlugin(): IPhysicsEnginePlugin;
  93864. /**
  93865. * Gets the list of physic impostors
  93866. * @returns an array of PhysicsImpostor
  93867. */
  93868. getImpostors(): Array<PhysicsImpostor>;
  93869. /**
  93870. * Gets the impostor for a physics enabled object
  93871. * @param object defines the object impersonated by the impostor
  93872. * @returns the PhysicsImpostor or null if not found
  93873. */
  93874. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  93875. /**
  93876. * Gets the impostor for a physics body object
  93877. * @param body defines physics body used by the impostor
  93878. * @returns the PhysicsImpostor or null if not found
  93879. */
  93880. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  93881. /**
  93882. * Does a raycast in the physics world
  93883. * @param from when should the ray start?
  93884. * @param to when should the ray end?
  93885. * @returns PhysicsRaycastResult
  93886. */
  93887. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93888. /**
  93889. * Called by the scene. No need to call it.
  93890. * @param delta defines the timespam between frames
  93891. */
  93892. _step(delta: number): void;
  93893. }
  93894. }
  93895. declare module BABYLON {
  93896. /**
  93897. * The interface for the physics imposter parameters
  93898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93899. */
  93900. export interface PhysicsImpostorParameters {
  93901. /**
  93902. * The mass of the physics imposter
  93903. */
  93904. mass: number;
  93905. /**
  93906. * The friction of the physics imposter
  93907. */
  93908. friction?: number;
  93909. /**
  93910. * The coefficient of restitution of the physics imposter
  93911. */
  93912. restitution?: number;
  93913. /**
  93914. * The native options of the physics imposter
  93915. */
  93916. nativeOptions?: any;
  93917. /**
  93918. * Specifies if the parent should be ignored
  93919. */
  93920. ignoreParent?: boolean;
  93921. /**
  93922. * Specifies if bi-directional transformations should be disabled
  93923. */
  93924. disableBidirectionalTransformation?: boolean;
  93925. /**
  93926. * The pressure inside the physics imposter, soft object only
  93927. */
  93928. pressure?: number;
  93929. /**
  93930. * The stiffness the physics imposter, soft object only
  93931. */
  93932. stiffness?: number;
  93933. /**
  93934. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  93935. */
  93936. velocityIterations?: number;
  93937. /**
  93938. * The number of iterations used in maintaining consistent vertex positions, soft object only
  93939. */
  93940. positionIterations?: number;
  93941. /**
  93942. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  93943. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  93944. * Add to fix multiple points
  93945. */
  93946. fixedPoints?: number;
  93947. /**
  93948. * The collision margin around a soft object
  93949. */
  93950. margin?: number;
  93951. /**
  93952. * The collision margin around a soft object
  93953. */
  93954. damping?: number;
  93955. /**
  93956. * The path for a rope based on an extrusion
  93957. */
  93958. path?: any;
  93959. /**
  93960. * The shape of an extrusion used for a rope based on an extrusion
  93961. */
  93962. shape?: any;
  93963. }
  93964. /**
  93965. * Interface for a physics-enabled object
  93966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93967. */
  93968. export interface IPhysicsEnabledObject {
  93969. /**
  93970. * The position of the physics-enabled object
  93971. */
  93972. position: Vector3;
  93973. /**
  93974. * The rotation of the physics-enabled object
  93975. */
  93976. rotationQuaternion: Nullable<Quaternion>;
  93977. /**
  93978. * The scale of the physics-enabled object
  93979. */
  93980. scaling: Vector3;
  93981. /**
  93982. * The rotation of the physics-enabled object
  93983. */
  93984. rotation?: Vector3;
  93985. /**
  93986. * The parent of the physics-enabled object
  93987. */
  93988. parent?: any;
  93989. /**
  93990. * The bounding info of the physics-enabled object
  93991. * @returns The bounding info of the physics-enabled object
  93992. */
  93993. getBoundingInfo(): BoundingInfo;
  93994. /**
  93995. * Computes the world matrix
  93996. * @param force Specifies if the world matrix should be computed by force
  93997. * @returns A world matrix
  93998. */
  93999. computeWorldMatrix(force: boolean): Matrix;
  94000. /**
  94001. * Gets the world matrix
  94002. * @returns A world matrix
  94003. */
  94004. getWorldMatrix?(): Matrix;
  94005. /**
  94006. * Gets the child meshes
  94007. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94008. * @returns An array of abstract meshes
  94009. */
  94010. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94011. /**
  94012. * Gets the vertex data
  94013. * @param kind The type of vertex data
  94014. * @returns A nullable array of numbers, or a float32 array
  94015. */
  94016. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94017. /**
  94018. * Gets the indices from the mesh
  94019. * @returns A nullable array of index arrays
  94020. */
  94021. getIndices?(): Nullable<IndicesArray>;
  94022. /**
  94023. * Gets the scene from the mesh
  94024. * @returns the indices array or null
  94025. */
  94026. getScene?(): Scene;
  94027. /**
  94028. * Gets the absolute position from the mesh
  94029. * @returns the absolute position
  94030. */
  94031. getAbsolutePosition(): Vector3;
  94032. /**
  94033. * Gets the absolute pivot point from the mesh
  94034. * @returns the absolute pivot point
  94035. */
  94036. getAbsolutePivotPoint(): Vector3;
  94037. /**
  94038. * Rotates the mesh
  94039. * @param axis The axis of rotation
  94040. * @param amount The amount of rotation
  94041. * @param space The space of the rotation
  94042. * @returns The rotation transform node
  94043. */
  94044. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94045. /**
  94046. * Translates the mesh
  94047. * @param axis The axis of translation
  94048. * @param distance The distance of translation
  94049. * @param space The space of the translation
  94050. * @returns The transform node
  94051. */
  94052. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94053. /**
  94054. * Sets the absolute position of the mesh
  94055. * @param absolutePosition The absolute position of the mesh
  94056. * @returns The transform node
  94057. */
  94058. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94059. /**
  94060. * Gets the class name of the mesh
  94061. * @returns The class name
  94062. */
  94063. getClassName(): string;
  94064. }
  94065. /**
  94066. * Represents a physics imposter
  94067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94068. */
  94069. export class PhysicsImpostor {
  94070. /**
  94071. * The physics-enabled object used as the physics imposter
  94072. */
  94073. object: IPhysicsEnabledObject;
  94074. /**
  94075. * The type of the physics imposter
  94076. */
  94077. type: number;
  94078. private _options;
  94079. private _scene?;
  94080. /**
  94081. * The default object size of the imposter
  94082. */
  94083. static DEFAULT_OBJECT_SIZE: Vector3;
  94084. /**
  94085. * The identity quaternion of the imposter
  94086. */
  94087. static IDENTITY_QUATERNION: Quaternion;
  94088. /** @hidden */
  94089. _pluginData: any;
  94090. private _physicsEngine;
  94091. private _physicsBody;
  94092. private _bodyUpdateRequired;
  94093. private _onBeforePhysicsStepCallbacks;
  94094. private _onAfterPhysicsStepCallbacks;
  94095. /** @hidden */
  94096. _onPhysicsCollideCallbacks: Array<{
  94097. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94098. otherImpostors: Array<PhysicsImpostor>;
  94099. }>;
  94100. private _deltaPosition;
  94101. private _deltaRotation;
  94102. private _deltaRotationConjugated;
  94103. /** @hidden */
  94104. _isFromLine: boolean;
  94105. private _parent;
  94106. private _isDisposed;
  94107. private static _tmpVecs;
  94108. private static _tmpQuat;
  94109. /**
  94110. * Specifies if the physics imposter is disposed
  94111. */
  94112. get isDisposed(): boolean;
  94113. /**
  94114. * Gets the mass of the physics imposter
  94115. */
  94116. get mass(): number;
  94117. set mass(value: number);
  94118. /**
  94119. * Gets the coefficient of friction
  94120. */
  94121. get friction(): number;
  94122. /**
  94123. * Sets the coefficient of friction
  94124. */
  94125. set friction(value: number);
  94126. /**
  94127. * Gets the coefficient of restitution
  94128. */
  94129. get restitution(): number;
  94130. /**
  94131. * Sets the coefficient of restitution
  94132. */
  94133. set restitution(value: number);
  94134. /**
  94135. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94136. */
  94137. get pressure(): number;
  94138. /**
  94139. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  94140. */
  94141. set pressure(value: number);
  94142. /**
  94143. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94144. */
  94145. get stiffness(): number;
  94146. /**
  94147. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94148. */
  94149. set stiffness(value: number);
  94150. /**
  94151. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94152. */
  94153. get velocityIterations(): number;
  94154. /**
  94155. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94156. */
  94157. set velocityIterations(value: number);
  94158. /**
  94159. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94160. */
  94161. get positionIterations(): number;
  94162. /**
  94163. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94164. */
  94165. set positionIterations(value: number);
  94166. /**
  94167. * The unique id of the physics imposter
  94168. * set by the physics engine when adding this impostor to the array
  94169. */
  94170. uniqueId: number;
  94171. /**
  94172. * @hidden
  94173. */
  94174. soft: boolean;
  94175. /**
  94176. * @hidden
  94177. */
  94178. segments: number;
  94179. private _joints;
  94180. /**
  94181. * Initializes the physics imposter
  94182. * @param object The physics-enabled object used as the physics imposter
  94183. * @param type The type of the physics imposter
  94184. * @param _options The options for the physics imposter
  94185. * @param _scene The Babylon scene
  94186. */
  94187. constructor(
  94188. /**
  94189. * The physics-enabled object used as the physics imposter
  94190. */
  94191. object: IPhysicsEnabledObject,
  94192. /**
  94193. * The type of the physics imposter
  94194. */
  94195. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  94196. /**
  94197. * This function will completly initialize this impostor.
  94198. * It will create a new body - but only if this mesh has no parent.
  94199. * If it has, this impostor will not be used other than to define the impostor
  94200. * of the child mesh.
  94201. * @hidden
  94202. */
  94203. _init(): void;
  94204. private _getPhysicsParent;
  94205. /**
  94206. * Should a new body be generated.
  94207. * @returns boolean specifying if body initialization is required
  94208. */
  94209. isBodyInitRequired(): boolean;
  94210. /**
  94211. * Sets the updated scaling
  94212. * @param updated Specifies if the scaling is updated
  94213. */
  94214. setScalingUpdated(): void;
  94215. /**
  94216. * Force a regeneration of this or the parent's impostor's body.
  94217. * Use under cautious - This will remove all joints already implemented.
  94218. */
  94219. forceUpdate(): void;
  94220. /**
  94221. * Gets the body that holds this impostor. Either its own, or its parent.
  94222. */
  94223. get physicsBody(): any;
  94224. /**
  94225. * Get the parent of the physics imposter
  94226. * @returns Physics imposter or null
  94227. */
  94228. get parent(): Nullable<PhysicsImpostor>;
  94229. /**
  94230. * Sets the parent of the physics imposter
  94231. */
  94232. set parent(value: Nullable<PhysicsImpostor>);
  94233. /**
  94234. * Set the physics body. Used mainly by the physics engine/plugin
  94235. */
  94236. set physicsBody(physicsBody: any);
  94237. /**
  94238. * Resets the update flags
  94239. */
  94240. resetUpdateFlags(): void;
  94241. /**
  94242. * Gets the object extend size
  94243. * @returns the object extend size
  94244. */
  94245. getObjectExtendSize(): Vector3;
  94246. /**
  94247. * Gets the object center
  94248. * @returns The object center
  94249. */
  94250. getObjectCenter(): Vector3;
  94251. /**
  94252. * Get a specific parametes from the options parameter
  94253. * @param paramName The object parameter name
  94254. * @returns The object parameter
  94255. */
  94256. getParam(paramName: string): any;
  94257. /**
  94258. * Sets a specific parameter in the options given to the physics plugin
  94259. * @param paramName The parameter name
  94260. * @param value The value of the parameter
  94261. */
  94262. setParam(paramName: string, value: number): void;
  94263. /**
  94264. * Specifically change the body's mass option. Won't recreate the physics body object
  94265. * @param mass The mass of the physics imposter
  94266. */
  94267. setMass(mass: number): void;
  94268. /**
  94269. * Gets the linear velocity
  94270. * @returns linear velocity or null
  94271. */
  94272. getLinearVelocity(): Nullable<Vector3>;
  94273. /**
  94274. * Sets the linear velocity
  94275. * @param velocity linear velocity or null
  94276. */
  94277. setLinearVelocity(velocity: Nullable<Vector3>): void;
  94278. /**
  94279. * Gets the angular velocity
  94280. * @returns angular velocity or null
  94281. */
  94282. getAngularVelocity(): Nullable<Vector3>;
  94283. /**
  94284. * Sets the angular velocity
  94285. * @param velocity The velocity or null
  94286. */
  94287. setAngularVelocity(velocity: Nullable<Vector3>): void;
  94288. /**
  94289. * Execute a function with the physics plugin native code
  94290. * Provide a function the will have two variables - the world object and the physics body object
  94291. * @param func The function to execute with the physics plugin native code
  94292. */
  94293. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  94294. /**
  94295. * Register a function that will be executed before the physics world is stepping forward
  94296. * @param func The function to execute before the physics world is stepped forward
  94297. */
  94298. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94299. /**
  94300. * Unregister a function that will be executed before the physics world is stepping forward
  94301. * @param func The function to execute before the physics world is stepped forward
  94302. */
  94303. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94304. /**
  94305. * Register a function that will be executed after the physics step
  94306. * @param func The function to execute after physics step
  94307. */
  94308. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94309. /**
  94310. * Unregisters a function that will be executed after the physics step
  94311. * @param func The function to execute after physics step
  94312. */
  94313. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94314. /**
  94315. * register a function that will be executed when this impostor collides against a different body
  94316. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  94317. * @param func Callback that is executed on collision
  94318. */
  94319. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  94320. /**
  94321. * Unregisters the physics imposter on contact
  94322. * @param collideAgainst The physics object to collide against
  94323. * @param func Callback to execute on collision
  94324. */
  94325. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  94326. private _tmpQuat;
  94327. private _tmpQuat2;
  94328. /**
  94329. * Get the parent rotation
  94330. * @returns The parent rotation
  94331. */
  94332. getParentsRotation(): Quaternion;
  94333. /**
  94334. * this function is executed by the physics engine.
  94335. */
  94336. beforeStep: () => void;
  94337. /**
  94338. * this function is executed by the physics engine
  94339. */
  94340. afterStep: () => void;
  94341. /**
  94342. * Legacy collision detection event support
  94343. */
  94344. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  94345. /**
  94346. * event and body object due to cannon's event-based architecture.
  94347. */
  94348. onCollide: (e: {
  94349. body: any;
  94350. }) => void;
  94351. /**
  94352. * Apply a force
  94353. * @param force The force to apply
  94354. * @param contactPoint The contact point for the force
  94355. * @returns The physics imposter
  94356. */
  94357. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94358. /**
  94359. * Apply an impulse
  94360. * @param force The impulse force
  94361. * @param contactPoint The contact point for the impulse force
  94362. * @returns The physics imposter
  94363. */
  94364. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94365. /**
  94366. * A help function to create a joint
  94367. * @param otherImpostor A physics imposter used to create a joint
  94368. * @param jointType The type of joint
  94369. * @param jointData The data for the joint
  94370. * @returns The physics imposter
  94371. */
  94372. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  94373. /**
  94374. * Add a joint to this impostor with a different impostor
  94375. * @param otherImpostor A physics imposter used to add a joint
  94376. * @param joint The joint to add
  94377. * @returns The physics imposter
  94378. */
  94379. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  94380. /**
  94381. * Add an anchor to a cloth impostor
  94382. * @param otherImpostor rigid impostor to anchor to
  94383. * @param width ratio across width from 0 to 1
  94384. * @param height ratio up height from 0 to 1
  94385. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  94386. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  94387. * @returns impostor the soft imposter
  94388. */
  94389. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94390. /**
  94391. * Add a hook to a rope impostor
  94392. * @param otherImpostor rigid impostor to anchor to
  94393. * @param length ratio across rope from 0 to 1
  94394. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  94395. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  94396. * @returns impostor the rope imposter
  94397. */
  94398. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94399. /**
  94400. * Will keep this body still, in a sleep mode.
  94401. * @returns the physics imposter
  94402. */
  94403. sleep(): PhysicsImpostor;
  94404. /**
  94405. * Wake the body up.
  94406. * @returns The physics imposter
  94407. */
  94408. wakeUp(): PhysicsImpostor;
  94409. /**
  94410. * Clones the physics imposter
  94411. * @param newObject The physics imposter clones to this physics-enabled object
  94412. * @returns A nullable physics imposter
  94413. */
  94414. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94415. /**
  94416. * Disposes the physics imposter
  94417. */
  94418. dispose(): void;
  94419. /**
  94420. * Sets the delta position
  94421. * @param position The delta position amount
  94422. */
  94423. setDeltaPosition(position: Vector3): void;
  94424. /**
  94425. * Sets the delta rotation
  94426. * @param rotation The delta rotation amount
  94427. */
  94428. setDeltaRotation(rotation: Quaternion): void;
  94429. /**
  94430. * Gets the box size of the physics imposter and stores the result in the input parameter
  94431. * @param result Stores the box size
  94432. * @returns The physics imposter
  94433. */
  94434. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  94435. /**
  94436. * Gets the radius of the physics imposter
  94437. * @returns Radius of the physics imposter
  94438. */
  94439. getRadius(): number;
  94440. /**
  94441. * Sync a bone with this impostor
  94442. * @param bone The bone to sync to the impostor.
  94443. * @param boneMesh The mesh that the bone is influencing.
  94444. * @param jointPivot The pivot of the joint / bone in local space.
  94445. * @param distToJoint Optional distance from the impostor to the joint.
  94446. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94447. */
  94448. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  94449. /**
  94450. * Sync impostor to a bone
  94451. * @param bone The bone that the impostor will be synced to.
  94452. * @param boneMesh The mesh that the bone is influencing.
  94453. * @param jointPivot The pivot of the joint / bone in local space.
  94454. * @param distToJoint Optional distance from the impostor to the joint.
  94455. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94456. * @param boneAxis Optional vector3 axis the bone is aligned with
  94457. */
  94458. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  94459. /**
  94460. * No-Imposter type
  94461. */
  94462. static NoImpostor: number;
  94463. /**
  94464. * Sphere-Imposter type
  94465. */
  94466. static SphereImpostor: number;
  94467. /**
  94468. * Box-Imposter type
  94469. */
  94470. static BoxImpostor: number;
  94471. /**
  94472. * Plane-Imposter type
  94473. */
  94474. static PlaneImpostor: number;
  94475. /**
  94476. * Mesh-imposter type
  94477. */
  94478. static MeshImpostor: number;
  94479. /**
  94480. * Capsule-Impostor type (Ammo.js plugin only)
  94481. */
  94482. static CapsuleImpostor: number;
  94483. /**
  94484. * Cylinder-Imposter type
  94485. */
  94486. static CylinderImpostor: number;
  94487. /**
  94488. * Particle-Imposter type
  94489. */
  94490. static ParticleImpostor: number;
  94491. /**
  94492. * Heightmap-Imposter type
  94493. */
  94494. static HeightmapImpostor: number;
  94495. /**
  94496. * ConvexHull-Impostor type (Ammo.js plugin only)
  94497. */
  94498. static ConvexHullImpostor: number;
  94499. /**
  94500. * Custom-Imposter type (Ammo.js plugin only)
  94501. */
  94502. static CustomImpostor: number;
  94503. /**
  94504. * Rope-Imposter type
  94505. */
  94506. static RopeImpostor: number;
  94507. /**
  94508. * Cloth-Imposter type
  94509. */
  94510. static ClothImpostor: number;
  94511. /**
  94512. * Softbody-Imposter type
  94513. */
  94514. static SoftbodyImpostor: number;
  94515. }
  94516. }
  94517. declare module BABYLON {
  94518. /**
  94519. * @hidden
  94520. **/
  94521. export class _CreationDataStorage {
  94522. closePath?: boolean;
  94523. closeArray?: boolean;
  94524. idx: number[];
  94525. dashSize: number;
  94526. gapSize: number;
  94527. path3D: Path3D;
  94528. pathArray: Vector3[][];
  94529. arc: number;
  94530. radius: number;
  94531. cap: number;
  94532. tessellation: number;
  94533. }
  94534. /**
  94535. * @hidden
  94536. **/
  94537. class _InstanceDataStorage {
  94538. visibleInstances: any;
  94539. batchCache: _InstancesBatch;
  94540. instancesBufferSize: number;
  94541. instancesBuffer: Nullable<Buffer>;
  94542. instancesData: Float32Array;
  94543. overridenInstanceCount: number;
  94544. isFrozen: boolean;
  94545. previousBatch: Nullable<_InstancesBatch>;
  94546. hardwareInstancedRendering: boolean;
  94547. sideOrientation: number;
  94548. manualUpdate: boolean;
  94549. }
  94550. /**
  94551. * @hidden
  94552. **/
  94553. export class _InstancesBatch {
  94554. mustReturn: boolean;
  94555. visibleInstances: Nullable<InstancedMesh[]>[];
  94556. renderSelf: boolean[];
  94557. hardwareInstancedRendering: boolean[];
  94558. }
  94559. /**
  94560. * Class used to represent renderable models
  94561. */
  94562. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  94563. /**
  94564. * Mesh side orientation : usually the external or front surface
  94565. */
  94566. static readonly FRONTSIDE: number;
  94567. /**
  94568. * Mesh side orientation : usually the internal or back surface
  94569. */
  94570. static readonly BACKSIDE: number;
  94571. /**
  94572. * Mesh side orientation : both internal and external or front and back surfaces
  94573. */
  94574. static readonly DOUBLESIDE: number;
  94575. /**
  94576. * Mesh side orientation : by default, `FRONTSIDE`
  94577. */
  94578. static readonly DEFAULTSIDE: number;
  94579. /**
  94580. * Mesh cap setting : no cap
  94581. */
  94582. static readonly NO_CAP: number;
  94583. /**
  94584. * Mesh cap setting : one cap at the beginning of the mesh
  94585. */
  94586. static readonly CAP_START: number;
  94587. /**
  94588. * Mesh cap setting : one cap at the end of the mesh
  94589. */
  94590. static readonly CAP_END: number;
  94591. /**
  94592. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  94593. */
  94594. static readonly CAP_ALL: number;
  94595. /**
  94596. * Mesh pattern setting : no flip or rotate
  94597. */
  94598. static readonly NO_FLIP: number;
  94599. /**
  94600. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  94601. */
  94602. static readonly FLIP_TILE: number;
  94603. /**
  94604. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  94605. */
  94606. static readonly ROTATE_TILE: number;
  94607. /**
  94608. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  94609. */
  94610. static readonly FLIP_ROW: number;
  94611. /**
  94612. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  94613. */
  94614. static readonly ROTATE_ROW: number;
  94615. /**
  94616. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  94617. */
  94618. static readonly FLIP_N_ROTATE_TILE: number;
  94619. /**
  94620. * Mesh pattern setting : rotate pattern and rotate
  94621. */
  94622. static readonly FLIP_N_ROTATE_ROW: number;
  94623. /**
  94624. * Mesh tile positioning : part tiles same on left/right or top/bottom
  94625. */
  94626. static readonly CENTER: number;
  94627. /**
  94628. * Mesh tile positioning : part tiles on left
  94629. */
  94630. static readonly LEFT: number;
  94631. /**
  94632. * Mesh tile positioning : part tiles on right
  94633. */
  94634. static readonly RIGHT: number;
  94635. /**
  94636. * Mesh tile positioning : part tiles on top
  94637. */
  94638. static readonly TOP: number;
  94639. /**
  94640. * Mesh tile positioning : part tiles on bottom
  94641. */
  94642. static readonly BOTTOM: number;
  94643. /**
  94644. * Gets the default side orientation.
  94645. * @param orientation the orientation to value to attempt to get
  94646. * @returns the default orientation
  94647. * @hidden
  94648. */
  94649. static _GetDefaultSideOrientation(orientation?: number): number;
  94650. private _internalMeshDataInfo;
  94651. /**
  94652. * An event triggered before rendering the mesh
  94653. */
  94654. get onBeforeRenderObservable(): Observable<Mesh>;
  94655. /**
  94656. * An event triggered before binding the mesh
  94657. */
  94658. get onBeforeBindObservable(): Observable<Mesh>;
  94659. /**
  94660. * An event triggered after rendering the mesh
  94661. */
  94662. get onAfterRenderObservable(): Observable<Mesh>;
  94663. /**
  94664. * An event triggered before drawing the mesh
  94665. */
  94666. get onBeforeDrawObservable(): Observable<Mesh>;
  94667. private _onBeforeDrawObserver;
  94668. /**
  94669. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  94670. */
  94671. set onBeforeDraw(callback: () => void);
  94672. get hasInstances(): boolean;
  94673. /**
  94674. * Gets the delay loading state of the mesh (when delay loading is turned on)
  94675. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  94676. */
  94677. delayLoadState: number;
  94678. /**
  94679. * Gets the list of instances created from this mesh
  94680. * it is not supposed to be modified manually.
  94681. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  94682. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94683. */
  94684. instances: InstancedMesh[];
  94685. /**
  94686. * Gets the file containing delay loading data for this mesh
  94687. */
  94688. delayLoadingFile: string;
  94689. /** @hidden */
  94690. _binaryInfo: any;
  94691. /**
  94692. * User defined function used to change how LOD level selection is done
  94693. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94694. */
  94695. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  94696. /**
  94697. * Gets or sets the morph target manager
  94698. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94699. */
  94700. get morphTargetManager(): Nullable<MorphTargetManager>;
  94701. set morphTargetManager(value: Nullable<MorphTargetManager>);
  94702. /** @hidden */
  94703. _creationDataStorage: Nullable<_CreationDataStorage>;
  94704. /** @hidden */
  94705. _geometry: Nullable<Geometry>;
  94706. /** @hidden */
  94707. _delayInfo: Array<string>;
  94708. /** @hidden */
  94709. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  94710. /** @hidden */
  94711. _instanceDataStorage: _InstanceDataStorage;
  94712. private _effectiveMaterial;
  94713. /** @hidden */
  94714. _shouldGenerateFlatShading: boolean;
  94715. /** @hidden */
  94716. _originalBuilderSideOrientation: number;
  94717. /**
  94718. * Use this property to change the original side orientation defined at construction time
  94719. */
  94720. overrideMaterialSideOrientation: Nullable<number>;
  94721. /**
  94722. * Gets the source mesh (the one used to clone this one from)
  94723. */
  94724. get source(): Nullable<Mesh>;
  94725. /**
  94726. * Gets or sets a boolean indicating that this mesh does not use index buffer
  94727. */
  94728. get isUnIndexed(): boolean;
  94729. set isUnIndexed(value: boolean);
  94730. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  94731. get worldMatrixInstancedBuffer(): Float32Array;
  94732. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  94733. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  94734. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  94735. /**
  94736. * @constructor
  94737. * @param name The value used by scene.getMeshByName() to do a lookup.
  94738. * @param scene The scene to add this mesh to.
  94739. * @param parent The parent of this mesh, if it has one
  94740. * @param source An optional Mesh from which geometry is shared, cloned.
  94741. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94742. * When false, achieved by calling a clone(), also passing False.
  94743. * This will make creation of children, recursive.
  94744. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  94745. */
  94746. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  94747. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94748. doNotInstantiate: boolean;
  94749. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94750. /**
  94751. * Gets the class name
  94752. * @returns the string "Mesh".
  94753. */
  94754. getClassName(): string;
  94755. /** @hidden */
  94756. get _isMesh(): boolean;
  94757. /**
  94758. * Returns a description of this mesh
  94759. * @param fullDetails define if full details about this mesh must be used
  94760. * @returns a descriptive string representing this mesh
  94761. */
  94762. toString(fullDetails?: boolean): string;
  94763. /** @hidden */
  94764. _unBindEffect(): void;
  94765. /**
  94766. * Gets a boolean indicating if this mesh has LOD
  94767. */
  94768. get hasLODLevels(): boolean;
  94769. /**
  94770. * Gets the list of MeshLODLevel associated with the current mesh
  94771. * @returns an array of MeshLODLevel
  94772. */
  94773. getLODLevels(): MeshLODLevel[];
  94774. private _sortLODLevels;
  94775. /**
  94776. * Add a mesh as LOD level triggered at the given distance.
  94777. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94778. * @param distance The distance from the center of the object to show this level
  94779. * @param mesh The mesh to be added as LOD level (can be null)
  94780. * @return This mesh (for chaining)
  94781. */
  94782. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  94783. /**
  94784. * Returns the LOD level mesh at the passed distance or null if not found.
  94785. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94786. * @param distance The distance from the center of the object to show this level
  94787. * @returns a Mesh or `null`
  94788. */
  94789. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  94790. /**
  94791. * Remove a mesh from the LOD array
  94792. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94793. * @param mesh defines the mesh to be removed
  94794. * @return This mesh (for chaining)
  94795. */
  94796. removeLODLevel(mesh: Mesh): Mesh;
  94797. /**
  94798. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  94799. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94800. * @param camera defines the camera to use to compute distance
  94801. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  94802. * @return This mesh (for chaining)
  94803. */
  94804. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  94805. /**
  94806. * Gets the mesh internal Geometry object
  94807. */
  94808. get geometry(): Nullable<Geometry>;
  94809. /**
  94810. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  94811. * @returns the total number of vertices
  94812. */
  94813. getTotalVertices(): number;
  94814. /**
  94815. * Returns the content of an associated vertex buffer
  94816. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94817. * - VertexBuffer.PositionKind
  94818. * - VertexBuffer.UVKind
  94819. * - VertexBuffer.UV2Kind
  94820. * - VertexBuffer.UV3Kind
  94821. * - VertexBuffer.UV4Kind
  94822. * - VertexBuffer.UV5Kind
  94823. * - VertexBuffer.UV6Kind
  94824. * - VertexBuffer.ColorKind
  94825. * - VertexBuffer.MatricesIndicesKind
  94826. * - VertexBuffer.MatricesIndicesExtraKind
  94827. * - VertexBuffer.MatricesWeightsKind
  94828. * - VertexBuffer.MatricesWeightsExtraKind
  94829. * @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
  94830. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  94831. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  94832. */
  94833. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94834. /**
  94835. * Returns the mesh VertexBuffer object from the requested `kind`
  94836. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94837. * - VertexBuffer.PositionKind
  94838. * - VertexBuffer.NormalKind
  94839. * - VertexBuffer.UVKind
  94840. * - VertexBuffer.UV2Kind
  94841. * - VertexBuffer.UV3Kind
  94842. * - VertexBuffer.UV4Kind
  94843. * - VertexBuffer.UV5Kind
  94844. * - VertexBuffer.UV6Kind
  94845. * - VertexBuffer.ColorKind
  94846. * - VertexBuffer.MatricesIndicesKind
  94847. * - VertexBuffer.MatricesIndicesExtraKind
  94848. * - VertexBuffer.MatricesWeightsKind
  94849. * - VertexBuffer.MatricesWeightsExtraKind
  94850. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  94851. */
  94852. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94853. /**
  94854. * Tests if a specific vertex buffer is associated with this mesh
  94855. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94856. * - VertexBuffer.PositionKind
  94857. * - VertexBuffer.NormalKind
  94858. * - VertexBuffer.UVKind
  94859. * - VertexBuffer.UV2Kind
  94860. * - VertexBuffer.UV3Kind
  94861. * - VertexBuffer.UV4Kind
  94862. * - VertexBuffer.UV5Kind
  94863. * - VertexBuffer.UV6Kind
  94864. * - VertexBuffer.ColorKind
  94865. * - VertexBuffer.MatricesIndicesKind
  94866. * - VertexBuffer.MatricesIndicesExtraKind
  94867. * - VertexBuffer.MatricesWeightsKind
  94868. * - VertexBuffer.MatricesWeightsExtraKind
  94869. * @returns a boolean
  94870. */
  94871. isVerticesDataPresent(kind: string): boolean;
  94872. /**
  94873. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  94874. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94875. * - VertexBuffer.PositionKind
  94876. * - VertexBuffer.UVKind
  94877. * - VertexBuffer.UV2Kind
  94878. * - VertexBuffer.UV3Kind
  94879. * - VertexBuffer.UV4Kind
  94880. * - VertexBuffer.UV5Kind
  94881. * - VertexBuffer.UV6Kind
  94882. * - VertexBuffer.ColorKind
  94883. * - VertexBuffer.MatricesIndicesKind
  94884. * - VertexBuffer.MatricesIndicesExtraKind
  94885. * - VertexBuffer.MatricesWeightsKind
  94886. * - VertexBuffer.MatricesWeightsExtraKind
  94887. * @returns a boolean
  94888. */
  94889. isVertexBufferUpdatable(kind: string): boolean;
  94890. /**
  94891. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  94892. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94893. * - VertexBuffer.PositionKind
  94894. * - VertexBuffer.NormalKind
  94895. * - VertexBuffer.UVKind
  94896. * - VertexBuffer.UV2Kind
  94897. * - VertexBuffer.UV3Kind
  94898. * - VertexBuffer.UV4Kind
  94899. * - VertexBuffer.UV5Kind
  94900. * - VertexBuffer.UV6Kind
  94901. * - VertexBuffer.ColorKind
  94902. * - VertexBuffer.MatricesIndicesKind
  94903. * - VertexBuffer.MatricesIndicesExtraKind
  94904. * - VertexBuffer.MatricesWeightsKind
  94905. * - VertexBuffer.MatricesWeightsExtraKind
  94906. * @returns an array of strings
  94907. */
  94908. getVerticesDataKinds(): string[];
  94909. /**
  94910. * Returns a positive integer : the total number of indices in this mesh geometry.
  94911. * @returns the numner of indices or zero if the mesh has no geometry.
  94912. */
  94913. getTotalIndices(): number;
  94914. /**
  94915. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94916. * @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.
  94917. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94918. * @returns the indices array or an empty array if the mesh has no geometry
  94919. */
  94920. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94921. get isBlocked(): boolean;
  94922. /**
  94923. * Determine if the current mesh is ready to be rendered
  94924. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94925. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  94926. * @returns true if all associated assets are ready (material, textures, shaders)
  94927. */
  94928. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  94929. /**
  94930. * 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.
  94931. */
  94932. get areNormalsFrozen(): boolean;
  94933. /**
  94934. * 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.
  94935. * @returns the current mesh
  94936. */
  94937. freezeNormals(): Mesh;
  94938. /**
  94939. * 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
  94940. * @returns the current mesh
  94941. */
  94942. unfreezeNormals(): Mesh;
  94943. /**
  94944. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  94945. */
  94946. set overridenInstanceCount(count: number);
  94947. /** @hidden */
  94948. _preActivate(): Mesh;
  94949. /** @hidden */
  94950. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94951. /** @hidden */
  94952. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  94953. /**
  94954. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94955. * This means the mesh underlying bounding box and sphere are recomputed.
  94956. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94957. * @returns the current mesh
  94958. */
  94959. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  94960. /** @hidden */
  94961. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  94962. /**
  94963. * This function will subdivide the mesh into multiple submeshes
  94964. * @param count defines the expected number of submeshes
  94965. */
  94966. subdivide(count: number): void;
  94967. /**
  94968. * Copy a FloatArray into a specific associated vertex buffer
  94969. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94970. * - VertexBuffer.PositionKind
  94971. * - VertexBuffer.UVKind
  94972. * - VertexBuffer.UV2Kind
  94973. * - VertexBuffer.UV3Kind
  94974. * - VertexBuffer.UV4Kind
  94975. * - VertexBuffer.UV5Kind
  94976. * - VertexBuffer.UV6Kind
  94977. * - VertexBuffer.ColorKind
  94978. * - VertexBuffer.MatricesIndicesKind
  94979. * - VertexBuffer.MatricesIndicesExtraKind
  94980. * - VertexBuffer.MatricesWeightsKind
  94981. * - VertexBuffer.MatricesWeightsExtraKind
  94982. * @param data defines the data source
  94983. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  94984. * @param stride defines the data stride size (can be null)
  94985. * @returns the current mesh
  94986. */
  94987. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94988. /**
  94989. * Delete a vertex buffer associated with this mesh
  94990. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  94991. * - VertexBuffer.PositionKind
  94992. * - VertexBuffer.UVKind
  94993. * - VertexBuffer.UV2Kind
  94994. * - VertexBuffer.UV3Kind
  94995. * - VertexBuffer.UV4Kind
  94996. * - VertexBuffer.UV5Kind
  94997. * - VertexBuffer.UV6Kind
  94998. * - VertexBuffer.ColorKind
  94999. * - VertexBuffer.MatricesIndicesKind
  95000. * - VertexBuffer.MatricesIndicesExtraKind
  95001. * - VertexBuffer.MatricesWeightsKind
  95002. * - VertexBuffer.MatricesWeightsExtraKind
  95003. */
  95004. removeVerticesData(kind: string): void;
  95005. /**
  95006. * Flags an associated vertex buffer as updatable
  95007. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95008. * - VertexBuffer.PositionKind
  95009. * - VertexBuffer.UVKind
  95010. * - VertexBuffer.UV2Kind
  95011. * - VertexBuffer.UV3Kind
  95012. * - VertexBuffer.UV4Kind
  95013. * - VertexBuffer.UV5Kind
  95014. * - VertexBuffer.UV6Kind
  95015. * - VertexBuffer.ColorKind
  95016. * - VertexBuffer.MatricesIndicesKind
  95017. * - VertexBuffer.MatricesIndicesExtraKind
  95018. * - VertexBuffer.MatricesWeightsKind
  95019. * - VertexBuffer.MatricesWeightsExtraKind
  95020. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95021. */
  95022. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95023. /**
  95024. * Sets the mesh global Vertex Buffer
  95025. * @param buffer defines the buffer to use
  95026. * @returns the current mesh
  95027. */
  95028. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95029. /**
  95030. * Update a specific associated vertex buffer
  95031. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95032. * - VertexBuffer.PositionKind
  95033. * - VertexBuffer.UVKind
  95034. * - VertexBuffer.UV2Kind
  95035. * - VertexBuffer.UV3Kind
  95036. * - VertexBuffer.UV4Kind
  95037. * - VertexBuffer.UV5Kind
  95038. * - VertexBuffer.UV6Kind
  95039. * - VertexBuffer.ColorKind
  95040. * - VertexBuffer.MatricesIndicesKind
  95041. * - VertexBuffer.MatricesIndicesExtraKind
  95042. * - VertexBuffer.MatricesWeightsKind
  95043. * - VertexBuffer.MatricesWeightsExtraKind
  95044. * @param data defines the data source
  95045. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95046. * @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)
  95047. * @returns the current mesh
  95048. */
  95049. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95050. /**
  95051. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95052. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95053. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95054. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95055. * @returns the current mesh
  95056. */
  95057. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95058. /**
  95059. * Creates a un-shared specific occurence of the geometry for the mesh.
  95060. * @returns the current mesh
  95061. */
  95062. makeGeometryUnique(): Mesh;
  95063. /**
  95064. * Set the index buffer of this mesh
  95065. * @param indices defines the source data
  95066. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95067. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95068. * @returns the current mesh
  95069. */
  95070. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95071. /**
  95072. * Update the current index buffer
  95073. * @param indices defines the source data
  95074. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95075. * @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)
  95076. * @returns the current mesh
  95077. */
  95078. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95079. /**
  95080. * Invert the geometry to move from a right handed system to a left handed one.
  95081. * @returns the current mesh
  95082. */
  95083. toLeftHanded(): Mesh;
  95084. /** @hidden */
  95085. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95086. /** @hidden */
  95087. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95088. /**
  95089. * Registers for this mesh a javascript function called just before the rendering process
  95090. * @param func defines the function to call before rendering this mesh
  95091. * @returns the current mesh
  95092. */
  95093. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95094. /**
  95095. * Disposes a previously registered javascript function called before the rendering
  95096. * @param func defines the function to remove
  95097. * @returns the current mesh
  95098. */
  95099. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95100. /**
  95101. * Registers for this mesh a javascript function called just after the rendering is complete
  95102. * @param func defines the function to call after rendering this mesh
  95103. * @returns the current mesh
  95104. */
  95105. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95106. /**
  95107. * Disposes a previously registered javascript function called after the rendering.
  95108. * @param func defines the function to remove
  95109. * @returns the current mesh
  95110. */
  95111. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95112. /** @hidden */
  95113. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95114. /** @hidden */
  95115. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95116. /** @hidden */
  95117. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95118. /** @hidden */
  95119. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95120. /** @hidden */
  95121. _rebuild(): void;
  95122. /** @hidden */
  95123. _freeze(): void;
  95124. /** @hidden */
  95125. _unFreeze(): void;
  95126. /**
  95127. * 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
  95128. * @param subMesh defines the subMesh to render
  95129. * @param enableAlphaMode defines if alpha mode can be changed
  95130. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95131. * @returns the current mesh
  95132. */
  95133. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95134. private _onBeforeDraw;
  95135. /**
  95136. * Renormalize the mesh and patch it up if there are no weights
  95137. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95138. * However in the case of zero weights then we set just a single influence to 1.
  95139. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  95140. */
  95141. cleanMatrixWeights(): void;
  95142. private normalizeSkinFourWeights;
  95143. private normalizeSkinWeightsAndExtra;
  95144. /**
  95145. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  95146. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  95147. * the user know there was an issue with importing the mesh
  95148. * @returns a validation object with skinned, valid and report string
  95149. */
  95150. validateSkinning(): {
  95151. skinned: boolean;
  95152. valid: boolean;
  95153. report: string;
  95154. };
  95155. /** @hidden */
  95156. _checkDelayState(): Mesh;
  95157. private _queueLoad;
  95158. /**
  95159. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95160. * A mesh is in the frustum if its bounding box intersects the frustum
  95161. * @param frustumPlanes defines the frustum to test
  95162. * @returns true if the mesh is in the frustum planes
  95163. */
  95164. isInFrustum(frustumPlanes: Plane[]): boolean;
  95165. /**
  95166. * Sets the mesh material by the material or multiMaterial `id` property
  95167. * @param id is a string identifying the material or the multiMaterial
  95168. * @returns the current mesh
  95169. */
  95170. setMaterialByID(id: string): Mesh;
  95171. /**
  95172. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  95173. * @returns an array of IAnimatable
  95174. */
  95175. getAnimatables(): IAnimatable[];
  95176. /**
  95177. * Modifies the mesh geometry according to the passed transformation matrix.
  95178. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  95179. * The mesh normals are modified using the same transformation.
  95180. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95181. * @param transform defines the transform matrix to use
  95182. * @see http://doc.babylonjs.com/resources/baking_transformations
  95183. * @returns the current mesh
  95184. */
  95185. bakeTransformIntoVertices(transform: Matrix): Mesh;
  95186. /**
  95187. * Modifies the mesh geometry according to its own current World Matrix.
  95188. * The mesh World Matrix is then reset.
  95189. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  95190. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95191. * @see http://doc.babylonjs.com/resources/baking_transformations
  95192. * @returns the current mesh
  95193. */
  95194. bakeCurrentTransformIntoVertices(): Mesh;
  95195. /** @hidden */
  95196. get _positions(): Nullable<Vector3[]>;
  95197. /** @hidden */
  95198. _resetPointsArrayCache(): Mesh;
  95199. /** @hidden */
  95200. _generatePointsArray(): boolean;
  95201. /**
  95202. * Returns a new Mesh object generated from the current mesh properties.
  95203. * This method must not get confused with createInstance()
  95204. * @param name is a string, the name given to the new mesh
  95205. * @param newParent can be any Node object (default `null`)
  95206. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  95207. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  95208. * @returns a new mesh
  95209. */
  95210. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  95211. /**
  95212. * Releases resources associated with this mesh.
  95213. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95214. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95215. */
  95216. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95217. /** @hidden */
  95218. _disposeInstanceSpecificData(): void;
  95219. /**
  95220. * Modifies the mesh geometry according to a displacement map.
  95221. * 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.
  95222. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95223. * @param url is a string, the URL from the image file is to be downloaded.
  95224. * @param minHeight is the lower limit of the displacement.
  95225. * @param maxHeight is the upper limit of the displacement.
  95226. * @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.
  95227. * @param uvOffset is an optional vector2 used to offset UV.
  95228. * @param uvScale is an optional vector2 used to scale UV.
  95229. * @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.
  95230. * @returns the Mesh.
  95231. */
  95232. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95233. /**
  95234. * Modifies the mesh geometry according to a displacementMap buffer.
  95235. * 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.
  95236. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95237. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  95238. * @param heightMapWidth is the width of the buffer image.
  95239. * @param heightMapHeight is the height of the buffer image.
  95240. * @param minHeight is the lower limit of the displacement.
  95241. * @param maxHeight is the upper limit of the displacement.
  95242. * @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.
  95243. * @param uvOffset is an optional vector2 used to offset UV.
  95244. * @param uvScale is an optional vector2 used to scale UV.
  95245. * @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.
  95246. * @returns the Mesh.
  95247. */
  95248. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95249. /**
  95250. * Modify the mesh to get a flat shading rendering.
  95251. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  95252. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  95253. * @returns current mesh
  95254. */
  95255. convertToFlatShadedMesh(): Mesh;
  95256. /**
  95257. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  95258. * In other words, more vertices, no more indices and a single bigger VBO.
  95259. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  95260. * @returns current mesh
  95261. */
  95262. convertToUnIndexedMesh(): Mesh;
  95263. /**
  95264. * Inverses facet orientations.
  95265. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95266. * @param flipNormals will also inverts the normals
  95267. * @returns current mesh
  95268. */
  95269. flipFaces(flipNormals?: boolean): Mesh;
  95270. /**
  95271. * Increase the number of facets and hence vertices in a mesh
  95272. * Vertex normals are interpolated from existing vertex normals
  95273. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95274. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  95275. */
  95276. increaseVertices(numberPerEdge: number): void;
  95277. /**
  95278. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  95279. * This will undo any application of covertToFlatShadedMesh
  95280. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95281. */
  95282. forceSharedVertices(): void;
  95283. /** @hidden */
  95284. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  95285. /** @hidden */
  95286. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  95287. /**
  95288. * Creates a new InstancedMesh object from the mesh model.
  95289. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95290. * @param name defines the name of the new instance
  95291. * @returns a new InstancedMesh
  95292. */
  95293. createInstance(name: string): InstancedMesh;
  95294. /**
  95295. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  95296. * After this call, all the mesh instances have the same submeshes than the current mesh.
  95297. * @returns the current mesh
  95298. */
  95299. synchronizeInstances(): Mesh;
  95300. /**
  95301. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  95302. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  95303. * This should be used together with the simplification to avoid disappearing triangles.
  95304. * @param successCallback an optional success callback to be called after the optimization finished.
  95305. * @returns the current mesh
  95306. */
  95307. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  95308. /**
  95309. * Serialize current mesh
  95310. * @param serializationObject defines the object which will receive the serialization data
  95311. */
  95312. serialize(serializationObject: any): void;
  95313. /** @hidden */
  95314. _syncGeometryWithMorphTargetManager(): void;
  95315. /** @hidden */
  95316. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  95317. /**
  95318. * Returns a new Mesh object parsed from the source provided.
  95319. * @param parsedMesh is the source
  95320. * @param scene defines the hosting scene
  95321. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  95322. * @returns a new Mesh
  95323. */
  95324. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  95325. /**
  95326. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  95327. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95328. * @param name defines the name of the mesh to create
  95329. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  95330. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  95331. * @param closePath creates a seam between the first and the last points of each path of the path array
  95332. * @param offset is taken in account only if the `pathArray` is containing a single path
  95333. * @param scene defines the hosting scene
  95334. * @param updatable defines if the mesh must be flagged as updatable
  95335. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95336. * @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)
  95337. * @returns a new Mesh
  95338. */
  95339. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95340. /**
  95341. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  95342. * @param name defines the name of the mesh to create
  95343. * @param radius sets the radius size (float) of the polygon (default 0.5)
  95344. * @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
  95345. * @param scene defines the hosting scene
  95346. * @param updatable defines if the mesh must be flagged as updatable
  95347. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95348. * @returns a new Mesh
  95349. */
  95350. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95351. /**
  95352. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  95353. * @param name defines the name of the mesh to create
  95354. * @param size sets the size (float) of each box side (default 1)
  95355. * @param scene defines the hosting scene
  95356. * @param updatable defines if the mesh must be flagged as updatable
  95357. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95358. * @returns a new Mesh
  95359. */
  95360. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95361. /**
  95362. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  95363. * @param name defines the name of the mesh to create
  95364. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95365. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95366. * @param scene defines the hosting scene
  95367. * @param updatable defines if the mesh must be flagged as updatable
  95368. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95369. * @returns a new Mesh
  95370. */
  95371. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95372. /**
  95373. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  95374. * @param name defines the name of the mesh to create
  95375. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95376. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95377. * @param scene defines the hosting scene
  95378. * @returns a new Mesh
  95379. */
  95380. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  95381. /**
  95382. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  95383. * @param name defines the name of the mesh to create
  95384. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  95385. * @param diameterTop set the top cap diameter (floats, default 1)
  95386. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  95387. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  95388. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  95389. * @param scene defines the hosting scene
  95390. * @param updatable defines if the mesh must be flagged as updatable
  95391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95392. * @returns a new Mesh
  95393. */
  95394. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  95395. /**
  95396. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  95397. * @param name defines the name of the mesh to create
  95398. * @param diameter sets the diameter size (float) of the torus (default 1)
  95399. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  95400. * @param tessellation sets the number of torus sides (postive integer, default 16)
  95401. * @param scene defines the hosting scene
  95402. * @param updatable defines if the mesh must be flagged as updatable
  95403. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95404. * @returns a new Mesh
  95405. */
  95406. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95407. /**
  95408. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  95409. * @param name defines the name of the mesh to create
  95410. * @param radius sets the global radius size (float) of the torus knot (default 2)
  95411. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  95412. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  95413. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  95414. * @param p the number of windings on X axis (positive integers, default 2)
  95415. * @param q the number of windings on Y axis (positive integers, default 3)
  95416. * @param scene defines the hosting scene
  95417. * @param updatable defines if the mesh must be flagged as updatable
  95418. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95419. * @returns a new Mesh
  95420. */
  95421. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95422. /**
  95423. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  95424. * @param name defines the name of the mesh to create
  95425. * @param points is an array successive Vector3
  95426. * @param scene defines the hosting scene
  95427. * @param updatable defines if the mesh must be flagged as updatable
  95428. * @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).
  95429. * @returns a new Mesh
  95430. */
  95431. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  95432. /**
  95433. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  95434. * @param name defines the name of the mesh to create
  95435. * @param points is an array successive Vector3
  95436. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  95437. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95438. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  95439. * @param scene defines the hosting scene
  95440. * @param updatable defines if the mesh must be flagged as updatable
  95441. * @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)
  95442. * @returns a new Mesh
  95443. */
  95444. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  95445. /**
  95446. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  95447. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  95448. * 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.
  95449. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95450. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95451. * Remember you can only change the shape positions, not their number when updating a polygon.
  95452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  95453. * @param name defines the name of the mesh to create
  95454. * @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
  95455. * @param scene defines the hosting scene
  95456. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95457. * @param updatable defines if the mesh must be flagged as updatable
  95458. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95459. * @param earcutInjection can be used to inject your own earcut reference
  95460. * @returns a new Mesh
  95461. */
  95462. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95463. /**
  95464. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  95465. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  95466. * @param name defines the name of the mesh to create
  95467. * @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
  95468. * @param depth defines the height of extrusion
  95469. * @param scene defines the hosting scene
  95470. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95471. * @param updatable defines if the mesh must be flagged as updatable
  95472. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95473. * @param earcutInjection can be used to inject your own earcut reference
  95474. * @returns a new Mesh
  95475. */
  95476. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95477. /**
  95478. * Creates an extruded shape mesh.
  95479. * 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
  95480. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95481. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95482. * @param name defines the name of the mesh to create
  95483. * @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
  95484. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95485. * @param scale is the value to scale the shape
  95486. * @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
  95487. * @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
  95488. * @param scene defines the hosting scene
  95489. * @param updatable defines if the mesh must be flagged as updatable
  95490. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95491. * @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)
  95492. * @returns a new Mesh
  95493. */
  95494. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95495. /**
  95496. * Creates an custom extruded shape mesh.
  95497. * The custom extrusion is a parametric shape.
  95498. * It has no predefined shape. Its final shape will depend on the input parameters.
  95499. * Please consider using the same method from the MeshBuilder class instead
  95500. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95501. * @param name defines the name of the mesh to create
  95502. * @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
  95503. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95504. * @param scaleFunction is a custom Javascript function called on each path point
  95505. * @param rotationFunction is a custom Javascript function called on each path point
  95506. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  95507. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  95508. * @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
  95509. * @param scene defines the hosting scene
  95510. * @param updatable defines if the mesh must be flagged as updatable
  95511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95512. * @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)
  95513. * @returns a new Mesh
  95514. */
  95515. 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;
  95516. /**
  95517. * Creates lathe mesh.
  95518. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  95519. * Please consider using the same method from the MeshBuilder class instead
  95520. * @param name defines the name of the mesh to create
  95521. * @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
  95522. * @param radius is the radius value of the lathe
  95523. * @param tessellation is the side number of the lathe.
  95524. * @param scene defines the hosting scene
  95525. * @param updatable defines if the mesh must be flagged as updatable
  95526. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95527. * @returns a new Mesh
  95528. */
  95529. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95530. /**
  95531. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  95532. * @param name defines the name of the mesh to create
  95533. * @param size sets the size (float) of both sides of the plane at once (default 1)
  95534. * @param scene defines the hosting scene
  95535. * @param updatable defines if the mesh must be flagged as updatable
  95536. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95537. * @returns a new Mesh
  95538. */
  95539. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95540. /**
  95541. * Creates a ground mesh.
  95542. * Please consider using the same method from the MeshBuilder class instead
  95543. * @param name defines the name of the mesh to create
  95544. * @param width set the width of the ground
  95545. * @param height set the height of the ground
  95546. * @param subdivisions sets the number of subdivisions per side
  95547. * @param scene defines the hosting scene
  95548. * @param updatable defines if the mesh must be flagged as updatable
  95549. * @returns a new Mesh
  95550. */
  95551. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  95552. /**
  95553. * Creates a tiled ground mesh.
  95554. * Please consider using the same method from the MeshBuilder class instead
  95555. * @param name defines the name of the mesh to create
  95556. * @param xmin set the ground minimum X coordinate
  95557. * @param zmin set the ground minimum Y coordinate
  95558. * @param xmax set the ground maximum X coordinate
  95559. * @param zmax set the ground maximum Z coordinate
  95560. * @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
  95561. * @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
  95562. * @param scene defines the hosting scene
  95563. * @param updatable defines if the mesh must be flagged as updatable
  95564. * @returns a new Mesh
  95565. */
  95566. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  95567. w: number;
  95568. h: number;
  95569. }, precision: {
  95570. w: number;
  95571. h: number;
  95572. }, scene: Scene, updatable?: boolean): Mesh;
  95573. /**
  95574. * Creates a ground mesh from a height map.
  95575. * Please consider using the same method from the MeshBuilder class instead
  95576. * @see http://doc.babylonjs.com/babylon101/height_map
  95577. * @param name defines the name of the mesh to create
  95578. * @param url sets the URL of the height map image resource
  95579. * @param width set the ground width size
  95580. * @param height set the ground height size
  95581. * @param subdivisions sets the number of subdivision per side
  95582. * @param minHeight is the minimum altitude on the ground
  95583. * @param maxHeight is the maximum altitude on the ground
  95584. * @param scene defines the hosting scene
  95585. * @param updatable defines if the mesh must be flagged as updatable
  95586. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  95587. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95588. * @returns a new Mesh
  95589. */
  95590. 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;
  95591. /**
  95592. * Creates a tube mesh.
  95593. * The tube is a parametric shape.
  95594. * It has no predefined shape. Its final shape will depend on the input parameters.
  95595. * Please consider using the same method from the MeshBuilder class instead
  95596. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95597. * @param name defines the name of the mesh to create
  95598. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  95599. * @param radius sets the tube radius size
  95600. * @param tessellation is the number of sides on the tubular surface
  95601. * @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
  95602. * @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
  95603. * @param scene defines the hosting scene
  95604. * @param updatable defines if the mesh must be flagged as updatable
  95605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95606. * @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)
  95607. * @returns a new Mesh
  95608. */
  95609. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  95610. (i: number, distance: number): number;
  95611. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95612. /**
  95613. * Creates a polyhedron mesh.
  95614. * Please consider using the same method from the MeshBuilder class instead.
  95615. * * 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
  95616. * * The parameter `size` (positive float, default 1) sets the polygon size
  95617. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  95618. * * 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`
  95619. * * 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
  95620. * * 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)`)
  95621. * * 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
  95622. * * 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
  95623. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95624. * * If you create a double-sided mesh, you can choose what parts of 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
  95625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95626. * @param name defines the name of the mesh to create
  95627. * @param options defines the options used to create the mesh
  95628. * @param scene defines the hosting scene
  95629. * @returns a new Mesh
  95630. */
  95631. static CreatePolyhedron(name: string, options: {
  95632. type?: number;
  95633. size?: number;
  95634. sizeX?: number;
  95635. sizeY?: number;
  95636. sizeZ?: number;
  95637. custom?: any;
  95638. faceUV?: Vector4[];
  95639. faceColors?: Color4[];
  95640. updatable?: boolean;
  95641. sideOrientation?: number;
  95642. }, scene: Scene): Mesh;
  95643. /**
  95644. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  95645. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  95646. * * 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`)
  95647. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  95648. * * 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
  95649. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95650. * * If you create a double-sided mesh, you can choose what parts of 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
  95651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95652. * @param name defines the name of the mesh
  95653. * @param options defines the options used to create the mesh
  95654. * @param scene defines the hosting scene
  95655. * @returns a new Mesh
  95656. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  95657. */
  95658. static CreateIcoSphere(name: string, options: {
  95659. radius?: number;
  95660. flat?: boolean;
  95661. subdivisions?: number;
  95662. sideOrientation?: number;
  95663. updatable?: boolean;
  95664. }, scene: Scene): Mesh;
  95665. /**
  95666. * Creates a decal mesh.
  95667. * Please consider using the same method from the MeshBuilder class instead.
  95668. * A decal is a mesh usually applied as a model onto the surface of another mesh
  95669. * @param name defines the name of the mesh
  95670. * @param sourceMesh defines the mesh receiving the decal
  95671. * @param position sets the position of the decal in world coordinates
  95672. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  95673. * @param size sets the decal scaling
  95674. * @param angle sets the angle to rotate the decal
  95675. * @returns a new Mesh
  95676. */
  95677. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  95678. /**
  95679. * Prepare internal position array for software CPU skinning
  95680. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  95681. */
  95682. setPositionsForCPUSkinning(): Float32Array;
  95683. /**
  95684. * Prepare internal normal array for software CPU skinning
  95685. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  95686. */
  95687. setNormalsForCPUSkinning(): Float32Array;
  95688. /**
  95689. * Updates the vertex buffer by applying transformation from the bones
  95690. * @param skeleton defines the skeleton to apply to current mesh
  95691. * @returns the current mesh
  95692. */
  95693. applySkeleton(skeleton: Skeleton): Mesh;
  95694. /**
  95695. * 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
  95696. * @param meshes defines the list of meshes to scan
  95697. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  95698. */
  95699. static MinMax(meshes: AbstractMesh[]): {
  95700. min: Vector3;
  95701. max: Vector3;
  95702. };
  95703. /**
  95704. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  95705. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  95706. * @returns a vector3
  95707. */
  95708. static Center(meshesOrMinMaxVector: {
  95709. min: Vector3;
  95710. max: Vector3;
  95711. } | AbstractMesh[]): Vector3;
  95712. /**
  95713. * Merge the array of meshes into a single mesh for performance reasons.
  95714. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  95715. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  95716. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  95717. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  95718. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  95719. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  95720. * @returns a new mesh
  95721. */
  95722. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  95723. /** @hidden */
  95724. addInstance(instance: InstancedMesh): void;
  95725. /** @hidden */
  95726. removeInstance(instance: InstancedMesh): void;
  95727. }
  95728. }
  95729. declare module BABYLON {
  95730. /**
  95731. * This is the base class of all the camera used in the application.
  95732. * @see http://doc.babylonjs.com/features/cameras
  95733. */
  95734. export class Camera extends Node {
  95735. /** @hidden */
  95736. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  95737. /**
  95738. * This is the default projection mode used by the cameras.
  95739. * It helps recreating a feeling of perspective and better appreciate depth.
  95740. * This is the best way to simulate real life cameras.
  95741. */
  95742. static readonly PERSPECTIVE_CAMERA: number;
  95743. /**
  95744. * This helps creating camera with an orthographic mode.
  95745. * 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.
  95746. */
  95747. static readonly ORTHOGRAPHIC_CAMERA: number;
  95748. /**
  95749. * This is the default FOV mode for perspective cameras.
  95750. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  95751. */
  95752. static readonly FOVMODE_VERTICAL_FIXED: number;
  95753. /**
  95754. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  95755. */
  95756. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  95757. /**
  95758. * This specifies ther is no need for a camera rig.
  95759. * Basically only one eye is rendered corresponding to the camera.
  95760. */
  95761. static readonly RIG_MODE_NONE: number;
  95762. /**
  95763. * Simulates a camera Rig with one blue eye and one red eye.
  95764. * This can be use with 3d blue and red glasses.
  95765. */
  95766. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  95767. /**
  95768. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  95769. */
  95770. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  95771. /**
  95772. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  95773. */
  95774. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  95775. /**
  95776. * Defines that both eyes of the camera will be rendered over under each other.
  95777. */
  95778. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  95779. /**
  95780. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  95781. */
  95782. static readonly RIG_MODE_VR: number;
  95783. /**
  95784. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  95785. */
  95786. static readonly RIG_MODE_WEBVR: number;
  95787. /**
  95788. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  95789. */
  95790. static readonly RIG_MODE_CUSTOM: number;
  95791. /**
  95792. * Defines if by default attaching controls should prevent the default javascript event to continue.
  95793. */
  95794. static ForceAttachControlToAlwaysPreventDefault: boolean;
  95795. /**
  95796. * Define the input manager associated with the camera.
  95797. */
  95798. inputs: CameraInputsManager<Camera>;
  95799. /** @hidden */
  95800. _position: Vector3;
  95801. /**
  95802. * Define the current local position of the camera in the scene
  95803. */
  95804. get position(): Vector3;
  95805. set position(newPosition: Vector3);
  95806. /**
  95807. * The vector the camera should consider as up.
  95808. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  95809. */
  95810. upVector: Vector3;
  95811. /**
  95812. * Define the current limit on the left side for an orthographic camera
  95813. * In scene unit
  95814. */
  95815. orthoLeft: Nullable<number>;
  95816. /**
  95817. * Define the current limit on the right side for an orthographic camera
  95818. * In scene unit
  95819. */
  95820. orthoRight: Nullable<number>;
  95821. /**
  95822. * Define the current limit on the bottom side for an orthographic camera
  95823. * In scene unit
  95824. */
  95825. orthoBottom: Nullable<number>;
  95826. /**
  95827. * Define the current limit on the top side for an orthographic camera
  95828. * In scene unit
  95829. */
  95830. orthoTop: Nullable<number>;
  95831. /**
  95832. * Field Of View is set in Radians. (default is 0.8)
  95833. */
  95834. fov: number;
  95835. /**
  95836. * Define the minimum distance the camera can see from.
  95837. * This is important to note that the depth buffer are not infinite and the closer it starts
  95838. * the more your scene might encounter depth fighting issue.
  95839. */
  95840. minZ: number;
  95841. /**
  95842. * Define the maximum distance the camera can see to.
  95843. * This is important to note that the depth buffer are not infinite and the further it end
  95844. * the more your scene might encounter depth fighting issue.
  95845. */
  95846. maxZ: number;
  95847. /**
  95848. * Define the default inertia of the camera.
  95849. * This helps giving a smooth feeling to the camera movement.
  95850. */
  95851. inertia: number;
  95852. /**
  95853. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  95854. */
  95855. mode: number;
  95856. /**
  95857. * Define wether the camera is intermediate.
  95858. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  95859. */
  95860. isIntermediate: boolean;
  95861. /**
  95862. * Define the viewport of the camera.
  95863. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  95864. */
  95865. viewport: Viewport;
  95866. /**
  95867. * Restricts the camera to viewing objects with the same layerMask.
  95868. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  95869. */
  95870. layerMask: number;
  95871. /**
  95872. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  95873. */
  95874. fovMode: number;
  95875. /**
  95876. * Rig mode of the camera.
  95877. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  95878. * This is normally controlled byt the camera themselves as internal use.
  95879. */
  95880. cameraRigMode: number;
  95881. /**
  95882. * Defines the distance between both "eyes" in case of a RIG
  95883. */
  95884. interaxialDistance: number;
  95885. /**
  95886. * Defines if stereoscopic rendering is done side by side or over under.
  95887. */
  95888. isStereoscopicSideBySide: boolean;
  95889. /**
  95890. * 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
  95891. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  95892. * else in the scene. (Eg. security camera)
  95893. *
  95894. * 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)
  95895. */
  95896. customRenderTargets: RenderTargetTexture[];
  95897. /**
  95898. * When set, the camera will render to this render target instead of the default canvas
  95899. *
  95900. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  95901. */
  95902. outputRenderTarget: Nullable<RenderTargetTexture>;
  95903. /**
  95904. * Observable triggered when the camera view matrix has changed.
  95905. */
  95906. onViewMatrixChangedObservable: Observable<Camera>;
  95907. /**
  95908. * Observable triggered when the camera Projection matrix has changed.
  95909. */
  95910. onProjectionMatrixChangedObservable: Observable<Camera>;
  95911. /**
  95912. * Observable triggered when the inputs have been processed.
  95913. */
  95914. onAfterCheckInputsObservable: Observable<Camera>;
  95915. /**
  95916. * Observable triggered when reset has been called and applied to the camera.
  95917. */
  95918. onRestoreStateObservable: Observable<Camera>;
  95919. /** @hidden */
  95920. _cameraRigParams: any;
  95921. /** @hidden */
  95922. _rigCameras: Camera[];
  95923. /** @hidden */
  95924. _rigPostProcess: Nullable<PostProcess>;
  95925. protected _webvrViewMatrix: Matrix;
  95926. /** @hidden */
  95927. _skipRendering: boolean;
  95928. /** @hidden */
  95929. _projectionMatrix: Matrix;
  95930. /** @hidden */
  95931. _postProcesses: Nullable<PostProcess>[];
  95932. /** @hidden */
  95933. _activeMeshes: SmartArray<AbstractMesh>;
  95934. protected _globalPosition: Vector3;
  95935. /** @hidden */
  95936. _computedViewMatrix: Matrix;
  95937. private _doNotComputeProjectionMatrix;
  95938. private _transformMatrix;
  95939. private _frustumPlanes;
  95940. private _refreshFrustumPlanes;
  95941. private _storedFov;
  95942. private _stateStored;
  95943. /**
  95944. * Instantiates a new camera object.
  95945. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  95946. * @see http://doc.babylonjs.com/features/cameras
  95947. * @param name Defines the name of the camera in the scene
  95948. * @param position Defines the position of the camera
  95949. * @param scene Defines the scene the camera belongs too
  95950. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  95951. */
  95952. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95953. /**
  95954. * Store current camera state (fov, position, etc..)
  95955. * @returns the camera
  95956. */
  95957. storeState(): Camera;
  95958. /**
  95959. * Restores the camera state values if it has been stored. You must call storeState() first
  95960. */
  95961. protected _restoreStateValues(): boolean;
  95962. /**
  95963. * Restored camera state. You must call storeState() first.
  95964. * @returns true if restored and false otherwise
  95965. */
  95966. restoreState(): boolean;
  95967. /**
  95968. * Gets the class name of the camera.
  95969. * @returns the class name
  95970. */
  95971. getClassName(): string;
  95972. /** @hidden */
  95973. readonly _isCamera: boolean;
  95974. /**
  95975. * Gets a string representation of the camera useful for debug purpose.
  95976. * @param fullDetails Defines that a more verboe level of logging is required
  95977. * @returns the string representation
  95978. */
  95979. toString(fullDetails?: boolean): string;
  95980. /**
  95981. * Gets the current world space position of the camera.
  95982. */
  95983. get globalPosition(): Vector3;
  95984. /**
  95985. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  95986. * @returns the active meshe list
  95987. */
  95988. getActiveMeshes(): SmartArray<AbstractMesh>;
  95989. /**
  95990. * Check wether a mesh is part of the current active mesh list of the camera
  95991. * @param mesh Defines the mesh to check
  95992. * @returns true if active, false otherwise
  95993. */
  95994. isActiveMesh(mesh: Mesh): boolean;
  95995. /**
  95996. * Is this camera ready to be used/rendered
  95997. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  95998. * @return true if the camera is ready
  95999. */
  96000. isReady(completeCheck?: boolean): boolean;
  96001. /** @hidden */
  96002. _initCache(): void;
  96003. /** @hidden */
  96004. _updateCache(ignoreParentClass?: boolean): void;
  96005. /** @hidden */
  96006. _isSynchronized(): boolean;
  96007. /** @hidden */
  96008. _isSynchronizedViewMatrix(): boolean;
  96009. /** @hidden */
  96010. _isSynchronizedProjectionMatrix(): boolean;
  96011. /**
  96012. * Attach the input controls to a specific dom element to get the input from.
  96013. * @param element Defines the element the controls should be listened from
  96014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96015. */
  96016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96017. /**
  96018. * Detach the current controls from the specified dom element.
  96019. * @param element Defines the element to stop listening the inputs from
  96020. */
  96021. detachControl(element: HTMLElement): void;
  96022. /**
  96023. * Update the camera state according to the different inputs gathered during the frame.
  96024. */
  96025. update(): void;
  96026. /** @hidden */
  96027. _checkInputs(): void;
  96028. /** @hidden */
  96029. get rigCameras(): Camera[];
  96030. /**
  96031. * Gets the post process used by the rig cameras
  96032. */
  96033. get rigPostProcess(): Nullable<PostProcess>;
  96034. /**
  96035. * Internal, gets the first post proces.
  96036. * @returns the first post process to be run on this camera.
  96037. */
  96038. _getFirstPostProcess(): Nullable<PostProcess>;
  96039. private _cascadePostProcessesToRigCams;
  96040. /**
  96041. * Attach a post process to the camera.
  96042. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96043. * @param postProcess The post process to attach to the camera
  96044. * @param insertAt The position of the post process in case several of them are in use in the scene
  96045. * @returns the position the post process has been inserted at
  96046. */
  96047. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96048. /**
  96049. * Detach a post process to the camera.
  96050. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96051. * @param postProcess The post process to detach from the camera
  96052. */
  96053. detachPostProcess(postProcess: PostProcess): void;
  96054. /**
  96055. * Gets the current world matrix of the camera
  96056. */
  96057. getWorldMatrix(): Matrix;
  96058. /** @hidden */
  96059. _getViewMatrix(): Matrix;
  96060. /**
  96061. * Gets the current view matrix of the camera.
  96062. * @param force forces the camera to recompute the matrix without looking at the cached state
  96063. * @returns the view matrix
  96064. */
  96065. getViewMatrix(force?: boolean): Matrix;
  96066. /**
  96067. * Freeze the projection matrix.
  96068. * It will prevent the cache check of the camera projection compute and can speed up perf
  96069. * if no parameter of the camera are meant to change
  96070. * @param projection Defines manually a projection if necessary
  96071. */
  96072. freezeProjectionMatrix(projection?: Matrix): void;
  96073. /**
  96074. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96075. */
  96076. unfreezeProjectionMatrix(): void;
  96077. /**
  96078. * Gets the current projection matrix of the camera.
  96079. * @param force forces the camera to recompute the matrix without looking at the cached state
  96080. * @returns the projection matrix
  96081. */
  96082. getProjectionMatrix(force?: boolean): Matrix;
  96083. /**
  96084. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96085. * @returns a Matrix
  96086. */
  96087. getTransformationMatrix(): Matrix;
  96088. private _updateFrustumPlanes;
  96089. /**
  96090. * Checks if a cullable object (mesh...) is in the camera frustum
  96091. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96092. * @param target The object to check
  96093. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96094. * @returns true if the object is in frustum otherwise false
  96095. */
  96096. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96097. /**
  96098. * Checks if a cullable object (mesh...) is in the camera frustum
  96099. * Unlike isInFrustum this cheks the full bounding box
  96100. * @param target The object to check
  96101. * @returns true if the object is in frustum otherwise false
  96102. */
  96103. isCompletelyInFrustum(target: ICullable): boolean;
  96104. /**
  96105. * Gets a ray in the forward direction from the camera.
  96106. * @param length Defines the length of the ray to create
  96107. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96108. * @param origin Defines the start point of the ray which defaults to the camera position
  96109. * @returns the forward ray
  96110. */
  96111. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96112. /**
  96113. * Releases resources associated with this node.
  96114. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96115. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96116. */
  96117. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96118. /** @hidden */
  96119. _isLeftCamera: boolean;
  96120. /**
  96121. * Gets the left camera of a rig setup in case of Rigged Camera
  96122. */
  96123. get isLeftCamera(): boolean;
  96124. /** @hidden */
  96125. _isRightCamera: boolean;
  96126. /**
  96127. * Gets the right camera of a rig setup in case of Rigged Camera
  96128. */
  96129. get isRightCamera(): boolean;
  96130. /**
  96131. * Gets the left camera of a rig setup in case of Rigged Camera
  96132. */
  96133. get leftCamera(): Nullable<FreeCamera>;
  96134. /**
  96135. * Gets the right camera of a rig setup in case of Rigged Camera
  96136. */
  96137. get rightCamera(): Nullable<FreeCamera>;
  96138. /**
  96139. * Gets the left camera target of a rig setup in case of Rigged Camera
  96140. * @returns the target position
  96141. */
  96142. getLeftTarget(): Nullable<Vector3>;
  96143. /**
  96144. * Gets the right camera target of a rig setup in case of Rigged Camera
  96145. * @returns the target position
  96146. */
  96147. getRightTarget(): Nullable<Vector3>;
  96148. /**
  96149. * @hidden
  96150. */
  96151. setCameraRigMode(mode: number, rigParams: any): void;
  96152. /** @hidden */
  96153. static _setStereoscopicRigMode(camera: Camera): void;
  96154. /** @hidden */
  96155. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  96156. /** @hidden */
  96157. static _setVRRigMode(camera: Camera, rigParams: any): void;
  96158. /** @hidden */
  96159. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  96160. /** @hidden */
  96161. _getVRProjectionMatrix(): Matrix;
  96162. protected _updateCameraRotationMatrix(): void;
  96163. protected _updateWebVRCameraRotationMatrix(): void;
  96164. /**
  96165. * This function MUST be overwritten by the different WebVR cameras available.
  96166. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96167. * @hidden
  96168. */
  96169. _getWebVRProjectionMatrix(): Matrix;
  96170. /**
  96171. * This function MUST be overwritten by the different WebVR cameras available.
  96172. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96173. * @hidden
  96174. */
  96175. _getWebVRViewMatrix(): Matrix;
  96176. /** @hidden */
  96177. setCameraRigParameter(name: string, value: any): void;
  96178. /**
  96179. * needs to be overridden by children so sub has required properties to be copied
  96180. * @hidden
  96181. */
  96182. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96183. /**
  96184. * May need to be overridden by children
  96185. * @hidden
  96186. */
  96187. _updateRigCameras(): void;
  96188. /** @hidden */
  96189. _setupInputs(): void;
  96190. /**
  96191. * Serialiaze the camera setup to a json represention
  96192. * @returns the JSON representation
  96193. */
  96194. serialize(): any;
  96195. /**
  96196. * Clones the current camera.
  96197. * @param name The cloned camera name
  96198. * @returns the cloned camera
  96199. */
  96200. clone(name: string): Camera;
  96201. /**
  96202. * Gets the direction of the camera relative to a given local axis.
  96203. * @param localAxis Defines the reference axis to provide a relative direction.
  96204. * @return the direction
  96205. */
  96206. getDirection(localAxis: Vector3): Vector3;
  96207. /**
  96208. * Returns the current camera absolute rotation
  96209. */
  96210. get absoluteRotation(): Quaternion;
  96211. /**
  96212. * Gets the direction of the camera relative to a given local axis into a passed vector.
  96213. * @param localAxis Defines the reference axis to provide a relative direction.
  96214. * @param result Defines the vector to store the result in
  96215. */
  96216. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  96217. /**
  96218. * Gets a camera constructor for a given camera type
  96219. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  96220. * @param name The name of the camera the result will be able to instantiate
  96221. * @param scene The scene the result will construct the camera in
  96222. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  96223. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  96224. * @returns a factory method to construc the camera
  96225. */
  96226. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  96227. /**
  96228. * Compute the world matrix of the camera.
  96229. * @returns the camera world matrix
  96230. */
  96231. computeWorldMatrix(): Matrix;
  96232. /**
  96233. * Parse a JSON and creates the camera from the parsed information
  96234. * @param parsedCamera The JSON to parse
  96235. * @param scene The scene to instantiate the camera in
  96236. * @returns the newly constructed camera
  96237. */
  96238. static Parse(parsedCamera: any, scene: Scene): Camera;
  96239. }
  96240. }
  96241. declare module BABYLON {
  96242. /**
  96243. * Class containing static functions to help procedurally build meshes
  96244. */
  96245. export class DiscBuilder {
  96246. /**
  96247. * Creates a plane polygonal mesh. By default, this is a disc
  96248. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  96249. * * 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
  96250. * * 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
  96251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96254. * @param name defines the name of the mesh
  96255. * @param options defines the options used to create the mesh
  96256. * @param scene defines the hosting scene
  96257. * @returns the plane polygonal mesh
  96258. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  96259. */
  96260. static CreateDisc(name: string, options: {
  96261. radius?: number;
  96262. tessellation?: number;
  96263. arc?: number;
  96264. updatable?: boolean;
  96265. sideOrientation?: number;
  96266. frontUVs?: Vector4;
  96267. backUVs?: Vector4;
  96268. }, scene?: Nullable<Scene>): Mesh;
  96269. }
  96270. }
  96271. declare module BABYLON {
  96272. /**
  96273. * This represents all the required information to add a fresnel effect on a material:
  96274. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96275. */
  96276. export class FresnelParameters {
  96277. private _isEnabled;
  96278. /**
  96279. * Define if the fresnel effect is enable or not.
  96280. */
  96281. get isEnabled(): boolean;
  96282. set isEnabled(value: boolean);
  96283. /**
  96284. * Define the color used on edges (grazing angle)
  96285. */
  96286. leftColor: Color3;
  96287. /**
  96288. * Define the color used on center
  96289. */
  96290. rightColor: Color3;
  96291. /**
  96292. * Define bias applied to computed fresnel term
  96293. */
  96294. bias: number;
  96295. /**
  96296. * Defined the power exponent applied to fresnel term
  96297. */
  96298. power: number;
  96299. /**
  96300. * Clones the current fresnel and its valuues
  96301. * @returns a clone fresnel configuration
  96302. */
  96303. clone(): FresnelParameters;
  96304. /**
  96305. * Serializes the current fresnel parameters to a JSON representation.
  96306. * @return the JSON serialization
  96307. */
  96308. serialize(): any;
  96309. /**
  96310. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96311. * @param parsedFresnelParameters Define the JSON representation
  96312. * @returns the parsed parameters
  96313. */
  96314. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96315. }
  96316. }
  96317. declare module BABYLON {
  96318. /**
  96319. * Base class of materials working in push mode in babylon JS
  96320. * @hidden
  96321. */
  96322. export class PushMaterial extends Material {
  96323. protected _activeEffect: Effect;
  96324. protected _normalMatrix: Matrix;
  96325. /**
  96326. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96327. * This means that the material can keep using a previous shader while a new one is being compiled.
  96328. * This is mostly used when shader parallel compilation is supported (true by default)
  96329. */
  96330. allowShaderHotSwapping: boolean;
  96331. constructor(name: string, scene: Scene);
  96332. getEffect(): Effect;
  96333. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96334. /**
  96335. * Binds the given world matrix to the active effect
  96336. *
  96337. * @param world the matrix to bind
  96338. */
  96339. bindOnlyWorldMatrix(world: Matrix): void;
  96340. /**
  96341. * Binds the given normal matrix to the active effect
  96342. *
  96343. * @param normalMatrix the matrix to bind
  96344. */
  96345. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96346. bind(world: Matrix, mesh?: Mesh): void;
  96347. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96348. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96349. }
  96350. }
  96351. declare module BABYLON {
  96352. /**
  96353. * This groups all the flags used to control the materials channel.
  96354. */
  96355. export class MaterialFlags {
  96356. private static _DiffuseTextureEnabled;
  96357. /**
  96358. * Are diffuse textures enabled in the application.
  96359. */
  96360. static get DiffuseTextureEnabled(): boolean;
  96361. static set DiffuseTextureEnabled(value: boolean);
  96362. private static _AmbientTextureEnabled;
  96363. /**
  96364. * Are ambient textures enabled in the application.
  96365. */
  96366. static get AmbientTextureEnabled(): boolean;
  96367. static set AmbientTextureEnabled(value: boolean);
  96368. private static _OpacityTextureEnabled;
  96369. /**
  96370. * Are opacity textures enabled in the application.
  96371. */
  96372. static get OpacityTextureEnabled(): boolean;
  96373. static set OpacityTextureEnabled(value: boolean);
  96374. private static _ReflectionTextureEnabled;
  96375. /**
  96376. * Are reflection textures enabled in the application.
  96377. */
  96378. static get ReflectionTextureEnabled(): boolean;
  96379. static set ReflectionTextureEnabled(value: boolean);
  96380. private static _EmissiveTextureEnabled;
  96381. /**
  96382. * Are emissive textures enabled in the application.
  96383. */
  96384. static get EmissiveTextureEnabled(): boolean;
  96385. static set EmissiveTextureEnabled(value: boolean);
  96386. private static _SpecularTextureEnabled;
  96387. /**
  96388. * Are specular textures enabled in the application.
  96389. */
  96390. static get SpecularTextureEnabled(): boolean;
  96391. static set SpecularTextureEnabled(value: boolean);
  96392. private static _BumpTextureEnabled;
  96393. /**
  96394. * Are bump textures enabled in the application.
  96395. */
  96396. static get BumpTextureEnabled(): boolean;
  96397. static set BumpTextureEnabled(value: boolean);
  96398. private static _LightmapTextureEnabled;
  96399. /**
  96400. * Are lightmap textures enabled in the application.
  96401. */
  96402. static get LightmapTextureEnabled(): boolean;
  96403. static set LightmapTextureEnabled(value: boolean);
  96404. private static _RefractionTextureEnabled;
  96405. /**
  96406. * Are refraction textures enabled in the application.
  96407. */
  96408. static get RefractionTextureEnabled(): boolean;
  96409. static set RefractionTextureEnabled(value: boolean);
  96410. private static _ColorGradingTextureEnabled;
  96411. /**
  96412. * Are color grading textures enabled in the application.
  96413. */
  96414. static get ColorGradingTextureEnabled(): boolean;
  96415. static set ColorGradingTextureEnabled(value: boolean);
  96416. private static _FresnelEnabled;
  96417. /**
  96418. * Are fresnels enabled in the application.
  96419. */
  96420. static get FresnelEnabled(): boolean;
  96421. static set FresnelEnabled(value: boolean);
  96422. private static _ClearCoatTextureEnabled;
  96423. /**
  96424. * Are clear coat textures enabled in the application.
  96425. */
  96426. static get ClearCoatTextureEnabled(): boolean;
  96427. static set ClearCoatTextureEnabled(value: boolean);
  96428. private static _ClearCoatBumpTextureEnabled;
  96429. /**
  96430. * Are clear coat bump textures enabled in the application.
  96431. */
  96432. static get ClearCoatBumpTextureEnabled(): boolean;
  96433. static set ClearCoatBumpTextureEnabled(value: boolean);
  96434. private static _ClearCoatTintTextureEnabled;
  96435. /**
  96436. * Are clear coat tint textures enabled in the application.
  96437. */
  96438. static get ClearCoatTintTextureEnabled(): boolean;
  96439. static set ClearCoatTintTextureEnabled(value: boolean);
  96440. private static _SheenTextureEnabled;
  96441. /**
  96442. * Are sheen textures enabled in the application.
  96443. */
  96444. static get SheenTextureEnabled(): boolean;
  96445. static set SheenTextureEnabled(value: boolean);
  96446. private static _AnisotropicTextureEnabled;
  96447. /**
  96448. * Are anisotropic textures enabled in the application.
  96449. */
  96450. static get AnisotropicTextureEnabled(): boolean;
  96451. static set AnisotropicTextureEnabled(value: boolean);
  96452. private static _ThicknessTextureEnabled;
  96453. /**
  96454. * Are thickness textures enabled in the application.
  96455. */
  96456. static get ThicknessTextureEnabled(): boolean;
  96457. static set ThicknessTextureEnabled(value: boolean);
  96458. }
  96459. }
  96460. declare module BABYLON {
  96461. /** @hidden */
  96462. export var defaultFragmentDeclaration: {
  96463. name: string;
  96464. shader: string;
  96465. };
  96466. }
  96467. declare module BABYLON {
  96468. /** @hidden */
  96469. export var defaultUboDeclaration: {
  96470. name: string;
  96471. shader: string;
  96472. };
  96473. }
  96474. declare module BABYLON {
  96475. /** @hidden */
  96476. export var lightFragmentDeclaration: {
  96477. name: string;
  96478. shader: string;
  96479. };
  96480. }
  96481. declare module BABYLON {
  96482. /** @hidden */
  96483. export var lightUboDeclaration: {
  96484. name: string;
  96485. shader: string;
  96486. };
  96487. }
  96488. declare module BABYLON {
  96489. /** @hidden */
  96490. export var lightsFragmentFunctions: {
  96491. name: string;
  96492. shader: string;
  96493. };
  96494. }
  96495. declare module BABYLON {
  96496. /** @hidden */
  96497. export var shadowsFragmentFunctions: {
  96498. name: string;
  96499. shader: string;
  96500. };
  96501. }
  96502. declare module BABYLON {
  96503. /** @hidden */
  96504. export var fresnelFunction: {
  96505. name: string;
  96506. shader: string;
  96507. };
  96508. }
  96509. declare module BABYLON {
  96510. /** @hidden */
  96511. export var reflectionFunction: {
  96512. name: string;
  96513. shader: string;
  96514. };
  96515. }
  96516. declare module BABYLON {
  96517. /** @hidden */
  96518. export var bumpFragmentFunctions: {
  96519. name: string;
  96520. shader: string;
  96521. };
  96522. }
  96523. declare module BABYLON {
  96524. /** @hidden */
  96525. export var logDepthDeclaration: {
  96526. name: string;
  96527. shader: string;
  96528. };
  96529. }
  96530. declare module BABYLON {
  96531. /** @hidden */
  96532. export var bumpFragment: {
  96533. name: string;
  96534. shader: string;
  96535. };
  96536. }
  96537. declare module BABYLON {
  96538. /** @hidden */
  96539. export var depthPrePass: {
  96540. name: string;
  96541. shader: string;
  96542. };
  96543. }
  96544. declare module BABYLON {
  96545. /** @hidden */
  96546. export var lightFragment: {
  96547. name: string;
  96548. shader: string;
  96549. };
  96550. }
  96551. declare module BABYLON {
  96552. /** @hidden */
  96553. export var logDepthFragment: {
  96554. name: string;
  96555. shader: string;
  96556. };
  96557. }
  96558. declare module BABYLON {
  96559. /** @hidden */
  96560. export var defaultPixelShader: {
  96561. name: string;
  96562. shader: string;
  96563. };
  96564. }
  96565. declare module BABYLON {
  96566. /** @hidden */
  96567. export var defaultVertexDeclaration: {
  96568. name: string;
  96569. shader: string;
  96570. };
  96571. }
  96572. declare module BABYLON {
  96573. /** @hidden */
  96574. export var bumpVertexDeclaration: {
  96575. name: string;
  96576. shader: string;
  96577. };
  96578. }
  96579. declare module BABYLON {
  96580. /** @hidden */
  96581. export var bumpVertex: {
  96582. name: string;
  96583. shader: string;
  96584. };
  96585. }
  96586. declare module BABYLON {
  96587. /** @hidden */
  96588. export var fogVertex: {
  96589. name: string;
  96590. shader: string;
  96591. };
  96592. }
  96593. declare module BABYLON {
  96594. /** @hidden */
  96595. export var shadowsVertex: {
  96596. name: string;
  96597. shader: string;
  96598. };
  96599. }
  96600. declare module BABYLON {
  96601. /** @hidden */
  96602. export var pointCloudVertex: {
  96603. name: string;
  96604. shader: string;
  96605. };
  96606. }
  96607. declare module BABYLON {
  96608. /** @hidden */
  96609. export var logDepthVertex: {
  96610. name: string;
  96611. shader: string;
  96612. };
  96613. }
  96614. declare module BABYLON {
  96615. /** @hidden */
  96616. export var defaultVertexShader: {
  96617. name: string;
  96618. shader: string;
  96619. };
  96620. }
  96621. declare module BABYLON {
  96622. /** @hidden */
  96623. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96624. MAINUV1: boolean;
  96625. MAINUV2: boolean;
  96626. DIFFUSE: boolean;
  96627. DIFFUSEDIRECTUV: number;
  96628. AMBIENT: boolean;
  96629. AMBIENTDIRECTUV: number;
  96630. OPACITY: boolean;
  96631. OPACITYDIRECTUV: number;
  96632. OPACITYRGB: boolean;
  96633. REFLECTION: boolean;
  96634. EMISSIVE: boolean;
  96635. EMISSIVEDIRECTUV: number;
  96636. SPECULAR: boolean;
  96637. SPECULARDIRECTUV: number;
  96638. BUMP: boolean;
  96639. BUMPDIRECTUV: number;
  96640. PARALLAX: boolean;
  96641. PARALLAXOCCLUSION: boolean;
  96642. SPECULAROVERALPHA: boolean;
  96643. CLIPPLANE: boolean;
  96644. CLIPPLANE2: boolean;
  96645. CLIPPLANE3: boolean;
  96646. CLIPPLANE4: boolean;
  96647. ALPHATEST: boolean;
  96648. DEPTHPREPASS: boolean;
  96649. ALPHAFROMDIFFUSE: boolean;
  96650. POINTSIZE: boolean;
  96651. FOG: boolean;
  96652. SPECULARTERM: boolean;
  96653. DIFFUSEFRESNEL: boolean;
  96654. OPACITYFRESNEL: boolean;
  96655. REFLECTIONFRESNEL: boolean;
  96656. REFRACTIONFRESNEL: boolean;
  96657. EMISSIVEFRESNEL: boolean;
  96658. FRESNEL: boolean;
  96659. NORMAL: boolean;
  96660. UV1: boolean;
  96661. UV2: boolean;
  96662. VERTEXCOLOR: boolean;
  96663. VERTEXALPHA: boolean;
  96664. NUM_BONE_INFLUENCERS: number;
  96665. BonesPerMesh: number;
  96666. BONETEXTURE: boolean;
  96667. INSTANCES: boolean;
  96668. GLOSSINESS: boolean;
  96669. ROUGHNESS: boolean;
  96670. EMISSIVEASILLUMINATION: boolean;
  96671. LINKEMISSIVEWITHDIFFUSE: boolean;
  96672. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96673. LIGHTMAP: boolean;
  96674. LIGHTMAPDIRECTUV: number;
  96675. OBJECTSPACE_NORMALMAP: boolean;
  96676. USELIGHTMAPASSHADOWMAP: boolean;
  96677. REFLECTIONMAP_3D: boolean;
  96678. REFLECTIONMAP_SPHERICAL: boolean;
  96679. REFLECTIONMAP_PLANAR: boolean;
  96680. REFLECTIONMAP_CUBIC: boolean;
  96681. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96682. REFLECTIONMAP_PROJECTION: boolean;
  96683. REFLECTIONMAP_SKYBOX: boolean;
  96684. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96685. REFLECTIONMAP_EXPLICIT: boolean;
  96686. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96687. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96688. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96689. INVERTCUBICMAP: boolean;
  96690. LOGARITHMICDEPTH: boolean;
  96691. REFRACTION: boolean;
  96692. REFRACTIONMAP_3D: boolean;
  96693. REFLECTIONOVERALPHA: boolean;
  96694. TWOSIDEDLIGHTING: boolean;
  96695. SHADOWFLOAT: boolean;
  96696. MORPHTARGETS: boolean;
  96697. MORPHTARGETS_NORMAL: boolean;
  96698. MORPHTARGETS_TANGENT: boolean;
  96699. MORPHTARGETS_UV: boolean;
  96700. NUM_MORPH_INFLUENCERS: number;
  96701. NONUNIFORMSCALING: boolean;
  96702. PREMULTIPLYALPHA: boolean;
  96703. IMAGEPROCESSING: boolean;
  96704. VIGNETTE: boolean;
  96705. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96706. VIGNETTEBLENDMODEOPAQUE: boolean;
  96707. TONEMAPPING: boolean;
  96708. TONEMAPPING_ACES: boolean;
  96709. CONTRAST: boolean;
  96710. COLORCURVES: boolean;
  96711. COLORGRADING: boolean;
  96712. COLORGRADING3D: boolean;
  96713. SAMPLER3DGREENDEPTH: boolean;
  96714. SAMPLER3DBGRMAP: boolean;
  96715. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96716. MULTIVIEW: boolean;
  96717. /**
  96718. * If the reflection texture on this material is in linear color space
  96719. * @hidden
  96720. */
  96721. IS_REFLECTION_LINEAR: boolean;
  96722. /**
  96723. * If the refraction texture on this material is in linear color space
  96724. * @hidden
  96725. */
  96726. IS_REFRACTION_LINEAR: boolean;
  96727. EXPOSURE: boolean;
  96728. constructor();
  96729. setReflectionMode(modeToEnable: string): void;
  96730. }
  96731. /**
  96732. * This is the default material used in Babylon. It is the best trade off between quality
  96733. * and performances.
  96734. * @see http://doc.babylonjs.com/babylon101/materials
  96735. */
  96736. export class StandardMaterial extends PushMaterial {
  96737. private _diffuseTexture;
  96738. /**
  96739. * The basic texture of the material as viewed under a light.
  96740. */
  96741. diffuseTexture: Nullable<BaseTexture>;
  96742. private _ambientTexture;
  96743. /**
  96744. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96745. */
  96746. ambientTexture: Nullable<BaseTexture>;
  96747. private _opacityTexture;
  96748. /**
  96749. * Define the transparency of the material from a texture.
  96750. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96751. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96752. */
  96753. opacityTexture: Nullable<BaseTexture>;
  96754. private _reflectionTexture;
  96755. /**
  96756. * Define the texture used to display the reflection.
  96757. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96758. */
  96759. reflectionTexture: Nullable<BaseTexture>;
  96760. private _emissiveTexture;
  96761. /**
  96762. * Define texture of the material as if self lit.
  96763. * This will be mixed in the final result even in the absence of light.
  96764. */
  96765. emissiveTexture: Nullable<BaseTexture>;
  96766. private _specularTexture;
  96767. /**
  96768. * Define how the color and intensity of the highlight given by the light in the material.
  96769. */
  96770. specularTexture: Nullable<BaseTexture>;
  96771. private _bumpTexture;
  96772. /**
  96773. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96774. * 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.
  96775. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96776. */
  96777. bumpTexture: Nullable<BaseTexture>;
  96778. private _lightmapTexture;
  96779. /**
  96780. * Complex lighting can be computationally expensive to compute at runtime.
  96781. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96782. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96783. */
  96784. lightmapTexture: Nullable<BaseTexture>;
  96785. private _refractionTexture;
  96786. /**
  96787. * Define the texture used to display the refraction.
  96788. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96789. */
  96790. refractionTexture: Nullable<BaseTexture>;
  96791. /**
  96792. * The color of the material lit by the environmental background lighting.
  96793. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96794. */
  96795. ambientColor: Color3;
  96796. /**
  96797. * The basic color of the material as viewed under a light.
  96798. */
  96799. diffuseColor: Color3;
  96800. /**
  96801. * Define how the color and intensity of the highlight given by the light in the material.
  96802. */
  96803. specularColor: Color3;
  96804. /**
  96805. * Define the color of the material as if self lit.
  96806. * This will be mixed in the final result even in the absence of light.
  96807. */
  96808. emissiveColor: Color3;
  96809. /**
  96810. * Defines how sharp are the highlights in the material.
  96811. * The bigger the value the sharper giving a more glossy feeling to the result.
  96812. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96813. */
  96814. specularPower: number;
  96815. private _useAlphaFromDiffuseTexture;
  96816. /**
  96817. * Does the transparency come from the diffuse texture alpha channel.
  96818. */
  96819. useAlphaFromDiffuseTexture: boolean;
  96820. private _useEmissiveAsIllumination;
  96821. /**
  96822. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96823. */
  96824. useEmissiveAsIllumination: boolean;
  96825. private _linkEmissiveWithDiffuse;
  96826. /**
  96827. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96828. * the emissive level when the final color is close to one.
  96829. */
  96830. linkEmissiveWithDiffuse: boolean;
  96831. private _useSpecularOverAlpha;
  96832. /**
  96833. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96834. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96835. */
  96836. useSpecularOverAlpha: boolean;
  96837. private _useReflectionOverAlpha;
  96838. /**
  96839. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96840. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96841. */
  96842. useReflectionOverAlpha: boolean;
  96843. private _disableLighting;
  96844. /**
  96845. * Does lights from the scene impacts this material.
  96846. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96847. */
  96848. disableLighting: boolean;
  96849. private _useObjectSpaceNormalMap;
  96850. /**
  96851. * Allows using an object space normal map (instead of tangent space).
  96852. */
  96853. useObjectSpaceNormalMap: boolean;
  96854. private _useParallax;
  96855. /**
  96856. * Is parallax enabled or not.
  96857. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96858. */
  96859. useParallax: boolean;
  96860. private _useParallaxOcclusion;
  96861. /**
  96862. * Is parallax occlusion enabled or not.
  96863. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96864. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96865. */
  96866. useParallaxOcclusion: boolean;
  96867. /**
  96868. * 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.
  96869. */
  96870. parallaxScaleBias: number;
  96871. private _roughness;
  96872. /**
  96873. * Helps to define how blurry the reflections should appears in the material.
  96874. */
  96875. roughness: number;
  96876. /**
  96877. * In case of refraction, define the value of the index of refraction.
  96878. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96879. */
  96880. indexOfRefraction: number;
  96881. /**
  96882. * Invert the refraction texture alongside the y axis.
  96883. * It can be useful with procedural textures or probe for instance.
  96884. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96885. */
  96886. invertRefractionY: boolean;
  96887. /**
  96888. * Defines the alpha limits in alpha test mode.
  96889. */
  96890. alphaCutOff: number;
  96891. private _useLightmapAsShadowmap;
  96892. /**
  96893. * In case of light mapping, define whether the map contains light or shadow informations.
  96894. */
  96895. useLightmapAsShadowmap: boolean;
  96896. private _diffuseFresnelParameters;
  96897. /**
  96898. * Define the diffuse fresnel parameters of the material.
  96899. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96900. */
  96901. diffuseFresnelParameters: FresnelParameters;
  96902. private _opacityFresnelParameters;
  96903. /**
  96904. * Define the opacity fresnel parameters of the material.
  96905. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96906. */
  96907. opacityFresnelParameters: FresnelParameters;
  96908. private _reflectionFresnelParameters;
  96909. /**
  96910. * Define the reflection fresnel parameters of the material.
  96911. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96912. */
  96913. reflectionFresnelParameters: FresnelParameters;
  96914. private _refractionFresnelParameters;
  96915. /**
  96916. * Define the refraction fresnel parameters of the material.
  96917. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96918. */
  96919. refractionFresnelParameters: FresnelParameters;
  96920. private _emissiveFresnelParameters;
  96921. /**
  96922. * Define the emissive fresnel parameters of the material.
  96923. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96924. */
  96925. emissiveFresnelParameters: FresnelParameters;
  96926. private _useReflectionFresnelFromSpecular;
  96927. /**
  96928. * If true automatically deducts the fresnels values from the material specularity.
  96929. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96930. */
  96931. useReflectionFresnelFromSpecular: boolean;
  96932. private _useGlossinessFromSpecularMapAlpha;
  96933. /**
  96934. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96935. */
  96936. useGlossinessFromSpecularMapAlpha: boolean;
  96937. private _maxSimultaneousLights;
  96938. /**
  96939. * Defines the maximum number of lights that can be used in the material
  96940. */
  96941. maxSimultaneousLights: number;
  96942. private _invertNormalMapX;
  96943. /**
  96944. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96945. */
  96946. invertNormalMapX: boolean;
  96947. private _invertNormalMapY;
  96948. /**
  96949. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96950. */
  96951. invertNormalMapY: boolean;
  96952. private _twoSidedLighting;
  96953. /**
  96954. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96955. */
  96956. twoSidedLighting: boolean;
  96957. /**
  96958. * Default configuration related to image processing available in the standard Material.
  96959. */
  96960. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96961. /**
  96962. * Gets the image processing configuration used either in this material.
  96963. */
  96964. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  96965. /**
  96966. * Sets the Default image processing configuration used either in the this material.
  96967. *
  96968. * If sets to null, the scene one is in use.
  96969. */
  96970. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  96971. /**
  96972. * Keep track of the image processing observer to allow dispose and replace.
  96973. */
  96974. private _imageProcessingObserver;
  96975. /**
  96976. * Attaches a new image processing configuration to the Standard Material.
  96977. * @param configuration
  96978. */
  96979. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96980. /**
  96981. * Gets wether the color curves effect is enabled.
  96982. */
  96983. get cameraColorCurvesEnabled(): boolean;
  96984. /**
  96985. * Sets wether the color curves effect is enabled.
  96986. */
  96987. set cameraColorCurvesEnabled(value: boolean);
  96988. /**
  96989. * Gets wether the color grading effect is enabled.
  96990. */
  96991. get cameraColorGradingEnabled(): boolean;
  96992. /**
  96993. * Gets wether the color grading effect is enabled.
  96994. */
  96995. set cameraColorGradingEnabled(value: boolean);
  96996. /**
  96997. * Gets wether tonemapping is enabled or not.
  96998. */
  96999. get cameraToneMappingEnabled(): boolean;
  97000. /**
  97001. * Sets wether tonemapping is enabled or not
  97002. */
  97003. set cameraToneMappingEnabled(value: boolean);
  97004. /**
  97005. * The camera exposure used on this material.
  97006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97007. * This corresponds to a photographic exposure.
  97008. */
  97009. get cameraExposure(): number;
  97010. /**
  97011. * The camera exposure used on this material.
  97012. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97013. * This corresponds to a photographic exposure.
  97014. */
  97015. set cameraExposure(value: number);
  97016. /**
  97017. * Gets The camera contrast used on this material.
  97018. */
  97019. get cameraContrast(): number;
  97020. /**
  97021. * Sets The camera contrast used on this material.
  97022. */
  97023. set cameraContrast(value: number);
  97024. /**
  97025. * Gets the Color Grading 2D Lookup Texture.
  97026. */
  97027. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97028. /**
  97029. * Sets the Color Grading 2D Lookup Texture.
  97030. */
  97031. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97032. /**
  97033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97035. * 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;
  97036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97037. */
  97038. get cameraColorCurves(): Nullable<ColorCurves>;
  97039. /**
  97040. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97041. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97042. * 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;
  97043. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97044. */
  97045. set cameraColorCurves(value: Nullable<ColorCurves>);
  97046. /**
  97047. * Custom callback helping to override the default shader used in the material.
  97048. */
  97049. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97050. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97051. protected _worldViewProjectionMatrix: Matrix;
  97052. protected _globalAmbientColor: Color3;
  97053. protected _useLogarithmicDepth: boolean;
  97054. protected _rebuildInParallel: boolean;
  97055. /**
  97056. * Instantiates a new standard material.
  97057. * This is the default material used in Babylon. It is the best trade off between quality
  97058. * and performances.
  97059. * @see http://doc.babylonjs.com/babylon101/materials
  97060. * @param name Define the name of the material in the scene
  97061. * @param scene Define the scene the material belong to
  97062. */
  97063. constructor(name: string, scene: Scene);
  97064. /**
  97065. * Gets a boolean indicating that current material needs to register RTT
  97066. */
  97067. get hasRenderTargetTextures(): boolean;
  97068. /**
  97069. * Gets the current class name of the material e.g. "StandardMaterial"
  97070. * Mainly use in serialization.
  97071. * @returns the class name
  97072. */
  97073. getClassName(): string;
  97074. /**
  97075. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97076. * You can try switching to logarithmic depth.
  97077. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97078. */
  97079. get useLogarithmicDepth(): boolean;
  97080. set useLogarithmicDepth(value: boolean);
  97081. /**
  97082. * Specifies if the material will require alpha blending
  97083. * @returns a boolean specifying if alpha blending is needed
  97084. */
  97085. needAlphaBlending(): boolean;
  97086. /**
  97087. * Specifies if this material should be rendered in alpha test mode
  97088. * @returns a boolean specifying if an alpha test is needed.
  97089. */
  97090. needAlphaTesting(): boolean;
  97091. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97092. /**
  97093. * Get the texture used for alpha test purpose.
  97094. * @returns the diffuse texture in case of the standard material.
  97095. */
  97096. getAlphaTestTexture(): Nullable<BaseTexture>;
  97097. /**
  97098. * Get if the submesh is ready to be used and all its information available.
  97099. * Child classes can use it to update shaders
  97100. * @param mesh defines the mesh to check
  97101. * @param subMesh defines which submesh to check
  97102. * @param useInstances specifies that instances should be used
  97103. * @returns a boolean indicating that the submesh is ready or not
  97104. */
  97105. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97106. /**
  97107. * Builds the material UBO layouts.
  97108. * Used internally during the effect preparation.
  97109. */
  97110. buildUniformLayout(): void;
  97111. /**
  97112. * Unbinds the material from the mesh
  97113. */
  97114. unbind(): void;
  97115. /**
  97116. * Binds the submesh to this material by preparing the effect and shader to draw
  97117. * @param world defines the world transformation matrix
  97118. * @param mesh defines the mesh containing the submesh
  97119. * @param subMesh defines the submesh to bind the material to
  97120. */
  97121. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97122. /**
  97123. * Get the list of animatables in the material.
  97124. * @returns the list of animatables object used in the material
  97125. */
  97126. getAnimatables(): IAnimatable[];
  97127. /**
  97128. * Gets the active textures from the material
  97129. * @returns an array of textures
  97130. */
  97131. getActiveTextures(): BaseTexture[];
  97132. /**
  97133. * Specifies if the material uses a texture
  97134. * @param texture defines the texture to check against the material
  97135. * @returns a boolean specifying if the material uses the texture
  97136. */
  97137. hasTexture(texture: BaseTexture): boolean;
  97138. /**
  97139. * Disposes the material
  97140. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97141. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97142. */
  97143. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97144. /**
  97145. * Makes a duplicate of the material, and gives it a new name
  97146. * @param name defines the new name for the duplicated material
  97147. * @returns the cloned material
  97148. */
  97149. clone(name: string): StandardMaterial;
  97150. /**
  97151. * Serializes this material in a JSON representation
  97152. * @returns the serialized material object
  97153. */
  97154. serialize(): any;
  97155. /**
  97156. * Creates a standard material from parsed material data
  97157. * @param source defines the JSON representation of the material
  97158. * @param scene defines the hosting scene
  97159. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97160. * @returns a new standard material
  97161. */
  97162. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97163. /**
  97164. * Are diffuse textures enabled in the application.
  97165. */
  97166. static get DiffuseTextureEnabled(): boolean;
  97167. static set DiffuseTextureEnabled(value: boolean);
  97168. /**
  97169. * Are ambient textures enabled in the application.
  97170. */
  97171. static get AmbientTextureEnabled(): boolean;
  97172. static set AmbientTextureEnabled(value: boolean);
  97173. /**
  97174. * Are opacity textures enabled in the application.
  97175. */
  97176. static get OpacityTextureEnabled(): boolean;
  97177. static set OpacityTextureEnabled(value: boolean);
  97178. /**
  97179. * Are reflection textures enabled in the application.
  97180. */
  97181. static get ReflectionTextureEnabled(): boolean;
  97182. static set ReflectionTextureEnabled(value: boolean);
  97183. /**
  97184. * Are emissive textures enabled in the application.
  97185. */
  97186. static get EmissiveTextureEnabled(): boolean;
  97187. static set EmissiveTextureEnabled(value: boolean);
  97188. /**
  97189. * Are specular textures enabled in the application.
  97190. */
  97191. static get SpecularTextureEnabled(): boolean;
  97192. static set SpecularTextureEnabled(value: boolean);
  97193. /**
  97194. * Are bump textures enabled in the application.
  97195. */
  97196. static get BumpTextureEnabled(): boolean;
  97197. static set BumpTextureEnabled(value: boolean);
  97198. /**
  97199. * Are lightmap textures enabled in the application.
  97200. */
  97201. static get LightmapTextureEnabled(): boolean;
  97202. static set LightmapTextureEnabled(value: boolean);
  97203. /**
  97204. * Are refraction textures enabled in the application.
  97205. */
  97206. static get RefractionTextureEnabled(): boolean;
  97207. static set RefractionTextureEnabled(value: boolean);
  97208. /**
  97209. * Are color grading textures enabled in the application.
  97210. */
  97211. static get ColorGradingTextureEnabled(): boolean;
  97212. static set ColorGradingTextureEnabled(value: boolean);
  97213. /**
  97214. * Are fresnels enabled in the application.
  97215. */
  97216. static get FresnelEnabled(): boolean;
  97217. static set FresnelEnabled(value: boolean);
  97218. }
  97219. }
  97220. declare module BABYLON {
  97221. /**
  97222. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  97223. *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.
  97224. * The SPS is also a particle system. It provides some methods to manage the particles.
  97225. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  97226. *
  97227. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  97228. */
  97229. export class SolidParticleSystem implements IDisposable {
  97230. /**
  97231. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  97232. * Example : var p = SPS.particles[i];
  97233. */
  97234. particles: SolidParticle[];
  97235. /**
  97236. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  97237. */
  97238. nbParticles: number;
  97239. /**
  97240. * If the particles must ever face the camera (default false). Useful for planar particles.
  97241. */
  97242. billboard: boolean;
  97243. /**
  97244. * Recompute normals when adding a shape
  97245. */
  97246. recomputeNormals: boolean;
  97247. /**
  97248. * This a counter ofr your own usage. It's not set by any SPS functions.
  97249. */
  97250. counter: number;
  97251. /**
  97252. * The SPS name. This name is also given to the underlying mesh.
  97253. */
  97254. name: string;
  97255. /**
  97256. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  97257. */
  97258. mesh: Mesh;
  97259. /**
  97260. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  97261. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  97262. */
  97263. vars: any;
  97264. /**
  97265. * This array is populated when the SPS is set as 'pickable'.
  97266. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  97267. * Each element of this array is an object `{idx: int, faceId: int}`.
  97268. * `idx` is the picked particle index in the `SPS.particles` array
  97269. * `faceId` is the picked face index counted within this particle.
  97270. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  97271. */
  97272. pickedParticles: {
  97273. idx: number;
  97274. faceId: number;
  97275. }[];
  97276. /**
  97277. * This array is populated when `enableDepthSort` is set to true.
  97278. * Each element of this array is an instance of the class DepthSortedParticle.
  97279. */
  97280. depthSortedParticles: DepthSortedParticle[];
  97281. /**
  97282. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  97283. * @hidden
  97284. */
  97285. _bSphereOnly: boolean;
  97286. /**
  97287. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  97288. * @hidden
  97289. */
  97290. _bSphereRadiusFactor: number;
  97291. private _scene;
  97292. private _positions;
  97293. private _indices;
  97294. private _normals;
  97295. private _colors;
  97296. private _uvs;
  97297. private _indices32;
  97298. private _positions32;
  97299. private _normals32;
  97300. private _fixedNormal32;
  97301. private _colors32;
  97302. private _uvs32;
  97303. private _index;
  97304. private _updatable;
  97305. private _pickable;
  97306. private _isVisibilityBoxLocked;
  97307. private _alwaysVisible;
  97308. private _depthSort;
  97309. private _expandable;
  97310. private _shapeCounter;
  97311. private _copy;
  97312. private _color;
  97313. private _computeParticleColor;
  97314. private _computeParticleTexture;
  97315. private _computeParticleRotation;
  97316. private _computeParticleVertex;
  97317. private _computeBoundingBox;
  97318. private _depthSortParticles;
  97319. private _camera;
  97320. private _mustUnrotateFixedNormals;
  97321. private _particlesIntersect;
  97322. private _needs32Bits;
  97323. private _isNotBuilt;
  97324. private _lastParticleId;
  97325. private _idxOfId;
  97326. private _multimaterialEnabled;
  97327. private _useModelMaterial;
  97328. private _indicesByMaterial;
  97329. private _materialIndexes;
  97330. private _depthSortFunction;
  97331. private _materialSortFunction;
  97332. private _materials;
  97333. private _multimaterial;
  97334. private _materialIndexesById;
  97335. private _defaultMaterial;
  97336. private _autoUpdateSubMeshes;
  97337. /**
  97338. * Creates a SPS (Solid Particle System) object.
  97339. * @param name (String) is the SPS name, this will be the underlying mesh name.
  97340. * @param scene (Scene) is the scene in which the SPS is added.
  97341. * @param options defines the options of the sps e.g.
  97342. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  97343. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  97344. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  97345. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  97346. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  97347. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  97348. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  97349. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  97350. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  97351. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  97352. */
  97353. constructor(name: string, scene: Scene, options?: {
  97354. updatable?: boolean;
  97355. isPickable?: boolean;
  97356. enableDepthSort?: boolean;
  97357. particleIntersection?: boolean;
  97358. boundingSphereOnly?: boolean;
  97359. bSphereRadiusFactor?: number;
  97360. expandable?: boolean;
  97361. useModelMaterial?: boolean;
  97362. enableMultiMaterial?: boolean;
  97363. });
  97364. /**
  97365. * Builds the SPS underlying mesh. Returns a standard Mesh.
  97366. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  97367. * @returns the created mesh
  97368. */
  97369. buildMesh(): Mesh;
  97370. /**
  97371. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  97372. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  97373. * Thus the particles generated from `digest()` have their property `position` set yet.
  97374. * @param mesh ( Mesh ) is the mesh to be digested
  97375. * @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
  97376. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  97377. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  97378. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97379. * @returns the current SPS
  97380. */
  97381. digest(mesh: Mesh, options?: {
  97382. facetNb?: number;
  97383. number?: number;
  97384. delta?: number;
  97385. storage?: [];
  97386. }): SolidParticleSystem;
  97387. /**
  97388. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  97389. * @hidden
  97390. */
  97391. private _unrotateFixedNormals;
  97392. /**
  97393. * Resets the temporary working copy particle
  97394. * @hidden
  97395. */
  97396. private _resetCopy;
  97397. /**
  97398. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  97399. * @param p the current index in the positions array to be updated
  97400. * @param ind the current index in the indices array
  97401. * @param shape a Vector3 array, the shape geometry
  97402. * @param positions the positions array to be updated
  97403. * @param meshInd the shape indices array
  97404. * @param indices the indices array to be updated
  97405. * @param meshUV the shape uv array
  97406. * @param uvs the uv array to be updated
  97407. * @param meshCol the shape color array
  97408. * @param colors the color array to be updated
  97409. * @param meshNor the shape normals array
  97410. * @param normals the normals array to be updated
  97411. * @param idx the particle index
  97412. * @param idxInShape the particle index in its shape
  97413. * @param options the addShape() method passed options
  97414. * @model the particle model
  97415. * @hidden
  97416. */
  97417. private _meshBuilder;
  97418. /**
  97419. * Returns a shape Vector3 array from positions float array
  97420. * @param positions float array
  97421. * @returns a vector3 array
  97422. * @hidden
  97423. */
  97424. private _posToShape;
  97425. /**
  97426. * Returns a shapeUV array from a float uvs (array deep copy)
  97427. * @param uvs as a float array
  97428. * @returns a shapeUV array
  97429. * @hidden
  97430. */
  97431. private _uvsToShapeUV;
  97432. /**
  97433. * Adds a new particle object in the particles array
  97434. * @param idx particle index in particles array
  97435. * @param id particle id
  97436. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  97437. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  97438. * @param model particle ModelShape object
  97439. * @param shapeId model shape identifier
  97440. * @param idxInShape index of the particle in the current model
  97441. * @param bInfo model bounding info object
  97442. * @param storage target storage array, if any
  97443. * @hidden
  97444. */
  97445. private _addParticle;
  97446. /**
  97447. * Adds some particles to the SPS from the model shape. Returns the shape id.
  97448. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  97449. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  97450. * @param nb (positive integer) the number of particles to be created from this model
  97451. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  97452. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  97453. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97454. * @returns the number of shapes in the system
  97455. */
  97456. addShape(mesh: Mesh, nb: number, options?: {
  97457. positionFunction?: any;
  97458. vertexFunction?: any;
  97459. storage?: [];
  97460. }): number;
  97461. /**
  97462. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  97463. * @hidden
  97464. */
  97465. private _rebuildParticle;
  97466. /**
  97467. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  97468. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  97469. * @returns the SPS.
  97470. */
  97471. rebuildMesh(reset?: boolean): SolidParticleSystem;
  97472. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  97473. * Returns an array with the removed particles.
  97474. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  97475. * The SPS can't be empty so at least one particle needs to remain in place.
  97476. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  97477. * @param start index of the first particle to remove
  97478. * @param end index of the last particle to remove (included)
  97479. * @returns an array populated with the removed particles
  97480. */
  97481. removeParticles(start: number, end: number): SolidParticle[];
  97482. /**
  97483. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  97484. * @param solidParticleArray an array populated with Solid Particles objects
  97485. * @returns the SPS
  97486. */
  97487. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  97488. /**
  97489. * Creates a new particle and modifies the SPS mesh geometry :
  97490. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  97491. * - calls _addParticle() to populate the particle array
  97492. * factorized code from addShape() and insertParticlesFromArray()
  97493. * @param idx particle index in the particles array
  97494. * @param i particle index in its shape
  97495. * @param modelShape particle ModelShape object
  97496. * @param shape shape vertex array
  97497. * @param meshInd shape indices array
  97498. * @param meshUV shape uv array
  97499. * @param meshCol shape color array
  97500. * @param meshNor shape normals array
  97501. * @param bbInfo shape bounding info
  97502. * @param storage target particle storage
  97503. * @options addShape() passed options
  97504. * @hidden
  97505. */
  97506. private _insertNewParticle;
  97507. /**
  97508. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  97509. * This method calls `updateParticle()` for each particle of the SPS.
  97510. * For an animated SPS, it is usually called within the render loop.
  97511. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  97512. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  97513. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  97514. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  97515. * @returns the SPS.
  97516. */
  97517. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  97518. /**
  97519. * Disposes the SPS.
  97520. */
  97521. dispose(): void;
  97522. /**
  97523. * Returns a SolidParticle object from its identifier : particle.id
  97524. * @param id (integer) the particle Id
  97525. * @returns the searched particle or null if not found in the SPS.
  97526. */
  97527. getParticleById(id: number): Nullable<SolidParticle>;
  97528. /**
  97529. * Returns a new array populated with the particles having the passed shapeId.
  97530. * @param shapeId (integer) the shape identifier
  97531. * @returns a new solid particle array
  97532. */
  97533. getParticlesByShapeId(shapeId: number): SolidParticle[];
  97534. /**
  97535. * Populates the passed array "ref" with the particles having the passed shapeId.
  97536. * @param shapeId the shape identifier
  97537. * @returns the SPS
  97538. * @param ref
  97539. */
  97540. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  97541. /**
  97542. * Computes the required SubMeshes according the materials assigned to the particles.
  97543. * @returns the solid particle system.
  97544. * Does nothing if called before the SPS mesh is built.
  97545. */
  97546. computeSubMeshes(): SolidParticleSystem;
  97547. /**
  97548. * Sorts the solid particles by material when MultiMaterial is enabled.
  97549. * Updates the indices32 array.
  97550. * Updates the indicesByMaterial array.
  97551. * Updates the mesh indices array.
  97552. * @returns the SPS
  97553. * @hidden
  97554. */
  97555. private _sortParticlesByMaterial;
  97556. /**
  97557. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  97558. * @hidden
  97559. */
  97560. private _setMaterialIndexesById;
  97561. /**
  97562. * Returns an array with unique values of Materials from the passed array
  97563. * @param array the material array to be checked and filtered
  97564. * @hidden
  97565. */
  97566. private _filterUniqueMaterialId;
  97567. /**
  97568. * Sets a new Standard Material as _defaultMaterial if not already set.
  97569. * @hidden
  97570. */
  97571. private _setDefaultMaterial;
  97572. /**
  97573. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  97574. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97575. * @returns the SPS.
  97576. */
  97577. refreshVisibleSize(): SolidParticleSystem;
  97578. /**
  97579. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  97580. * @param size the size (float) of the visibility box
  97581. * note : this doesn't lock the SPS mesh bounding box.
  97582. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97583. */
  97584. setVisibilityBox(size: number): void;
  97585. /**
  97586. * Gets whether the SPS as always visible or not
  97587. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97588. */
  97589. get isAlwaysVisible(): boolean;
  97590. /**
  97591. * Sets the SPS as always visible or not
  97592. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97593. */
  97594. set isAlwaysVisible(val: boolean);
  97595. /**
  97596. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97597. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97598. */
  97599. set isVisibilityBoxLocked(val: boolean);
  97600. /**
  97601. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97602. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97603. */
  97604. get isVisibilityBoxLocked(): boolean;
  97605. /**
  97606. * Tells to `setParticles()` to compute the particle rotations or not.
  97607. * Default value : true. The SPS is faster when it's set to false.
  97608. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97609. */
  97610. set computeParticleRotation(val: boolean);
  97611. /**
  97612. * Tells to `setParticles()` to compute the particle colors or not.
  97613. * Default value : true. The SPS is faster when it's set to false.
  97614. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97615. */
  97616. set computeParticleColor(val: boolean);
  97617. set computeParticleTexture(val: boolean);
  97618. /**
  97619. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  97620. * Default value : false. The SPS is faster when it's set to false.
  97621. * Note : the particle custom vertex positions aren't stored values.
  97622. */
  97623. set computeParticleVertex(val: boolean);
  97624. /**
  97625. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  97626. */
  97627. set computeBoundingBox(val: boolean);
  97628. /**
  97629. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  97630. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97631. * Default : `true`
  97632. */
  97633. set depthSortParticles(val: boolean);
  97634. /**
  97635. * Gets if `setParticles()` computes the particle rotations or not.
  97636. * Default value : true. The SPS is faster when it's set to false.
  97637. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97638. */
  97639. get computeParticleRotation(): boolean;
  97640. /**
  97641. * Gets if `setParticles()` computes the particle colors or not.
  97642. * Default value : true. The SPS is faster when it's set to false.
  97643. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97644. */
  97645. get computeParticleColor(): boolean;
  97646. /**
  97647. * Gets if `setParticles()` computes the particle textures or not.
  97648. * Default value : true. The SPS is faster when it's set to false.
  97649. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  97650. */
  97651. get computeParticleTexture(): boolean;
  97652. /**
  97653. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  97654. * Default value : false. The SPS is faster when it's set to false.
  97655. * Note : the particle custom vertex positions aren't stored values.
  97656. */
  97657. get computeParticleVertex(): boolean;
  97658. /**
  97659. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  97660. */
  97661. get computeBoundingBox(): boolean;
  97662. /**
  97663. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  97664. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97665. * Default : `true`
  97666. */
  97667. get depthSortParticles(): boolean;
  97668. /**
  97669. * Gets if the SPS is created as expandable at construction time.
  97670. * Default : `false`
  97671. */
  97672. get expandable(): boolean;
  97673. /**
  97674. * Gets if the SPS supports the Multi Materials
  97675. */
  97676. get multimaterialEnabled(): boolean;
  97677. /**
  97678. * Gets if the SPS uses the model materials for its own multimaterial.
  97679. */
  97680. get useModelMaterial(): boolean;
  97681. /**
  97682. * The SPS used material array.
  97683. */
  97684. get materials(): Material[];
  97685. /**
  97686. * Sets the SPS MultiMaterial from the passed materials.
  97687. * Note : the passed array is internally copied and not used then by reference.
  97688. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  97689. */
  97690. setMultiMaterial(materials: Material[]): void;
  97691. /**
  97692. * The SPS computed multimaterial object
  97693. */
  97694. get multimaterial(): MultiMaterial;
  97695. set multimaterial(mm: MultiMaterial);
  97696. /**
  97697. * If the subMeshes must be updated on the next call to setParticles()
  97698. */
  97699. get autoUpdateSubMeshes(): boolean;
  97700. set autoUpdateSubMeshes(val: boolean);
  97701. /**
  97702. * This function does nothing. It may be overwritten to set all the particle first values.
  97703. * The SPS doesn't call this function, you may have to call it by your own.
  97704. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97705. */
  97706. initParticles(): void;
  97707. /**
  97708. * This function does nothing. It may be overwritten to recycle a particle.
  97709. * The SPS doesn't call this function, you may have to call it by your own.
  97710. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97711. * @param particle The particle to recycle
  97712. * @returns the recycled particle
  97713. */
  97714. recycleParticle(particle: SolidParticle): SolidParticle;
  97715. /**
  97716. * Updates a particle : this function should be overwritten by the user.
  97717. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  97718. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97719. * @example : just set a particle position or velocity and recycle conditions
  97720. * @param particle The particle to update
  97721. * @returns the updated particle
  97722. */
  97723. updateParticle(particle: SolidParticle): SolidParticle;
  97724. /**
  97725. * Updates a vertex of a particle : it can be overwritten by the user.
  97726. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  97727. * @param particle the current particle
  97728. * @param vertex the current index of the current particle
  97729. * @param pt the index of the current vertex in the particle shape
  97730. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  97731. * @example : just set a vertex particle position
  97732. * @returns the updated vertex
  97733. */
  97734. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  97735. /**
  97736. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  97737. * This does nothing and may be overwritten by the user.
  97738. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97739. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97740. * @param update the boolean update value actually passed to setParticles()
  97741. */
  97742. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97743. /**
  97744. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  97745. * This will be passed three parameters.
  97746. * This does nothing and may be overwritten by the user.
  97747. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97748. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97749. * @param update the boolean update value actually passed to setParticles()
  97750. */
  97751. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97752. }
  97753. }
  97754. declare module BABYLON {
  97755. /**
  97756. * Represents one particle of a solid particle system.
  97757. */
  97758. export class SolidParticle {
  97759. /**
  97760. * particle global index
  97761. */
  97762. idx: number;
  97763. /**
  97764. * particle identifier
  97765. */
  97766. id: number;
  97767. /**
  97768. * The color of the particle
  97769. */
  97770. color: Nullable<Color4>;
  97771. /**
  97772. * The world space position of the particle.
  97773. */
  97774. position: Vector3;
  97775. /**
  97776. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  97777. */
  97778. rotation: Vector3;
  97779. /**
  97780. * The world space rotation quaternion of the particle.
  97781. */
  97782. rotationQuaternion: Nullable<Quaternion>;
  97783. /**
  97784. * The scaling of the particle.
  97785. */
  97786. scaling: Vector3;
  97787. /**
  97788. * The uvs of the particle.
  97789. */
  97790. uvs: Vector4;
  97791. /**
  97792. * The current speed of the particle.
  97793. */
  97794. velocity: Vector3;
  97795. /**
  97796. * The pivot point in the particle local space.
  97797. */
  97798. pivot: Vector3;
  97799. /**
  97800. * Must the particle be translated from its pivot point in its local space ?
  97801. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  97802. * Default : false
  97803. */
  97804. translateFromPivot: boolean;
  97805. /**
  97806. * Is the particle active or not ?
  97807. */
  97808. alive: boolean;
  97809. /**
  97810. * Is the particle visible or not ?
  97811. */
  97812. isVisible: boolean;
  97813. /**
  97814. * Index of this particle in the global "positions" array (Internal use)
  97815. * @hidden
  97816. */
  97817. _pos: number;
  97818. /**
  97819. * @hidden Index of this particle in the global "indices" array (Internal use)
  97820. */
  97821. _ind: number;
  97822. /**
  97823. * @hidden ModelShape of this particle (Internal use)
  97824. */
  97825. _model: ModelShape;
  97826. /**
  97827. * ModelShape id of this particle
  97828. */
  97829. shapeId: number;
  97830. /**
  97831. * Index of the particle in its shape id
  97832. */
  97833. idxInShape: number;
  97834. /**
  97835. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  97836. */
  97837. _modelBoundingInfo: BoundingInfo;
  97838. /**
  97839. * @hidden Particle BoundingInfo object (Internal use)
  97840. */
  97841. _boundingInfo: BoundingInfo;
  97842. /**
  97843. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  97844. */
  97845. _sps: SolidParticleSystem;
  97846. /**
  97847. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  97848. */
  97849. _stillInvisible: boolean;
  97850. /**
  97851. * @hidden Last computed particle rotation matrix
  97852. */
  97853. _rotationMatrix: number[];
  97854. /**
  97855. * Parent particle Id, if any.
  97856. * Default null.
  97857. */
  97858. parentId: Nullable<number>;
  97859. /**
  97860. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  97861. */
  97862. materialIndex: Nullable<number>;
  97863. /**
  97864. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  97865. * The possible values are :
  97866. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  97867. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97868. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  97869. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  97870. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97871. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  97872. * */
  97873. cullingStrategy: number;
  97874. /**
  97875. * @hidden Internal global position in the SPS.
  97876. */
  97877. _globalPosition: Vector3;
  97878. /**
  97879. * Creates a Solid Particle object.
  97880. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  97881. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  97882. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  97883. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  97884. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  97885. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  97886. * @param shapeId (integer) is the model shape identifier in the SPS.
  97887. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  97888. * @param sps defines the sps it is associated to
  97889. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  97890. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  97891. */
  97892. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  97893. /**
  97894. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  97895. * @param target the particle target
  97896. * @returns the current particle
  97897. */
  97898. copyToRef(target: SolidParticle): SolidParticle;
  97899. /**
  97900. * Legacy support, changed scale to scaling
  97901. */
  97902. get scale(): Vector3;
  97903. /**
  97904. * Legacy support, changed scale to scaling
  97905. */
  97906. set scale(scale: Vector3);
  97907. /**
  97908. * Legacy support, changed quaternion to rotationQuaternion
  97909. */
  97910. get quaternion(): Nullable<Quaternion>;
  97911. /**
  97912. * Legacy support, changed quaternion to rotationQuaternion
  97913. */
  97914. set quaternion(q: Nullable<Quaternion>);
  97915. /**
  97916. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  97917. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  97918. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  97919. * @returns true if it intersects
  97920. */
  97921. intersectsMesh(target: Mesh | SolidParticle): boolean;
  97922. /**
  97923. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  97924. * A particle is in the frustum if its bounding box intersects the frustum
  97925. * @param frustumPlanes defines the frustum to test
  97926. * @returns true if the particle is in the frustum planes
  97927. */
  97928. isInFrustum(frustumPlanes: Plane[]): boolean;
  97929. /**
  97930. * get the rotation matrix of the particle
  97931. * @hidden
  97932. */
  97933. getRotationMatrix(m: Matrix): void;
  97934. }
  97935. /**
  97936. * Represents the shape of the model used by one particle of a solid particle system.
  97937. * SPS internal tool, don't use it manually.
  97938. */
  97939. export class ModelShape {
  97940. /**
  97941. * The shape id
  97942. * @hidden
  97943. */
  97944. shapeID: number;
  97945. /**
  97946. * flat array of model positions (internal use)
  97947. * @hidden
  97948. */
  97949. _shape: Vector3[];
  97950. /**
  97951. * flat array of model UVs (internal use)
  97952. * @hidden
  97953. */
  97954. _shapeUV: number[];
  97955. /**
  97956. * color array of the model
  97957. * @hidden
  97958. */
  97959. _shapeColors: number[];
  97960. /**
  97961. * indices array of the model
  97962. * @hidden
  97963. */
  97964. _indices: number[];
  97965. /**
  97966. * normals array of the model
  97967. * @hidden
  97968. */
  97969. _normals: number[];
  97970. /**
  97971. * length of the shape in the model indices array (internal use)
  97972. * @hidden
  97973. */
  97974. _indicesLength: number;
  97975. /**
  97976. * Custom position function (internal use)
  97977. * @hidden
  97978. */
  97979. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  97980. /**
  97981. * Custom vertex function (internal use)
  97982. * @hidden
  97983. */
  97984. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  97985. /**
  97986. * Model material (internal use)
  97987. * @hidden
  97988. */
  97989. _material: Nullable<Material>;
  97990. /**
  97991. * 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.
  97992. * SPS internal tool, don't use it manually.
  97993. * @hidden
  97994. */
  97995. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  97996. }
  97997. /**
  97998. * Represents a Depth Sorted Particle in the solid particle system.
  97999. * @hidden
  98000. */
  98001. export class DepthSortedParticle {
  98002. /**
  98003. * Index of the particle in the "indices" array
  98004. */
  98005. ind: number;
  98006. /**
  98007. * Length of the particle shape in the "indices" array
  98008. */
  98009. indicesLength: number;
  98010. /**
  98011. * Squared distance from the particle to the camera
  98012. */
  98013. sqDistance: number;
  98014. /**
  98015. * Material index when used with MultiMaterials
  98016. */
  98017. materialIndex: number;
  98018. /**
  98019. * Creates a new sorted particle
  98020. * @param materialIndex
  98021. */
  98022. constructor(ind: number, indLength: number, materialIndex: number);
  98023. }
  98024. }
  98025. declare module BABYLON {
  98026. /**
  98027. * @hidden
  98028. */
  98029. export class _MeshCollisionData {
  98030. _checkCollisions: boolean;
  98031. _collisionMask: number;
  98032. _collisionGroup: number;
  98033. _collider: Nullable<Collider>;
  98034. _oldPositionForCollisions: Vector3;
  98035. _diffPositionForCollisions: Vector3;
  98036. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98037. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98038. }
  98039. }
  98040. declare module BABYLON {
  98041. /** @hidden */
  98042. class _FacetDataStorage {
  98043. facetPositions: Vector3[];
  98044. facetNormals: Vector3[];
  98045. facetPartitioning: number[][];
  98046. facetNb: number;
  98047. partitioningSubdivisions: number;
  98048. partitioningBBoxRatio: number;
  98049. facetDataEnabled: boolean;
  98050. facetParameters: any;
  98051. bbSize: Vector3;
  98052. subDiv: {
  98053. max: number;
  98054. X: number;
  98055. Y: number;
  98056. Z: number;
  98057. };
  98058. facetDepthSort: boolean;
  98059. facetDepthSortEnabled: boolean;
  98060. depthSortedIndices: IndicesArray;
  98061. depthSortedFacets: {
  98062. ind: number;
  98063. sqDistance: number;
  98064. }[];
  98065. facetDepthSortFunction: (f1: {
  98066. ind: number;
  98067. sqDistance: number;
  98068. }, f2: {
  98069. ind: number;
  98070. sqDistance: number;
  98071. }) => number;
  98072. facetDepthSortFrom: Vector3;
  98073. facetDepthSortOrigin: Vector3;
  98074. invertedMatrix: Matrix;
  98075. }
  98076. /**
  98077. * @hidden
  98078. **/
  98079. class _InternalAbstractMeshDataInfo {
  98080. _hasVertexAlpha: boolean;
  98081. _useVertexColors: boolean;
  98082. _numBoneInfluencers: number;
  98083. _applyFog: boolean;
  98084. _receiveShadows: boolean;
  98085. _facetData: _FacetDataStorage;
  98086. _visibility: number;
  98087. _skeleton: Nullable<Skeleton>;
  98088. _layerMask: number;
  98089. _computeBonesUsingShaders: boolean;
  98090. _isActive: boolean;
  98091. _onlyForInstances: boolean;
  98092. _isActiveIntermediate: boolean;
  98093. _onlyForInstancesIntermediate: boolean;
  98094. _actAsRegularMesh: boolean;
  98095. }
  98096. /**
  98097. * Class used to store all common mesh properties
  98098. */
  98099. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98100. /** No occlusion */
  98101. static OCCLUSION_TYPE_NONE: number;
  98102. /** Occlusion set to optimisitic */
  98103. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98104. /** Occlusion set to strict */
  98105. static OCCLUSION_TYPE_STRICT: number;
  98106. /** Use an accurante occlusion algorithm */
  98107. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98108. /** Use a conservative occlusion algorithm */
  98109. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98110. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98111. * Test order :
  98112. * Is the bounding sphere outside the frustum ?
  98113. * If not, are the bounding box vertices outside the frustum ?
  98114. * It not, then the cullable object is in the frustum.
  98115. */
  98116. static readonly CULLINGSTRATEGY_STANDARD: number;
  98117. /** Culling strategy : Bounding Sphere Only.
  98118. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98119. * It's also less accurate than the standard because some not visible objects can still be selected.
  98120. * Test : is the bounding sphere outside the frustum ?
  98121. * If not, then the cullable object is in the frustum.
  98122. */
  98123. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98124. /** Culling strategy : Optimistic Inclusion.
  98125. * This in an inclusion test first, then the standard exclusion test.
  98126. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98127. * 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.
  98128. * Anyway, it's as accurate as the standard strategy.
  98129. * Test :
  98130. * Is the cullable object bounding sphere center in the frustum ?
  98131. * If not, apply the default culling strategy.
  98132. */
  98133. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98134. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98135. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98136. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  98137. * 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.
  98138. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  98139. * Test :
  98140. * Is the cullable object bounding sphere center in the frustum ?
  98141. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  98142. */
  98143. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  98144. /**
  98145. * No billboard
  98146. */
  98147. static get BILLBOARDMODE_NONE(): number;
  98148. /** Billboard on X axis */
  98149. static get BILLBOARDMODE_X(): number;
  98150. /** Billboard on Y axis */
  98151. static get BILLBOARDMODE_Y(): number;
  98152. /** Billboard on Z axis */
  98153. static get BILLBOARDMODE_Z(): number;
  98154. /** Billboard on all axes */
  98155. static get BILLBOARDMODE_ALL(): number;
  98156. /** Billboard on using position instead of orientation */
  98157. static get BILLBOARDMODE_USE_POSITION(): number;
  98158. /** @hidden */
  98159. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  98160. /**
  98161. * The culling strategy to use to check whether the mesh must be rendered or not.
  98162. * This value can be changed at any time and will be used on the next render mesh selection.
  98163. * The possible values are :
  98164. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98165. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98166. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98167. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98168. * Please read each static variable documentation to get details about the culling process.
  98169. * */
  98170. cullingStrategy: number;
  98171. /**
  98172. * Gets the number of facets in the mesh
  98173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98174. */
  98175. get facetNb(): number;
  98176. /**
  98177. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  98178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98179. */
  98180. get partitioningSubdivisions(): number;
  98181. set partitioningSubdivisions(nb: number);
  98182. /**
  98183. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  98184. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  98185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98186. */
  98187. get partitioningBBoxRatio(): number;
  98188. set partitioningBBoxRatio(ratio: number);
  98189. /**
  98190. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  98191. * Works only for updatable meshes.
  98192. * Doesn't work with multi-materials
  98193. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98194. */
  98195. get mustDepthSortFacets(): boolean;
  98196. set mustDepthSortFacets(sort: boolean);
  98197. /**
  98198. * The location (Vector3) where the facet depth sort must be computed from.
  98199. * By default, the active camera position.
  98200. * Used only when facet depth sort is enabled
  98201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98202. */
  98203. get facetDepthSortFrom(): Vector3;
  98204. set facetDepthSortFrom(location: Vector3);
  98205. /**
  98206. * gets a boolean indicating if facetData is enabled
  98207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98208. */
  98209. get isFacetDataEnabled(): boolean;
  98210. /** @hidden */
  98211. _updateNonUniformScalingState(value: boolean): boolean;
  98212. /**
  98213. * An event triggered when this mesh collides with another one
  98214. */
  98215. onCollideObservable: Observable<AbstractMesh>;
  98216. /** Set a function to call when this mesh collides with another one */
  98217. set onCollide(callback: () => void);
  98218. /**
  98219. * An event triggered when the collision's position changes
  98220. */
  98221. onCollisionPositionChangeObservable: Observable<Vector3>;
  98222. /** Set a function to call when the collision's position changes */
  98223. set onCollisionPositionChange(callback: () => void);
  98224. /**
  98225. * An event triggered when material is changed
  98226. */
  98227. onMaterialChangedObservable: Observable<AbstractMesh>;
  98228. /**
  98229. * Gets or sets the orientation for POV movement & rotation
  98230. */
  98231. definedFacingForward: boolean;
  98232. /** @hidden */
  98233. _occlusionQuery: Nullable<WebGLQuery>;
  98234. /** @hidden */
  98235. _renderingGroup: Nullable<RenderingGroup>;
  98236. /**
  98237. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98238. */
  98239. get visibility(): number;
  98240. /**
  98241. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98242. */
  98243. set visibility(value: number);
  98244. /** Gets or sets the alpha index used to sort transparent meshes
  98245. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  98246. */
  98247. alphaIndex: number;
  98248. /**
  98249. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  98250. */
  98251. isVisible: boolean;
  98252. /**
  98253. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  98254. */
  98255. isPickable: boolean;
  98256. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  98257. showSubMeshesBoundingBox: boolean;
  98258. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  98259. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  98260. */
  98261. isBlocker: boolean;
  98262. /**
  98263. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  98264. */
  98265. enablePointerMoveEvents: boolean;
  98266. /**
  98267. * Specifies the rendering group id for this mesh (0 by default)
  98268. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  98269. */
  98270. renderingGroupId: number;
  98271. private _material;
  98272. /** Gets or sets current material */
  98273. get material(): Nullable<Material>;
  98274. set material(value: Nullable<Material>);
  98275. /**
  98276. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  98277. * @see http://doc.babylonjs.com/babylon101/shadows
  98278. */
  98279. get receiveShadows(): boolean;
  98280. set receiveShadows(value: boolean);
  98281. /** Defines color to use when rendering outline */
  98282. outlineColor: Color3;
  98283. /** Define width to use when rendering outline */
  98284. outlineWidth: number;
  98285. /** Defines color to use when rendering overlay */
  98286. overlayColor: Color3;
  98287. /** Defines alpha to use when rendering overlay */
  98288. overlayAlpha: number;
  98289. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  98290. get hasVertexAlpha(): boolean;
  98291. set hasVertexAlpha(value: boolean);
  98292. /** 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) */
  98293. get useVertexColors(): boolean;
  98294. set useVertexColors(value: boolean);
  98295. /**
  98296. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  98297. */
  98298. get computeBonesUsingShaders(): boolean;
  98299. set computeBonesUsingShaders(value: boolean);
  98300. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  98301. get numBoneInfluencers(): number;
  98302. set numBoneInfluencers(value: number);
  98303. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  98304. get applyFog(): boolean;
  98305. set applyFog(value: boolean);
  98306. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  98307. useOctreeForRenderingSelection: boolean;
  98308. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  98309. useOctreeForPicking: boolean;
  98310. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  98311. useOctreeForCollisions: boolean;
  98312. /**
  98313. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  98314. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  98315. */
  98316. get layerMask(): number;
  98317. set layerMask(value: number);
  98318. /**
  98319. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  98320. */
  98321. alwaysSelectAsActiveMesh: boolean;
  98322. /**
  98323. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  98324. */
  98325. doNotSyncBoundingInfo: boolean;
  98326. /**
  98327. * Gets or sets the current action manager
  98328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98329. */
  98330. actionManager: Nullable<AbstractActionManager>;
  98331. private _meshCollisionData;
  98332. /**
  98333. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  98334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98335. */
  98336. ellipsoid: Vector3;
  98337. /**
  98338. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  98339. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98340. */
  98341. ellipsoidOffset: Vector3;
  98342. /**
  98343. * Gets or sets a collision mask used to mask collisions (default is -1).
  98344. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98345. */
  98346. get collisionMask(): number;
  98347. set collisionMask(mask: number);
  98348. /**
  98349. * Gets or sets the current collision group mask (-1 by default).
  98350. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98351. */
  98352. get collisionGroup(): number;
  98353. set collisionGroup(mask: number);
  98354. /**
  98355. * Defines edge width used when edgesRenderer is enabled
  98356. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98357. */
  98358. edgesWidth: number;
  98359. /**
  98360. * Defines edge color used when edgesRenderer is enabled
  98361. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98362. */
  98363. edgesColor: Color4;
  98364. /** @hidden */
  98365. _edgesRenderer: Nullable<IEdgesRenderer>;
  98366. /** @hidden */
  98367. _masterMesh: Nullable<AbstractMesh>;
  98368. /** @hidden */
  98369. _boundingInfo: Nullable<BoundingInfo>;
  98370. /** @hidden */
  98371. _renderId: number;
  98372. /**
  98373. * Gets or sets the list of subMeshes
  98374. * @see http://doc.babylonjs.com/how_to/multi_materials
  98375. */
  98376. subMeshes: SubMesh[];
  98377. /** @hidden */
  98378. _intersectionsInProgress: AbstractMesh[];
  98379. /** @hidden */
  98380. _unIndexed: boolean;
  98381. /** @hidden */
  98382. _lightSources: Light[];
  98383. /** Gets the list of lights affecting that mesh */
  98384. get lightSources(): Light[];
  98385. /** @hidden */
  98386. get _positions(): Nullable<Vector3[]>;
  98387. /** @hidden */
  98388. _waitingData: {
  98389. lods: Nullable<any>;
  98390. actions: Nullable<any>;
  98391. freezeWorldMatrix: Nullable<boolean>;
  98392. };
  98393. /** @hidden */
  98394. _bonesTransformMatrices: Nullable<Float32Array>;
  98395. /** @hidden */
  98396. _transformMatrixTexture: Nullable<RawTexture>;
  98397. /**
  98398. * Gets or sets a skeleton to apply skining transformations
  98399. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98400. */
  98401. set skeleton(value: Nullable<Skeleton>);
  98402. get skeleton(): Nullable<Skeleton>;
  98403. /**
  98404. * An event triggered when the mesh is rebuilt.
  98405. */
  98406. onRebuildObservable: Observable<AbstractMesh>;
  98407. /**
  98408. * Creates a new AbstractMesh
  98409. * @param name defines the name of the mesh
  98410. * @param scene defines the hosting scene
  98411. */
  98412. constructor(name: string, scene?: Nullable<Scene>);
  98413. /**
  98414. * Returns the string "AbstractMesh"
  98415. * @returns "AbstractMesh"
  98416. */
  98417. getClassName(): string;
  98418. /**
  98419. * Gets a string representation of the current mesh
  98420. * @param fullDetails defines a boolean indicating if full details must be included
  98421. * @returns a string representation of the current mesh
  98422. */
  98423. toString(fullDetails?: boolean): string;
  98424. /**
  98425. * @hidden
  98426. */
  98427. protected _getEffectiveParent(): Nullable<Node>;
  98428. /** @hidden */
  98429. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  98430. /** @hidden */
  98431. _rebuild(): void;
  98432. /** @hidden */
  98433. _resyncLightSources(): void;
  98434. /** @hidden */
  98435. _resyncLightSource(light: Light): void;
  98436. /** @hidden */
  98437. _unBindEffect(): void;
  98438. /** @hidden */
  98439. _removeLightSource(light: Light, dispose: boolean): void;
  98440. private _markSubMeshesAsDirty;
  98441. /** @hidden */
  98442. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  98443. /** @hidden */
  98444. _markSubMeshesAsAttributesDirty(): void;
  98445. /** @hidden */
  98446. _markSubMeshesAsMiscDirty(): void;
  98447. /**
  98448. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  98449. */
  98450. get scaling(): Vector3;
  98451. set scaling(newScaling: Vector3);
  98452. /**
  98453. * Returns true if the mesh is blocked. Implemented by child classes
  98454. */
  98455. get isBlocked(): boolean;
  98456. /**
  98457. * Returns the mesh itself by default. Implemented by child classes
  98458. * @param camera defines the camera to use to pick the right LOD level
  98459. * @returns the currentAbstractMesh
  98460. */
  98461. getLOD(camera: Camera): Nullable<AbstractMesh>;
  98462. /**
  98463. * Returns 0 by default. Implemented by child classes
  98464. * @returns an integer
  98465. */
  98466. getTotalVertices(): number;
  98467. /**
  98468. * Returns a positive integer : the total number of indices in this mesh geometry.
  98469. * @returns the numner of indices or zero if the mesh has no geometry.
  98470. */
  98471. getTotalIndices(): number;
  98472. /**
  98473. * Returns null by default. Implemented by child classes
  98474. * @returns null
  98475. */
  98476. getIndices(): Nullable<IndicesArray>;
  98477. /**
  98478. * Returns the array of the requested vertex data kind. Implemented by child classes
  98479. * @param kind defines the vertex data kind to use
  98480. * @returns null
  98481. */
  98482. getVerticesData(kind: string): Nullable<FloatArray>;
  98483. /**
  98484. * Sets the vertex data of the mesh geometry for the requested `kind`.
  98485. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  98486. * Note that a new underlying VertexBuffer object is created each call.
  98487. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  98488. * @param kind defines vertex data kind:
  98489. * * VertexBuffer.PositionKind
  98490. * * VertexBuffer.UVKind
  98491. * * VertexBuffer.UV2Kind
  98492. * * VertexBuffer.UV3Kind
  98493. * * VertexBuffer.UV4Kind
  98494. * * VertexBuffer.UV5Kind
  98495. * * VertexBuffer.UV6Kind
  98496. * * VertexBuffer.ColorKind
  98497. * * VertexBuffer.MatricesIndicesKind
  98498. * * VertexBuffer.MatricesIndicesExtraKind
  98499. * * VertexBuffer.MatricesWeightsKind
  98500. * * VertexBuffer.MatricesWeightsExtraKind
  98501. * @param data defines the data source
  98502. * @param updatable defines if the data must be flagged as updatable (or static)
  98503. * @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
  98504. * @returns the current mesh
  98505. */
  98506. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98507. /**
  98508. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  98509. * If the mesh has no geometry, it is simply returned as it is.
  98510. * @param kind defines vertex data kind:
  98511. * * VertexBuffer.PositionKind
  98512. * * VertexBuffer.UVKind
  98513. * * VertexBuffer.UV2Kind
  98514. * * VertexBuffer.UV3Kind
  98515. * * VertexBuffer.UV4Kind
  98516. * * VertexBuffer.UV5Kind
  98517. * * VertexBuffer.UV6Kind
  98518. * * VertexBuffer.ColorKind
  98519. * * VertexBuffer.MatricesIndicesKind
  98520. * * VertexBuffer.MatricesIndicesExtraKind
  98521. * * VertexBuffer.MatricesWeightsKind
  98522. * * VertexBuffer.MatricesWeightsExtraKind
  98523. * @param data defines the data source
  98524. * @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
  98525. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  98526. * @returns the current mesh
  98527. */
  98528. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98529. /**
  98530. * Sets the mesh indices,
  98531. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  98532. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  98533. * @param totalVertices Defines the total number of vertices
  98534. * @returns the current mesh
  98535. */
  98536. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  98537. /**
  98538. * Gets a boolean indicating if specific vertex data is present
  98539. * @param kind defines the vertex data kind to use
  98540. * @returns true is data kind is present
  98541. */
  98542. isVerticesDataPresent(kind: string): boolean;
  98543. /**
  98544. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  98545. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  98546. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  98547. * @returns a BoundingInfo
  98548. */
  98549. getBoundingInfo(): BoundingInfo;
  98550. /**
  98551. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  98552. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  98553. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  98554. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  98555. * @returns the current mesh
  98556. */
  98557. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  98558. /**
  98559. * Overwrite the current bounding info
  98560. * @param boundingInfo defines the new bounding info
  98561. * @returns the current mesh
  98562. */
  98563. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  98564. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  98565. get useBones(): boolean;
  98566. /** @hidden */
  98567. _preActivate(): void;
  98568. /** @hidden */
  98569. _preActivateForIntermediateRendering(renderId: number): void;
  98570. /** @hidden */
  98571. _activate(renderId: number, intermediateRendering: boolean): boolean;
  98572. /** @hidden */
  98573. _postActivate(): void;
  98574. /** @hidden */
  98575. _freeze(): void;
  98576. /** @hidden */
  98577. _unFreeze(): void;
  98578. /**
  98579. * Gets the current world matrix
  98580. * @returns a Matrix
  98581. */
  98582. getWorldMatrix(): Matrix;
  98583. /** @hidden */
  98584. _getWorldMatrixDeterminant(): number;
  98585. /**
  98586. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  98587. */
  98588. get isAnInstance(): boolean;
  98589. /**
  98590. * Gets a boolean indicating if this mesh has instances
  98591. */
  98592. get hasInstances(): boolean;
  98593. /**
  98594. * Perform relative position change from the point of view of behind the front of the mesh.
  98595. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98596. * Supports definition of mesh facing forward or backward
  98597. * @param amountRight defines the distance on the right axis
  98598. * @param amountUp defines the distance on the up axis
  98599. * @param amountForward defines the distance on the forward axis
  98600. * @returns the current mesh
  98601. */
  98602. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  98603. /**
  98604. * Calculate relative position change from the point of view of behind the front of the mesh.
  98605. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98606. * Supports definition of mesh facing forward or backward
  98607. * @param amountRight defines the distance on the right axis
  98608. * @param amountUp defines the distance on the up axis
  98609. * @param amountForward defines the distance on the forward axis
  98610. * @returns the new displacement vector
  98611. */
  98612. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  98613. /**
  98614. * Perform relative rotation change from the point of view of behind the front of the mesh.
  98615. * Supports definition of mesh facing forward or backward
  98616. * @param flipBack defines the flip
  98617. * @param twirlClockwise defines the twirl
  98618. * @param tiltRight defines the tilt
  98619. * @returns the current mesh
  98620. */
  98621. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  98622. /**
  98623. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  98624. * Supports definition of mesh facing forward or backward.
  98625. * @param flipBack defines the flip
  98626. * @param twirlClockwise defines the twirl
  98627. * @param tiltRight defines the tilt
  98628. * @returns the new rotation vector
  98629. */
  98630. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  98631. /**
  98632. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98633. * This means the mesh underlying bounding box and sphere are recomputed.
  98634. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98635. * @returns the current mesh
  98636. */
  98637. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  98638. /** @hidden */
  98639. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  98640. /** @hidden */
  98641. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  98642. /** @hidden */
  98643. _updateBoundingInfo(): AbstractMesh;
  98644. /** @hidden */
  98645. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  98646. /** @hidden */
  98647. protected _afterComputeWorldMatrix(): void;
  98648. /** @hidden */
  98649. get _effectiveMesh(): AbstractMesh;
  98650. /**
  98651. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98652. * A mesh is in the frustum if its bounding box intersects the frustum
  98653. * @param frustumPlanes defines the frustum to test
  98654. * @returns true if the mesh is in the frustum planes
  98655. */
  98656. isInFrustum(frustumPlanes: Plane[]): boolean;
  98657. /**
  98658. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  98659. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  98660. * @param frustumPlanes defines the frustum to test
  98661. * @returns true if the mesh is completely in the frustum planes
  98662. */
  98663. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98664. /**
  98665. * True if the mesh intersects another mesh or a SolidParticle object
  98666. * @param mesh defines a target mesh or SolidParticle to test
  98667. * @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)
  98668. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  98669. * @returns true if there is an intersection
  98670. */
  98671. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  98672. /**
  98673. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  98674. * @param point defines the point to test
  98675. * @returns true if there is an intersection
  98676. */
  98677. intersectsPoint(point: Vector3): boolean;
  98678. /**
  98679. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  98680. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98681. */
  98682. get checkCollisions(): boolean;
  98683. set checkCollisions(collisionEnabled: boolean);
  98684. /**
  98685. * Gets Collider object used to compute collisions (not physics)
  98686. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98687. */
  98688. get collider(): Nullable<Collider>;
  98689. /**
  98690. * Move the mesh using collision engine
  98691. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98692. * @param displacement defines the requested displacement vector
  98693. * @returns the current mesh
  98694. */
  98695. moveWithCollisions(displacement: Vector3): AbstractMesh;
  98696. private _onCollisionPositionChange;
  98697. /** @hidden */
  98698. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  98699. /** @hidden */
  98700. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  98701. /** @hidden */
  98702. _checkCollision(collider: Collider): AbstractMesh;
  98703. /** @hidden */
  98704. _generatePointsArray(): boolean;
  98705. /**
  98706. * Checks if the passed Ray intersects with the mesh
  98707. * @param ray defines the ray to use
  98708. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  98709. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98710. * @returns the picking info
  98711. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  98712. */
  98713. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  98714. /**
  98715. * Clones the current mesh
  98716. * @param name defines the mesh name
  98717. * @param newParent defines the new mesh parent
  98718. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  98719. * @returns the new mesh
  98720. */
  98721. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  98722. /**
  98723. * Disposes all the submeshes of the current meshnp
  98724. * @returns the current mesh
  98725. */
  98726. releaseSubMeshes(): AbstractMesh;
  98727. /**
  98728. * Releases resources associated with this abstract mesh.
  98729. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98730. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98731. */
  98732. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98733. /**
  98734. * Adds the passed mesh as a child to the current mesh
  98735. * @param mesh defines the child mesh
  98736. * @returns the current mesh
  98737. */
  98738. addChild(mesh: AbstractMesh): AbstractMesh;
  98739. /**
  98740. * Removes the passed mesh from the current mesh children list
  98741. * @param mesh defines the child mesh
  98742. * @returns the current mesh
  98743. */
  98744. removeChild(mesh: AbstractMesh): AbstractMesh;
  98745. /** @hidden */
  98746. private _initFacetData;
  98747. /**
  98748. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  98749. * This method can be called within the render loop.
  98750. * 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
  98751. * @returns the current mesh
  98752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98753. */
  98754. updateFacetData(): AbstractMesh;
  98755. /**
  98756. * Returns the facetLocalNormals array.
  98757. * The normals are expressed in the mesh local spac
  98758. * @returns an array of Vector3
  98759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98760. */
  98761. getFacetLocalNormals(): Vector3[];
  98762. /**
  98763. * Returns the facetLocalPositions array.
  98764. * The facet positions are expressed in the mesh local space
  98765. * @returns an array of Vector3
  98766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98767. */
  98768. getFacetLocalPositions(): Vector3[];
  98769. /**
  98770. * Returns the facetLocalPartioning array
  98771. * @returns an array of array of numbers
  98772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98773. */
  98774. getFacetLocalPartitioning(): number[][];
  98775. /**
  98776. * Returns the i-th facet position in the world system.
  98777. * This method allocates a new Vector3 per call
  98778. * @param i defines the facet index
  98779. * @returns a new Vector3
  98780. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98781. */
  98782. getFacetPosition(i: number): Vector3;
  98783. /**
  98784. * Sets the reference Vector3 with the i-th facet position in the world system
  98785. * @param i defines the facet index
  98786. * @param ref defines the target vector
  98787. * @returns the current mesh
  98788. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98789. */
  98790. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  98791. /**
  98792. * Returns the i-th facet normal in the world system.
  98793. * This method allocates a new Vector3 per call
  98794. * @param i defines the facet index
  98795. * @returns a new Vector3
  98796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98797. */
  98798. getFacetNormal(i: number): Vector3;
  98799. /**
  98800. * Sets the reference Vector3 with the i-th facet normal in the world system
  98801. * @param i defines the facet index
  98802. * @param ref defines the target vector
  98803. * @returns the current mesh
  98804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98805. */
  98806. getFacetNormalToRef(i: number, ref: Vector3): this;
  98807. /**
  98808. * 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)
  98809. * @param x defines x coordinate
  98810. * @param y defines y coordinate
  98811. * @param z defines z coordinate
  98812. * @returns the array of facet indexes
  98813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98814. */
  98815. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  98816. /**
  98817. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  98818. * @param projected sets as the (x,y,z) world projection on the facet
  98819. * @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
  98820. * @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
  98821. * @param x defines x coordinate
  98822. * @param y defines y coordinate
  98823. * @param z defines z coordinate
  98824. * @returns the face index if found (or null instead)
  98825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98826. */
  98827. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98828. /**
  98829. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  98830. * @param projected sets as the (x,y,z) local projection on the facet
  98831. * @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
  98832. * @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
  98833. * @param x defines x coordinate
  98834. * @param y defines y coordinate
  98835. * @param z defines z coordinate
  98836. * @returns the face index if found (or null instead)
  98837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98838. */
  98839. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98840. /**
  98841. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  98842. * @returns the parameters
  98843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98844. */
  98845. getFacetDataParameters(): any;
  98846. /**
  98847. * Disables the feature FacetData and frees the related memory
  98848. * @returns the current mesh
  98849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98850. */
  98851. disableFacetData(): AbstractMesh;
  98852. /**
  98853. * Updates the AbstractMesh indices array
  98854. * @param indices defines the data source
  98855. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98856. * @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)
  98857. * @returns the current mesh
  98858. */
  98859. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98860. /**
  98861. * Creates new normals data for the mesh
  98862. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  98863. * @returns the current mesh
  98864. */
  98865. createNormals(updatable: boolean): AbstractMesh;
  98866. /**
  98867. * Align the mesh with a normal
  98868. * @param normal defines the normal to use
  98869. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  98870. * @returns the current mesh
  98871. */
  98872. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  98873. /** @hidden */
  98874. _checkOcclusionQuery(): boolean;
  98875. /**
  98876. * Disables the mesh edge rendering mode
  98877. * @returns the currentAbstractMesh
  98878. */
  98879. disableEdgesRendering(): AbstractMesh;
  98880. /**
  98881. * Enables the edge rendering mode on the mesh.
  98882. * This mode makes the mesh edges visible
  98883. * @param epsilon defines the maximal distance between two angles to detect a face
  98884. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98885. * @returns the currentAbstractMesh
  98886. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98887. */
  98888. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98889. }
  98890. }
  98891. declare module BABYLON {
  98892. /**
  98893. * Interface used to define ActionEvent
  98894. */
  98895. export interface IActionEvent {
  98896. /** The mesh or sprite that triggered the action */
  98897. source: any;
  98898. /** The X mouse cursor position at the time of the event */
  98899. pointerX: number;
  98900. /** The Y mouse cursor position at the time of the event */
  98901. pointerY: number;
  98902. /** The mesh that is currently pointed at (can be null) */
  98903. meshUnderPointer: Nullable<AbstractMesh>;
  98904. /** the original (browser) event that triggered the ActionEvent */
  98905. sourceEvent?: any;
  98906. /** additional data for the event */
  98907. additionalData?: any;
  98908. }
  98909. /**
  98910. * ActionEvent is the event being sent when an action is triggered.
  98911. */
  98912. export class ActionEvent implements IActionEvent {
  98913. /** The mesh or sprite that triggered the action */
  98914. source: any;
  98915. /** The X mouse cursor position at the time of the event */
  98916. pointerX: number;
  98917. /** The Y mouse cursor position at the time of the event */
  98918. pointerY: number;
  98919. /** The mesh that is currently pointed at (can be null) */
  98920. meshUnderPointer: Nullable<AbstractMesh>;
  98921. /** the original (browser) event that triggered the ActionEvent */
  98922. sourceEvent?: any;
  98923. /** additional data for the event */
  98924. additionalData?: any;
  98925. /**
  98926. * Creates a new ActionEvent
  98927. * @param source The mesh or sprite that triggered the action
  98928. * @param pointerX The X mouse cursor position at the time of the event
  98929. * @param pointerY The Y mouse cursor position at the time of the event
  98930. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  98931. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  98932. * @param additionalData additional data for the event
  98933. */
  98934. constructor(
  98935. /** The mesh or sprite that triggered the action */
  98936. source: any,
  98937. /** The X mouse cursor position at the time of the event */
  98938. pointerX: number,
  98939. /** The Y mouse cursor position at the time of the event */
  98940. pointerY: number,
  98941. /** The mesh that is currently pointed at (can be null) */
  98942. meshUnderPointer: Nullable<AbstractMesh>,
  98943. /** the original (browser) event that triggered the ActionEvent */
  98944. sourceEvent?: any,
  98945. /** additional data for the event */
  98946. additionalData?: any);
  98947. /**
  98948. * Helper function to auto-create an ActionEvent from a source mesh.
  98949. * @param source The source mesh that triggered the event
  98950. * @param evt The original (browser) event
  98951. * @param additionalData additional data for the event
  98952. * @returns the new ActionEvent
  98953. */
  98954. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  98955. /**
  98956. * Helper function to auto-create an ActionEvent from a source sprite
  98957. * @param source The source sprite that triggered the event
  98958. * @param scene Scene associated with the sprite
  98959. * @param evt The original (browser) event
  98960. * @param additionalData additional data for the event
  98961. * @returns the new ActionEvent
  98962. */
  98963. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  98964. /**
  98965. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  98966. * @param scene the scene where the event occurred
  98967. * @param evt The original (browser) event
  98968. * @returns the new ActionEvent
  98969. */
  98970. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  98971. /**
  98972. * Helper function to auto-create an ActionEvent from a primitive
  98973. * @param prim defines the target primitive
  98974. * @param pointerPos defines the pointer position
  98975. * @param evt The original (browser) event
  98976. * @param additionalData additional data for the event
  98977. * @returns the new ActionEvent
  98978. */
  98979. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  98980. }
  98981. }
  98982. declare module BABYLON {
  98983. /**
  98984. * Abstract class used to decouple action Manager from scene and meshes.
  98985. * Do not instantiate.
  98986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98987. */
  98988. export abstract class AbstractActionManager implements IDisposable {
  98989. /** Gets the list of active triggers */
  98990. static Triggers: {
  98991. [key: string]: number;
  98992. };
  98993. /** Gets the cursor to use when hovering items */
  98994. hoverCursor: string;
  98995. /** Gets the list of actions */
  98996. actions: IAction[];
  98997. /**
  98998. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  98999. */
  99000. isRecursive: boolean;
  99001. /**
  99002. * Releases all associated resources
  99003. */
  99004. abstract dispose(): void;
  99005. /**
  99006. * Does this action manager has pointer triggers
  99007. */
  99008. abstract get hasPointerTriggers(): boolean;
  99009. /**
  99010. * Does this action manager has pick triggers
  99011. */
  99012. abstract get hasPickTriggers(): boolean;
  99013. /**
  99014. * Process a specific trigger
  99015. * @param trigger defines the trigger to process
  99016. * @param evt defines the event details to be processed
  99017. */
  99018. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99019. /**
  99020. * Does this action manager handles actions of any of the given triggers
  99021. * @param triggers defines the triggers to be tested
  99022. * @return a boolean indicating whether one (or more) of the triggers is handled
  99023. */
  99024. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99025. /**
  99026. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99027. * speed.
  99028. * @param triggerA defines the trigger to be tested
  99029. * @param triggerB defines the trigger to be tested
  99030. * @return a boolean indicating whether one (or more) of the triggers is handled
  99031. */
  99032. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99033. /**
  99034. * Does this action manager handles actions of a given trigger
  99035. * @param trigger defines the trigger to be tested
  99036. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99037. * @return whether the trigger is handled
  99038. */
  99039. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99040. /**
  99041. * Serialize this manager to a JSON object
  99042. * @param name defines the property name to store this manager
  99043. * @returns a JSON representation of this manager
  99044. */
  99045. abstract serialize(name: string): any;
  99046. /**
  99047. * Registers an action to this action manager
  99048. * @param action defines the action to be registered
  99049. * @return the action amended (prepared) after registration
  99050. */
  99051. abstract registerAction(action: IAction): Nullable<IAction>;
  99052. /**
  99053. * Unregisters an action to this action manager
  99054. * @param action defines the action to be unregistered
  99055. * @return a boolean indicating whether the action has been unregistered
  99056. */
  99057. abstract unregisterAction(action: IAction): Boolean;
  99058. /**
  99059. * Does exist one action manager with at least one trigger
  99060. **/
  99061. static get HasTriggers(): boolean;
  99062. /**
  99063. * Does exist one action manager with at least one pick trigger
  99064. **/
  99065. static get HasPickTriggers(): boolean;
  99066. /**
  99067. * Does exist one action manager that handles actions of a given trigger
  99068. * @param trigger defines the trigger to be tested
  99069. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99070. **/
  99071. static HasSpecificTrigger(trigger: number): boolean;
  99072. }
  99073. }
  99074. declare module BABYLON {
  99075. /**
  99076. * Defines how a node can be built from a string name.
  99077. */
  99078. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99079. /**
  99080. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99081. */
  99082. export class Node implements IBehaviorAware<Node> {
  99083. /** @hidden */
  99084. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99085. private static _NodeConstructors;
  99086. /**
  99087. * Add a new node constructor
  99088. * @param type defines the type name of the node to construct
  99089. * @param constructorFunc defines the constructor function
  99090. */
  99091. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99092. /**
  99093. * Returns a node constructor based on type name
  99094. * @param type defines the type name
  99095. * @param name defines the new node name
  99096. * @param scene defines the hosting scene
  99097. * @param options defines optional options to transmit to constructors
  99098. * @returns the new constructor or null
  99099. */
  99100. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99101. /**
  99102. * Gets or sets the name of the node
  99103. */
  99104. name: string;
  99105. /**
  99106. * Gets or sets the id of the node
  99107. */
  99108. id: string;
  99109. /**
  99110. * Gets or sets the unique id of the node
  99111. */
  99112. uniqueId: number;
  99113. /**
  99114. * Gets or sets a string used to store user defined state for the node
  99115. */
  99116. state: string;
  99117. /**
  99118. * Gets or sets an object used to store user defined information for the node
  99119. */
  99120. metadata: any;
  99121. /**
  99122. * For internal use only. Please do not use.
  99123. */
  99124. reservedDataStore: any;
  99125. /**
  99126. * List of inspectable custom properties (used by the Inspector)
  99127. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99128. */
  99129. inspectableCustomProperties: IInspectable[];
  99130. private _doNotSerialize;
  99131. /**
  99132. * Gets or sets a boolean used to define if the node must be serialized
  99133. */
  99134. get doNotSerialize(): boolean;
  99135. set doNotSerialize(value: boolean);
  99136. /** @hidden */
  99137. _isDisposed: boolean;
  99138. /**
  99139. * Gets a list of Animations associated with the node
  99140. */
  99141. animations: Animation[];
  99142. protected _ranges: {
  99143. [name: string]: Nullable<AnimationRange>;
  99144. };
  99145. /**
  99146. * Callback raised when the node is ready to be used
  99147. */
  99148. onReady: Nullable<(node: Node) => void>;
  99149. private _isEnabled;
  99150. private _isParentEnabled;
  99151. private _isReady;
  99152. /** @hidden */
  99153. _currentRenderId: number;
  99154. private _parentUpdateId;
  99155. /** @hidden */
  99156. _childUpdateId: number;
  99157. /** @hidden */
  99158. _waitingParentId: Nullable<string>;
  99159. /** @hidden */
  99160. _scene: Scene;
  99161. /** @hidden */
  99162. _cache: any;
  99163. private _parentNode;
  99164. private _children;
  99165. /** @hidden */
  99166. _worldMatrix: Matrix;
  99167. /** @hidden */
  99168. _worldMatrixDeterminant: number;
  99169. /** @hidden */
  99170. _worldMatrixDeterminantIsDirty: boolean;
  99171. /** @hidden */
  99172. private _sceneRootNodesIndex;
  99173. /**
  99174. * Gets a boolean indicating if the node has been disposed
  99175. * @returns true if the node was disposed
  99176. */
  99177. isDisposed(): boolean;
  99178. /**
  99179. * Gets or sets the parent of the node (without keeping the current position in the scene)
  99180. * @see https://doc.babylonjs.com/how_to/parenting
  99181. */
  99182. set parent(parent: Nullable<Node>);
  99183. get parent(): Nullable<Node>;
  99184. /** @hidden */
  99185. _addToSceneRootNodes(): void;
  99186. /** @hidden */
  99187. _removeFromSceneRootNodes(): void;
  99188. private _animationPropertiesOverride;
  99189. /**
  99190. * Gets or sets the animation properties override
  99191. */
  99192. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99193. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99194. /**
  99195. * Gets a string idenfifying the name of the class
  99196. * @returns "Node" string
  99197. */
  99198. getClassName(): string;
  99199. /** @hidden */
  99200. readonly _isNode: boolean;
  99201. /**
  99202. * An event triggered when the mesh is disposed
  99203. */
  99204. onDisposeObservable: Observable<Node>;
  99205. private _onDisposeObserver;
  99206. /**
  99207. * Sets a callback that will be raised when the node will be disposed
  99208. */
  99209. set onDispose(callback: () => void);
  99210. /**
  99211. * Creates a new Node
  99212. * @param name the name and id to be given to this node
  99213. * @param scene the scene this node will be added to
  99214. */
  99215. constructor(name: string, scene?: Nullable<Scene>);
  99216. /**
  99217. * Gets the scene of the node
  99218. * @returns a scene
  99219. */
  99220. getScene(): Scene;
  99221. /**
  99222. * Gets the engine of the node
  99223. * @returns a Engine
  99224. */
  99225. getEngine(): Engine;
  99226. private _behaviors;
  99227. /**
  99228. * Attach a behavior to the node
  99229. * @see http://doc.babylonjs.com/features/behaviour
  99230. * @param behavior defines the behavior to attach
  99231. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  99232. * @returns the current Node
  99233. */
  99234. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  99235. /**
  99236. * Remove an attached behavior
  99237. * @see http://doc.babylonjs.com/features/behaviour
  99238. * @param behavior defines the behavior to attach
  99239. * @returns the current Node
  99240. */
  99241. removeBehavior(behavior: Behavior<Node>): Node;
  99242. /**
  99243. * Gets the list of attached behaviors
  99244. * @see http://doc.babylonjs.com/features/behaviour
  99245. */
  99246. get behaviors(): Behavior<Node>[];
  99247. /**
  99248. * Gets an attached behavior by name
  99249. * @param name defines the name of the behavior to look for
  99250. * @see http://doc.babylonjs.com/features/behaviour
  99251. * @returns null if behavior was not found else the requested behavior
  99252. */
  99253. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  99254. /**
  99255. * Returns the latest update of the World matrix
  99256. * @returns a Matrix
  99257. */
  99258. getWorldMatrix(): Matrix;
  99259. /** @hidden */
  99260. _getWorldMatrixDeterminant(): number;
  99261. /**
  99262. * Returns directly the latest state of the mesh World matrix.
  99263. * A Matrix is returned.
  99264. */
  99265. get worldMatrixFromCache(): Matrix;
  99266. /** @hidden */
  99267. _initCache(): void;
  99268. /** @hidden */
  99269. updateCache(force?: boolean): void;
  99270. /** @hidden */
  99271. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99272. /** @hidden */
  99273. _updateCache(ignoreParentClass?: boolean): void;
  99274. /** @hidden */
  99275. _isSynchronized(): boolean;
  99276. /** @hidden */
  99277. _markSyncedWithParent(): void;
  99278. /** @hidden */
  99279. isSynchronizedWithParent(): boolean;
  99280. /** @hidden */
  99281. isSynchronized(): boolean;
  99282. /**
  99283. * Is this node ready to be used/rendered
  99284. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99285. * @return true if the node is ready
  99286. */
  99287. isReady(completeCheck?: boolean): boolean;
  99288. /**
  99289. * Is this node enabled?
  99290. * 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
  99291. * @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
  99292. * @return whether this node (and its parent) is enabled
  99293. */
  99294. isEnabled(checkAncestors?: boolean): boolean;
  99295. /** @hidden */
  99296. protected _syncParentEnabledState(): void;
  99297. /**
  99298. * Set the enabled state of this node
  99299. * @param value defines the new enabled state
  99300. */
  99301. setEnabled(value: boolean): void;
  99302. /**
  99303. * Is this node a descendant of the given node?
  99304. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  99305. * @param ancestor defines the parent node to inspect
  99306. * @returns a boolean indicating if this node is a descendant of the given node
  99307. */
  99308. isDescendantOf(ancestor: Node): boolean;
  99309. /** @hidden */
  99310. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  99311. /**
  99312. * Will return all nodes that have this node as ascendant
  99313. * @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
  99314. * @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
  99315. * @return all children nodes of all types
  99316. */
  99317. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  99318. /**
  99319. * Get all child-meshes of this node
  99320. * @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)
  99321. * @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
  99322. * @returns an array of AbstractMesh
  99323. */
  99324. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  99325. /**
  99326. * Get all direct children of this node
  99327. * @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
  99328. * @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)
  99329. * @returns an array of Node
  99330. */
  99331. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  99332. /** @hidden */
  99333. _setReady(state: boolean): void;
  99334. /**
  99335. * Get an animation by name
  99336. * @param name defines the name of the animation to look for
  99337. * @returns null if not found else the requested animation
  99338. */
  99339. getAnimationByName(name: string): Nullable<Animation>;
  99340. /**
  99341. * Creates an animation range for this node
  99342. * @param name defines the name of the range
  99343. * @param from defines the starting key
  99344. * @param to defines the end key
  99345. */
  99346. createAnimationRange(name: string, from: number, to: number): void;
  99347. /**
  99348. * Delete a specific animation range
  99349. * @param name defines the name of the range to delete
  99350. * @param deleteFrames defines if animation frames from the range must be deleted as well
  99351. */
  99352. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  99353. /**
  99354. * Get an animation range by name
  99355. * @param name defines the name of the animation range to look for
  99356. * @returns null if not found else the requested animation range
  99357. */
  99358. getAnimationRange(name: string): Nullable<AnimationRange>;
  99359. /**
  99360. * Gets the list of all animation ranges defined on this node
  99361. * @returns an array
  99362. */
  99363. getAnimationRanges(): Nullable<AnimationRange>[];
  99364. /**
  99365. * Will start the animation sequence
  99366. * @param name defines the range frames for animation sequence
  99367. * @param loop defines if the animation should loop (false by default)
  99368. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  99369. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  99370. * @returns the object created for this animation. If range does not exist, it will return null
  99371. */
  99372. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  99373. /**
  99374. * Serialize animation ranges into a JSON compatible object
  99375. * @returns serialization object
  99376. */
  99377. serializeAnimationRanges(): any;
  99378. /**
  99379. * Computes the world matrix of the node
  99380. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99381. * @returns the world matrix
  99382. */
  99383. computeWorldMatrix(force?: boolean): Matrix;
  99384. /**
  99385. * Releases resources associated with this node.
  99386. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99387. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99388. */
  99389. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99390. /**
  99391. * Parse animation range data from a serialization object and store them into a given node
  99392. * @param node defines where to store the animation ranges
  99393. * @param parsedNode defines the serialization object to read data from
  99394. * @param scene defines the hosting scene
  99395. */
  99396. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  99397. /**
  99398. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  99399. * @param includeDescendants Include bounding info from descendants as well (true by default)
  99400. * @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
  99401. * @returns the new bounding vectors
  99402. */
  99403. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  99404. min: Vector3;
  99405. max: Vector3;
  99406. };
  99407. }
  99408. }
  99409. declare module BABYLON {
  99410. /**
  99411. * @hidden
  99412. */
  99413. export class _IAnimationState {
  99414. key: number;
  99415. repeatCount: number;
  99416. workValue?: any;
  99417. loopMode?: number;
  99418. offsetValue?: any;
  99419. highLimitValue?: any;
  99420. }
  99421. /**
  99422. * Class used to store any kind of animation
  99423. */
  99424. export class Animation {
  99425. /**Name of the animation */
  99426. name: string;
  99427. /**Property to animate */
  99428. targetProperty: string;
  99429. /**The frames per second of the animation */
  99430. framePerSecond: number;
  99431. /**The data type of the animation */
  99432. dataType: number;
  99433. /**The loop mode of the animation */
  99434. loopMode?: number | undefined;
  99435. /**Specifies if blending should be enabled */
  99436. enableBlending?: boolean | undefined;
  99437. /**
  99438. * Use matrix interpolation instead of using direct key value when animating matrices
  99439. */
  99440. static AllowMatricesInterpolation: boolean;
  99441. /**
  99442. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  99443. */
  99444. static AllowMatrixDecomposeForInterpolation: boolean;
  99445. /**
  99446. * Stores the key frames of the animation
  99447. */
  99448. private _keys;
  99449. /**
  99450. * Stores the easing function of the animation
  99451. */
  99452. private _easingFunction;
  99453. /**
  99454. * @hidden Internal use only
  99455. */
  99456. _runtimeAnimations: RuntimeAnimation[];
  99457. /**
  99458. * The set of event that will be linked to this animation
  99459. */
  99460. private _events;
  99461. /**
  99462. * Stores an array of target property paths
  99463. */
  99464. targetPropertyPath: string[];
  99465. /**
  99466. * Stores the blending speed of the animation
  99467. */
  99468. blendingSpeed: number;
  99469. /**
  99470. * Stores the animation ranges for the animation
  99471. */
  99472. private _ranges;
  99473. /**
  99474. * @hidden Internal use
  99475. */
  99476. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  99477. /**
  99478. * Sets up an animation
  99479. * @param property The property to animate
  99480. * @param animationType The animation type to apply
  99481. * @param framePerSecond The frames per second of the animation
  99482. * @param easingFunction The easing function used in the animation
  99483. * @returns The created animation
  99484. */
  99485. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  99486. /**
  99487. * Create and start an animation on a node
  99488. * @param name defines the name of the global animation that will be run on all nodes
  99489. * @param node defines the root node where the animation will take place
  99490. * @param targetProperty defines property to animate
  99491. * @param framePerSecond defines the number of frame per second yo use
  99492. * @param totalFrame defines the number of frames in total
  99493. * @param from defines the initial value
  99494. * @param to defines the final value
  99495. * @param loopMode defines which loop mode you want to use (off by default)
  99496. * @param easingFunction defines the easing function to use (linear by default)
  99497. * @param onAnimationEnd defines the callback to call when animation end
  99498. * @returns the animatable created for this animation
  99499. */
  99500. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99501. /**
  99502. * Create and start an animation on a node and its descendants
  99503. * @param name defines the name of the global animation that will be run on all nodes
  99504. * @param node defines the root node where the animation will take place
  99505. * @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
  99506. * @param targetProperty defines property to animate
  99507. * @param framePerSecond defines the number of frame per second to use
  99508. * @param totalFrame defines the number of frames in total
  99509. * @param from defines the initial value
  99510. * @param to defines the final value
  99511. * @param loopMode defines which loop mode you want to use (off by default)
  99512. * @param easingFunction defines the easing function to use (linear by default)
  99513. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  99514. * @returns the list of animatables created for all nodes
  99515. * @example https://www.babylonjs-playground.com/#MH0VLI
  99516. */
  99517. 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[]>;
  99518. /**
  99519. * Creates a new animation, merges it with the existing animations and starts it
  99520. * @param name Name of the animation
  99521. * @param node Node which contains the scene that begins the animations
  99522. * @param targetProperty Specifies which property to animate
  99523. * @param framePerSecond The frames per second of the animation
  99524. * @param totalFrame The total number of frames
  99525. * @param from The frame at the beginning of the animation
  99526. * @param to The frame at the end of the animation
  99527. * @param loopMode Specifies the loop mode of the animation
  99528. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  99529. * @param onAnimationEnd Callback to run once the animation is complete
  99530. * @returns Nullable animation
  99531. */
  99532. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99533. /**
  99534. * Transition property of an host to the target Value
  99535. * @param property The property to transition
  99536. * @param targetValue The target Value of the property
  99537. * @param host The object where the property to animate belongs
  99538. * @param scene Scene used to run the animation
  99539. * @param frameRate Framerate (in frame/s) to use
  99540. * @param transition The transition type we want to use
  99541. * @param duration The duration of the animation, in milliseconds
  99542. * @param onAnimationEnd Callback trigger at the end of the animation
  99543. * @returns Nullable animation
  99544. */
  99545. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  99546. /**
  99547. * Return the array of runtime animations currently using this animation
  99548. */
  99549. get runtimeAnimations(): RuntimeAnimation[];
  99550. /**
  99551. * Specifies if any of the runtime animations are currently running
  99552. */
  99553. get hasRunningRuntimeAnimations(): boolean;
  99554. /**
  99555. * Initializes the animation
  99556. * @param name Name of the animation
  99557. * @param targetProperty Property to animate
  99558. * @param framePerSecond The frames per second of the animation
  99559. * @param dataType The data type of the animation
  99560. * @param loopMode The loop mode of the animation
  99561. * @param enableBlending Specifies if blending should be enabled
  99562. */
  99563. constructor(
  99564. /**Name of the animation */
  99565. name: string,
  99566. /**Property to animate */
  99567. targetProperty: string,
  99568. /**The frames per second of the animation */
  99569. framePerSecond: number,
  99570. /**The data type of the animation */
  99571. dataType: number,
  99572. /**The loop mode of the animation */
  99573. loopMode?: number | undefined,
  99574. /**Specifies if blending should be enabled */
  99575. enableBlending?: boolean | undefined);
  99576. /**
  99577. * Converts the animation to a string
  99578. * @param fullDetails support for multiple levels of logging within scene loading
  99579. * @returns String form of the animation
  99580. */
  99581. toString(fullDetails?: boolean): string;
  99582. /**
  99583. * Add an event to this animation
  99584. * @param event Event to add
  99585. */
  99586. addEvent(event: AnimationEvent): void;
  99587. /**
  99588. * Remove all events found at the given frame
  99589. * @param frame The frame to remove events from
  99590. */
  99591. removeEvents(frame: number): void;
  99592. /**
  99593. * Retrieves all the events from the animation
  99594. * @returns Events from the animation
  99595. */
  99596. getEvents(): AnimationEvent[];
  99597. /**
  99598. * Creates an animation range
  99599. * @param name Name of the animation range
  99600. * @param from Starting frame of the animation range
  99601. * @param to Ending frame of the animation
  99602. */
  99603. createRange(name: string, from: number, to: number): void;
  99604. /**
  99605. * Deletes an animation range by name
  99606. * @param name Name of the animation range to delete
  99607. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  99608. */
  99609. deleteRange(name: string, deleteFrames?: boolean): void;
  99610. /**
  99611. * Gets the animation range by name, or null if not defined
  99612. * @param name Name of the animation range
  99613. * @returns Nullable animation range
  99614. */
  99615. getRange(name: string): Nullable<AnimationRange>;
  99616. /**
  99617. * Gets the key frames from the animation
  99618. * @returns The key frames of the animation
  99619. */
  99620. getKeys(): Array<IAnimationKey>;
  99621. /**
  99622. * Gets the highest frame rate of the animation
  99623. * @returns Highest frame rate of the animation
  99624. */
  99625. getHighestFrame(): number;
  99626. /**
  99627. * Gets the easing function of the animation
  99628. * @returns Easing function of the animation
  99629. */
  99630. getEasingFunction(): IEasingFunction;
  99631. /**
  99632. * Sets the easing function of the animation
  99633. * @param easingFunction A custom mathematical formula for animation
  99634. */
  99635. setEasingFunction(easingFunction: EasingFunction): void;
  99636. /**
  99637. * Interpolates a scalar linearly
  99638. * @param startValue Start value of the animation curve
  99639. * @param endValue End value of the animation curve
  99640. * @param gradient Scalar amount to interpolate
  99641. * @returns Interpolated scalar value
  99642. */
  99643. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  99644. /**
  99645. * Interpolates a scalar cubically
  99646. * @param startValue Start value of the animation curve
  99647. * @param outTangent End tangent of the animation
  99648. * @param endValue End value of the animation curve
  99649. * @param inTangent Start tangent of the animation curve
  99650. * @param gradient Scalar amount to interpolate
  99651. * @returns Interpolated scalar value
  99652. */
  99653. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  99654. /**
  99655. * Interpolates a quaternion using a spherical linear interpolation
  99656. * @param startValue Start value of the animation curve
  99657. * @param endValue End value of the animation curve
  99658. * @param gradient Scalar amount to interpolate
  99659. * @returns Interpolated quaternion value
  99660. */
  99661. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  99662. /**
  99663. * Interpolates a quaternion cubically
  99664. * @param startValue Start value of the animation curve
  99665. * @param outTangent End tangent of the animation curve
  99666. * @param endValue End value of the animation curve
  99667. * @param inTangent Start tangent of the animation curve
  99668. * @param gradient Scalar amount to interpolate
  99669. * @returns Interpolated quaternion value
  99670. */
  99671. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  99672. /**
  99673. * Interpolates a Vector3 linearl
  99674. * @param startValue Start value of the animation curve
  99675. * @param endValue End value of the animation curve
  99676. * @param gradient Scalar amount to interpolate
  99677. * @returns Interpolated scalar value
  99678. */
  99679. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  99680. /**
  99681. * Interpolates a Vector3 cubically
  99682. * @param startValue Start value of the animation curve
  99683. * @param outTangent End tangent of the animation
  99684. * @param endValue End value of the animation curve
  99685. * @param inTangent Start tangent of the animation curve
  99686. * @param gradient Scalar amount to interpolate
  99687. * @returns InterpolatedVector3 value
  99688. */
  99689. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  99690. /**
  99691. * Interpolates a Vector2 linearly
  99692. * @param startValue Start value of the animation curve
  99693. * @param endValue End value of the animation curve
  99694. * @param gradient Scalar amount to interpolate
  99695. * @returns Interpolated Vector2 value
  99696. */
  99697. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  99698. /**
  99699. * Interpolates a Vector2 cubically
  99700. * @param startValue Start value of the animation curve
  99701. * @param outTangent End tangent of the animation
  99702. * @param endValue End value of the animation curve
  99703. * @param inTangent Start tangent of the animation curve
  99704. * @param gradient Scalar amount to interpolate
  99705. * @returns Interpolated Vector2 value
  99706. */
  99707. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  99708. /**
  99709. * Interpolates a size linearly
  99710. * @param startValue Start value of the animation curve
  99711. * @param endValue End value of the animation curve
  99712. * @param gradient Scalar amount to interpolate
  99713. * @returns Interpolated Size value
  99714. */
  99715. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  99716. /**
  99717. * Interpolates a Color3 linearly
  99718. * @param startValue Start value of the animation curve
  99719. * @param endValue End value of the animation curve
  99720. * @param gradient Scalar amount to interpolate
  99721. * @returns Interpolated Color3 value
  99722. */
  99723. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  99724. /**
  99725. * Interpolates a Color4 linearly
  99726. * @param startValue Start value of the animation curve
  99727. * @param endValue End value of the animation curve
  99728. * @param gradient Scalar amount to interpolate
  99729. * @returns Interpolated Color3 value
  99730. */
  99731. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  99732. /**
  99733. * @hidden Internal use only
  99734. */
  99735. _getKeyValue(value: any): any;
  99736. /**
  99737. * @hidden Internal use only
  99738. */
  99739. _interpolate(currentFrame: number, state: _IAnimationState): any;
  99740. /**
  99741. * Defines the function to use to interpolate matrices
  99742. * @param startValue defines the start matrix
  99743. * @param endValue defines the end matrix
  99744. * @param gradient defines the gradient between both matrices
  99745. * @param result defines an optional target matrix where to store the interpolation
  99746. * @returns the interpolated matrix
  99747. */
  99748. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  99749. /**
  99750. * Makes a copy of the animation
  99751. * @returns Cloned animation
  99752. */
  99753. clone(): Animation;
  99754. /**
  99755. * Sets the key frames of the animation
  99756. * @param values The animation key frames to set
  99757. */
  99758. setKeys(values: Array<IAnimationKey>): void;
  99759. /**
  99760. * Serializes the animation to an object
  99761. * @returns Serialized object
  99762. */
  99763. serialize(): any;
  99764. /**
  99765. * Float animation type
  99766. */
  99767. static readonly ANIMATIONTYPE_FLOAT: number;
  99768. /**
  99769. * Vector3 animation type
  99770. */
  99771. static readonly ANIMATIONTYPE_VECTOR3: number;
  99772. /**
  99773. * Quaternion animation type
  99774. */
  99775. static readonly ANIMATIONTYPE_QUATERNION: number;
  99776. /**
  99777. * Matrix animation type
  99778. */
  99779. static readonly ANIMATIONTYPE_MATRIX: number;
  99780. /**
  99781. * Color3 animation type
  99782. */
  99783. static readonly ANIMATIONTYPE_COLOR3: number;
  99784. /**
  99785. * Color3 animation type
  99786. */
  99787. static readonly ANIMATIONTYPE_COLOR4: number;
  99788. /**
  99789. * Vector2 animation type
  99790. */
  99791. static readonly ANIMATIONTYPE_VECTOR2: number;
  99792. /**
  99793. * Size animation type
  99794. */
  99795. static readonly ANIMATIONTYPE_SIZE: number;
  99796. /**
  99797. * Relative Loop Mode
  99798. */
  99799. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  99800. /**
  99801. * Cycle Loop Mode
  99802. */
  99803. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  99804. /**
  99805. * Constant Loop Mode
  99806. */
  99807. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  99808. /** @hidden */
  99809. static _UniversalLerp(left: any, right: any, amount: number): any;
  99810. /**
  99811. * Parses an animation object and creates an animation
  99812. * @param parsedAnimation Parsed animation object
  99813. * @returns Animation object
  99814. */
  99815. static Parse(parsedAnimation: any): Animation;
  99816. /**
  99817. * Appends the serialized animations from the source animations
  99818. * @param source Source containing the animations
  99819. * @param destination Target to store the animations
  99820. */
  99821. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99822. }
  99823. }
  99824. declare module BABYLON {
  99825. /**
  99826. * Interface containing an array of animations
  99827. */
  99828. export interface IAnimatable {
  99829. /**
  99830. * Array of animations
  99831. */
  99832. animations: Nullable<Array<Animation>>;
  99833. }
  99834. }
  99835. declare module BABYLON {
  99836. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  99837. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99838. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99839. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99840. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99841. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99842. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99843. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99844. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99845. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99846. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99847. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99848. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99849. /**
  99850. * Decorator used to define property that can be serialized as reference to a camera
  99851. * @param sourceName defines the name of the property to decorate
  99852. */
  99853. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99854. /**
  99855. * Class used to help serialization objects
  99856. */
  99857. export class SerializationHelper {
  99858. /** @hidden */
  99859. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  99860. /** @hidden */
  99861. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  99862. /** @hidden */
  99863. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  99864. /** @hidden */
  99865. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  99866. /**
  99867. * Appends the serialized animations from the source animations
  99868. * @param source Source containing the animations
  99869. * @param destination Target to store the animations
  99870. */
  99871. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99872. /**
  99873. * Static function used to serialized a specific entity
  99874. * @param entity defines the entity to serialize
  99875. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  99876. * @returns a JSON compatible object representing the serialization of the entity
  99877. */
  99878. static Serialize<T>(entity: T, serializationObject?: any): any;
  99879. /**
  99880. * Creates a new entity from a serialization data object
  99881. * @param creationFunction defines a function used to instanciated the new entity
  99882. * @param source defines the source serialization data
  99883. * @param scene defines the hosting scene
  99884. * @param rootUrl defines the root url for resources
  99885. * @returns a new entity
  99886. */
  99887. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  99888. /**
  99889. * Clones an object
  99890. * @param creationFunction defines the function used to instanciate the new object
  99891. * @param source defines the source object
  99892. * @returns the cloned object
  99893. */
  99894. static Clone<T>(creationFunction: () => T, source: T): T;
  99895. /**
  99896. * Instanciates a new object based on a source one (some data will be shared between both object)
  99897. * @param creationFunction defines the function used to instanciate the new object
  99898. * @param source defines the source object
  99899. * @returns the new object
  99900. */
  99901. static Instanciate<T>(creationFunction: () => T, source: T): T;
  99902. }
  99903. }
  99904. declare module BABYLON {
  99905. /**
  99906. * Class used to manipulate GUIDs
  99907. */
  99908. export class GUID {
  99909. /**
  99910. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99911. * Be aware Math.random() could cause collisions, but:
  99912. * "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"
  99913. * @returns a pseudo random id
  99914. */
  99915. static RandomId(): string;
  99916. }
  99917. }
  99918. declare module BABYLON {
  99919. /**
  99920. * Base class of all the textures in babylon.
  99921. * It groups all the common properties the materials, post process, lights... might need
  99922. * in order to make a correct use of the texture.
  99923. */
  99924. export class BaseTexture implements IAnimatable {
  99925. /**
  99926. * Default anisotropic filtering level for the application.
  99927. * It is set to 4 as a good tradeoff between perf and quality.
  99928. */
  99929. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  99930. /**
  99931. * Gets or sets the unique id of the texture
  99932. */
  99933. uniqueId: number;
  99934. /**
  99935. * Define the name of the texture.
  99936. */
  99937. name: string;
  99938. /**
  99939. * Gets or sets an object used to store user defined information.
  99940. */
  99941. metadata: any;
  99942. /**
  99943. * For internal use only. Please do not use.
  99944. */
  99945. reservedDataStore: any;
  99946. private _hasAlpha;
  99947. /**
  99948. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  99949. */
  99950. set hasAlpha(value: boolean);
  99951. get hasAlpha(): boolean;
  99952. /**
  99953. * Defines if the alpha value should be determined via the rgb values.
  99954. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  99955. */
  99956. getAlphaFromRGB: boolean;
  99957. /**
  99958. * Intensity or strength of the texture.
  99959. * It is commonly used by materials to fine tune the intensity of the texture
  99960. */
  99961. level: number;
  99962. /**
  99963. * Define the UV chanel to use starting from 0 and defaulting to 0.
  99964. * This is part of the texture as textures usually maps to one uv set.
  99965. */
  99966. coordinatesIndex: number;
  99967. private _coordinatesMode;
  99968. /**
  99969. * How a texture is mapped.
  99970. *
  99971. * | Value | Type | Description |
  99972. * | ----- | ----------------------------------- | ----------- |
  99973. * | 0 | EXPLICIT_MODE | |
  99974. * | 1 | SPHERICAL_MODE | |
  99975. * | 2 | PLANAR_MODE | |
  99976. * | 3 | CUBIC_MODE | |
  99977. * | 4 | PROJECTION_MODE | |
  99978. * | 5 | SKYBOX_MODE | |
  99979. * | 6 | INVCUBIC_MODE | |
  99980. * | 7 | EQUIRECTANGULAR_MODE | |
  99981. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  99982. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  99983. */
  99984. set coordinatesMode(value: number);
  99985. get coordinatesMode(): number;
  99986. /**
  99987. * | Value | Type | Description |
  99988. * | ----- | ------------------ | ----------- |
  99989. * | 0 | CLAMP_ADDRESSMODE | |
  99990. * | 1 | WRAP_ADDRESSMODE | |
  99991. * | 2 | MIRROR_ADDRESSMODE | |
  99992. */
  99993. wrapU: number;
  99994. /**
  99995. * | Value | Type | Description |
  99996. * | ----- | ------------------ | ----------- |
  99997. * | 0 | CLAMP_ADDRESSMODE | |
  99998. * | 1 | WRAP_ADDRESSMODE | |
  99999. * | 2 | MIRROR_ADDRESSMODE | |
  100000. */
  100001. wrapV: number;
  100002. /**
  100003. * | Value | Type | Description |
  100004. * | ----- | ------------------ | ----------- |
  100005. * | 0 | CLAMP_ADDRESSMODE | |
  100006. * | 1 | WRAP_ADDRESSMODE | |
  100007. * | 2 | MIRROR_ADDRESSMODE | |
  100008. */
  100009. wrapR: number;
  100010. /**
  100011. * With compliant hardware and browser (supporting anisotropic filtering)
  100012. * this defines the level of anisotropic filtering in the texture.
  100013. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100014. */
  100015. anisotropicFilteringLevel: number;
  100016. /**
  100017. * Define if the texture is a cube texture or if false a 2d texture.
  100018. */
  100019. get isCube(): boolean;
  100020. set isCube(value: boolean);
  100021. /**
  100022. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100023. */
  100024. get is3D(): boolean;
  100025. set is3D(value: boolean);
  100026. /**
  100027. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100028. */
  100029. get is2DArray(): boolean;
  100030. set is2DArray(value: boolean);
  100031. /**
  100032. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100033. * HDR texture are usually stored in linear space.
  100034. * This only impacts the PBR and Background materials
  100035. */
  100036. gammaSpace: boolean;
  100037. /**
  100038. * Gets or sets whether or not the texture contains RGBD data.
  100039. */
  100040. get isRGBD(): boolean;
  100041. set isRGBD(value: boolean);
  100042. /**
  100043. * Is Z inverted in the texture (useful in a cube texture).
  100044. */
  100045. invertZ: boolean;
  100046. /**
  100047. * Are mip maps generated for this texture or not.
  100048. */
  100049. get noMipmap(): boolean;
  100050. /**
  100051. * @hidden
  100052. */
  100053. lodLevelInAlpha: boolean;
  100054. /**
  100055. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100056. */
  100057. get lodGenerationOffset(): number;
  100058. set lodGenerationOffset(value: number);
  100059. /**
  100060. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100061. */
  100062. get lodGenerationScale(): number;
  100063. set lodGenerationScale(value: number);
  100064. /**
  100065. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100066. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100067. * average roughness values.
  100068. */
  100069. get linearSpecularLOD(): boolean;
  100070. set linearSpecularLOD(value: boolean);
  100071. /**
  100072. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100073. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100074. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100075. */
  100076. get irradianceTexture(): Nullable<BaseTexture>;
  100077. set irradianceTexture(value: Nullable<BaseTexture>);
  100078. /**
  100079. * Define if the texture is a render target.
  100080. */
  100081. isRenderTarget: boolean;
  100082. /**
  100083. * Define the unique id of the texture in the scene.
  100084. */
  100085. get uid(): string;
  100086. /**
  100087. * Return a string representation of the texture.
  100088. * @returns the texture as a string
  100089. */
  100090. toString(): string;
  100091. /**
  100092. * Get the class name of the texture.
  100093. * @returns "BaseTexture"
  100094. */
  100095. getClassName(): string;
  100096. /**
  100097. * Define the list of animation attached to the texture.
  100098. */
  100099. animations: Animation[];
  100100. /**
  100101. * An event triggered when the texture is disposed.
  100102. */
  100103. onDisposeObservable: Observable<BaseTexture>;
  100104. private _onDisposeObserver;
  100105. /**
  100106. * Callback triggered when the texture has been disposed.
  100107. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100108. */
  100109. set onDispose(callback: () => void);
  100110. /**
  100111. * Define the current state of the loading sequence when in delayed load mode.
  100112. */
  100113. delayLoadState: number;
  100114. private _scene;
  100115. /** @hidden */
  100116. _texture: Nullable<InternalTexture>;
  100117. private _uid;
  100118. /**
  100119. * Define if the texture is preventinga material to render or not.
  100120. * If not and the texture is not ready, the engine will use a default black texture instead.
  100121. */
  100122. get isBlocking(): boolean;
  100123. /**
  100124. * Instantiates a new BaseTexture.
  100125. * Base class of all the textures in babylon.
  100126. * It groups all the common properties the materials, post process, lights... might need
  100127. * in order to make a correct use of the texture.
  100128. * @param scene Define the scene the texture blongs to
  100129. */
  100130. constructor(scene: Nullable<Scene>);
  100131. /**
  100132. * Get the scene the texture belongs to.
  100133. * @returns the scene or null if undefined
  100134. */
  100135. getScene(): Nullable<Scene>;
  100136. /**
  100137. * Get the texture transform matrix used to offset tile the texture for istance.
  100138. * @returns the transformation matrix
  100139. */
  100140. getTextureMatrix(): Matrix;
  100141. /**
  100142. * Get the texture reflection matrix used to rotate/transform the reflection.
  100143. * @returns the reflection matrix
  100144. */
  100145. getReflectionTextureMatrix(): Matrix;
  100146. /**
  100147. * Get the underlying lower level texture from Babylon.
  100148. * @returns the insternal texture
  100149. */
  100150. getInternalTexture(): Nullable<InternalTexture>;
  100151. /**
  100152. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  100153. * @returns true if ready or not blocking
  100154. */
  100155. isReadyOrNotBlocking(): boolean;
  100156. /**
  100157. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  100158. * @returns true if fully ready
  100159. */
  100160. isReady(): boolean;
  100161. private _cachedSize;
  100162. /**
  100163. * Get the size of the texture.
  100164. * @returns the texture size.
  100165. */
  100166. getSize(): ISize;
  100167. /**
  100168. * Get the base size of the texture.
  100169. * It can be different from the size if the texture has been resized for POT for instance
  100170. * @returns the base size
  100171. */
  100172. getBaseSize(): ISize;
  100173. /**
  100174. * Update the sampling mode of the texture.
  100175. * Default is Trilinear mode.
  100176. *
  100177. * | Value | Type | Description |
  100178. * | ----- | ------------------ | ----------- |
  100179. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  100180. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  100181. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  100182. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  100183. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  100184. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  100185. * | 7 | NEAREST_LINEAR | |
  100186. * | 8 | NEAREST_NEAREST | |
  100187. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  100188. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  100189. * | 11 | LINEAR_LINEAR | |
  100190. * | 12 | LINEAR_NEAREST | |
  100191. *
  100192. * > _mag_: magnification filter (close to the viewer)
  100193. * > _min_: minification filter (far from the viewer)
  100194. * > _mip_: filter used between mip map levels
  100195. *@param samplingMode Define the new sampling mode of the texture
  100196. */
  100197. updateSamplingMode(samplingMode: number): void;
  100198. /**
  100199. * Scales the texture if is `canRescale()`
  100200. * @param ratio the resize factor we want to use to rescale
  100201. */
  100202. scale(ratio: number): void;
  100203. /**
  100204. * Get if the texture can rescale.
  100205. */
  100206. get canRescale(): boolean;
  100207. /** @hidden */
  100208. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  100209. /** @hidden */
  100210. _rebuild(): void;
  100211. /**
  100212. * Triggers the load sequence in delayed load mode.
  100213. */
  100214. delayLoad(): void;
  100215. /**
  100216. * Clones the texture.
  100217. * @returns the cloned texture
  100218. */
  100219. clone(): Nullable<BaseTexture>;
  100220. /**
  100221. * Get the texture underlying type (INT, FLOAT...)
  100222. */
  100223. get textureType(): number;
  100224. /**
  100225. * Get the texture underlying format (RGB, RGBA...)
  100226. */
  100227. get textureFormat(): number;
  100228. /**
  100229. * Indicates that textures need to be re-calculated for all materials
  100230. */
  100231. protected _markAllSubMeshesAsTexturesDirty(): void;
  100232. /**
  100233. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  100234. * This will returns an RGBA array buffer containing either in values (0-255) or
  100235. * float values (0-1) depending of the underlying buffer type.
  100236. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  100237. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  100238. * @param buffer defines a user defined buffer to fill with data (can be null)
  100239. * @returns The Array buffer containing the pixels data.
  100240. */
  100241. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  100242. /**
  100243. * Release and destroy the underlying lower level texture aka internalTexture.
  100244. */
  100245. releaseInternalTexture(): void;
  100246. /** @hidden */
  100247. get _lodTextureHigh(): Nullable<BaseTexture>;
  100248. /** @hidden */
  100249. get _lodTextureMid(): Nullable<BaseTexture>;
  100250. /** @hidden */
  100251. get _lodTextureLow(): Nullable<BaseTexture>;
  100252. /**
  100253. * Dispose the texture and release its associated resources.
  100254. */
  100255. dispose(): void;
  100256. /**
  100257. * Serialize the texture into a JSON representation that can be parsed later on.
  100258. * @returns the JSON representation of the texture
  100259. */
  100260. serialize(): any;
  100261. /**
  100262. * Helper function to be called back once a list of texture contains only ready textures.
  100263. * @param textures Define the list of textures to wait for
  100264. * @param callback Define the callback triggered once the entire list will be ready
  100265. */
  100266. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  100267. }
  100268. }
  100269. declare module BABYLON {
  100270. /**
  100271. * Options to be used when creating an effect.
  100272. */
  100273. export interface IEffectCreationOptions {
  100274. /**
  100275. * Atrributes that will be used in the shader.
  100276. */
  100277. attributes: string[];
  100278. /**
  100279. * Uniform varible names that will be set in the shader.
  100280. */
  100281. uniformsNames: string[];
  100282. /**
  100283. * Uniform buffer variable names that will be set in the shader.
  100284. */
  100285. uniformBuffersNames: string[];
  100286. /**
  100287. * Sampler texture variable names that will be set in the shader.
  100288. */
  100289. samplers: string[];
  100290. /**
  100291. * Define statements that will be set in the shader.
  100292. */
  100293. defines: any;
  100294. /**
  100295. * Possible fallbacks for this effect to improve performance when needed.
  100296. */
  100297. fallbacks: Nullable<IEffectFallbacks>;
  100298. /**
  100299. * Callback that will be called when the shader is compiled.
  100300. */
  100301. onCompiled: Nullable<(effect: Effect) => void>;
  100302. /**
  100303. * Callback that will be called if an error occurs during shader compilation.
  100304. */
  100305. onError: Nullable<(effect: Effect, errors: string) => void>;
  100306. /**
  100307. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100308. */
  100309. indexParameters?: any;
  100310. /**
  100311. * Max number of lights that can be used in the shader.
  100312. */
  100313. maxSimultaneousLights?: number;
  100314. /**
  100315. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  100316. */
  100317. transformFeedbackVaryings?: Nullable<string[]>;
  100318. }
  100319. /**
  100320. * Effect containing vertex and fragment shader that can be executed on an object.
  100321. */
  100322. export class Effect implements IDisposable {
  100323. /**
  100324. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  100325. */
  100326. static ShadersRepository: string;
  100327. /**
  100328. * Name of the effect.
  100329. */
  100330. name: any;
  100331. /**
  100332. * String container all the define statements that should be set on the shader.
  100333. */
  100334. defines: string;
  100335. /**
  100336. * Callback that will be called when the shader is compiled.
  100337. */
  100338. onCompiled: Nullable<(effect: Effect) => void>;
  100339. /**
  100340. * Callback that will be called if an error occurs during shader compilation.
  100341. */
  100342. onError: Nullable<(effect: Effect, errors: string) => void>;
  100343. /**
  100344. * Callback that will be called when effect is bound.
  100345. */
  100346. onBind: Nullable<(effect: Effect) => void>;
  100347. /**
  100348. * Unique ID of the effect.
  100349. */
  100350. uniqueId: number;
  100351. /**
  100352. * Observable that will be called when the shader is compiled.
  100353. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  100354. */
  100355. onCompileObservable: Observable<Effect>;
  100356. /**
  100357. * Observable that will be called if an error occurs during shader compilation.
  100358. */
  100359. onErrorObservable: Observable<Effect>;
  100360. /** @hidden */
  100361. _onBindObservable: Nullable<Observable<Effect>>;
  100362. /**
  100363. * Observable that will be called when effect is bound.
  100364. */
  100365. get onBindObservable(): Observable<Effect>;
  100366. /** @hidden */
  100367. _bonesComputationForcedToCPU: boolean;
  100368. private static _uniqueIdSeed;
  100369. private _engine;
  100370. private _uniformBuffersNames;
  100371. private _uniformsNames;
  100372. private _samplerList;
  100373. private _samplers;
  100374. private _isReady;
  100375. private _compilationError;
  100376. private _allFallbacksProcessed;
  100377. private _attributesNames;
  100378. private _attributes;
  100379. private _attributeLocationByName;
  100380. private _uniforms;
  100381. /**
  100382. * Key for the effect.
  100383. * @hidden
  100384. */
  100385. _key: string;
  100386. private _indexParameters;
  100387. private _fallbacks;
  100388. private _vertexSourceCode;
  100389. private _fragmentSourceCode;
  100390. private _vertexSourceCodeOverride;
  100391. private _fragmentSourceCodeOverride;
  100392. private _transformFeedbackVaryings;
  100393. /**
  100394. * Compiled shader to webGL program.
  100395. * @hidden
  100396. */
  100397. _pipelineContext: Nullable<IPipelineContext>;
  100398. private _valueCache;
  100399. private static _baseCache;
  100400. /**
  100401. * Instantiates an effect.
  100402. * An effect can be used to create/manage/execute vertex and fragment shaders.
  100403. * @param baseName Name of the effect.
  100404. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  100405. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  100406. * @param samplers List of sampler variables that will be passed to the shader.
  100407. * @param engine Engine to be used to render the effect
  100408. * @param defines Define statements to be added to the shader.
  100409. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  100410. * @param onCompiled Callback that will be called when the shader is compiled.
  100411. * @param onError Callback that will be called if an error occurs during shader compilation.
  100412. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100413. */
  100414. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  100415. private _useFinalCode;
  100416. /**
  100417. * Unique key for this effect
  100418. */
  100419. get key(): string;
  100420. /**
  100421. * If the effect has been compiled and prepared.
  100422. * @returns if the effect is compiled and prepared.
  100423. */
  100424. isReady(): boolean;
  100425. private _isReadyInternal;
  100426. /**
  100427. * The engine the effect was initialized with.
  100428. * @returns the engine.
  100429. */
  100430. getEngine(): Engine;
  100431. /**
  100432. * The pipeline context for this effect
  100433. * @returns the associated pipeline context
  100434. */
  100435. getPipelineContext(): Nullable<IPipelineContext>;
  100436. /**
  100437. * The set of names of attribute variables for the shader.
  100438. * @returns An array of attribute names.
  100439. */
  100440. getAttributesNames(): string[];
  100441. /**
  100442. * Returns the attribute at the given index.
  100443. * @param index The index of the attribute.
  100444. * @returns The location of the attribute.
  100445. */
  100446. getAttributeLocation(index: number): number;
  100447. /**
  100448. * Returns the attribute based on the name of the variable.
  100449. * @param name of the attribute to look up.
  100450. * @returns the attribute location.
  100451. */
  100452. getAttributeLocationByName(name: string): number;
  100453. /**
  100454. * The number of attributes.
  100455. * @returns the numnber of attributes.
  100456. */
  100457. getAttributesCount(): number;
  100458. /**
  100459. * Gets the index of a uniform variable.
  100460. * @param uniformName of the uniform to look up.
  100461. * @returns the index.
  100462. */
  100463. getUniformIndex(uniformName: string): number;
  100464. /**
  100465. * Returns the attribute based on the name of the variable.
  100466. * @param uniformName of the uniform to look up.
  100467. * @returns the location of the uniform.
  100468. */
  100469. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  100470. /**
  100471. * Returns an array of sampler variable names
  100472. * @returns The array of sampler variable neames.
  100473. */
  100474. getSamplers(): string[];
  100475. /**
  100476. * The error from the last compilation.
  100477. * @returns the error string.
  100478. */
  100479. getCompilationError(): string;
  100480. /**
  100481. * Gets a boolean indicating that all fallbacks were used during compilation
  100482. * @returns true if all fallbacks were used
  100483. */
  100484. allFallbacksProcessed(): boolean;
  100485. /**
  100486. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  100487. * @param func The callback to be used.
  100488. */
  100489. executeWhenCompiled(func: (effect: Effect) => void): void;
  100490. private _checkIsReady;
  100491. private _loadShader;
  100492. /**
  100493. * Recompiles the webGL program
  100494. * @param vertexSourceCode The source code for the vertex shader.
  100495. * @param fragmentSourceCode The source code for the fragment shader.
  100496. * @param onCompiled Callback called when completed.
  100497. * @param onError Callback called on error.
  100498. * @hidden
  100499. */
  100500. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  100501. /**
  100502. * Prepares the effect
  100503. * @hidden
  100504. */
  100505. _prepareEffect(): void;
  100506. private _processCompilationErrors;
  100507. /**
  100508. * Checks if the effect is supported. (Must be called after compilation)
  100509. */
  100510. get isSupported(): boolean;
  100511. /**
  100512. * Binds a texture to the engine to be used as output of the shader.
  100513. * @param channel Name of the output variable.
  100514. * @param texture Texture to bind.
  100515. * @hidden
  100516. */
  100517. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  100518. /**
  100519. * Sets a texture on the engine to be used in the shader.
  100520. * @param channel Name of the sampler variable.
  100521. * @param texture Texture to set.
  100522. */
  100523. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  100524. /**
  100525. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  100526. * @param channel Name of the sampler variable.
  100527. * @param texture Texture to set.
  100528. */
  100529. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  100530. /**
  100531. * Sets an array of textures on the engine to be used in the shader.
  100532. * @param channel Name of the variable.
  100533. * @param textures Textures to set.
  100534. */
  100535. setTextureArray(channel: string, textures: BaseTexture[]): void;
  100536. /**
  100537. * 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)
  100538. * @param channel Name of the sampler variable.
  100539. * @param postProcess Post process to get the input texture from.
  100540. */
  100541. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  100542. /**
  100543. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  100544. * 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)
  100545. * @param channel Name of the sampler variable.
  100546. * @param postProcess Post process to get the output texture from.
  100547. */
  100548. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  100549. /** @hidden */
  100550. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  100551. /** @hidden */
  100552. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  100553. /** @hidden */
  100554. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  100555. /** @hidden */
  100556. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  100557. /**
  100558. * Binds a buffer to a uniform.
  100559. * @param buffer Buffer to bind.
  100560. * @param name Name of the uniform variable to bind to.
  100561. */
  100562. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  100563. /**
  100564. * Binds block to a uniform.
  100565. * @param blockName Name of the block to bind.
  100566. * @param index Index to bind.
  100567. */
  100568. bindUniformBlock(blockName: string, index: number): void;
  100569. /**
  100570. * Sets an interger value on a uniform variable.
  100571. * @param uniformName Name of the variable.
  100572. * @param value Value to be set.
  100573. * @returns this effect.
  100574. */
  100575. setInt(uniformName: string, value: number): Effect;
  100576. /**
  100577. * Sets an int array on a uniform variable.
  100578. * @param uniformName Name of the variable.
  100579. * @param array array to be set.
  100580. * @returns this effect.
  100581. */
  100582. setIntArray(uniformName: string, array: Int32Array): Effect;
  100583. /**
  100584. * 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)
  100585. * @param uniformName Name of the variable.
  100586. * @param array array to be set.
  100587. * @returns this effect.
  100588. */
  100589. setIntArray2(uniformName: string, array: Int32Array): Effect;
  100590. /**
  100591. * 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)
  100592. * @param uniformName Name of the variable.
  100593. * @param array array to be set.
  100594. * @returns this effect.
  100595. */
  100596. setIntArray3(uniformName: string, array: Int32Array): Effect;
  100597. /**
  100598. * 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)
  100599. * @param uniformName Name of the variable.
  100600. * @param array array to be set.
  100601. * @returns this effect.
  100602. */
  100603. setIntArray4(uniformName: string, array: Int32Array): Effect;
  100604. /**
  100605. * Sets an float array on a uniform variable.
  100606. * @param uniformName Name of the variable.
  100607. * @param array array to be set.
  100608. * @returns this effect.
  100609. */
  100610. setFloatArray(uniformName: string, array: Float32Array): Effect;
  100611. /**
  100612. * 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)
  100613. * @param uniformName Name of the variable.
  100614. * @param array array to be set.
  100615. * @returns this effect.
  100616. */
  100617. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  100618. /**
  100619. * 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)
  100620. * @param uniformName Name of the variable.
  100621. * @param array array to be set.
  100622. * @returns this effect.
  100623. */
  100624. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  100625. /**
  100626. * 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)
  100627. * @param uniformName Name of the variable.
  100628. * @param array array to be set.
  100629. * @returns this effect.
  100630. */
  100631. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  100632. /**
  100633. * Sets an array on a uniform variable.
  100634. * @param uniformName Name of the variable.
  100635. * @param array array to be set.
  100636. * @returns this effect.
  100637. */
  100638. setArray(uniformName: string, array: number[]): Effect;
  100639. /**
  100640. * 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)
  100641. * @param uniformName Name of the variable.
  100642. * @param array array to be set.
  100643. * @returns this effect.
  100644. */
  100645. setArray2(uniformName: string, array: number[]): Effect;
  100646. /**
  100647. * 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)
  100648. * @param uniformName Name of the variable.
  100649. * @param array array to be set.
  100650. * @returns this effect.
  100651. */
  100652. setArray3(uniformName: string, array: number[]): Effect;
  100653. /**
  100654. * 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)
  100655. * @param uniformName Name of the variable.
  100656. * @param array array to be set.
  100657. * @returns this effect.
  100658. */
  100659. setArray4(uniformName: string, array: number[]): Effect;
  100660. /**
  100661. * Sets matrices on a uniform variable.
  100662. * @param uniformName Name of the variable.
  100663. * @param matrices matrices to be set.
  100664. * @returns this effect.
  100665. */
  100666. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  100667. /**
  100668. * Sets matrix on a uniform variable.
  100669. * @param uniformName Name of the variable.
  100670. * @param matrix matrix to be set.
  100671. * @returns this effect.
  100672. */
  100673. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  100674. /**
  100675. * 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)
  100676. * @param uniformName Name of the variable.
  100677. * @param matrix matrix to be set.
  100678. * @returns this effect.
  100679. */
  100680. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  100681. /**
  100682. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  100683. * @param uniformName Name of the variable.
  100684. * @param matrix matrix to be set.
  100685. * @returns this effect.
  100686. */
  100687. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  100688. /**
  100689. * Sets a float on a uniform variable.
  100690. * @param uniformName Name of the variable.
  100691. * @param value value to be set.
  100692. * @returns this effect.
  100693. */
  100694. setFloat(uniformName: string, value: number): Effect;
  100695. /**
  100696. * Sets a boolean on a uniform variable.
  100697. * @param uniformName Name of the variable.
  100698. * @param bool value to be set.
  100699. * @returns this effect.
  100700. */
  100701. setBool(uniformName: string, bool: boolean): Effect;
  100702. /**
  100703. * Sets a Vector2 on a uniform variable.
  100704. * @param uniformName Name of the variable.
  100705. * @param vector2 vector2 to be set.
  100706. * @returns this effect.
  100707. */
  100708. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  100709. /**
  100710. * Sets a float2 on a uniform variable.
  100711. * @param uniformName Name of the variable.
  100712. * @param x First float in float2.
  100713. * @param y Second float in float2.
  100714. * @returns this effect.
  100715. */
  100716. setFloat2(uniformName: string, x: number, y: number): Effect;
  100717. /**
  100718. * Sets a Vector3 on a uniform variable.
  100719. * @param uniformName Name of the variable.
  100720. * @param vector3 Value to be set.
  100721. * @returns this effect.
  100722. */
  100723. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  100724. /**
  100725. * Sets a float3 on a uniform variable.
  100726. * @param uniformName Name of the variable.
  100727. * @param x First float in float3.
  100728. * @param y Second float in float3.
  100729. * @param z Third float in float3.
  100730. * @returns this effect.
  100731. */
  100732. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  100733. /**
  100734. * Sets a Vector4 on a uniform variable.
  100735. * @param uniformName Name of the variable.
  100736. * @param vector4 Value to be set.
  100737. * @returns this effect.
  100738. */
  100739. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  100740. /**
  100741. * Sets a float4 on a uniform variable.
  100742. * @param uniformName Name of the variable.
  100743. * @param x First float in float4.
  100744. * @param y Second float in float4.
  100745. * @param z Third float in float4.
  100746. * @param w Fourth float in float4.
  100747. * @returns this effect.
  100748. */
  100749. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  100750. /**
  100751. * Sets a Color3 on a uniform variable.
  100752. * @param uniformName Name of the variable.
  100753. * @param color3 Value to be set.
  100754. * @returns this effect.
  100755. */
  100756. setColor3(uniformName: string, color3: IColor3Like): Effect;
  100757. /**
  100758. * Sets a Color4 on a uniform variable.
  100759. * @param uniformName Name of the variable.
  100760. * @param color3 Value to be set.
  100761. * @param alpha Alpha value to be set.
  100762. * @returns this effect.
  100763. */
  100764. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  100765. /**
  100766. * Sets a Color4 on a uniform variable
  100767. * @param uniformName defines the name of the variable
  100768. * @param color4 defines the value to be set
  100769. * @returns this effect.
  100770. */
  100771. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  100772. /** Release all associated resources */
  100773. dispose(): void;
  100774. /**
  100775. * This function will add a new shader to the shader store
  100776. * @param name the name of the shader
  100777. * @param pixelShader optional pixel shader content
  100778. * @param vertexShader optional vertex shader content
  100779. */
  100780. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  100781. /**
  100782. * Store of each shader (The can be looked up using effect.key)
  100783. */
  100784. static ShadersStore: {
  100785. [key: string]: string;
  100786. };
  100787. /**
  100788. * Store of each included file for a shader (The can be looked up using effect.key)
  100789. */
  100790. static IncludesShadersStore: {
  100791. [key: string]: string;
  100792. };
  100793. /**
  100794. * Resets the cache of effects.
  100795. */
  100796. static ResetCache(): void;
  100797. }
  100798. }
  100799. declare module BABYLON {
  100800. /**
  100801. * Interface used to describe the capabilities of the engine relatively to the current browser
  100802. */
  100803. export interface EngineCapabilities {
  100804. /** Maximum textures units per fragment shader */
  100805. maxTexturesImageUnits: number;
  100806. /** Maximum texture units per vertex shader */
  100807. maxVertexTextureImageUnits: number;
  100808. /** Maximum textures units in the entire pipeline */
  100809. maxCombinedTexturesImageUnits: number;
  100810. /** Maximum texture size */
  100811. maxTextureSize: number;
  100812. /** Maximum texture samples */
  100813. maxSamples?: number;
  100814. /** Maximum cube texture size */
  100815. maxCubemapTextureSize: number;
  100816. /** Maximum render texture size */
  100817. maxRenderTextureSize: number;
  100818. /** Maximum number of vertex attributes */
  100819. maxVertexAttribs: number;
  100820. /** Maximum number of varyings */
  100821. maxVaryingVectors: number;
  100822. /** Maximum number of uniforms per vertex shader */
  100823. maxVertexUniformVectors: number;
  100824. /** Maximum number of uniforms per fragment shader */
  100825. maxFragmentUniformVectors: number;
  100826. /** Defines if standard derivates (dx/dy) are supported */
  100827. standardDerivatives: boolean;
  100828. /** Defines if s3tc texture compression is supported */
  100829. s3tc?: WEBGL_compressed_texture_s3tc;
  100830. /** Defines if pvrtc texture compression is supported */
  100831. pvrtc: any;
  100832. /** Defines if etc1 texture compression is supported */
  100833. etc1: any;
  100834. /** Defines if etc2 texture compression is supported */
  100835. etc2: any;
  100836. /** Defines if astc texture compression is supported */
  100837. astc: any;
  100838. /** Defines if float textures are supported */
  100839. textureFloat: boolean;
  100840. /** Defines if vertex array objects are supported */
  100841. vertexArrayObject: boolean;
  100842. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  100843. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  100844. /** Gets the maximum level of anisotropy supported */
  100845. maxAnisotropy: number;
  100846. /** Defines if instancing is supported */
  100847. instancedArrays: boolean;
  100848. /** Defines if 32 bits indices are supported */
  100849. uintIndices: boolean;
  100850. /** Defines if high precision shaders are supported */
  100851. highPrecisionShaderSupported: boolean;
  100852. /** Defines if depth reading in the fragment shader is supported */
  100853. fragmentDepthSupported: boolean;
  100854. /** Defines if float texture linear filtering is supported*/
  100855. textureFloatLinearFiltering: boolean;
  100856. /** Defines if rendering to float textures is supported */
  100857. textureFloatRender: boolean;
  100858. /** Defines if half float textures are supported*/
  100859. textureHalfFloat: boolean;
  100860. /** Defines if half float texture linear filtering is supported*/
  100861. textureHalfFloatLinearFiltering: boolean;
  100862. /** Defines if rendering to half float textures is supported */
  100863. textureHalfFloatRender: boolean;
  100864. /** Defines if textureLOD shader command is supported */
  100865. textureLOD: boolean;
  100866. /** Defines if draw buffers extension is supported */
  100867. drawBuffersExtension: boolean;
  100868. /** Defines if depth textures are supported */
  100869. depthTextureExtension: boolean;
  100870. /** Defines if float color buffer are supported */
  100871. colorBufferFloat: boolean;
  100872. /** Gets disjoint timer query extension (null if not supported) */
  100873. timerQuery?: EXT_disjoint_timer_query;
  100874. /** Defines if timestamp can be used with timer query */
  100875. canUseTimestampForTimerQuery: boolean;
  100876. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  100877. multiview?: any;
  100878. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  100879. oculusMultiview?: any;
  100880. /** Function used to let the system compiles shaders in background */
  100881. parallelShaderCompile?: {
  100882. COMPLETION_STATUS_KHR: number;
  100883. };
  100884. /** Max number of texture samples for MSAA */
  100885. maxMSAASamples: number;
  100886. /** Defines if the blend min max extension is supported */
  100887. blendMinMax: boolean;
  100888. }
  100889. }
  100890. declare module BABYLON {
  100891. /**
  100892. * @hidden
  100893. **/
  100894. export class DepthCullingState {
  100895. private _isDepthTestDirty;
  100896. private _isDepthMaskDirty;
  100897. private _isDepthFuncDirty;
  100898. private _isCullFaceDirty;
  100899. private _isCullDirty;
  100900. private _isZOffsetDirty;
  100901. private _isFrontFaceDirty;
  100902. private _depthTest;
  100903. private _depthMask;
  100904. private _depthFunc;
  100905. private _cull;
  100906. private _cullFace;
  100907. private _zOffset;
  100908. private _frontFace;
  100909. /**
  100910. * Initializes the state.
  100911. */
  100912. constructor();
  100913. get isDirty(): boolean;
  100914. get zOffset(): number;
  100915. set zOffset(value: number);
  100916. get cullFace(): Nullable<number>;
  100917. set cullFace(value: Nullable<number>);
  100918. get cull(): Nullable<boolean>;
  100919. set cull(value: Nullable<boolean>);
  100920. get depthFunc(): Nullable<number>;
  100921. set depthFunc(value: Nullable<number>);
  100922. get depthMask(): boolean;
  100923. set depthMask(value: boolean);
  100924. get depthTest(): boolean;
  100925. set depthTest(value: boolean);
  100926. get frontFace(): Nullable<number>;
  100927. set frontFace(value: Nullable<number>);
  100928. reset(): void;
  100929. apply(gl: WebGLRenderingContext): void;
  100930. }
  100931. }
  100932. declare module BABYLON {
  100933. /**
  100934. * @hidden
  100935. **/
  100936. export class StencilState {
  100937. /** 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 */
  100938. static readonly ALWAYS: number;
  100939. /** Passed to stencilOperation to specify that stencil value must be kept */
  100940. static readonly KEEP: number;
  100941. /** Passed to stencilOperation to specify that stencil value must be replaced */
  100942. static readonly REPLACE: number;
  100943. private _isStencilTestDirty;
  100944. private _isStencilMaskDirty;
  100945. private _isStencilFuncDirty;
  100946. private _isStencilOpDirty;
  100947. private _stencilTest;
  100948. private _stencilMask;
  100949. private _stencilFunc;
  100950. private _stencilFuncRef;
  100951. private _stencilFuncMask;
  100952. private _stencilOpStencilFail;
  100953. private _stencilOpDepthFail;
  100954. private _stencilOpStencilDepthPass;
  100955. get isDirty(): boolean;
  100956. get stencilFunc(): number;
  100957. set stencilFunc(value: number);
  100958. get stencilFuncRef(): number;
  100959. set stencilFuncRef(value: number);
  100960. get stencilFuncMask(): number;
  100961. set stencilFuncMask(value: number);
  100962. get stencilOpStencilFail(): number;
  100963. set stencilOpStencilFail(value: number);
  100964. get stencilOpDepthFail(): number;
  100965. set stencilOpDepthFail(value: number);
  100966. get stencilOpStencilDepthPass(): number;
  100967. set stencilOpStencilDepthPass(value: number);
  100968. get stencilMask(): number;
  100969. set stencilMask(value: number);
  100970. get stencilTest(): boolean;
  100971. set stencilTest(value: boolean);
  100972. constructor();
  100973. reset(): void;
  100974. apply(gl: WebGLRenderingContext): void;
  100975. }
  100976. }
  100977. declare module BABYLON {
  100978. /**
  100979. * @hidden
  100980. **/
  100981. export class AlphaState {
  100982. private _isAlphaBlendDirty;
  100983. private _isBlendFunctionParametersDirty;
  100984. private _isBlendEquationParametersDirty;
  100985. private _isBlendConstantsDirty;
  100986. private _alphaBlend;
  100987. private _blendFunctionParameters;
  100988. private _blendEquationParameters;
  100989. private _blendConstants;
  100990. /**
  100991. * Initializes the state.
  100992. */
  100993. constructor();
  100994. get isDirty(): boolean;
  100995. get alphaBlend(): boolean;
  100996. set alphaBlend(value: boolean);
  100997. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  100998. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  100999. setAlphaEquationParameters(rgb: number, alpha: number): void;
  101000. reset(): void;
  101001. apply(gl: WebGLRenderingContext): void;
  101002. }
  101003. }
  101004. declare module BABYLON {
  101005. /** @hidden */
  101006. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101007. attributeProcessor(attribute: string): string;
  101008. varyingProcessor(varying: string, isFragment: boolean): string;
  101009. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101010. }
  101011. }
  101012. declare module BABYLON {
  101013. /**
  101014. * Interface for attribute information associated with buffer instanciation
  101015. */
  101016. export interface InstancingAttributeInfo {
  101017. /**
  101018. * Name of the GLSL attribute
  101019. * if attribute index is not specified, this is used to retrieve the index from the effect
  101020. */
  101021. attributeName: string;
  101022. /**
  101023. * Index/offset of the attribute in the vertex shader
  101024. * if not specified, this will be computes from the name.
  101025. */
  101026. index?: number;
  101027. /**
  101028. * size of the attribute, 1, 2, 3 or 4
  101029. */
  101030. attributeSize: number;
  101031. /**
  101032. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101033. */
  101034. offset: number;
  101035. /**
  101036. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101037. * default to 1
  101038. */
  101039. divisor?: number;
  101040. /**
  101041. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101042. * default is FLOAT
  101043. */
  101044. attributeType?: number;
  101045. /**
  101046. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101047. */
  101048. normalized?: boolean;
  101049. }
  101050. }
  101051. declare module BABYLON {
  101052. interface ThinEngine {
  101053. /**
  101054. * Update a video texture
  101055. * @param texture defines the texture to update
  101056. * @param video defines the video element to use
  101057. * @param invertY defines if data must be stored with Y axis inverted
  101058. */
  101059. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101060. }
  101061. }
  101062. declare module BABYLON {
  101063. /**
  101064. * Settings for finer control over video usage
  101065. */
  101066. export interface VideoTextureSettings {
  101067. /**
  101068. * Applies `autoplay` to video, if specified
  101069. */
  101070. autoPlay?: boolean;
  101071. /**
  101072. * Applies `loop` to video, if specified
  101073. */
  101074. loop?: boolean;
  101075. /**
  101076. * Automatically updates internal texture from video at every frame in the render loop
  101077. */
  101078. autoUpdateTexture: boolean;
  101079. /**
  101080. * Image src displayed during the video loading or until the user interacts with the video.
  101081. */
  101082. poster?: string;
  101083. }
  101084. /**
  101085. * If you want to display a video in your scene, this is the special texture for that.
  101086. * This special texture works similar to other textures, with the exception of a few parameters.
  101087. * @see https://doc.babylonjs.com/how_to/video_texture
  101088. */
  101089. export class VideoTexture extends Texture {
  101090. /**
  101091. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101092. */
  101093. readonly autoUpdateTexture: boolean;
  101094. /**
  101095. * The video instance used by the texture internally
  101096. */
  101097. readonly video: HTMLVideoElement;
  101098. private _onUserActionRequestedObservable;
  101099. /**
  101100. * Event triggerd when a dom action is required by the user to play the video.
  101101. * This happens due to recent changes in browser policies preventing video to auto start.
  101102. */
  101103. get onUserActionRequestedObservable(): Observable<Texture>;
  101104. private _generateMipMaps;
  101105. private _engine;
  101106. private _stillImageCaptured;
  101107. private _displayingPosterTexture;
  101108. private _settings;
  101109. private _createInternalTextureOnEvent;
  101110. private _frameId;
  101111. /**
  101112. * Creates a video texture.
  101113. * If you want to display a video in your scene, this is the special texture for that.
  101114. * This special texture works similar to other textures, with the exception of a few parameters.
  101115. * @see https://doc.babylonjs.com/how_to/video_texture
  101116. * @param name optional name, will detect from video source, if not defined
  101117. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101118. * @param scene is obviously the current scene.
  101119. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101120. * @param invertY is false by default but can be used to invert video on Y axis
  101121. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101122. * @param settings allows finer control over video usage
  101123. */
  101124. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101125. private _getName;
  101126. private _getVideo;
  101127. private _createInternalTexture;
  101128. private reset;
  101129. /**
  101130. * @hidden Internal method to initiate `update`.
  101131. */
  101132. _rebuild(): void;
  101133. /**
  101134. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  101135. */
  101136. update(): void;
  101137. /**
  101138. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  101139. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  101140. */
  101141. updateTexture(isVisible: boolean): void;
  101142. protected _updateInternalTexture: () => void;
  101143. /**
  101144. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  101145. * @param url New url.
  101146. */
  101147. updateURL(url: string): void;
  101148. /**
  101149. * Dispose the texture and release its associated resources.
  101150. */
  101151. dispose(): void;
  101152. /**
  101153. * Creates a video texture straight from a stream.
  101154. * @param scene Define the scene the texture should be created in
  101155. * @param stream Define the stream the texture should be created from
  101156. * @returns The created video texture as a promise
  101157. */
  101158. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  101159. /**
  101160. * Creates a video texture straight from your WebCam video feed.
  101161. * @param scene Define the scene the texture should be created in
  101162. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101163. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101164. * @returns The created video texture as a promise
  101165. */
  101166. static CreateFromWebCamAsync(scene: Scene, constraints: {
  101167. minWidth: number;
  101168. maxWidth: number;
  101169. minHeight: number;
  101170. maxHeight: number;
  101171. deviceId: string;
  101172. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  101173. /**
  101174. * Creates a video texture straight from your WebCam video feed.
  101175. * @param scene Define the scene the texture should be created in
  101176. * @param onReady Define a callback to triggered once the texture will be ready
  101177. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101178. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101179. */
  101180. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  101181. minWidth: number;
  101182. maxWidth: number;
  101183. minHeight: number;
  101184. maxHeight: number;
  101185. deviceId: string;
  101186. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  101187. }
  101188. }
  101189. declare module BABYLON {
  101190. /**
  101191. * Defines the interface used by objects working like Scene
  101192. * @hidden
  101193. */
  101194. interface ISceneLike {
  101195. _addPendingData(data: any): void;
  101196. _removePendingData(data: any): void;
  101197. offlineProvider: IOfflineProvider;
  101198. }
  101199. /** Interface defining initialization parameters for Engine class */
  101200. export interface EngineOptions extends WebGLContextAttributes {
  101201. /**
  101202. * Defines if the engine should no exceed a specified device ratio
  101203. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  101204. */
  101205. limitDeviceRatio?: number;
  101206. /**
  101207. * Defines if webvr should be enabled automatically
  101208. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101209. */
  101210. autoEnableWebVR?: boolean;
  101211. /**
  101212. * Defines if webgl2 should be turned off even if supported
  101213. * @see http://doc.babylonjs.com/features/webgl2
  101214. */
  101215. disableWebGL2Support?: boolean;
  101216. /**
  101217. * Defines if webaudio should be initialized as well
  101218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101219. */
  101220. audioEngine?: boolean;
  101221. /**
  101222. * Defines if animations should run using a deterministic lock step
  101223. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101224. */
  101225. deterministicLockstep?: boolean;
  101226. /** Defines the maximum steps to use with deterministic lock step mode */
  101227. lockstepMaxSteps?: number;
  101228. /** Defines the seconds between each deterministic lock step */
  101229. timeStep?: number;
  101230. /**
  101231. * Defines that engine should ignore context lost events
  101232. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  101233. */
  101234. doNotHandleContextLost?: boolean;
  101235. /**
  101236. * Defines that engine should ignore modifying touch action attribute and style
  101237. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  101238. */
  101239. doNotHandleTouchAction?: boolean;
  101240. /**
  101241. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  101242. */
  101243. useHighPrecisionFloats?: boolean;
  101244. }
  101245. /**
  101246. * The base engine class (root of all engines)
  101247. */
  101248. export class ThinEngine {
  101249. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  101250. static ExceptionList: ({
  101251. key: string;
  101252. capture: string;
  101253. captureConstraint: number;
  101254. targets: string[];
  101255. } | {
  101256. key: string;
  101257. capture: null;
  101258. captureConstraint: null;
  101259. targets: string[];
  101260. })[];
  101261. /** @hidden */
  101262. static _TextureLoaders: IInternalTextureLoader[];
  101263. /**
  101264. * Returns the current npm package of the sdk
  101265. */
  101266. static get NpmPackage(): string;
  101267. /**
  101268. * Returns the current version of the framework
  101269. */
  101270. static get Version(): string;
  101271. /**
  101272. * Returns a string describing the current engine
  101273. */
  101274. get description(): string;
  101275. /**
  101276. * Gets or sets the epsilon value used by collision engine
  101277. */
  101278. static CollisionsEpsilon: number;
  101279. /**
  101280. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101281. */
  101282. static get ShadersRepository(): string;
  101283. static set ShadersRepository(value: string);
  101284. /**
  101285. * Gets or sets the textures that the engine should not attempt to load as compressed
  101286. */
  101287. protected _excludedCompressedTextures: string[];
  101288. /**
  101289. * Filters the compressed texture formats to only include
  101290. * files that are not included in the skippable list
  101291. *
  101292. * @param url the current extension
  101293. * @param textureFormatInUse the current compressed texture format
  101294. * @returns "format" string
  101295. */
  101296. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  101297. /** @hidden */
  101298. _shaderProcessor: IShaderProcessor;
  101299. /**
  101300. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  101301. */
  101302. forcePOTTextures: boolean;
  101303. /**
  101304. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  101305. */
  101306. isFullscreen: boolean;
  101307. /**
  101308. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  101309. */
  101310. cullBackFaces: boolean;
  101311. /**
  101312. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  101313. */
  101314. renderEvenInBackground: boolean;
  101315. /**
  101316. * Gets or sets a boolean indicating that cache can be kept between frames
  101317. */
  101318. preventCacheWipeBetweenFrames: boolean;
  101319. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  101320. validateShaderPrograms: boolean;
  101321. /**
  101322. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  101323. * This can provide greater z depth for distant objects.
  101324. */
  101325. useReverseDepthBuffer: boolean;
  101326. /**
  101327. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  101328. */
  101329. disableUniformBuffers: boolean;
  101330. /** @hidden */
  101331. _uniformBuffers: UniformBuffer[];
  101332. /**
  101333. * Gets a boolean indicating that the engine supports uniform buffers
  101334. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  101335. */
  101336. get supportsUniformBuffers(): boolean;
  101337. /** @hidden */
  101338. _gl: WebGLRenderingContext;
  101339. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  101340. protected _windowIsBackground: boolean;
  101341. protected _webGLVersion: number;
  101342. protected _creationOptions: EngineOptions;
  101343. protected _highPrecisionShadersAllowed: boolean;
  101344. /** @hidden */
  101345. get _shouldUseHighPrecisionShader(): boolean;
  101346. /**
  101347. * Gets a boolean indicating that only power of 2 textures are supported
  101348. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  101349. */
  101350. get needPOTTextures(): boolean;
  101351. /** @hidden */
  101352. _badOS: boolean;
  101353. /** @hidden */
  101354. _badDesktopOS: boolean;
  101355. private _hardwareScalingLevel;
  101356. /** @hidden */
  101357. _caps: EngineCapabilities;
  101358. private _isStencilEnable;
  101359. private _glVersion;
  101360. private _glRenderer;
  101361. private _glVendor;
  101362. /** @hidden */
  101363. _videoTextureSupported: boolean;
  101364. protected _renderingQueueLaunched: boolean;
  101365. protected _activeRenderLoops: (() => void)[];
  101366. /**
  101367. * Observable signaled when a context lost event is raised
  101368. */
  101369. onContextLostObservable: Observable<ThinEngine>;
  101370. /**
  101371. * Observable signaled when a context restored event is raised
  101372. */
  101373. onContextRestoredObservable: Observable<ThinEngine>;
  101374. private _onContextLost;
  101375. private _onContextRestored;
  101376. protected _contextWasLost: boolean;
  101377. /** @hidden */
  101378. _doNotHandleContextLost: boolean;
  101379. /**
  101380. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  101381. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  101382. */
  101383. get doNotHandleContextLost(): boolean;
  101384. set doNotHandleContextLost(value: boolean);
  101385. /**
  101386. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  101387. */
  101388. disableVertexArrayObjects: boolean;
  101389. /** @hidden */
  101390. protected _colorWrite: boolean;
  101391. /** @hidden */
  101392. protected _colorWriteChanged: boolean;
  101393. /** @hidden */
  101394. protected _depthCullingState: DepthCullingState;
  101395. /** @hidden */
  101396. protected _stencilState: StencilState;
  101397. /** @hidden */
  101398. _alphaState: AlphaState;
  101399. /** @hidden */
  101400. _alphaMode: number;
  101401. /** @hidden */
  101402. _alphaEquation: number;
  101403. /** @hidden */
  101404. _internalTexturesCache: InternalTexture[];
  101405. /** @hidden */
  101406. protected _activeChannel: number;
  101407. private _currentTextureChannel;
  101408. /** @hidden */
  101409. protected _boundTexturesCache: {
  101410. [key: string]: Nullable<InternalTexture>;
  101411. };
  101412. /** @hidden */
  101413. protected _currentEffect: Nullable<Effect>;
  101414. /** @hidden */
  101415. protected _currentProgram: Nullable<WebGLProgram>;
  101416. private _compiledEffects;
  101417. private _vertexAttribArraysEnabled;
  101418. /** @hidden */
  101419. protected _cachedViewport: Nullable<IViewportLike>;
  101420. private _cachedVertexArrayObject;
  101421. /** @hidden */
  101422. protected _cachedVertexBuffers: any;
  101423. /** @hidden */
  101424. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  101425. /** @hidden */
  101426. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  101427. /** @hidden */
  101428. _currentRenderTarget: Nullable<InternalTexture>;
  101429. private _uintIndicesCurrentlySet;
  101430. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  101431. /** @hidden */
  101432. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  101433. private _currentBufferPointers;
  101434. private _currentInstanceLocations;
  101435. private _currentInstanceBuffers;
  101436. private _textureUnits;
  101437. /** @hidden */
  101438. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101439. /** @hidden */
  101440. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101441. /** @hidden */
  101442. _boundRenderFunction: any;
  101443. private _vaoRecordInProgress;
  101444. private _mustWipeVertexAttributes;
  101445. private _emptyTexture;
  101446. private _emptyCubeTexture;
  101447. private _emptyTexture3D;
  101448. private _emptyTexture2DArray;
  101449. /** @hidden */
  101450. _frameHandler: number;
  101451. private _nextFreeTextureSlots;
  101452. private _maxSimultaneousTextures;
  101453. private _activeRequests;
  101454. protected _texturesSupported: string[];
  101455. /** @hidden */
  101456. _textureFormatInUse: Nullable<string>;
  101457. protected get _supportsHardwareTextureRescaling(): boolean;
  101458. /**
  101459. * Gets the list of texture formats supported
  101460. */
  101461. get texturesSupported(): Array<string>;
  101462. /**
  101463. * Gets the list of texture formats in use
  101464. */
  101465. get textureFormatInUse(): Nullable<string>;
  101466. /**
  101467. * Gets the current viewport
  101468. */
  101469. get currentViewport(): Nullable<IViewportLike>;
  101470. /**
  101471. * Gets the default empty texture
  101472. */
  101473. get emptyTexture(): InternalTexture;
  101474. /**
  101475. * Gets the default empty 3D texture
  101476. */
  101477. get emptyTexture3D(): InternalTexture;
  101478. /**
  101479. * Gets the default empty 2D array texture
  101480. */
  101481. get emptyTexture2DArray(): InternalTexture;
  101482. /**
  101483. * Gets the default empty cube texture
  101484. */
  101485. get emptyCubeTexture(): InternalTexture;
  101486. /**
  101487. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  101488. */
  101489. readonly premultipliedAlpha: boolean;
  101490. /**
  101491. * Observable event triggered before each texture is initialized
  101492. */
  101493. onBeforeTextureInitObservable: Observable<Texture>;
  101494. /**
  101495. * Creates a new engine
  101496. * @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
  101497. * @param antialias defines enable antialiasing (default: false)
  101498. * @param options defines further options to be sent to the getContext() function
  101499. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101500. */
  101501. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101502. private _rebuildInternalTextures;
  101503. private _rebuildEffects;
  101504. /**
  101505. * Gets a boolean indicating if all created effects are ready
  101506. * @returns true if all effects are ready
  101507. */
  101508. areAllEffectsReady(): boolean;
  101509. protected _rebuildBuffers(): void;
  101510. private _initGLContext;
  101511. /**
  101512. * Gets version of the current webGL context
  101513. */
  101514. get webGLVersion(): number;
  101515. /**
  101516. * Gets a string idenfifying the name of the class
  101517. * @returns "Engine" string
  101518. */
  101519. getClassName(): string;
  101520. /**
  101521. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  101522. */
  101523. get isStencilEnable(): boolean;
  101524. /** @hidden */
  101525. _prepareWorkingCanvas(): void;
  101526. /**
  101527. * Reset the texture cache to empty state
  101528. */
  101529. resetTextureCache(): void;
  101530. /**
  101531. * Gets an object containing information about the current webGL context
  101532. * @returns an object containing the vender, the renderer and the version of the current webGL context
  101533. */
  101534. getGlInfo(): {
  101535. vendor: string;
  101536. renderer: string;
  101537. version: string;
  101538. };
  101539. /**
  101540. * Defines the hardware scaling level.
  101541. * By default the hardware scaling level is computed from the window device ratio.
  101542. * 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.
  101543. * @param level defines the level to use
  101544. */
  101545. setHardwareScalingLevel(level: number): void;
  101546. /**
  101547. * Gets the current hardware scaling level.
  101548. * By default the hardware scaling level is computed from the window device ratio.
  101549. * 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.
  101550. * @returns a number indicating the current hardware scaling level
  101551. */
  101552. getHardwareScalingLevel(): number;
  101553. /**
  101554. * Gets the list of loaded textures
  101555. * @returns an array containing all loaded textures
  101556. */
  101557. getLoadedTexturesCache(): InternalTexture[];
  101558. /**
  101559. * Gets the object containing all engine capabilities
  101560. * @returns the EngineCapabilities object
  101561. */
  101562. getCaps(): EngineCapabilities;
  101563. /**
  101564. * stop executing a render loop function and remove it from the execution array
  101565. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  101566. */
  101567. stopRenderLoop(renderFunction?: () => void): void;
  101568. /** @hidden */
  101569. _renderLoop(): void;
  101570. /**
  101571. * Gets the HTML canvas attached with the current webGL context
  101572. * @returns a HTML canvas
  101573. */
  101574. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  101575. /**
  101576. * Gets host window
  101577. * @returns the host window object
  101578. */
  101579. getHostWindow(): Nullable<Window>;
  101580. /**
  101581. * Gets the current render width
  101582. * @param useScreen defines if screen size must be used (or the current render target if any)
  101583. * @returns a number defining the current render width
  101584. */
  101585. getRenderWidth(useScreen?: boolean): number;
  101586. /**
  101587. * Gets the current render height
  101588. * @param useScreen defines if screen size must be used (or the current render target if any)
  101589. * @returns a number defining the current render height
  101590. */
  101591. getRenderHeight(useScreen?: boolean): number;
  101592. /**
  101593. * Can be used to override the current requestAnimationFrame requester.
  101594. * @hidden
  101595. */
  101596. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  101597. /**
  101598. * Register and execute a render loop. The engine can have more than one render function
  101599. * @param renderFunction defines the function to continuously execute
  101600. */
  101601. runRenderLoop(renderFunction: () => void): void;
  101602. /**
  101603. * Clear the current render buffer or the current render target (if any is set up)
  101604. * @param color defines the color to use
  101605. * @param backBuffer defines if the back buffer must be cleared
  101606. * @param depth defines if the depth buffer must be cleared
  101607. * @param stencil defines if the stencil buffer must be cleared
  101608. */
  101609. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101610. private _viewportCached;
  101611. /** @hidden */
  101612. _viewport(x: number, y: number, width: number, height: number): void;
  101613. /**
  101614. * Set the WebGL's viewport
  101615. * @param viewport defines the viewport element to be used
  101616. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  101617. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  101618. */
  101619. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  101620. /**
  101621. * Begin a new frame
  101622. */
  101623. beginFrame(): void;
  101624. /**
  101625. * Enf the current frame
  101626. */
  101627. endFrame(): void;
  101628. /**
  101629. * Resize the view according to the canvas' size
  101630. */
  101631. resize(): void;
  101632. /**
  101633. * Force a specific size of the canvas
  101634. * @param width defines the new canvas' width
  101635. * @param height defines the new canvas' height
  101636. */
  101637. setSize(width: number, height: number): void;
  101638. /**
  101639. * Binds the frame buffer to the specified texture.
  101640. * @param texture The texture to render to or null for the default canvas
  101641. * @param faceIndex The face of the texture to render to in case of cube texture
  101642. * @param requiredWidth The width of the target to render to
  101643. * @param requiredHeight The height of the target to render to
  101644. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  101645. * @param depthStencilTexture The depth stencil texture to use to render
  101646. * @param lodLevel defines le lod level to bind to the frame buffer
  101647. */
  101648. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  101649. /** @hidden */
  101650. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  101651. /**
  101652. * Unbind the current render target texture from the webGL context
  101653. * @param texture defines the render target texture to unbind
  101654. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101655. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101656. */
  101657. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101658. /**
  101659. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  101660. */
  101661. flushFramebuffer(): void;
  101662. /**
  101663. * Unbind the current render target and bind the default framebuffer
  101664. */
  101665. restoreDefaultFramebuffer(): void;
  101666. /** @hidden */
  101667. protected _resetVertexBufferBinding(): void;
  101668. /**
  101669. * Creates a vertex buffer
  101670. * @param data the data for the vertex buffer
  101671. * @returns the new WebGL static buffer
  101672. */
  101673. createVertexBuffer(data: DataArray): DataBuffer;
  101674. private _createVertexBuffer;
  101675. /**
  101676. * Creates a dynamic vertex buffer
  101677. * @param data the data for the dynamic vertex buffer
  101678. * @returns the new WebGL dynamic buffer
  101679. */
  101680. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  101681. protected _resetIndexBufferBinding(): void;
  101682. /**
  101683. * Creates a new index buffer
  101684. * @param indices defines the content of the index buffer
  101685. * @param updatable defines if the index buffer must be updatable
  101686. * @returns a new webGL buffer
  101687. */
  101688. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  101689. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  101690. /**
  101691. * Bind a webGL buffer to the webGL context
  101692. * @param buffer defines the buffer to bind
  101693. */
  101694. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  101695. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  101696. private bindBuffer;
  101697. /**
  101698. * update the bound buffer with the given data
  101699. * @param data defines the data to update
  101700. */
  101701. updateArrayBuffer(data: Float32Array): void;
  101702. private _vertexAttribPointer;
  101703. private _bindIndexBufferWithCache;
  101704. private _bindVertexBuffersAttributes;
  101705. /**
  101706. * Records a vertex array object
  101707. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101708. * @param vertexBuffers defines the list of vertex buffers to store
  101709. * @param indexBuffer defines the index buffer to store
  101710. * @param effect defines the effect to store
  101711. * @returns the new vertex array object
  101712. */
  101713. recordVertexArrayObject(vertexBuffers: {
  101714. [key: string]: VertexBuffer;
  101715. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  101716. /**
  101717. * Bind a specific vertex array object
  101718. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101719. * @param vertexArrayObject defines the vertex array object to bind
  101720. * @param indexBuffer defines the index buffer to bind
  101721. */
  101722. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  101723. /**
  101724. * Bind webGl buffers directly to the webGL context
  101725. * @param vertexBuffer defines the vertex buffer to bind
  101726. * @param indexBuffer defines the index buffer to bind
  101727. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  101728. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  101729. * @param effect defines the effect associated with the vertex buffer
  101730. */
  101731. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  101732. private _unbindVertexArrayObject;
  101733. /**
  101734. * Bind a list of vertex buffers to the webGL context
  101735. * @param vertexBuffers defines the list of vertex buffers to bind
  101736. * @param indexBuffer defines the index buffer to bind
  101737. * @param effect defines the effect associated with the vertex buffers
  101738. */
  101739. bindBuffers(vertexBuffers: {
  101740. [key: string]: Nullable<VertexBuffer>;
  101741. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  101742. /**
  101743. * Unbind all instance attributes
  101744. */
  101745. unbindInstanceAttributes(): void;
  101746. /**
  101747. * Release and free the memory of a vertex array object
  101748. * @param vao defines the vertex array object to delete
  101749. */
  101750. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  101751. /** @hidden */
  101752. _releaseBuffer(buffer: DataBuffer): boolean;
  101753. protected _deleteBuffer(buffer: DataBuffer): void;
  101754. /**
  101755. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  101756. * @param instancesBuffer defines the webGL buffer to update and bind
  101757. * @param data defines the data to store in the buffer
  101758. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  101759. */
  101760. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  101761. /**
  101762. * Bind the content of a webGL buffer used with instanciation
  101763. * @param instancesBuffer defines the webGL buffer to bind
  101764. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  101765. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  101766. */
  101767. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  101768. /**
  101769. * Disable the instance attribute corresponding to the name in parameter
  101770. * @param name defines the name of the attribute to disable
  101771. */
  101772. disableInstanceAttributeByName(name: string): void;
  101773. /**
  101774. * Disable the instance attribute corresponding to the location in parameter
  101775. * @param attributeLocation defines the attribute location of the attribute to disable
  101776. */
  101777. disableInstanceAttribute(attributeLocation: number): void;
  101778. /**
  101779. * Disable the attribute corresponding to the location in parameter
  101780. * @param attributeLocation defines the attribute location of the attribute to disable
  101781. */
  101782. disableAttributeByIndex(attributeLocation: number): void;
  101783. /**
  101784. * Send a draw order
  101785. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101786. * @param indexStart defines the starting index
  101787. * @param indexCount defines the number of index to draw
  101788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101789. */
  101790. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101791. /**
  101792. * Draw a list of points
  101793. * @param verticesStart defines the index of first vertex to draw
  101794. * @param verticesCount defines the count of vertices to draw
  101795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101796. */
  101797. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101798. /**
  101799. * Draw a list of unindexed primitives
  101800. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101801. * @param verticesStart defines the index of first vertex to draw
  101802. * @param verticesCount defines the count of vertices to draw
  101803. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101804. */
  101805. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101806. /**
  101807. * Draw a list of indexed primitives
  101808. * @param fillMode defines the primitive to use
  101809. * @param indexStart defines the starting index
  101810. * @param indexCount defines the number of index to draw
  101811. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101812. */
  101813. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101814. /**
  101815. * Draw a list of unindexed primitives
  101816. * @param fillMode defines the primitive to use
  101817. * @param verticesStart defines the index of first vertex to draw
  101818. * @param verticesCount defines the count of vertices to draw
  101819. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101820. */
  101821. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101822. private _drawMode;
  101823. /** @hidden */
  101824. protected _reportDrawCall(): void;
  101825. /** @hidden */
  101826. _releaseEffect(effect: Effect): void;
  101827. /** @hidden */
  101828. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  101829. /**
  101830. * Create a new effect (used to store vertex/fragment shaders)
  101831. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  101832. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  101833. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  101834. * @param samplers defines an array of string used to represent textures
  101835. * @param defines defines the string containing the defines to use to compile the shaders
  101836. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  101837. * @param onCompiled defines a function to call when the effect creation is successful
  101838. * @param onError defines a function to call when the effect creation has failed
  101839. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  101840. * @returns the new Effect
  101841. */
  101842. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  101843. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  101844. private _compileShader;
  101845. private _compileRawShader;
  101846. /**
  101847. * Directly creates a webGL program
  101848. * @param pipelineContext defines the pipeline context to attach to
  101849. * @param vertexCode defines the vertex shader code to use
  101850. * @param fragmentCode defines the fragment shader code to use
  101851. * @param context defines the webGL context to use (if not set, the current one will be used)
  101852. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101853. * @returns the new webGL program
  101854. */
  101855. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101856. /**
  101857. * Creates a webGL program
  101858. * @param pipelineContext defines the pipeline context to attach to
  101859. * @param vertexCode defines the vertex shader code to use
  101860. * @param fragmentCode defines the fragment shader code to use
  101861. * @param defines defines the string containing the defines to use to compile the shaders
  101862. * @param context defines the webGL context to use (if not set, the current one will be used)
  101863. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101864. * @returns the new webGL program
  101865. */
  101866. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101867. /**
  101868. * Creates a new pipeline context
  101869. * @returns the new pipeline
  101870. */
  101871. createPipelineContext(): IPipelineContext;
  101872. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101873. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  101874. /** @hidden */
  101875. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  101876. /** @hidden */
  101877. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  101878. /** @hidden */
  101879. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  101880. /**
  101881. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  101882. * @param pipelineContext defines the pipeline context to use
  101883. * @param uniformsNames defines the list of uniform names
  101884. * @returns an array of webGL uniform locations
  101885. */
  101886. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101887. /**
  101888. * Gets the lsit of active attributes for a given webGL program
  101889. * @param pipelineContext defines the pipeline context to use
  101890. * @param attributesNames defines the list of attribute names to get
  101891. * @returns an array of indices indicating the offset of each attribute
  101892. */
  101893. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101894. /**
  101895. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  101896. * @param effect defines the effect to activate
  101897. */
  101898. enableEffect(effect: Nullable<Effect>): void;
  101899. /**
  101900. * Set the value of an uniform to a number (int)
  101901. * @param uniform defines the webGL uniform location where to store the value
  101902. * @param value defines the int number to store
  101903. */
  101904. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  101905. /**
  101906. * Set the value of an uniform to an array of int32
  101907. * @param uniform defines the webGL uniform location where to store the value
  101908. * @param array defines the array of int32 to store
  101909. */
  101910. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101911. /**
  101912. * Set the value of an uniform to an array of int32 (stored as vec2)
  101913. * @param uniform defines the webGL uniform location where to store the value
  101914. * @param array defines the array of int32 to store
  101915. */
  101916. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101917. /**
  101918. * Set the value of an uniform to an array of int32 (stored as vec3)
  101919. * @param uniform defines the webGL uniform location where to store the value
  101920. * @param array defines the array of int32 to store
  101921. */
  101922. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101923. /**
  101924. * Set the value of an uniform to an array of int32 (stored as vec4)
  101925. * @param uniform defines the webGL uniform location where to store the value
  101926. * @param array defines the array of int32 to store
  101927. */
  101928. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101929. /**
  101930. * Set the value of an uniform to an array of number
  101931. * @param uniform defines the webGL uniform location where to store the value
  101932. * @param array defines the array of number to store
  101933. */
  101934. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101935. /**
  101936. * Set the value of an uniform to an array of number (stored as vec2)
  101937. * @param uniform defines the webGL uniform location where to store the value
  101938. * @param array defines the array of number to store
  101939. */
  101940. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101941. /**
  101942. * Set the value of an uniform to an array of number (stored as vec3)
  101943. * @param uniform defines the webGL uniform location where to store the value
  101944. * @param array defines the array of number to store
  101945. */
  101946. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101947. /**
  101948. * Set the value of an uniform to an array of number (stored as vec4)
  101949. * @param uniform defines the webGL uniform location where to store the value
  101950. * @param array defines the array of number to store
  101951. */
  101952. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101953. /**
  101954. * Set the value of an uniform to an array of float32 (stored as matrices)
  101955. * @param uniform defines the webGL uniform location where to store the value
  101956. * @param matrices defines the array of float32 to store
  101957. */
  101958. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  101959. /**
  101960. * Set the value of an uniform to a matrix (3x3)
  101961. * @param uniform defines the webGL uniform location where to store the value
  101962. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  101963. */
  101964. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  101965. /**
  101966. * Set the value of an uniform to a matrix (2x2)
  101967. * @param uniform defines the webGL uniform location where to store the value
  101968. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  101969. */
  101970. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  101971. /**
  101972. * Set the value of an uniform to a number (float)
  101973. * @param uniform defines the webGL uniform location where to store the value
  101974. * @param value defines the float number to store
  101975. */
  101976. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  101977. /**
  101978. * Set the value of an uniform to a vec2
  101979. * @param uniform defines the webGL uniform location where to store the value
  101980. * @param x defines the 1st component of the value
  101981. * @param y defines the 2nd component of the value
  101982. */
  101983. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  101984. /**
  101985. * Set the value of an uniform to a vec3
  101986. * @param uniform defines the webGL uniform location where to store the value
  101987. * @param x defines the 1st component of the value
  101988. * @param y defines the 2nd component of the value
  101989. * @param z defines the 3rd component of the value
  101990. */
  101991. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  101992. /**
  101993. * Set the value of an uniform to a vec4
  101994. * @param uniform defines the webGL uniform location where to store the value
  101995. * @param x defines the 1st component of the value
  101996. * @param y defines the 2nd component of the value
  101997. * @param z defines the 3rd component of the value
  101998. * @param w defines the 4th component of the value
  101999. */
  102000. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  102001. /**
  102002. * Apply all cached states (depth, culling, stencil and alpha)
  102003. */
  102004. applyStates(): void;
  102005. /**
  102006. * Enable or disable color writing
  102007. * @param enable defines the state to set
  102008. */
  102009. setColorWrite(enable: boolean): void;
  102010. /**
  102011. * Gets a boolean indicating if color writing is enabled
  102012. * @returns the current color writing state
  102013. */
  102014. getColorWrite(): boolean;
  102015. /**
  102016. * Gets the depth culling state manager
  102017. */
  102018. get depthCullingState(): DepthCullingState;
  102019. /**
  102020. * Gets the alpha state manager
  102021. */
  102022. get alphaState(): AlphaState;
  102023. /**
  102024. * Gets the stencil state manager
  102025. */
  102026. get stencilState(): StencilState;
  102027. /**
  102028. * Clears the list of texture accessible through engine.
  102029. * This can help preventing texture load conflict due to name collision.
  102030. */
  102031. clearInternalTexturesCache(): void;
  102032. /**
  102033. * Force the entire cache to be cleared
  102034. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102035. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102036. */
  102037. wipeCaches(bruteForce?: boolean): void;
  102038. /** @hidden */
  102039. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102040. min: number;
  102041. mag: number;
  102042. };
  102043. /** @hidden */
  102044. _createTexture(): WebGLTexture;
  102045. /**
  102046. * Usually called from Texture.ts.
  102047. * Passed information to create a WebGLTexture
  102048. * @param urlArg defines a value which contains one of the following:
  102049. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102050. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102051. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102052. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102053. * @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)
  102054. * @param scene needed for loading to the correct scene
  102055. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102056. * @param onLoad optional callback to be called upon successful completion
  102057. * @param onError optional callback to be called upon failure
  102058. * @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
  102059. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102060. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102061. * @param forcedExtension defines the extension to use to pick the right loader
  102062. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102063. * @param mimeType defines an optional mime type
  102064. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102065. */
  102066. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  102067. /**
  102068. * @hidden
  102069. */
  102070. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102071. /**
  102072. * Creates a raw texture
  102073. * @param data defines the data to store in the texture
  102074. * @param width defines the width of the texture
  102075. * @param height defines the height of the texture
  102076. * @param format defines the format of the data
  102077. * @param generateMipMaps defines if the engine should generate the mip levels
  102078. * @param invertY defines if data must be stored with Y axis inverted
  102079. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102080. * @param compression defines the compression used (null by default)
  102081. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102082. * @returns the raw texture inside an InternalTexture
  102083. */
  102084. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102085. /**
  102086. * Creates a new raw cube texture
  102087. * @param data defines the array of data to use to create each face
  102088. * @param size defines the size of the textures
  102089. * @param format defines the format of the data
  102090. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102091. * @param generateMipMaps defines if the engine should generate the mip levels
  102092. * @param invertY defines if data must be stored with Y axis inverted
  102093. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102094. * @param compression defines the compression used (null by default)
  102095. * @returns the cube texture as an InternalTexture
  102096. */
  102097. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102098. /**
  102099. * Creates a new raw 3D texture
  102100. * @param data defines the data used to create the texture
  102101. * @param width defines the width of the texture
  102102. * @param height defines the height of the texture
  102103. * @param depth defines the depth of the texture
  102104. * @param format defines the format of the texture
  102105. * @param generateMipMaps defines if the engine must generate mip levels
  102106. * @param invertY defines if data must be stored with Y axis inverted
  102107. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102108. * @param compression defines the compressed used (can be null)
  102109. * @param textureType defines the compressed used (can be null)
  102110. * @returns a new raw 3D texture (stored in an InternalTexture)
  102111. */
  102112. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102113. /**
  102114. * Creates a new raw 2D array texture
  102115. * @param data defines the data used to create the texture
  102116. * @param width defines the width of the texture
  102117. * @param height defines the height of the texture
  102118. * @param depth defines the number of layers of the texture
  102119. * @param format defines the format of the texture
  102120. * @param generateMipMaps defines if the engine must generate mip levels
  102121. * @param invertY defines if data must be stored with Y axis inverted
  102122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102123. * @param compression defines the compressed used (can be null)
  102124. * @param textureType defines the compressed used (can be null)
  102125. * @returns a new raw 2D array texture (stored in an InternalTexture)
  102126. */
  102127. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102128. private _unpackFlipYCached;
  102129. /**
  102130. * In case you are sharing the context with other applications, it might
  102131. * be interested to not cache the unpack flip y state to ensure a consistent
  102132. * value would be set.
  102133. */
  102134. enableUnpackFlipYCached: boolean;
  102135. /** @hidden */
  102136. _unpackFlipY(value: boolean): void;
  102137. /** @hidden */
  102138. _getUnpackAlignement(): number;
  102139. private _getTextureTarget;
  102140. /**
  102141. * Update the sampling mode of a given texture
  102142. * @param samplingMode defines the required sampling mode
  102143. * @param texture defines the texture to update
  102144. * @param generateMipMaps defines whether to generate mipmaps for the texture
  102145. */
  102146. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  102147. /**
  102148. * Update the sampling mode of a given texture
  102149. * @param texture defines the texture to update
  102150. * @param wrapU defines the texture wrap mode of the u coordinates
  102151. * @param wrapV defines the texture wrap mode of the v coordinates
  102152. * @param wrapR defines the texture wrap mode of the r coordinates
  102153. */
  102154. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  102155. /** @hidden */
  102156. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  102157. width: number;
  102158. height: number;
  102159. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  102160. /** @hidden */
  102161. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102162. /** @hidden */
  102163. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  102164. /** @hidden */
  102165. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102166. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  102167. private _prepareWebGLTexture;
  102168. /** @hidden */
  102169. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  102170. private _getDepthStencilBuffer;
  102171. /** @hidden */
  102172. _releaseFramebufferObjects(texture: InternalTexture): void;
  102173. /** @hidden */
  102174. _releaseTexture(texture: InternalTexture): void;
  102175. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  102176. protected _setProgram(program: WebGLProgram): void;
  102177. protected _boundUniforms: {
  102178. [key: number]: WebGLUniformLocation;
  102179. };
  102180. /**
  102181. * Binds an effect to the webGL context
  102182. * @param effect defines the effect to bind
  102183. */
  102184. bindSamplers(effect: Effect): void;
  102185. private _activateCurrentTexture;
  102186. /** @hidden */
  102187. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  102188. /** @hidden */
  102189. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  102190. /**
  102191. * Unbind all textures from the webGL context
  102192. */
  102193. unbindAllTextures(): void;
  102194. /**
  102195. * Sets a texture to the according uniform.
  102196. * @param channel The texture channel
  102197. * @param uniform The uniform to set
  102198. * @param texture The texture to apply
  102199. */
  102200. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  102201. private _bindSamplerUniformToChannel;
  102202. private _getTextureWrapMode;
  102203. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  102204. /**
  102205. * Sets an array of texture to the webGL context
  102206. * @param channel defines the channel where the texture array must be set
  102207. * @param uniform defines the associated uniform location
  102208. * @param textures defines the array of textures to bind
  102209. */
  102210. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  102211. /** @hidden */
  102212. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  102213. private _setTextureParameterFloat;
  102214. private _setTextureParameterInteger;
  102215. /**
  102216. * Unbind all vertex attributes from the webGL context
  102217. */
  102218. unbindAllAttributes(): void;
  102219. /**
  102220. * 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
  102221. */
  102222. releaseEffects(): void;
  102223. /**
  102224. * Dispose and release all associated resources
  102225. */
  102226. dispose(): void;
  102227. /**
  102228. * Attach a new callback raised when context lost event is fired
  102229. * @param callback defines the callback to call
  102230. */
  102231. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102232. /**
  102233. * Attach a new callback raised when context restored event is fired
  102234. * @param callback defines the callback to call
  102235. */
  102236. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102237. /**
  102238. * Get the current error code of the webGL context
  102239. * @returns the error code
  102240. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  102241. */
  102242. getError(): number;
  102243. private _canRenderToFloatFramebuffer;
  102244. private _canRenderToHalfFloatFramebuffer;
  102245. private _canRenderToFramebuffer;
  102246. /** @hidden */
  102247. _getWebGLTextureType(type: number): number;
  102248. /** @hidden */
  102249. _getInternalFormat(format: number): number;
  102250. /** @hidden */
  102251. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  102252. /** @hidden */
  102253. _getRGBAMultiSampleBufferFormat(type: number): number;
  102254. /** @hidden */
  102255. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  102256. /**
  102257. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102258. * @param x defines the x coordinate of the rectangle where pixels must be read
  102259. * @param y defines the y coordinate of the rectangle where pixels must be read
  102260. * @param width defines the width of the rectangle where pixels must be read
  102261. * @param height defines the height of the rectangle where pixels must be read
  102262. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  102263. * @returns a Uint8Array containing RGBA colors
  102264. */
  102265. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  102266. private static _isSupported;
  102267. /**
  102268. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  102269. * @returns true if the engine can be created
  102270. * @ignorenaming
  102271. */
  102272. static isSupported(): boolean;
  102273. /**
  102274. * Find the next highest power of two.
  102275. * @param x Number to start search from.
  102276. * @return Next highest power of two.
  102277. */
  102278. static CeilingPOT(x: number): number;
  102279. /**
  102280. * Find the next lowest power of two.
  102281. * @param x Number to start search from.
  102282. * @return Next lowest power of two.
  102283. */
  102284. static FloorPOT(x: number): number;
  102285. /**
  102286. * Find the nearest power of two.
  102287. * @param x Number to start search from.
  102288. * @return Next nearest power of two.
  102289. */
  102290. static NearestPOT(x: number): number;
  102291. /**
  102292. * Get the closest exponent of two
  102293. * @param value defines the value to approximate
  102294. * @param max defines the maximum value to return
  102295. * @param mode defines how to define the closest value
  102296. * @returns closest exponent of two of the given value
  102297. */
  102298. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  102299. /**
  102300. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  102301. * @param func - the function to be called
  102302. * @param requester - the object that will request the next frame. Falls back to window.
  102303. * @returns frame number
  102304. */
  102305. static QueueNewFrame(func: () => void, requester?: any): number;
  102306. /**
  102307. * Gets host document
  102308. * @returns the host document object
  102309. */
  102310. getHostDocument(): Nullable<Document>;
  102311. }
  102312. }
  102313. declare module BABYLON {
  102314. /**
  102315. * Class representing spherical harmonics coefficients to the 3rd degree
  102316. */
  102317. export class SphericalHarmonics {
  102318. /**
  102319. * Defines whether or not the harmonics have been prescaled for rendering.
  102320. */
  102321. preScaled: boolean;
  102322. /**
  102323. * The l0,0 coefficients of the spherical harmonics
  102324. */
  102325. l00: Vector3;
  102326. /**
  102327. * The l1,-1 coefficients of the spherical harmonics
  102328. */
  102329. l1_1: Vector3;
  102330. /**
  102331. * The l1,0 coefficients of the spherical harmonics
  102332. */
  102333. l10: Vector3;
  102334. /**
  102335. * The l1,1 coefficients of the spherical harmonics
  102336. */
  102337. l11: Vector3;
  102338. /**
  102339. * The l2,-2 coefficients of the spherical harmonics
  102340. */
  102341. l2_2: Vector3;
  102342. /**
  102343. * The l2,-1 coefficients of the spherical harmonics
  102344. */
  102345. l2_1: Vector3;
  102346. /**
  102347. * The l2,0 coefficients of the spherical harmonics
  102348. */
  102349. l20: Vector3;
  102350. /**
  102351. * The l2,1 coefficients of the spherical harmonics
  102352. */
  102353. l21: Vector3;
  102354. /**
  102355. * The l2,2 coefficients of the spherical harmonics
  102356. */
  102357. l22: Vector3;
  102358. /**
  102359. * Adds a light to the spherical harmonics
  102360. * @param direction the direction of the light
  102361. * @param color the color of the light
  102362. * @param deltaSolidAngle the delta solid angle of the light
  102363. */
  102364. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  102365. /**
  102366. * Scales the spherical harmonics by the given amount
  102367. * @param scale the amount to scale
  102368. */
  102369. scaleInPlace(scale: number): void;
  102370. /**
  102371. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  102372. *
  102373. * ```
  102374. * E_lm = A_l * L_lm
  102375. * ```
  102376. *
  102377. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  102378. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  102379. * the scaling factors are given in equation 9.
  102380. */
  102381. convertIncidentRadianceToIrradiance(): void;
  102382. /**
  102383. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  102384. *
  102385. * ```
  102386. * L = (1/pi) * E * rho
  102387. * ```
  102388. *
  102389. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  102390. */
  102391. convertIrradianceToLambertianRadiance(): void;
  102392. /**
  102393. * Integrates the reconstruction coefficients directly in to the SH preventing further
  102394. * required operations at run time.
  102395. *
  102396. * This is simply done by scaling back the SH with Ylm constants parameter.
  102397. * The trigonometric part being applied by the shader at run time.
  102398. */
  102399. preScaleForRendering(): void;
  102400. /**
  102401. * Constructs a spherical harmonics from an array.
  102402. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  102403. * @returns the spherical harmonics
  102404. */
  102405. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  102406. /**
  102407. * Gets the spherical harmonics from polynomial
  102408. * @param polynomial the spherical polynomial
  102409. * @returns the spherical harmonics
  102410. */
  102411. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  102412. }
  102413. /**
  102414. * Class representing spherical polynomial coefficients to the 3rd degree
  102415. */
  102416. export class SphericalPolynomial {
  102417. private _harmonics;
  102418. /**
  102419. * The spherical harmonics used to create the polynomials.
  102420. */
  102421. get preScaledHarmonics(): SphericalHarmonics;
  102422. /**
  102423. * The x coefficients of the spherical polynomial
  102424. */
  102425. x: Vector3;
  102426. /**
  102427. * The y coefficients of the spherical polynomial
  102428. */
  102429. y: Vector3;
  102430. /**
  102431. * The z coefficients of the spherical polynomial
  102432. */
  102433. z: Vector3;
  102434. /**
  102435. * The xx coefficients of the spherical polynomial
  102436. */
  102437. xx: Vector3;
  102438. /**
  102439. * The yy coefficients of the spherical polynomial
  102440. */
  102441. yy: Vector3;
  102442. /**
  102443. * The zz coefficients of the spherical polynomial
  102444. */
  102445. zz: Vector3;
  102446. /**
  102447. * The xy coefficients of the spherical polynomial
  102448. */
  102449. xy: Vector3;
  102450. /**
  102451. * The yz coefficients of the spherical polynomial
  102452. */
  102453. yz: Vector3;
  102454. /**
  102455. * The zx coefficients of the spherical polynomial
  102456. */
  102457. zx: Vector3;
  102458. /**
  102459. * Adds an ambient color to the spherical polynomial
  102460. * @param color the color to add
  102461. */
  102462. addAmbient(color: Color3): void;
  102463. /**
  102464. * Scales the spherical polynomial by the given amount
  102465. * @param scale the amount to scale
  102466. */
  102467. scaleInPlace(scale: number): void;
  102468. /**
  102469. * Gets the spherical polynomial from harmonics
  102470. * @param harmonics the spherical harmonics
  102471. * @returns the spherical polynomial
  102472. */
  102473. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  102474. /**
  102475. * Constructs a spherical polynomial from an array.
  102476. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  102477. * @returns the spherical polynomial
  102478. */
  102479. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102480. }
  102481. }
  102482. declare module BABYLON {
  102483. /**
  102484. * Defines the source of the internal texture
  102485. */
  102486. export enum InternalTextureSource {
  102487. /**
  102488. * The source of the texture data is unknown
  102489. */
  102490. Unknown = 0,
  102491. /**
  102492. * Texture data comes from an URL
  102493. */
  102494. Url = 1,
  102495. /**
  102496. * Texture data is only used for temporary storage
  102497. */
  102498. Temp = 2,
  102499. /**
  102500. * Texture data comes from raw data (ArrayBuffer)
  102501. */
  102502. Raw = 3,
  102503. /**
  102504. * Texture content is dynamic (video or dynamic texture)
  102505. */
  102506. Dynamic = 4,
  102507. /**
  102508. * Texture content is generated by rendering to it
  102509. */
  102510. RenderTarget = 5,
  102511. /**
  102512. * Texture content is part of a multi render target process
  102513. */
  102514. MultiRenderTarget = 6,
  102515. /**
  102516. * Texture data comes from a cube data file
  102517. */
  102518. Cube = 7,
  102519. /**
  102520. * Texture data comes from a raw cube data
  102521. */
  102522. CubeRaw = 8,
  102523. /**
  102524. * Texture data come from a prefiltered cube data file
  102525. */
  102526. CubePrefiltered = 9,
  102527. /**
  102528. * Texture content is raw 3D data
  102529. */
  102530. Raw3D = 10,
  102531. /**
  102532. * Texture content is raw 2D array data
  102533. */
  102534. Raw2DArray = 11,
  102535. /**
  102536. * Texture content is a depth texture
  102537. */
  102538. Depth = 12,
  102539. /**
  102540. * Texture data comes from a raw cube data encoded with RGBD
  102541. */
  102542. CubeRawRGBD = 13
  102543. }
  102544. /**
  102545. * Class used to store data associated with WebGL texture data for the engine
  102546. * This class should not be used directly
  102547. */
  102548. export class InternalTexture {
  102549. /** @hidden */
  102550. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  102551. /**
  102552. * Defines if the texture is ready
  102553. */
  102554. isReady: boolean;
  102555. /**
  102556. * Defines if the texture is a cube texture
  102557. */
  102558. isCube: boolean;
  102559. /**
  102560. * Defines if the texture contains 3D data
  102561. */
  102562. is3D: boolean;
  102563. /**
  102564. * Defines if the texture contains 2D array data
  102565. */
  102566. is2DArray: boolean;
  102567. /**
  102568. * Defines if the texture contains multiview data
  102569. */
  102570. isMultiview: boolean;
  102571. /**
  102572. * Gets the URL used to load this texture
  102573. */
  102574. url: string;
  102575. /**
  102576. * Gets the sampling mode of the texture
  102577. */
  102578. samplingMode: number;
  102579. /**
  102580. * Gets a boolean indicating if the texture needs mipmaps generation
  102581. */
  102582. generateMipMaps: boolean;
  102583. /**
  102584. * Gets the number of samples used by the texture (WebGL2+ only)
  102585. */
  102586. samples: number;
  102587. /**
  102588. * Gets the type of the texture (int, float...)
  102589. */
  102590. type: number;
  102591. /**
  102592. * Gets the format of the texture (RGB, RGBA...)
  102593. */
  102594. format: number;
  102595. /**
  102596. * Observable called when the texture is loaded
  102597. */
  102598. onLoadedObservable: Observable<InternalTexture>;
  102599. /**
  102600. * Gets the width of the texture
  102601. */
  102602. width: number;
  102603. /**
  102604. * Gets the height of the texture
  102605. */
  102606. height: number;
  102607. /**
  102608. * Gets the depth of the texture
  102609. */
  102610. depth: number;
  102611. /**
  102612. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  102613. */
  102614. baseWidth: number;
  102615. /**
  102616. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  102617. */
  102618. baseHeight: number;
  102619. /**
  102620. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  102621. */
  102622. baseDepth: number;
  102623. /**
  102624. * Gets a boolean indicating if the texture is inverted on Y axis
  102625. */
  102626. invertY: boolean;
  102627. /** @hidden */
  102628. _invertVScale: boolean;
  102629. /** @hidden */
  102630. _associatedChannel: number;
  102631. /** @hidden */
  102632. _source: InternalTextureSource;
  102633. /** @hidden */
  102634. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102635. /** @hidden */
  102636. _bufferView: Nullable<ArrayBufferView>;
  102637. /** @hidden */
  102638. _bufferViewArray: Nullable<ArrayBufferView[]>;
  102639. /** @hidden */
  102640. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  102641. /** @hidden */
  102642. _size: number;
  102643. /** @hidden */
  102644. _extension: string;
  102645. /** @hidden */
  102646. _files: Nullable<string[]>;
  102647. /** @hidden */
  102648. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102649. /** @hidden */
  102650. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102651. /** @hidden */
  102652. _framebuffer: Nullable<WebGLFramebuffer>;
  102653. /** @hidden */
  102654. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  102655. /** @hidden */
  102656. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  102657. /** @hidden */
  102658. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  102659. /** @hidden */
  102660. _attachments: Nullable<number[]>;
  102661. /** @hidden */
  102662. _cachedCoordinatesMode: Nullable<number>;
  102663. /** @hidden */
  102664. _cachedWrapU: Nullable<number>;
  102665. /** @hidden */
  102666. _cachedWrapV: Nullable<number>;
  102667. /** @hidden */
  102668. _cachedWrapR: Nullable<number>;
  102669. /** @hidden */
  102670. _cachedAnisotropicFilteringLevel: Nullable<number>;
  102671. /** @hidden */
  102672. _isDisabled: boolean;
  102673. /** @hidden */
  102674. _compression: Nullable<string>;
  102675. /** @hidden */
  102676. _generateStencilBuffer: boolean;
  102677. /** @hidden */
  102678. _generateDepthBuffer: boolean;
  102679. /** @hidden */
  102680. _comparisonFunction: number;
  102681. /** @hidden */
  102682. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  102683. /** @hidden */
  102684. _lodGenerationScale: number;
  102685. /** @hidden */
  102686. _lodGenerationOffset: number;
  102687. /** @hidden */
  102688. _colorTextureArray: Nullable<WebGLTexture>;
  102689. /** @hidden */
  102690. _depthStencilTextureArray: Nullable<WebGLTexture>;
  102691. /** @hidden */
  102692. _lodTextureHigh: Nullable<BaseTexture>;
  102693. /** @hidden */
  102694. _lodTextureMid: Nullable<BaseTexture>;
  102695. /** @hidden */
  102696. _lodTextureLow: Nullable<BaseTexture>;
  102697. /** @hidden */
  102698. _isRGBD: boolean;
  102699. /** @hidden */
  102700. _linearSpecularLOD: boolean;
  102701. /** @hidden */
  102702. _irradianceTexture: Nullable<BaseTexture>;
  102703. /** @hidden */
  102704. _webGLTexture: Nullable<WebGLTexture>;
  102705. /** @hidden */
  102706. _references: number;
  102707. private _engine;
  102708. /**
  102709. * Gets the Engine the texture belongs to.
  102710. * @returns The babylon engine
  102711. */
  102712. getEngine(): ThinEngine;
  102713. /**
  102714. * Gets the data source type of the texture
  102715. */
  102716. get source(): InternalTextureSource;
  102717. /**
  102718. * Creates a new InternalTexture
  102719. * @param engine defines the engine to use
  102720. * @param source defines the type of data that will be used
  102721. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102722. */
  102723. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  102724. /**
  102725. * Increments the number of references (ie. the number of Texture that point to it)
  102726. */
  102727. incrementReferences(): void;
  102728. /**
  102729. * Change the size of the texture (not the size of the content)
  102730. * @param width defines the new width
  102731. * @param height defines the new height
  102732. * @param depth defines the new depth (1 by default)
  102733. */
  102734. updateSize(width: int, height: int, depth?: int): void;
  102735. /** @hidden */
  102736. _rebuild(): void;
  102737. /** @hidden */
  102738. _swapAndDie(target: InternalTexture): void;
  102739. /**
  102740. * Dispose the current allocated resources
  102741. */
  102742. dispose(): void;
  102743. }
  102744. }
  102745. declare module BABYLON {
  102746. /**
  102747. * Class used to work with sound analyzer using fast fourier transform (FFT)
  102748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102749. */
  102750. export class Analyser {
  102751. /**
  102752. * Gets or sets the smoothing
  102753. * @ignorenaming
  102754. */
  102755. SMOOTHING: number;
  102756. /**
  102757. * Gets or sets the FFT table size
  102758. * @ignorenaming
  102759. */
  102760. FFT_SIZE: number;
  102761. /**
  102762. * Gets or sets the bar graph amplitude
  102763. * @ignorenaming
  102764. */
  102765. BARGRAPHAMPLITUDE: number;
  102766. /**
  102767. * Gets or sets the position of the debug canvas
  102768. * @ignorenaming
  102769. */
  102770. DEBUGCANVASPOS: {
  102771. x: number;
  102772. y: number;
  102773. };
  102774. /**
  102775. * Gets or sets the debug canvas size
  102776. * @ignorenaming
  102777. */
  102778. DEBUGCANVASSIZE: {
  102779. width: number;
  102780. height: number;
  102781. };
  102782. private _byteFreqs;
  102783. private _byteTime;
  102784. private _floatFreqs;
  102785. private _webAudioAnalyser;
  102786. private _debugCanvas;
  102787. private _debugCanvasContext;
  102788. private _scene;
  102789. private _registerFunc;
  102790. private _audioEngine;
  102791. /**
  102792. * Creates a new analyser
  102793. * @param scene defines hosting scene
  102794. */
  102795. constructor(scene: Scene);
  102796. /**
  102797. * Get the number of data values you will have to play with for the visualization
  102798. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  102799. * @returns a number
  102800. */
  102801. getFrequencyBinCount(): number;
  102802. /**
  102803. * Gets the current frequency data as a byte array
  102804. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102805. * @returns a Uint8Array
  102806. */
  102807. getByteFrequencyData(): Uint8Array;
  102808. /**
  102809. * Gets the current waveform as a byte array
  102810. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  102811. * @returns a Uint8Array
  102812. */
  102813. getByteTimeDomainData(): Uint8Array;
  102814. /**
  102815. * Gets the current frequency data as a float array
  102816. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102817. * @returns a Float32Array
  102818. */
  102819. getFloatFrequencyData(): Float32Array;
  102820. /**
  102821. * Renders the debug canvas
  102822. */
  102823. drawDebugCanvas(): void;
  102824. /**
  102825. * Stops rendering the debug canvas and removes it
  102826. */
  102827. stopDebugCanvas(): void;
  102828. /**
  102829. * Connects two audio nodes
  102830. * @param inputAudioNode defines first node to connect
  102831. * @param outputAudioNode defines second node to connect
  102832. */
  102833. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  102834. /**
  102835. * Releases all associated resources
  102836. */
  102837. dispose(): void;
  102838. }
  102839. }
  102840. declare module BABYLON {
  102841. /**
  102842. * This represents an audio engine and it is responsible
  102843. * to play, synchronize and analyse sounds throughout the application.
  102844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102845. */
  102846. export interface IAudioEngine extends IDisposable {
  102847. /**
  102848. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102849. */
  102850. readonly canUseWebAudio: boolean;
  102851. /**
  102852. * Gets the current AudioContext if available.
  102853. */
  102854. readonly audioContext: Nullable<AudioContext>;
  102855. /**
  102856. * The master gain node defines the global audio volume of your audio engine.
  102857. */
  102858. readonly masterGain: GainNode;
  102859. /**
  102860. * Gets whether or not mp3 are supported by your browser.
  102861. */
  102862. readonly isMP3supported: boolean;
  102863. /**
  102864. * Gets whether or not ogg are supported by your browser.
  102865. */
  102866. readonly isOGGsupported: boolean;
  102867. /**
  102868. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102869. * @ignoreNaming
  102870. */
  102871. WarnedWebAudioUnsupported: boolean;
  102872. /**
  102873. * Defines if the audio engine relies on a custom unlocked button.
  102874. * In this case, the embedded button will not be displayed.
  102875. */
  102876. useCustomUnlockedButton: boolean;
  102877. /**
  102878. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  102879. */
  102880. readonly unlocked: boolean;
  102881. /**
  102882. * Event raised when audio has been unlocked on the browser.
  102883. */
  102884. onAudioUnlockedObservable: Observable<AudioEngine>;
  102885. /**
  102886. * Event raised when audio has been locked on the browser.
  102887. */
  102888. onAudioLockedObservable: Observable<AudioEngine>;
  102889. /**
  102890. * Flags the audio engine in Locked state.
  102891. * This happens due to new browser policies preventing audio to autoplay.
  102892. */
  102893. lock(): void;
  102894. /**
  102895. * Unlocks the audio engine once a user action has been done on the dom.
  102896. * This is helpful to resume play once browser policies have been satisfied.
  102897. */
  102898. unlock(): void;
  102899. }
  102900. /**
  102901. * This represents the default audio engine used in babylon.
  102902. * It is responsible to play, synchronize and analyse sounds throughout the application.
  102903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102904. */
  102905. export class AudioEngine implements IAudioEngine {
  102906. private _audioContext;
  102907. private _audioContextInitialized;
  102908. private _muteButton;
  102909. private _hostElement;
  102910. /**
  102911. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102912. */
  102913. canUseWebAudio: boolean;
  102914. /**
  102915. * The master gain node defines the global audio volume of your audio engine.
  102916. */
  102917. masterGain: GainNode;
  102918. /**
  102919. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102920. * @ignoreNaming
  102921. */
  102922. WarnedWebAudioUnsupported: boolean;
  102923. /**
  102924. * Gets whether or not mp3 are supported by your browser.
  102925. */
  102926. isMP3supported: boolean;
  102927. /**
  102928. * Gets whether or not ogg are supported by your browser.
  102929. */
  102930. isOGGsupported: boolean;
  102931. /**
  102932. * Gets whether audio has been unlocked on the device.
  102933. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  102934. * a user interaction has happened.
  102935. */
  102936. unlocked: boolean;
  102937. /**
  102938. * Defines if the audio engine relies on a custom unlocked button.
  102939. * In this case, the embedded button will not be displayed.
  102940. */
  102941. useCustomUnlockedButton: boolean;
  102942. /**
  102943. * Event raised when audio has been unlocked on the browser.
  102944. */
  102945. onAudioUnlockedObservable: Observable<AudioEngine>;
  102946. /**
  102947. * Event raised when audio has been locked on the browser.
  102948. */
  102949. onAudioLockedObservable: Observable<AudioEngine>;
  102950. /**
  102951. * Gets the current AudioContext if available.
  102952. */
  102953. get audioContext(): Nullable<AudioContext>;
  102954. private _connectedAnalyser;
  102955. /**
  102956. * Instantiates a new audio engine.
  102957. *
  102958. * There should be only one per page as some browsers restrict the number
  102959. * of audio contexts you can create.
  102960. * @param hostElement defines the host element where to display the mute icon if necessary
  102961. */
  102962. constructor(hostElement?: Nullable<HTMLElement>);
  102963. /**
  102964. * Flags the audio engine in Locked state.
  102965. * This happens due to new browser policies preventing audio to autoplay.
  102966. */
  102967. lock(): void;
  102968. /**
  102969. * Unlocks the audio engine once a user action has been done on the dom.
  102970. * This is helpful to resume play once browser policies have been satisfied.
  102971. */
  102972. unlock(): void;
  102973. private _resumeAudioContext;
  102974. private _initializeAudioContext;
  102975. private _tryToRun;
  102976. private _triggerRunningState;
  102977. private _triggerSuspendedState;
  102978. private _displayMuteButton;
  102979. private _moveButtonToTopLeft;
  102980. private _onResize;
  102981. private _hideMuteButton;
  102982. /**
  102983. * Destroy and release the resources associated with the audio ccontext.
  102984. */
  102985. dispose(): void;
  102986. /**
  102987. * Gets the global volume sets on the master gain.
  102988. * @returns the global volume if set or -1 otherwise
  102989. */
  102990. getGlobalVolume(): number;
  102991. /**
  102992. * Sets the global volume of your experience (sets on the master gain).
  102993. * @param newVolume Defines the new global volume of the application
  102994. */
  102995. setGlobalVolume(newVolume: number): void;
  102996. /**
  102997. * Connect the audio engine to an audio analyser allowing some amazing
  102998. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103000. * @param analyser The analyser to connect to the engine
  103001. */
  103002. connectToAnalyser(analyser: Analyser): void;
  103003. }
  103004. }
  103005. declare module BABYLON {
  103006. /**
  103007. * Interface used to present a loading screen while loading a scene
  103008. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103009. */
  103010. export interface ILoadingScreen {
  103011. /**
  103012. * Function called to display the loading screen
  103013. */
  103014. displayLoadingUI: () => void;
  103015. /**
  103016. * Function called to hide the loading screen
  103017. */
  103018. hideLoadingUI: () => void;
  103019. /**
  103020. * Gets or sets the color to use for the background
  103021. */
  103022. loadingUIBackgroundColor: string;
  103023. /**
  103024. * Gets or sets the text to display while loading
  103025. */
  103026. loadingUIText: string;
  103027. }
  103028. /**
  103029. * Class used for the default loading screen
  103030. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103031. */
  103032. export class DefaultLoadingScreen implements ILoadingScreen {
  103033. private _renderingCanvas;
  103034. private _loadingText;
  103035. private _loadingDivBackgroundColor;
  103036. private _loadingDiv;
  103037. private _loadingTextDiv;
  103038. /** Gets or sets the logo url to use for the default loading screen */
  103039. static DefaultLogoUrl: string;
  103040. /** Gets or sets the spinner url to use for the default loading screen */
  103041. static DefaultSpinnerUrl: string;
  103042. /**
  103043. * Creates a new default loading screen
  103044. * @param _renderingCanvas defines the canvas used to render the scene
  103045. * @param _loadingText defines the default text to display
  103046. * @param _loadingDivBackgroundColor defines the default background color
  103047. */
  103048. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103049. /**
  103050. * Function called to display the loading screen
  103051. */
  103052. displayLoadingUI(): void;
  103053. /**
  103054. * Function called to hide the loading screen
  103055. */
  103056. hideLoadingUI(): void;
  103057. /**
  103058. * Gets or sets the text to display while loading
  103059. */
  103060. set loadingUIText(text: string);
  103061. get loadingUIText(): string;
  103062. /**
  103063. * Gets or sets the color to use for the background
  103064. */
  103065. get loadingUIBackgroundColor(): string;
  103066. set loadingUIBackgroundColor(color: string);
  103067. private _resizeLoadingUI;
  103068. }
  103069. }
  103070. declare module BABYLON {
  103071. /**
  103072. * Interface for any object that can request an animation frame
  103073. */
  103074. export interface ICustomAnimationFrameRequester {
  103075. /**
  103076. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103077. */
  103078. renderFunction?: Function;
  103079. /**
  103080. * Called to request the next frame to render to
  103081. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103082. */
  103083. requestAnimationFrame: Function;
  103084. /**
  103085. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103086. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103087. */
  103088. requestID?: number;
  103089. }
  103090. }
  103091. declare module BABYLON {
  103092. /**
  103093. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  103094. */
  103095. export class PerformanceMonitor {
  103096. private _enabled;
  103097. private _rollingFrameTime;
  103098. private _lastFrameTimeMs;
  103099. /**
  103100. * constructor
  103101. * @param frameSampleSize The number of samples required to saturate the sliding window
  103102. */
  103103. constructor(frameSampleSize?: number);
  103104. /**
  103105. * Samples current frame
  103106. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  103107. */
  103108. sampleFrame(timeMs?: number): void;
  103109. /**
  103110. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103111. */
  103112. get averageFrameTime(): number;
  103113. /**
  103114. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103115. */
  103116. get averageFrameTimeVariance(): number;
  103117. /**
  103118. * Returns the frame time of the most recent frame
  103119. */
  103120. get instantaneousFrameTime(): number;
  103121. /**
  103122. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  103123. */
  103124. get averageFPS(): number;
  103125. /**
  103126. * Returns the average framerate in frames per second using the most recent frame time
  103127. */
  103128. get instantaneousFPS(): number;
  103129. /**
  103130. * Returns true if enough samples have been taken to completely fill the sliding window
  103131. */
  103132. get isSaturated(): boolean;
  103133. /**
  103134. * Enables contributions to the sliding window sample set
  103135. */
  103136. enable(): void;
  103137. /**
  103138. * Disables contributions to the sliding window sample set
  103139. * Samples will not be interpolated over the disabled period
  103140. */
  103141. disable(): void;
  103142. /**
  103143. * Returns true if sampling is enabled
  103144. */
  103145. get isEnabled(): boolean;
  103146. /**
  103147. * Resets performance monitor
  103148. */
  103149. reset(): void;
  103150. }
  103151. /**
  103152. * RollingAverage
  103153. *
  103154. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  103155. */
  103156. export class RollingAverage {
  103157. /**
  103158. * Current average
  103159. */
  103160. average: number;
  103161. /**
  103162. * Current variance
  103163. */
  103164. variance: number;
  103165. protected _samples: Array<number>;
  103166. protected _sampleCount: number;
  103167. protected _pos: number;
  103168. protected _m2: number;
  103169. /**
  103170. * constructor
  103171. * @param length The number of samples required to saturate the sliding window
  103172. */
  103173. constructor(length: number);
  103174. /**
  103175. * Adds a sample to the sample set
  103176. * @param v The sample value
  103177. */
  103178. add(v: number): void;
  103179. /**
  103180. * Returns previously added values or null if outside of history or outside the sliding window domain
  103181. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  103182. * @return Value previously recorded with add() or null if outside of range
  103183. */
  103184. history(i: number): number;
  103185. /**
  103186. * Returns true if enough samples have been taken to completely fill the sliding window
  103187. * @return true if sample-set saturated
  103188. */
  103189. isSaturated(): boolean;
  103190. /**
  103191. * Resets the rolling average (equivalent to 0 samples taken so far)
  103192. */
  103193. reset(): void;
  103194. /**
  103195. * Wraps a value around the sample range boundaries
  103196. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  103197. * @return Wrapped position in sample range
  103198. */
  103199. protected _wrapPosition(i: number): number;
  103200. }
  103201. }
  103202. declare module BABYLON {
  103203. /**
  103204. * This class is used to track a performance counter which is number based.
  103205. * The user has access to many properties which give statistics of different nature.
  103206. *
  103207. * The implementer can track two kinds of Performance Counter: time and count.
  103208. * 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.
  103209. * 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.
  103210. */
  103211. export class PerfCounter {
  103212. /**
  103213. * Gets or sets a global boolean to turn on and off all the counters
  103214. */
  103215. static Enabled: boolean;
  103216. /**
  103217. * Returns the smallest value ever
  103218. */
  103219. get min(): number;
  103220. /**
  103221. * Returns the biggest value ever
  103222. */
  103223. get max(): number;
  103224. /**
  103225. * Returns the average value since the performance counter is running
  103226. */
  103227. get average(): number;
  103228. /**
  103229. * Returns the average value of the last second the counter was monitored
  103230. */
  103231. get lastSecAverage(): number;
  103232. /**
  103233. * Returns the current value
  103234. */
  103235. get current(): number;
  103236. /**
  103237. * Gets the accumulated total
  103238. */
  103239. get total(): number;
  103240. /**
  103241. * Gets the total value count
  103242. */
  103243. get count(): number;
  103244. /**
  103245. * Creates a new counter
  103246. */
  103247. constructor();
  103248. /**
  103249. * Call this method to start monitoring a new frame.
  103250. * 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.
  103251. */
  103252. fetchNewFrame(): void;
  103253. /**
  103254. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  103255. * @param newCount the count value to add to the monitored count
  103256. * @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.
  103257. */
  103258. addCount(newCount: number, fetchResult: boolean): void;
  103259. /**
  103260. * Start monitoring this performance counter
  103261. */
  103262. beginMonitoring(): void;
  103263. /**
  103264. * Compute the time lapsed since the previous beginMonitoring() call.
  103265. * @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
  103266. */
  103267. endMonitoring(newFrame?: boolean): void;
  103268. private _fetchResult;
  103269. private _startMonitoringTime;
  103270. private _min;
  103271. private _max;
  103272. private _average;
  103273. private _current;
  103274. private _totalValueCount;
  103275. private _totalAccumulated;
  103276. private _lastSecAverage;
  103277. private _lastSecAccumulated;
  103278. private _lastSecTime;
  103279. private _lastSecValueCount;
  103280. }
  103281. }
  103282. declare module BABYLON {
  103283. interface ThinEngine {
  103284. /**
  103285. * Sets alpha constants used by some alpha blending modes
  103286. * @param r defines the red component
  103287. * @param g defines the green component
  103288. * @param b defines the blue component
  103289. * @param a defines the alpha component
  103290. */
  103291. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  103292. /**
  103293. * Sets the current alpha mode
  103294. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  103295. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  103296. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103297. */
  103298. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  103299. /**
  103300. * Gets the current alpha mode
  103301. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103302. * @returns the current alpha mode
  103303. */
  103304. getAlphaMode(): number;
  103305. /**
  103306. * Sets the current alpha equation
  103307. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  103308. */
  103309. setAlphaEquation(equation: number): void;
  103310. /**
  103311. * Gets the current alpha equation.
  103312. * @returns the current alpha equation
  103313. */
  103314. getAlphaEquation(): number;
  103315. }
  103316. }
  103317. declare module BABYLON {
  103318. /**
  103319. * Defines the interface used by display changed events
  103320. */
  103321. export interface IDisplayChangedEventArgs {
  103322. /** Gets the vrDisplay object (if any) */
  103323. vrDisplay: Nullable<any>;
  103324. /** Gets a boolean indicating if webVR is supported */
  103325. vrSupported: boolean;
  103326. }
  103327. /**
  103328. * Defines the interface used by objects containing a viewport (like a camera)
  103329. */
  103330. interface IViewportOwnerLike {
  103331. /**
  103332. * Gets or sets the viewport
  103333. */
  103334. viewport: IViewportLike;
  103335. }
  103336. /**
  103337. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  103338. */
  103339. export class Engine extends ThinEngine {
  103340. /** Defines that alpha blending is disabled */
  103341. static readonly ALPHA_DISABLE: number;
  103342. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  103343. static readonly ALPHA_ADD: number;
  103344. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  103345. static readonly ALPHA_COMBINE: number;
  103346. /** Defines that alpha blending to DEST - SRC * DEST */
  103347. static readonly ALPHA_SUBTRACT: number;
  103348. /** Defines that alpha blending to SRC * DEST */
  103349. static readonly ALPHA_MULTIPLY: number;
  103350. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  103351. static readonly ALPHA_MAXIMIZED: number;
  103352. /** Defines that alpha blending to SRC + DEST */
  103353. static readonly ALPHA_ONEONE: number;
  103354. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  103355. static readonly ALPHA_PREMULTIPLIED: number;
  103356. /**
  103357. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  103358. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  103359. */
  103360. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  103361. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  103362. static readonly ALPHA_INTERPOLATE: number;
  103363. /**
  103364. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  103365. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  103366. */
  103367. static readonly ALPHA_SCREENMODE: number;
  103368. /** Defines that the ressource is not delayed*/
  103369. static readonly DELAYLOADSTATE_NONE: number;
  103370. /** Defines that the ressource was successfully delay loaded */
  103371. static readonly DELAYLOADSTATE_LOADED: number;
  103372. /** Defines that the ressource is currently delay loading */
  103373. static readonly DELAYLOADSTATE_LOADING: number;
  103374. /** Defines that the ressource is delayed and has not started loading */
  103375. static readonly DELAYLOADSTATE_NOTLOADED: number;
  103376. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  103377. static readonly NEVER: number;
  103378. /** 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 */
  103379. static readonly ALWAYS: number;
  103380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  103381. static readonly LESS: number;
  103382. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  103383. static readonly EQUAL: number;
  103384. /** 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 */
  103385. static readonly LEQUAL: number;
  103386. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  103387. static readonly GREATER: number;
  103388. /** 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 */
  103389. static readonly GEQUAL: number;
  103390. /** 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 */
  103391. static readonly NOTEQUAL: number;
  103392. /** Passed to stencilOperation to specify that stencil value must be kept */
  103393. static readonly KEEP: number;
  103394. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103395. static readonly REPLACE: number;
  103396. /** Passed to stencilOperation to specify that stencil value must be incremented */
  103397. static readonly INCR: number;
  103398. /** Passed to stencilOperation to specify that stencil value must be decremented */
  103399. static readonly DECR: number;
  103400. /** Passed to stencilOperation to specify that stencil value must be inverted */
  103401. static readonly INVERT: number;
  103402. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  103403. static readonly INCR_WRAP: number;
  103404. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  103405. static readonly DECR_WRAP: number;
  103406. /** Texture is not repeating outside of 0..1 UVs */
  103407. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  103408. /** Texture is repeating outside of 0..1 UVs */
  103409. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  103410. /** Texture is repeating and mirrored */
  103411. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  103412. /** ALPHA */
  103413. static readonly TEXTUREFORMAT_ALPHA: number;
  103414. /** LUMINANCE */
  103415. static readonly TEXTUREFORMAT_LUMINANCE: number;
  103416. /** LUMINANCE_ALPHA */
  103417. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  103418. /** RGB */
  103419. static readonly TEXTUREFORMAT_RGB: number;
  103420. /** RGBA */
  103421. static readonly TEXTUREFORMAT_RGBA: number;
  103422. /** RED */
  103423. static readonly TEXTUREFORMAT_RED: number;
  103424. /** RED (2nd reference) */
  103425. static readonly TEXTUREFORMAT_R: number;
  103426. /** RG */
  103427. static readonly TEXTUREFORMAT_RG: number;
  103428. /** RED_INTEGER */
  103429. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  103430. /** RED_INTEGER (2nd reference) */
  103431. static readonly TEXTUREFORMAT_R_INTEGER: number;
  103432. /** RG_INTEGER */
  103433. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  103434. /** RGB_INTEGER */
  103435. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  103436. /** RGBA_INTEGER */
  103437. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  103438. /** UNSIGNED_BYTE */
  103439. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  103440. /** UNSIGNED_BYTE (2nd reference) */
  103441. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  103442. /** FLOAT */
  103443. static readonly TEXTURETYPE_FLOAT: number;
  103444. /** HALF_FLOAT */
  103445. static readonly TEXTURETYPE_HALF_FLOAT: number;
  103446. /** BYTE */
  103447. static readonly TEXTURETYPE_BYTE: number;
  103448. /** SHORT */
  103449. static readonly TEXTURETYPE_SHORT: number;
  103450. /** UNSIGNED_SHORT */
  103451. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  103452. /** INT */
  103453. static readonly TEXTURETYPE_INT: number;
  103454. /** UNSIGNED_INT */
  103455. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  103456. /** UNSIGNED_SHORT_4_4_4_4 */
  103457. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  103458. /** UNSIGNED_SHORT_5_5_5_1 */
  103459. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  103460. /** UNSIGNED_SHORT_5_6_5 */
  103461. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  103462. /** UNSIGNED_INT_2_10_10_10_REV */
  103463. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  103464. /** UNSIGNED_INT_24_8 */
  103465. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  103466. /** UNSIGNED_INT_10F_11F_11F_REV */
  103467. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  103468. /** UNSIGNED_INT_5_9_9_9_REV */
  103469. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  103470. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  103471. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  103472. /** nearest is mag = nearest and min = nearest and mip = linear */
  103473. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  103474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103475. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  103476. /** Trilinear is mag = linear and min = linear and mip = linear */
  103477. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  103478. /** nearest is mag = nearest and min = nearest and mip = linear */
  103479. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  103480. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103481. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  103482. /** Trilinear is mag = linear and min = linear and mip = linear */
  103483. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  103484. /** mag = nearest and min = nearest and mip = nearest */
  103485. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  103486. /** mag = nearest and min = linear and mip = nearest */
  103487. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  103488. /** mag = nearest and min = linear and mip = linear */
  103489. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  103490. /** mag = nearest and min = linear and mip = none */
  103491. static readonly TEXTURE_NEAREST_LINEAR: number;
  103492. /** mag = nearest and min = nearest and mip = none */
  103493. static readonly TEXTURE_NEAREST_NEAREST: number;
  103494. /** mag = linear and min = nearest and mip = nearest */
  103495. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  103496. /** mag = linear and min = nearest and mip = linear */
  103497. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  103498. /** mag = linear and min = linear and mip = none */
  103499. static readonly TEXTURE_LINEAR_LINEAR: number;
  103500. /** mag = linear and min = nearest and mip = none */
  103501. static readonly TEXTURE_LINEAR_NEAREST: number;
  103502. /** Explicit coordinates mode */
  103503. static readonly TEXTURE_EXPLICIT_MODE: number;
  103504. /** Spherical coordinates mode */
  103505. static readonly TEXTURE_SPHERICAL_MODE: number;
  103506. /** Planar coordinates mode */
  103507. static readonly TEXTURE_PLANAR_MODE: number;
  103508. /** Cubic coordinates mode */
  103509. static readonly TEXTURE_CUBIC_MODE: number;
  103510. /** Projection coordinates mode */
  103511. static readonly TEXTURE_PROJECTION_MODE: number;
  103512. /** Skybox coordinates mode */
  103513. static readonly TEXTURE_SKYBOX_MODE: number;
  103514. /** Inverse Cubic coordinates mode */
  103515. static readonly TEXTURE_INVCUBIC_MODE: number;
  103516. /** Equirectangular coordinates mode */
  103517. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  103518. /** Equirectangular Fixed coordinates mode */
  103519. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  103520. /** Equirectangular Fixed Mirrored coordinates mode */
  103521. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103522. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  103523. static readonly SCALEMODE_FLOOR: number;
  103524. /** Defines that texture rescaling will look for the nearest power of 2 size */
  103525. static readonly SCALEMODE_NEAREST: number;
  103526. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  103527. static readonly SCALEMODE_CEILING: number;
  103528. /**
  103529. * Returns the current npm package of the sdk
  103530. */
  103531. static get NpmPackage(): string;
  103532. /**
  103533. * Returns the current version of the framework
  103534. */
  103535. static get Version(): string;
  103536. /** Gets the list of created engines */
  103537. static get Instances(): Engine[];
  103538. /**
  103539. * Gets the latest created engine
  103540. */
  103541. static get LastCreatedEngine(): Nullable<Engine>;
  103542. /**
  103543. * Gets the latest created scene
  103544. */
  103545. static get LastCreatedScene(): Nullable<Scene>;
  103546. /**
  103547. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  103548. * @param flag defines which part of the materials must be marked as dirty
  103549. * @param predicate defines a predicate used to filter which materials should be affected
  103550. */
  103551. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103552. /**
  103553. * Method called to create the default loading screen.
  103554. * This can be overriden in your own app.
  103555. * @param canvas The rendering canvas element
  103556. * @returns The loading screen
  103557. */
  103558. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  103559. /**
  103560. * Method called to create the default rescale post process on each engine.
  103561. */
  103562. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  103563. /**
  103564. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  103565. **/
  103566. enableOfflineSupport: boolean;
  103567. /**
  103568. * 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)
  103569. **/
  103570. disableManifestCheck: boolean;
  103571. /**
  103572. * Gets the list of created scenes
  103573. */
  103574. scenes: Scene[];
  103575. /**
  103576. * Event raised when a new scene is created
  103577. */
  103578. onNewSceneAddedObservable: Observable<Scene>;
  103579. /**
  103580. * Gets the list of created postprocesses
  103581. */
  103582. postProcesses: PostProcess[];
  103583. /**
  103584. * Gets a boolean indicating if the pointer is currently locked
  103585. */
  103586. isPointerLock: boolean;
  103587. /**
  103588. * Observable event triggered each time the rendering canvas is resized
  103589. */
  103590. onResizeObservable: Observable<Engine>;
  103591. /**
  103592. * Observable event triggered each time the canvas loses focus
  103593. */
  103594. onCanvasBlurObservable: Observable<Engine>;
  103595. /**
  103596. * Observable event triggered each time the canvas gains focus
  103597. */
  103598. onCanvasFocusObservable: Observable<Engine>;
  103599. /**
  103600. * Observable event triggered each time the canvas receives pointerout event
  103601. */
  103602. onCanvasPointerOutObservable: Observable<PointerEvent>;
  103603. /**
  103604. * Observable raised when the engine begins a new frame
  103605. */
  103606. onBeginFrameObservable: Observable<Engine>;
  103607. /**
  103608. * If set, will be used to request the next animation frame for the render loop
  103609. */
  103610. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  103611. /**
  103612. * Observable raised when the engine ends the current frame
  103613. */
  103614. onEndFrameObservable: Observable<Engine>;
  103615. /**
  103616. * Observable raised when the engine is about to compile a shader
  103617. */
  103618. onBeforeShaderCompilationObservable: Observable<Engine>;
  103619. /**
  103620. * Observable raised when the engine has jsut compiled a shader
  103621. */
  103622. onAfterShaderCompilationObservable: Observable<Engine>;
  103623. /**
  103624. * Gets the audio engine
  103625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103626. * @ignorenaming
  103627. */
  103628. static audioEngine: IAudioEngine;
  103629. /**
  103630. * Default AudioEngine factory responsible of creating the Audio Engine.
  103631. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  103632. */
  103633. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  103634. /**
  103635. * Default offline support factory responsible of creating a tool used to store data locally.
  103636. * By default, this will create a Database object if the workload has been embedded.
  103637. */
  103638. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  103639. private _loadingScreen;
  103640. private _pointerLockRequested;
  103641. private _dummyFramebuffer;
  103642. private _rescalePostProcess;
  103643. private _deterministicLockstep;
  103644. private _lockstepMaxSteps;
  103645. private _timeStep;
  103646. protected get _supportsHardwareTextureRescaling(): boolean;
  103647. private _fps;
  103648. private _deltaTime;
  103649. /** @hidden */
  103650. _drawCalls: PerfCounter;
  103651. /**
  103652. * Turn this value on if you want to pause FPS computation when in background
  103653. */
  103654. disablePerformanceMonitorInBackground: boolean;
  103655. private _performanceMonitor;
  103656. /**
  103657. * Gets the performance monitor attached to this engine
  103658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103659. */
  103660. get performanceMonitor(): PerformanceMonitor;
  103661. private _onFocus;
  103662. private _onBlur;
  103663. private _onCanvasPointerOut;
  103664. private _onCanvasBlur;
  103665. private _onCanvasFocus;
  103666. private _onFullscreenChange;
  103667. private _onPointerLockChange;
  103668. /**
  103669. * Gets the HTML element used to attach event listeners
  103670. * @returns a HTML element
  103671. */
  103672. getInputElement(): Nullable<HTMLElement>;
  103673. /**
  103674. * Creates a new engine
  103675. * @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
  103676. * @param antialias defines enable antialiasing (default: false)
  103677. * @param options defines further options to be sent to the getContext() function
  103678. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103679. */
  103680. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103681. /**
  103682. * Gets current aspect ratio
  103683. * @param viewportOwner defines the camera to use to get the aspect ratio
  103684. * @param useScreen defines if screen size must be used (or the current render target if any)
  103685. * @returns a number defining the aspect ratio
  103686. */
  103687. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  103688. /**
  103689. * Gets current screen aspect ratio
  103690. * @returns a number defining the aspect ratio
  103691. */
  103692. getScreenAspectRatio(): number;
  103693. /**
  103694. * Gets the client rect of the HTML canvas attached with the current webGL context
  103695. * @returns a client rectanglee
  103696. */
  103697. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  103698. /**
  103699. * Gets the client rect of the HTML element used for events
  103700. * @returns a client rectanglee
  103701. */
  103702. getInputElementClientRect(): Nullable<ClientRect>;
  103703. /**
  103704. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  103705. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103706. * @returns true if engine is in deterministic lock step mode
  103707. */
  103708. isDeterministicLockStep(): boolean;
  103709. /**
  103710. * Gets the max steps when engine is running in deterministic lock step
  103711. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103712. * @returns the max steps
  103713. */
  103714. getLockstepMaxSteps(): number;
  103715. /**
  103716. * Returns the time in ms between steps when using deterministic lock step.
  103717. * @returns time step in (ms)
  103718. */
  103719. getTimeStep(): number;
  103720. /**
  103721. * Force the mipmap generation for the given render target texture
  103722. * @param texture defines the render target texture to use
  103723. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  103724. */
  103725. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  103726. /** States */
  103727. /**
  103728. * Set various states to the webGL context
  103729. * @param culling defines backface culling state
  103730. * @param zOffset defines the value to apply to zOffset (0 by default)
  103731. * @param force defines if states must be applied even if cache is up to date
  103732. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  103733. */
  103734. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  103735. /**
  103736. * Set the z offset to apply to current rendering
  103737. * @param value defines the offset to apply
  103738. */
  103739. setZOffset(value: number): void;
  103740. /**
  103741. * Gets the current value of the zOffset
  103742. * @returns the current zOffset state
  103743. */
  103744. getZOffset(): number;
  103745. /**
  103746. * Enable or disable depth buffering
  103747. * @param enable defines the state to set
  103748. */
  103749. setDepthBuffer(enable: boolean): void;
  103750. /**
  103751. * Gets a boolean indicating if depth writing is enabled
  103752. * @returns the current depth writing state
  103753. */
  103754. getDepthWrite(): boolean;
  103755. /**
  103756. * Enable or disable depth writing
  103757. * @param enable defines the state to set
  103758. */
  103759. setDepthWrite(enable: boolean): void;
  103760. /**
  103761. * Gets a boolean indicating if stencil buffer is enabled
  103762. * @returns the current stencil buffer state
  103763. */
  103764. getStencilBuffer(): boolean;
  103765. /**
  103766. * Enable or disable the stencil buffer
  103767. * @param enable defines if the stencil buffer must be enabled or disabled
  103768. */
  103769. setStencilBuffer(enable: boolean): void;
  103770. /**
  103771. * Gets the current stencil mask
  103772. * @returns a number defining the new stencil mask to use
  103773. */
  103774. getStencilMask(): number;
  103775. /**
  103776. * Sets the current stencil mask
  103777. * @param mask defines the new stencil mask to use
  103778. */
  103779. setStencilMask(mask: number): void;
  103780. /**
  103781. * Gets the current stencil function
  103782. * @returns a number defining the stencil function to use
  103783. */
  103784. getStencilFunction(): number;
  103785. /**
  103786. * Gets the current stencil reference value
  103787. * @returns a number defining the stencil reference value to use
  103788. */
  103789. getStencilFunctionReference(): number;
  103790. /**
  103791. * Gets the current stencil mask
  103792. * @returns a number defining the stencil mask to use
  103793. */
  103794. getStencilFunctionMask(): number;
  103795. /**
  103796. * Sets the current stencil function
  103797. * @param stencilFunc defines the new stencil function to use
  103798. */
  103799. setStencilFunction(stencilFunc: number): void;
  103800. /**
  103801. * Sets the current stencil reference
  103802. * @param reference defines the new stencil reference to use
  103803. */
  103804. setStencilFunctionReference(reference: number): void;
  103805. /**
  103806. * Sets the current stencil mask
  103807. * @param mask defines the new stencil mask to use
  103808. */
  103809. setStencilFunctionMask(mask: number): void;
  103810. /**
  103811. * Gets the current stencil operation when stencil fails
  103812. * @returns a number defining stencil operation to use when stencil fails
  103813. */
  103814. getStencilOperationFail(): number;
  103815. /**
  103816. * Gets the current stencil operation when depth fails
  103817. * @returns a number defining stencil operation to use when depth fails
  103818. */
  103819. getStencilOperationDepthFail(): number;
  103820. /**
  103821. * Gets the current stencil operation when stencil passes
  103822. * @returns a number defining stencil operation to use when stencil passes
  103823. */
  103824. getStencilOperationPass(): number;
  103825. /**
  103826. * Sets the stencil operation to use when stencil fails
  103827. * @param operation defines the stencil operation to use when stencil fails
  103828. */
  103829. setStencilOperationFail(operation: number): void;
  103830. /**
  103831. * Sets the stencil operation to use when depth fails
  103832. * @param operation defines the stencil operation to use when depth fails
  103833. */
  103834. setStencilOperationDepthFail(operation: number): void;
  103835. /**
  103836. * Sets the stencil operation to use when stencil passes
  103837. * @param operation defines the stencil operation to use when stencil passes
  103838. */
  103839. setStencilOperationPass(operation: number): void;
  103840. /**
  103841. * Sets a boolean indicating if the dithering state is enabled or disabled
  103842. * @param value defines the dithering state
  103843. */
  103844. setDitheringState(value: boolean): void;
  103845. /**
  103846. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  103847. * @param value defines the rasterizer state
  103848. */
  103849. setRasterizerState(value: boolean): void;
  103850. /**
  103851. * Gets the current depth function
  103852. * @returns a number defining the depth function
  103853. */
  103854. getDepthFunction(): Nullable<number>;
  103855. /**
  103856. * Sets the current depth function
  103857. * @param depthFunc defines the function to use
  103858. */
  103859. setDepthFunction(depthFunc: number): void;
  103860. /**
  103861. * Sets the current depth function to GREATER
  103862. */
  103863. setDepthFunctionToGreater(): void;
  103864. /**
  103865. * Sets the current depth function to GEQUAL
  103866. */
  103867. setDepthFunctionToGreaterOrEqual(): void;
  103868. /**
  103869. * Sets the current depth function to LESS
  103870. */
  103871. setDepthFunctionToLess(): void;
  103872. /**
  103873. * Sets the current depth function to LEQUAL
  103874. */
  103875. setDepthFunctionToLessOrEqual(): void;
  103876. private _cachedStencilBuffer;
  103877. private _cachedStencilFunction;
  103878. private _cachedStencilMask;
  103879. private _cachedStencilOperationPass;
  103880. private _cachedStencilOperationFail;
  103881. private _cachedStencilOperationDepthFail;
  103882. private _cachedStencilReference;
  103883. /**
  103884. * Caches the the state of the stencil buffer
  103885. */
  103886. cacheStencilState(): void;
  103887. /**
  103888. * Restores the state of the stencil buffer
  103889. */
  103890. restoreStencilState(): void;
  103891. /**
  103892. * Directly set the WebGL Viewport
  103893. * @param x defines the x coordinate of the viewport (in screen space)
  103894. * @param y defines the y coordinate of the viewport (in screen space)
  103895. * @param width defines the width of the viewport (in screen space)
  103896. * @param height defines the height of the viewport (in screen space)
  103897. * @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
  103898. */
  103899. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  103900. /**
  103901. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  103902. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  103903. * @param y defines the y-coordinate of the corner of the clear rectangle
  103904. * @param width defines the width of the clear rectangle
  103905. * @param height defines the height of the clear rectangle
  103906. * @param clearColor defines the clear color
  103907. */
  103908. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  103909. /**
  103910. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  103911. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  103912. * @param y defines the y-coordinate of the corner of the clear rectangle
  103913. * @param width defines the width of the clear rectangle
  103914. * @param height defines the height of the clear rectangle
  103915. */
  103916. enableScissor(x: number, y: number, width: number, height: number): void;
  103917. /**
  103918. * Disable previously set scissor test rectangle
  103919. */
  103920. disableScissor(): void;
  103921. protected _reportDrawCall(): void;
  103922. /**
  103923. * Initializes a webVR display and starts listening to display change events
  103924. * The onVRDisplayChangedObservable will be notified upon these changes
  103925. * @returns The onVRDisplayChangedObservable
  103926. */
  103927. initWebVR(): Observable<IDisplayChangedEventArgs>;
  103928. /** @hidden */
  103929. _prepareVRComponent(): void;
  103930. /** @hidden */
  103931. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  103932. /** @hidden */
  103933. _submitVRFrame(): void;
  103934. /**
  103935. * Call this function to leave webVR mode
  103936. * Will do nothing if webVR is not supported or if there is no webVR device
  103937. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103938. */
  103939. disableVR(): void;
  103940. /**
  103941. * Gets a boolean indicating that the system is in VR mode and is presenting
  103942. * @returns true if VR mode is engaged
  103943. */
  103944. isVRPresenting(): boolean;
  103945. /** @hidden */
  103946. _requestVRFrame(): void;
  103947. /** @hidden */
  103948. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103949. /**
  103950. * Gets the source code of the vertex shader associated with a specific webGL program
  103951. * @param program defines the program to use
  103952. * @returns a string containing the source code of the vertex shader associated with the program
  103953. */
  103954. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  103955. /**
  103956. * Gets the source code of the fragment shader associated with a specific webGL program
  103957. * @param program defines the program to use
  103958. * @returns a string containing the source code of the fragment shader associated with the program
  103959. */
  103960. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  103961. /**
  103962. * Sets a depth stencil texture from a render target to the according uniform.
  103963. * @param channel The texture channel
  103964. * @param uniform The uniform to set
  103965. * @param texture The render target texture containing the depth stencil texture to apply
  103966. */
  103967. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  103968. /**
  103969. * Sets a texture to the webGL context from a postprocess
  103970. * @param channel defines the channel to use
  103971. * @param postProcess defines the source postprocess
  103972. */
  103973. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  103974. /**
  103975. * Binds the output of the passed in post process to the texture channel specified
  103976. * @param channel The channel the texture should be bound to
  103977. * @param postProcess The post process which's output should be bound
  103978. */
  103979. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  103980. /** @hidden */
  103981. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  103982. protected _rebuildBuffers(): void;
  103983. /** @hidden */
  103984. _renderFrame(): void;
  103985. _renderLoop(): void;
  103986. /** @hidden */
  103987. _renderViews(): boolean;
  103988. /**
  103989. * Toggle full screen mode
  103990. * @param requestPointerLock defines if a pointer lock should be requested from the user
  103991. */
  103992. switchFullscreen(requestPointerLock: boolean): void;
  103993. /**
  103994. * Enters full screen mode
  103995. * @param requestPointerLock defines if a pointer lock should be requested from the user
  103996. */
  103997. enterFullscreen(requestPointerLock: boolean): void;
  103998. /**
  103999. * Exits full screen mode
  104000. */
  104001. exitFullscreen(): void;
  104002. /**
  104003. * Enters Pointerlock mode
  104004. */
  104005. enterPointerlock(): void;
  104006. /**
  104007. * Exits Pointerlock mode
  104008. */
  104009. exitPointerlock(): void;
  104010. /**
  104011. * Begin a new frame
  104012. */
  104013. beginFrame(): void;
  104014. /**
  104015. * Enf the current frame
  104016. */
  104017. endFrame(): void;
  104018. resize(): void;
  104019. /**
  104020. * Set the compressed texture format to use, based on the formats you have, and the formats
  104021. * supported by the hardware / browser.
  104022. *
  104023. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104024. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104025. * to API arguments needed to compressed textures. This puts the burden on the container
  104026. * generator to house the arcane code for determining these for current & future formats.
  104027. *
  104028. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104029. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104030. *
  104031. * Note: The result of this call is not taken into account when a texture is base64.
  104032. *
  104033. * @param formatsAvailable defines the list of those format families you have created
  104034. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104035. *
  104036. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104037. * @returns The extension selected.
  104038. */
  104039. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104040. /**
  104041. * Set the compressed texture extensions or file names to skip.
  104042. *
  104043. * @param skippedFiles defines the list of those texture files you want to skip
  104044. * Example: [".dds", ".env", "myfile.png"]
  104045. */
  104046. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104047. /**
  104048. * Force a specific size of the canvas
  104049. * @param width defines the new canvas' width
  104050. * @param height defines the new canvas' height
  104051. */
  104052. setSize(width: number, height: number): void;
  104053. /**
  104054. * Updates a dynamic vertex buffer.
  104055. * @param vertexBuffer the vertex buffer to update
  104056. * @param data the data used to update the vertex buffer
  104057. * @param byteOffset the byte offset of the data
  104058. * @param byteLength the byte length of the data
  104059. */
  104060. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104061. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104062. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104063. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104064. _releaseTexture(texture: InternalTexture): void;
  104065. /**
  104066. * @hidden
  104067. * Rescales a texture
  104068. * @param source input texutre
  104069. * @param destination destination texture
  104070. * @param scene scene to use to render the resize
  104071. * @param internalFormat format to use when resizing
  104072. * @param onComplete callback to be called when resize has completed
  104073. */
  104074. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104075. /**
  104076. * Gets the current framerate
  104077. * @returns a number representing the framerate
  104078. */
  104079. getFps(): number;
  104080. /**
  104081. * Gets the time spent between current and previous frame
  104082. * @returns a number representing the delta time in ms
  104083. */
  104084. getDeltaTime(): number;
  104085. private _measureFps;
  104086. /** @hidden */
  104087. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104088. /**
  104089. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104090. * @param renderTarget The render target to set the frame buffer for
  104091. */
  104092. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  104093. /**
  104094. * Update a dynamic index buffer
  104095. * @param indexBuffer defines the target index buffer
  104096. * @param indices defines the data to update
  104097. * @param offset defines the offset in the target index buffer where update should start
  104098. */
  104099. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  104100. /**
  104101. * Updates the sample count of a render target texture
  104102. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104103. * @param texture defines the texture to update
  104104. * @param samples defines the sample count to set
  104105. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104106. */
  104107. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  104108. /**
  104109. * Updates a depth texture Comparison Mode and Function.
  104110. * If the comparison Function is equal to 0, the mode will be set to none.
  104111. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  104112. * @param texture The texture to set the comparison function for
  104113. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  104114. */
  104115. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  104116. /**
  104117. * Creates a webGL buffer to use with instanciation
  104118. * @param capacity defines the size of the buffer
  104119. * @returns the webGL buffer
  104120. */
  104121. createInstancesBuffer(capacity: number): DataBuffer;
  104122. /**
  104123. * Delete a webGL buffer used with instanciation
  104124. * @param buffer defines the webGL buffer to delete
  104125. */
  104126. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  104127. /** @hidden */
  104128. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  104129. dispose(): void;
  104130. private _disableTouchAction;
  104131. /**
  104132. * Display the loading screen
  104133. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104134. */
  104135. displayLoadingUI(): void;
  104136. /**
  104137. * Hide the loading screen
  104138. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104139. */
  104140. hideLoadingUI(): void;
  104141. /**
  104142. * Gets the current loading screen object
  104143. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104144. */
  104145. get loadingScreen(): ILoadingScreen;
  104146. /**
  104147. * Sets the current loading screen object
  104148. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104149. */
  104150. set loadingScreen(loadingScreen: ILoadingScreen);
  104151. /**
  104152. * Sets the current loading screen text
  104153. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104154. */
  104155. set loadingUIText(text: string);
  104156. /**
  104157. * Sets the current loading screen background color
  104158. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104159. */
  104160. set loadingUIBackgroundColor(color: string);
  104161. /** Pointerlock and fullscreen */
  104162. /**
  104163. * Ask the browser to promote the current element to pointerlock mode
  104164. * @param element defines the DOM element to promote
  104165. */
  104166. static _RequestPointerlock(element: HTMLElement): void;
  104167. /**
  104168. * Asks the browser to exit pointerlock mode
  104169. */
  104170. static _ExitPointerlock(): void;
  104171. /**
  104172. * Ask the browser to promote the current element to fullscreen rendering mode
  104173. * @param element defines the DOM element to promote
  104174. */
  104175. static _RequestFullscreen(element: HTMLElement): void;
  104176. /**
  104177. * Asks the browser to exit fullscreen mode
  104178. */
  104179. static _ExitFullscreen(): void;
  104180. }
  104181. }
  104182. declare module BABYLON {
  104183. /**
  104184. * The engine store class is responsible to hold all the instances of Engine and Scene created
  104185. * during the life time of the application.
  104186. */
  104187. export class EngineStore {
  104188. /** Gets the list of created engines */
  104189. static Instances: Engine[];
  104190. /** @hidden */
  104191. static _LastCreatedScene: Nullable<Scene>;
  104192. /**
  104193. * Gets the latest created engine
  104194. */
  104195. static get LastCreatedEngine(): Nullable<Engine>;
  104196. /**
  104197. * Gets the latest created scene
  104198. */
  104199. static get LastCreatedScene(): Nullable<Scene>;
  104200. /**
  104201. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104202. * @ignorenaming
  104203. */
  104204. static UseFallbackTexture: boolean;
  104205. /**
  104206. * Texture content used if a texture cannot loaded
  104207. * @ignorenaming
  104208. */
  104209. static FallbackTexture: string;
  104210. }
  104211. }
  104212. declare module BABYLON {
  104213. /**
  104214. * Helper class that provides a small promise polyfill
  104215. */
  104216. export class PromisePolyfill {
  104217. /**
  104218. * Static function used to check if the polyfill is required
  104219. * If this is the case then the function will inject the polyfill to window.Promise
  104220. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  104221. */
  104222. static Apply(force?: boolean): void;
  104223. }
  104224. }
  104225. declare module BABYLON {
  104226. /**
  104227. * Interface for screenshot methods with describe argument called `size` as object with options
  104228. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  104229. */
  104230. export interface IScreenshotSize {
  104231. /**
  104232. * number in pixels for canvas height
  104233. */
  104234. height?: number;
  104235. /**
  104236. * multiplier allowing render at a higher or lower resolution
  104237. * If value is defined then height and width will be ignored and taken from camera
  104238. */
  104239. precision?: number;
  104240. /**
  104241. * number in pixels for canvas width
  104242. */
  104243. width?: number;
  104244. }
  104245. }
  104246. declare module BABYLON {
  104247. interface IColor4Like {
  104248. r: float;
  104249. g: float;
  104250. b: float;
  104251. a: float;
  104252. }
  104253. /**
  104254. * Class containing a set of static utilities functions
  104255. */
  104256. export class Tools {
  104257. /**
  104258. * Gets or sets the base URL to use to load assets
  104259. */
  104260. static get BaseUrl(): string;
  104261. static set BaseUrl(value: string);
  104262. /**
  104263. * Enable/Disable Custom HTTP Request Headers globally.
  104264. * default = false
  104265. * @see CustomRequestHeaders
  104266. */
  104267. static UseCustomRequestHeaders: boolean;
  104268. /**
  104269. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104270. * i.e. when loading files, where the server/service expects an Authorization header
  104271. */
  104272. static CustomRequestHeaders: {
  104273. [key: string]: string;
  104274. };
  104275. /**
  104276. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104277. */
  104278. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  104279. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  104280. /**
  104281. * Default behaviour for cors in the application.
  104282. * It can be a string if the expected behavior is identical in the entire app.
  104283. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104284. */
  104285. static CorsBehavior: string | ((url: string | string[]) => string);
  104286. /**
  104287. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104288. * @ignorenaming
  104289. */
  104290. static get UseFallbackTexture(): boolean;
  104291. static set UseFallbackTexture(value: boolean);
  104292. /**
  104293. * Use this object to register external classes like custom textures or material
  104294. * to allow the laoders to instantiate them
  104295. */
  104296. static get RegisteredExternalClasses(): {
  104297. [key: string]: Object;
  104298. };
  104299. static set RegisteredExternalClasses(classes: {
  104300. [key: string]: Object;
  104301. });
  104302. /**
  104303. * Texture content used if a texture cannot loaded
  104304. * @ignorenaming
  104305. */
  104306. static get fallbackTexture(): string;
  104307. static set fallbackTexture(value: string);
  104308. /**
  104309. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  104310. * @param u defines the coordinate on X axis
  104311. * @param v defines the coordinate on Y axis
  104312. * @param width defines the width of the source data
  104313. * @param height defines the height of the source data
  104314. * @param pixels defines the source byte array
  104315. * @param color defines the output color
  104316. */
  104317. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  104318. /**
  104319. * Interpolates between a and b via alpha
  104320. * @param a The lower value (returned when alpha = 0)
  104321. * @param b The upper value (returned when alpha = 1)
  104322. * @param alpha The interpolation-factor
  104323. * @return The mixed value
  104324. */
  104325. static Mix(a: number, b: number, alpha: number): number;
  104326. /**
  104327. * Tries to instantiate a new object from a given class name
  104328. * @param className defines the class name to instantiate
  104329. * @returns the new object or null if the system was not able to do the instantiation
  104330. */
  104331. static Instantiate(className: string): any;
  104332. /**
  104333. * Provides a slice function that will work even on IE
  104334. * @param data defines the array to slice
  104335. * @param start defines the start of the data (optional)
  104336. * @param end defines the end of the data (optional)
  104337. * @returns the new sliced array
  104338. */
  104339. static Slice<T>(data: T, start?: number, end?: number): T;
  104340. /**
  104341. * Polyfill for setImmediate
  104342. * @param action defines the action to execute after the current execution block
  104343. */
  104344. static SetImmediate(action: () => void): void;
  104345. /**
  104346. * Function indicating if a number is an exponent of 2
  104347. * @param value defines the value to test
  104348. * @returns true if the value is an exponent of 2
  104349. */
  104350. static IsExponentOfTwo(value: number): boolean;
  104351. private static _tmpFloatArray;
  104352. /**
  104353. * Returns the nearest 32-bit single precision float representation of a Number
  104354. * @param value A Number. If the parameter is of a different type, it will get converted
  104355. * to a number or to NaN if it cannot be converted
  104356. * @returns number
  104357. */
  104358. static FloatRound(value: number): number;
  104359. /**
  104360. * Extracts the filename from a path
  104361. * @param path defines the path to use
  104362. * @returns the filename
  104363. */
  104364. static GetFilename(path: string): string;
  104365. /**
  104366. * Extracts the "folder" part of a path (everything before the filename).
  104367. * @param uri The URI to extract the info from
  104368. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  104369. * @returns The "folder" part of the path
  104370. */
  104371. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  104372. /**
  104373. * Extracts text content from a DOM element hierarchy
  104374. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104375. */
  104376. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  104377. /**
  104378. * Convert an angle in radians to degrees
  104379. * @param angle defines the angle to convert
  104380. * @returns the angle in degrees
  104381. */
  104382. static ToDegrees(angle: number): number;
  104383. /**
  104384. * Convert an angle in degrees to radians
  104385. * @param angle defines the angle to convert
  104386. * @returns the angle in radians
  104387. */
  104388. static ToRadians(angle: number): number;
  104389. /**
  104390. * Returns an array if obj is not an array
  104391. * @param obj defines the object to evaluate as an array
  104392. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  104393. * @returns either obj directly if obj is an array or a new array containing obj
  104394. */
  104395. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  104396. /**
  104397. * Gets the pointer prefix to use
  104398. * @returns "pointer" if touch is enabled. Else returns "mouse"
  104399. */
  104400. static GetPointerPrefix(): string;
  104401. /**
  104402. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  104403. * @param url define the url we are trying
  104404. * @param element define the dom element where to configure the cors policy
  104405. */
  104406. static SetCorsBehavior(url: string | string[], element: {
  104407. crossOrigin: string | null;
  104408. }): void;
  104409. /**
  104410. * Removes unwanted characters from an url
  104411. * @param url defines the url to clean
  104412. * @returns the cleaned url
  104413. */
  104414. static CleanUrl(url: string): string;
  104415. /**
  104416. * Gets or sets a function used to pre-process url before using them to load assets
  104417. */
  104418. static get PreprocessUrl(): (url: string) => string;
  104419. static set PreprocessUrl(processor: (url: string) => string);
  104420. /**
  104421. * Loads an image as an HTMLImageElement.
  104422. * @param input url string, ArrayBuffer, or Blob to load
  104423. * @param onLoad callback called when the image successfully loads
  104424. * @param onError callback called when the image fails to load
  104425. * @param offlineProvider offline provider for caching
  104426. * @param mimeType optional mime type
  104427. * @returns the HTMLImageElement of the loaded image
  104428. */
  104429. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  104430. /**
  104431. * Loads a file from a url
  104432. * @param url url string, ArrayBuffer, or Blob to load
  104433. * @param onSuccess callback called when the file successfully loads
  104434. * @param onProgress callback called while file is loading (if the server supports this mode)
  104435. * @param offlineProvider defines the offline provider for caching
  104436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104437. * @param onError callback called when the file fails to load
  104438. * @returns a file request object
  104439. */
  104440. 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;
  104441. /**
  104442. * Loads a file from a url
  104443. * @param url the file url to load
  104444. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  104445. */
  104446. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  104447. /**
  104448. * Load a script (identified by an url). When the url returns, the
  104449. * content of this file is added into a new script element, attached to the DOM (body element)
  104450. * @param scriptUrl defines the url of the script to laod
  104451. * @param onSuccess defines the callback called when the script is loaded
  104452. * @param onError defines the callback to call if an error occurs
  104453. * @param scriptId defines the id of the script element
  104454. */
  104455. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  104456. /**
  104457. * Load an asynchronous script (identified by an url). When the url returns, the
  104458. * content of this file is added into a new script element, attached to the DOM (body element)
  104459. * @param scriptUrl defines the url of the script to laod
  104460. * @param scriptId defines the id of the script element
  104461. * @returns a promise request object
  104462. */
  104463. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  104464. /**
  104465. * Loads a file from a blob
  104466. * @param fileToLoad defines the blob to use
  104467. * @param callback defines the callback to call when data is loaded
  104468. * @param progressCallback defines the callback to call during loading process
  104469. * @returns a file request object
  104470. */
  104471. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  104472. /**
  104473. * Reads a file from a File object
  104474. * @param file defines the file to load
  104475. * @param onSuccess defines the callback to call when data is loaded
  104476. * @param onProgress defines the callback to call during loading process
  104477. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  104478. * @param onError defines the callback to call when an error occurs
  104479. * @returns a file request object
  104480. */
  104481. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  104482. /**
  104483. * Creates a data url from a given string content
  104484. * @param content defines the content to convert
  104485. * @returns the new data url link
  104486. */
  104487. static FileAsURL(content: string): string;
  104488. /**
  104489. * Format the given number to a specific decimal format
  104490. * @param value defines the number to format
  104491. * @param decimals defines the number of decimals to use
  104492. * @returns the formatted string
  104493. */
  104494. static Format(value: number, decimals?: number): string;
  104495. /**
  104496. * Tries to copy an object by duplicating every property
  104497. * @param source defines the source object
  104498. * @param destination defines the target object
  104499. * @param doNotCopyList defines a list of properties to avoid
  104500. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  104501. */
  104502. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  104503. /**
  104504. * Gets a boolean indicating if the given object has no own property
  104505. * @param obj defines the object to test
  104506. * @returns true if object has no own property
  104507. */
  104508. static IsEmpty(obj: any): boolean;
  104509. /**
  104510. * Function used to register events at window level
  104511. * @param windowElement defines the Window object to use
  104512. * @param events defines the events to register
  104513. */
  104514. static RegisterTopRootEvents(windowElement: Window, events: {
  104515. name: string;
  104516. handler: Nullable<(e: FocusEvent) => any>;
  104517. }[]): void;
  104518. /**
  104519. * Function used to unregister events from window level
  104520. * @param windowElement defines the Window object to use
  104521. * @param events defines the events to unregister
  104522. */
  104523. static UnregisterTopRootEvents(windowElement: Window, events: {
  104524. name: string;
  104525. handler: Nullable<(e: FocusEvent) => any>;
  104526. }[]): void;
  104527. /**
  104528. * @ignore
  104529. */
  104530. static _ScreenshotCanvas: HTMLCanvasElement;
  104531. /**
  104532. * Dumps the current bound framebuffer
  104533. * @param width defines the rendering width
  104534. * @param height defines the rendering height
  104535. * @param engine defines the hosting engine
  104536. * @param successCallback defines the callback triggered once the data are available
  104537. * @param mimeType defines the mime type of the result
  104538. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  104539. */
  104540. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104541. /**
  104542. * Converts the canvas data to blob.
  104543. * This acts as a polyfill for browsers not supporting the to blob function.
  104544. * @param canvas Defines the canvas to extract the data from
  104545. * @param successCallback Defines the callback triggered once the data are available
  104546. * @param mimeType Defines the mime type of the result
  104547. */
  104548. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  104549. /**
  104550. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  104551. * @param successCallback defines the callback triggered once the data are available
  104552. * @param mimeType defines the mime type of the result
  104553. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  104554. */
  104555. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104556. /**
  104557. * Downloads a blob in the browser
  104558. * @param blob defines the blob to download
  104559. * @param fileName defines the name of the downloaded file
  104560. */
  104561. static Download(blob: Blob, fileName: string): void;
  104562. /**
  104563. * Captures a screenshot of the current rendering
  104564. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104565. * @param engine defines the rendering engine
  104566. * @param camera defines the source camera
  104567. * @param size This parameter can be set to a single number or to an object with the
  104568. * following (optional) properties: precision, width, height. If a single number is passed,
  104569. * it will be used for both width and height. If an object is passed, the screenshot size
  104570. * will be derived from the parameters. The precision property is a multiplier allowing
  104571. * rendering at a higher or lower resolution
  104572. * @param successCallback defines the callback receives a single parameter which contains the
  104573. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104574. * src parameter of an <img> to display it
  104575. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104576. * Check your browser for supported MIME types
  104577. */
  104578. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  104579. /**
  104580. * Captures a screenshot of the current rendering
  104581. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104582. * @param engine defines the rendering engine
  104583. * @param camera defines the source camera
  104584. * @param size This parameter can be set to a single number or to an object with the
  104585. * following (optional) properties: precision, width, height. If a single number is passed,
  104586. * it will be used for both width and height. If an object is passed, the screenshot size
  104587. * will be derived from the parameters. The precision property is a multiplier allowing
  104588. * rendering at a higher or lower resolution
  104589. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104590. * Check your browser for supported MIME types
  104591. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104592. * to the src parameter of an <img> to display it
  104593. */
  104594. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  104595. /**
  104596. * Generates an image screenshot from the specified camera.
  104597. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104598. * @param engine The engine to use for rendering
  104599. * @param camera The camera to use for rendering
  104600. * @param size This parameter can be set to a single number or to an object with the
  104601. * following (optional) properties: precision, width, height. If a single number is passed,
  104602. * it will be used for both width and height. If an object is passed, the screenshot size
  104603. * will be derived from the parameters. The precision property is a multiplier allowing
  104604. * rendering at a higher or lower resolution
  104605. * @param successCallback The callback receives a single parameter which contains the
  104606. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104607. * src parameter of an <img> to display it
  104608. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104609. * Check your browser for supported MIME types
  104610. * @param samples Texture samples (default: 1)
  104611. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104612. * @param fileName A name for for the downloaded file.
  104613. */
  104614. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  104615. /**
  104616. * Generates an image screenshot from the specified camera.
  104617. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104618. * @param engine The engine to use for rendering
  104619. * @param camera The camera to use for rendering
  104620. * @param size This parameter can be set to a single number or to an object with the
  104621. * following (optional) properties: precision, width, height. If a single number is passed,
  104622. * it will be used for both width and height. If an object is passed, the screenshot size
  104623. * will be derived from the parameters. The precision property is a multiplier allowing
  104624. * rendering at a higher or lower resolution
  104625. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104626. * Check your browser for supported MIME types
  104627. * @param samples Texture samples (default: 1)
  104628. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104629. * @param fileName A name for for the downloaded file.
  104630. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104631. * to the src parameter of an <img> to display it
  104632. */
  104633. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  104634. /**
  104635. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104636. * Be aware Math.random() could cause collisions, but:
  104637. * "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"
  104638. * @returns a pseudo random id
  104639. */
  104640. static RandomId(): string;
  104641. /**
  104642. * Test if the given uri is a base64 string
  104643. * @param uri The uri to test
  104644. * @return True if the uri is a base64 string or false otherwise
  104645. */
  104646. static IsBase64(uri: string): boolean;
  104647. /**
  104648. * Decode the given base64 uri.
  104649. * @param uri The uri to decode
  104650. * @return The decoded base64 data.
  104651. */
  104652. static DecodeBase64(uri: string): ArrayBuffer;
  104653. /**
  104654. * Gets the absolute url.
  104655. * @param url the input url
  104656. * @return the absolute url
  104657. */
  104658. static GetAbsoluteUrl(url: string): string;
  104659. /**
  104660. * No log
  104661. */
  104662. static readonly NoneLogLevel: number;
  104663. /**
  104664. * Only message logs
  104665. */
  104666. static readonly MessageLogLevel: number;
  104667. /**
  104668. * Only warning logs
  104669. */
  104670. static readonly WarningLogLevel: number;
  104671. /**
  104672. * Only error logs
  104673. */
  104674. static readonly ErrorLogLevel: number;
  104675. /**
  104676. * All logs
  104677. */
  104678. static readonly AllLogLevel: number;
  104679. /**
  104680. * Gets a value indicating the number of loading errors
  104681. * @ignorenaming
  104682. */
  104683. static get errorsCount(): number;
  104684. /**
  104685. * Callback called when a new log is added
  104686. */
  104687. static OnNewCacheEntry: (entry: string) => void;
  104688. /**
  104689. * Log a message to the console
  104690. * @param message defines the message to log
  104691. */
  104692. static Log(message: string): void;
  104693. /**
  104694. * Write a warning message to the console
  104695. * @param message defines the message to log
  104696. */
  104697. static Warn(message: string): void;
  104698. /**
  104699. * Write an error message to the console
  104700. * @param message defines the message to log
  104701. */
  104702. static Error(message: string): void;
  104703. /**
  104704. * Gets current log cache (list of logs)
  104705. */
  104706. static get LogCache(): string;
  104707. /**
  104708. * Clears the log cache
  104709. */
  104710. static ClearLogCache(): void;
  104711. /**
  104712. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  104713. */
  104714. static set LogLevels(level: number);
  104715. /**
  104716. * Checks if the window object exists
  104717. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104718. */
  104719. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  104720. /**
  104721. * No performance log
  104722. */
  104723. static readonly PerformanceNoneLogLevel: number;
  104724. /**
  104725. * Use user marks to log performance
  104726. */
  104727. static readonly PerformanceUserMarkLogLevel: number;
  104728. /**
  104729. * Log performance to the console
  104730. */
  104731. static readonly PerformanceConsoleLogLevel: number;
  104732. private static _performance;
  104733. /**
  104734. * Sets the current performance log level
  104735. */
  104736. static set PerformanceLogLevel(level: number);
  104737. private static _StartPerformanceCounterDisabled;
  104738. private static _EndPerformanceCounterDisabled;
  104739. private static _StartUserMark;
  104740. private static _EndUserMark;
  104741. private static _StartPerformanceConsole;
  104742. private static _EndPerformanceConsole;
  104743. /**
  104744. * Starts a performance counter
  104745. */
  104746. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104747. /**
  104748. * Ends a specific performance coutner
  104749. */
  104750. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104751. /**
  104752. * Gets either window.performance.now() if supported or Date.now() else
  104753. */
  104754. static get Now(): number;
  104755. /**
  104756. * This method will return the name of the class used to create the instance of the given object.
  104757. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104758. * @param object the object to get the class name from
  104759. * @param isType defines if the object is actually a type
  104760. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104761. */
  104762. static GetClassName(object: any, isType?: boolean): string;
  104763. /**
  104764. * Gets the first element of an array satisfying a given predicate
  104765. * @param array defines the array to browse
  104766. * @param predicate defines the predicate to use
  104767. * @returns null if not found or the element
  104768. */
  104769. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  104770. /**
  104771. * This method will return the name of the full name of the class, including its owning module (if any).
  104772. * 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).
  104773. * @param object the object to get the class name from
  104774. * @param isType defines if the object is actually a type
  104775. * @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.
  104776. * @ignorenaming
  104777. */
  104778. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  104779. /**
  104780. * Returns a promise that resolves after the given amount of time.
  104781. * @param delay Number of milliseconds to delay
  104782. * @returns Promise that resolves after the given amount of time
  104783. */
  104784. static DelayAsync(delay: number): Promise<void>;
  104785. }
  104786. /**
  104787. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104788. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104789. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104790. * @param name The name of the class, case should be preserved
  104791. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104792. */
  104793. export function className(name: string, module?: string): (target: Object) => void;
  104794. /**
  104795. * An implementation of a loop for asynchronous functions.
  104796. */
  104797. export class AsyncLoop {
  104798. /**
  104799. * Defines the number of iterations for the loop
  104800. */
  104801. iterations: number;
  104802. /**
  104803. * Defines the current index of the loop.
  104804. */
  104805. index: number;
  104806. private _done;
  104807. private _fn;
  104808. private _successCallback;
  104809. /**
  104810. * Constructor.
  104811. * @param iterations the number of iterations.
  104812. * @param func the function to run each iteration
  104813. * @param successCallback the callback that will be called upon succesful execution
  104814. * @param offset starting offset.
  104815. */
  104816. constructor(
  104817. /**
  104818. * Defines the number of iterations for the loop
  104819. */
  104820. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  104821. /**
  104822. * Execute the next iteration. Must be called after the last iteration was finished.
  104823. */
  104824. executeNext(): void;
  104825. /**
  104826. * Break the loop and run the success callback.
  104827. */
  104828. breakLoop(): void;
  104829. /**
  104830. * Create and run an async loop.
  104831. * @param iterations the number of iterations.
  104832. * @param fn the function to run each iteration
  104833. * @param successCallback the callback that will be called upon succesful execution
  104834. * @param offset starting offset.
  104835. * @returns the created async loop object
  104836. */
  104837. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  104838. /**
  104839. * A for-loop that will run a given number of iterations synchronous and the rest async.
  104840. * @param iterations total number of iterations
  104841. * @param syncedIterations number of synchronous iterations in each async iteration.
  104842. * @param fn the function to call each iteration.
  104843. * @param callback a success call back that will be called when iterating stops.
  104844. * @param breakFunction a break condition (optional)
  104845. * @param timeout timeout settings for the setTimeout function. default - 0.
  104846. * @returns the created async loop object
  104847. */
  104848. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  104849. }
  104850. }
  104851. declare module BABYLON {
  104852. /**
  104853. * This class implement a typical dictionary using a string as key and the generic type T as value.
  104854. * The underlying implementation relies on an associative array to ensure the best performances.
  104855. * The value can be anything including 'null' but except 'undefined'
  104856. */
  104857. export class StringDictionary<T> {
  104858. /**
  104859. * This will clear this dictionary and copy the content from the 'source' one.
  104860. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  104861. * @param source the dictionary to take the content from and copy to this dictionary
  104862. */
  104863. copyFrom(source: StringDictionary<T>): void;
  104864. /**
  104865. * Get a value based from its key
  104866. * @param key the given key to get the matching value from
  104867. * @return the value if found, otherwise undefined is returned
  104868. */
  104869. get(key: string): T | undefined;
  104870. /**
  104871. * Get a value from its key or add it if it doesn't exist.
  104872. * This method will ensure you that a given key/data will be present in the dictionary.
  104873. * @param key the given key to get the matching value from
  104874. * @param factory the factory that will create the value if the key is not present in the dictionary.
  104875. * The factory will only be invoked if there's no data for the given key.
  104876. * @return the value corresponding to the key.
  104877. */
  104878. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  104879. /**
  104880. * Get a value from its key if present in the dictionary otherwise add it
  104881. * @param key the key to get the value from
  104882. * @param val if there's no such key/value pair in the dictionary add it with this value
  104883. * @return the value corresponding to the key
  104884. */
  104885. getOrAdd(key: string, val: T): T;
  104886. /**
  104887. * Check if there's a given key in the dictionary
  104888. * @param key the key to check for
  104889. * @return true if the key is present, false otherwise
  104890. */
  104891. contains(key: string): boolean;
  104892. /**
  104893. * Add a new key and its corresponding value
  104894. * @param key the key to add
  104895. * @param value the value corresponding to the key
  104896. * @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
  104897. */
  104898. add(key: string, value: T): boolean;
  104899. /**
  104900. * Update a specific value associated to a key
  104901. * @param key defines the key to use
  104902. * @param value defines the value to store
  104903. * @returns true if the value was updated (or false if the key was not found)
  104904. */
  104905. set(key: string, value: T): boolean;
  104906. /**
  104907. * Get the element of the given key and remove it from the dictionary
  104908. * @param key defines the key to search
  104909. * @returns the value associated with the key or null if not found
  104910. */
  104911. getAndRemove(key: string): Nullable<T>;
  104912. /**
  104913. * Remove a key/value from the dictionary.
  104914. * @param key the key to remove
  104915. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  104916. */
  104917. remove(key: string): boolean;
  104918. /**
  104919. * Clear the whole content of the dictionary
  104920. */
  104921. clear(): void;
  104922. /**
  104923. * Gets the current count
  104924. */
  104925. get count(): number;
  104926. /**
  104927. * Execute a callback on each key/val of the dictionary.
  104928. * Note that you can remove any element in this dictionary in the callback implementation
  104929. * @param callback the callback to execute on a given key/value pair
  104930. */
  104931. forEach(callback: (key: string, val: T) => void): void;
  104932. /**
  104933. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  104934. * If the callback returns null or undefined the method will iterate to the next key/value pair
  104935. * Note that you can remove any element in this dictionary in the callback implementation
  104936. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  104937. * @returns the first item
  104938. */
  104939. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  104940. private _count;
  104941. private _data;
  104942. }
  104943. }
  104944. declare module BABYLON {
  104945. /** @hidden */
  104946. export interface ICollisionCoordinator {
  104947. createCollider(): Collider;
  104948. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  104949. init(scene: Scene): void;
  104950. }
  104951. /** @hidden */
  104952. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  104953. private _scene;
  104954. private _scaledPosition;
  104955. private _scaledVelocity;
  104956. private _finalPosition;
  104957. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  104958. createCollider(): Collider;
  104959. init(scene: Scene): void;
  104960. private _collideWithWorld;
  104961. }
  104962. }
  104963. declare module BABYLON {
  104964. /**
  104965. * Class used to manage all inputs for the scene.
  104966. */
  104967. export class InputManager {
  104968. /** The distance in pixel that you have to move to prevent some events */
  104969. static DragMovementThreshold: number;
  104970. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  104971. static LongPressDelay: number;
  104972. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  104973. static DoubleClickDelay: number;
  104974. /** If you need to check double click without raising a single click at first click, enable this flag */
  104975. static ExclusiveDoubleClickMode: boolean;
  104976. private _wheelEventName;
  104977. private _onPointerMove;
  104978. private _onPointerDown;
  104979. private _onPointerUp;
  104980. private _initClickEvent;
  104981. private _initActionManager;
  104982. private _delayedSimpleClick;
  104983. private _delayedSimpleClickTimeout;
  104984. private _previousDelayedSimpleClickTimeout;
  104985. private _meshPickProceed;
  104986. private _previousButtonPressed;
  104987. private _currentPickResult;
  104988. private _previousPickResult;
  104989. private _totalPointersPressed;
  104990. private _doubleClickOccured;
  104991. private _pointerOverMesh;
  104992. private _pickedDownMesh;
  104993. private _pickedUpMesh;
  104994. private _pointerX;
  104995. private _pointerY;
  104996. private _unTranslatedPointerX;
  104997. private _unTranslatedPointerY;
  104998. private _startingPointerPosition;
  104999. private _previousStartingPointerPosition;
  105000. private _startingPointerTime;
  105001. private _previousStartingPointerTime;
  105002. private _pointerCaptures;
  105003. private _onKeyDown;
  105004. private _onKeyUp;
  105005. private _onCanvasFocusObserver;
  105006. private _onCanvasBlurObserver;
  105007. private _scene;
  105008. /**
  105009. * Creates a new InputManager
  105010. * @param scene defines the hosting scene
  105011. */
  105012. constructor(scene: Scene);
  105013. /**
  105014. * Gets the mesh that is currently under the pointer
  105015. */
  105016. get meshUnderPointer(): Nullable<AbstractMesh>;
  105017. /**
  105018. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105019. */
  105020. get unTranslatedPointer(): Vector2;
  105021. /**
  105022. * Gets or sets the current on-screen X position of the pointer
  105023. */
  105024. get pointerX(): number;
  105025. set pointerX(value: number);
  105026. /**
  105027. * Gets or sets the current on-screen Y position of the pointer
  105028. */
  105029. get pointerY(): number;
  105030. set pointerY(value: number);
  105031. private _updatePointerPosition;
  105032. private _processPointerMove;
  105033. private _setRayOnPointerInfo;
  105034. private _checkPrePointerObservable;
  105035. /**
  105036. * Use this method to simulate a pointer move on a mesh
  105037. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105038. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105039. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105040. */
  105041. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105042. /**
  105043. * Use this method to simulate a pointer down on a mesh
  105044. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105045. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105046. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105047. */
  105048. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105049. private _processPointerDown;
  105050. /** @hidden */
  105051. _isPointerSwiping(): boolean;
  105052. /**
  105053. * Use this method to simulate a pointer up on a mesh
  105054. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105055. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105056. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105057. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105058. */
  105059. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105060. private _processPointerUp;
  105061. /**
  105062. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105063. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105064. * @returns true if the pointer was captured
  105065. */
  105066. isPointerCaptured(pointerId?: number): boolean;
  105067. /**
  105068. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105069. * @param attachUp defines if you want to attach events to pointerup
  105070. * @param attachDown defines if you want to attach events to pointerdown
  105071. * @param attachMove defines if you want to attach events to pointermove
  105072. */
  105073. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105074. /**
  105075. * Detaches all event handlers
  105076. */
  105077. detachControl(): void;
  105078. /**
  105079. * Force the value of meshUnderPointer
  105080. * @param mesh defines the mesh to use
  105081. */
  105082. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105083. /**
  105084. * Gets the mesh under the pointer
  105085. * @returns a Mesh or null if no mesh is under the pointer
  105086. */
  105087. getPointerOverMesh(): Nullable<AbstractMesh>;
  105088. }
  105089. }
  105090. declare module BABYLON {
  105091. /**
  105092. * Helper class used to generate session unique ID
  105093. */
  105094. export class UniqueIdGenerator {
  105095. private static _UniqueIdCounter;
  105096. /**
  105097. * Gets an unique (relatively to the current scene) Id
  105098. */
  105099. static get UniqueId(): number;
  105100. }
  105101. }
  105102. declare module BABYLON {
  105103. /**
  105104. * This class defines the direct association between an animation and a target
  105105. */
  105106. export class TargetedAnimation {
  105107. /**
  105108. * Animation to perform
  105109. */
  105110. animation: Animation;
  105111. /**
  105112. * Target to animate
  105113. */
  105114. target: any;
  105115. /**
  105116. * Serialize the object
  105117. * @returns the JSON object representing the current entity
  105118. */
  105119. serialize(): any;
  105120. }
  105121. /**
  105122. * Use this class to create coordinated animations on multiple targets
  105123. */
  105124. export class AnimationGroup implements IDisposable {
  105125. /** The name of the animation group */
  105126. name: string;
  105127. private _scene;
  105128. private _targetedAnimations;
  105129. private _animatables;
  105130. private _from;
  105131. private _to;
  105132. private _isStarted;
  105133. private _isPaused;
  105134. private _speedRatio;
  105135. private _loopAnimation;
  105136. /**
  105137. * Gets or sets the unique id of the node
  105138. */
  105139. uniqueId: number;
  105140. /**
  105141. * This observable will notify when one animation have ended
  105142. */
  105143. onAnimationEndObservable: Observable<TargetedAnimation>;
  105144. /**
  105145. * Observer raised when one animation loops
  105146. */
  105147. onAnimationLoopObservable: Observable<TargetedAnimation>;
  105148. /**
  105149. * Observer raised when all animations have looped
  105150. */
  105151. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  105152. /**
  105153. * This observable will notify when all animations have ended.
  105154. */
  105155. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  105156. /**
  105157. * This observable will notify when all animations have paused.
  105158. */
  105159. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  105160. /**
  105161. * This observable will notify when all animations are playing.
  105162. */
  105163. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  105164. /**
  105165. * Gets the first frame
  105166. */
  105167. get from(): number;
  105168. /**
  105169. * Gets the last frame
  105170. */
  105171. get to(): number;
  105172. /**
  105173. * Define if the animations are started
  105174. */
  105175. get isStarted(): boolean;
  105176. /**
  105177. * Gets a value indicating that the current group is playing
  105178. */
  105179. get isPlaying(): boolean;
  105180. /**
  105181. * Gets or sets the speed ratio to use for all animations
  105182. */
  105183. get speedRatio(): number;
  105184. /**
  105185. * Gets or sets the speed ratio to use for all animations
  105186. */
  105187. set speedRatio(value: number);
  105188. /**
  105189. * Gets or sets if all animations should loop or not
  105190. */
  105191. get loopAnimation(): boolean;
  105192. set loopAnimation(value: boolean);
  105193. /**
  105194. * Gets the targeted animations for this animation group
  105195. */
  105196. get targetedAnimations(): Array<TargetedAnimation>;
  105197. /**
  105198. * returning the list of animatables controlled by this animation group.
  105199. */
  105200. get animatables(): Array<Animatable>;
  105201. /**
  105202. * Instantiates a new Animation Group.
  105203. * This helps managing several animations at once.
  105204. * @see http://doc.babylonjs.com/how_to/group
  105205. * @param name Defines the name of the group
  105206. * @param scene Defines the scene the group belongs to
  105207. */
  105208. constructor(
  105209. /** The name of the animation group */
  105210. name: string, scene?: Nullable<Scene>);
  105211. /**
  105212. * Add an animation (with its target) in the group
  105213. * @param animation defines the animation we want to add
  105214. * @param target defines the target of the animation
  105215. * @returns the TargetedAnimation object
  105216. */
  105217. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  105218. /**
  105219. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  105220. * It can add constant keys at begin or end
  105221. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  105222. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  105223. * @returns the animation group
  105224. */
  105225. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  105226. private _animationLoopCount;
  105227. private _animationLoopFlags;
  105228. private _processLoop;
  105229. /**
  105230. * Start all animations on given targets
  105231. * @param loop defines if animations must loop
  105232. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  105233. * @param from defines the from key (optional)
  105234. * @param to defines the to key (optional)
  105235. * @returns the current animation group
  105236. */
  105237. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  105238. /**
  105239. * Pause all animations
  105240. * @returns the animation group
  105241. */
  105242. pause(): AnimationGroup;
  105243. /**
  105244. * Play all animations to initial state
  105245. * This function will start() the animations if they were not started or will restart() them if they were paused
  105246. * @param loop defines if animations must loop
  105247. * @returns the animation group
  105248. */
  105249. play(loop?: boolean): AnimationGroup;
  105250. /**
  105251. * Reset all animations to initial state
  105252. * @returns the animation group
  105253. */
  105254. reset(): AnimationGroup;
  105255. /**
  105256. * Restart animations from key 0
  105257. * @returns the animation group
  105258. */
  105259. restart(): AnimationGroup;
  105260. /**
  105261. * Stop all animations
  105262. * @returns the animation group
  105263. */
  105264. stop(): AnimationGroup;
  105265. /**
  105266. * Set animation weight for all animatables
  105267. * @param weight defines the weight to use
  105268. * @return the animationGroup
  105269. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105270. */
  105271. setWeightForAllAnimatables(weight: number): AnimationGroup;
  105272. /**
  105273. * Synchronize and normalize all animatables with a source animatable
  105274. * @param root defines the root animatable to synchronize with
  105275. * @return the animationGroup
  105276. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105277. */
  105278. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  105279. /**
  105280. * Goes to a specific frame in this animation group
  105281. * @param frame the frame number to go to
  105282. * @return the animationGroup
  105283. */
  105284. goToFrame(frame: number): AnimationGroup;
  105285. /**
  105286. * Dispose all associated resources
  105287. */
  105288. dispose(): void;
  105289. private _checkAnimationGroupEnded;
  105290. /**
  105291. * Clone the current animation group and returns a copy
  105292. * @param newName defines the name of the new group
  105293. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  105294. * @returns the new aniamtion group
  105295. */
  105296. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  105297. /**
  105298. * Serializes the animationGroup to an object
  105299. * @returns Serialized object
  105300. */
  105301. serialize(): any;
  105302. /**
  105303. * Returns a new AnimationGroup object parsed from the source provided.
  105304. * @param parsedAnimationGroup defines the source
  105305. * @param scene defines the scene that will receive the animationGroup
  105306. * @returns a new AnimationGroup
  105307. */
  105308. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  105309. /**
  105310. * Returns the string "AnimationGroup"
  105311. * @returns "AnimationGroup"
  105312. */
  105313. getClassName(): string;
  105314. /**
  105315. * Creates a detailled string about the object
  105316. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  105317. * @returns a string representing the object
  105318. */
  105319. toString(fullDetails?: boolean): string;
  105320. }
  105321. }
  105322. declare module BABYLON {
  105323. /**
  105324. * Define an interface for all classes that will hold resources
  105325. */
  105326. export interface IDisposable {
  105327. /**
  105328. * Releases all held resources
  105329. */
  105330. dispose(): void;
  105331. }
  105332. /** Interface defining initialization parameters for Scene class */
  105333. export interface SceneOptions {
  105334. /**
  105335. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  105336. * It will improve performance when the number of geometries becomes important.
  105337. */
  105338. useGeometryUniqueIdsMap?: boolean;
  105339. /**
  105340. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  105341. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105342. */
  105343. useMaterialMeshMap?: boolean;
  105344. /**
  105345. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  105346. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105347. */
  105348. useClonedMeshhMap?: boolean;
  105349. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  105350. virtual?: boolean;
  105351. }
  105352. /**
  105353. * Represents a scene to be rendered by the engine.
  105354. * @see http://doc.babylonjs.com/features/scene
  105355. */
  105356. export class Scene extends AbstractScene implements IAnimatable {
  105357. /** The fog is deactivated */
  105358. static readonly FOGMODE_NONE: number;
  105359. /** The fog density is following an exponential function */
  105360. static readonly FOGMODE_EXP: number;
  105361. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  105362. static readonly FOGMODE_EXP2: number;
  105363. /** The fog density is following a linear function. */
  105364. static readonly FOGMODE_LINEAR: number;
  105365. /**
  105366. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  105367. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105368. */
  105369. static MinDeltaTime: number;
  105370. /**
  105371. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  105372. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105373. */
  105374. static MaxDeltaTime: number;
  105375. /**
  105376. * Factory used to create the default material.
  105377. * @param name The name of the material to create
  105378. * @param scene The scene to create the material for
  105379. * @returns The default material
  105380. */
  105381. static DefaultMaterialFactory(scene: Scene): Material;
  105382. /**
  105383. * Factory used to create the a collision coordinator.
  105384. * @returns The collision coordinator
  105385. */
  105386. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  105387. /** @hidden */
  105388. _inputManager: InputManager;
  105389. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  105390. cameraToUseForPointers: Nullable<Camera>;
  105391. /** @hidden */
  105392. readonly _isScene: boolean;
  105393. /**
  105394. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  105395. */
  105396. autoClear: boolean;
  105397. /**
  105398. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  105399. */
  105400. autoClearDepthAndStencil: boolean;
  105401. /**
  105402. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  105403. */
  105404. clearColor: Color4;
  105405. /**
  105406. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  105407. */
  105408. ambientColor: Color3;
  105409. /**
  105410. * This is use to store the default BRDF lookup for PBR materials in your scene.
  105411. * It should only be one of the following (if not the default embedded one):
  105412. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105413. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  105414. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105415. * The material properties need to be setup according to the type of texture in use.
  105416. */
  105417. environmentBRDFTexture: BaseTexture;
  105418. /** @hidden */
  105419. protected _environmentTexture: Nullable<BaseTexture>;
  105420. /**
  105421. * Texture used in all pbr material as the reflection texture.
  105422. * As in the majority of the scene they are the same (exception for multi room and so on),
  105423. * this is easier to reference from here than from all the materials.
  105424. */
  105425. get environmentTexture(): Nullable<BaseTexture>;
  105426. /**
  105427. * Texture used in all pbr material as the reflection texture.
  105428. * As in the majority of the scene they are the same (exception for multi room and so on),
  105429. * this is easier to set here than in all the materials.
  105430. */
  105431. set environmentTexture(value: Nullable<BaseTexture>);
  105432. /** @hidden */
  105433. protected _environmentIntensity: number;
  105434. /**
  105435. * Intensity of the environment in all pbr material.
  105436. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105437. * As in the majority of the scene they are the same (exception for multi room and so on),
  105438. * this is easier to reference from here than from all the materials.
  105439. */
  105440. get environmentIntensity(): number;
  105441. /**
  105442. * Intensity of the environment in all pbr material.
  105443. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105444. * As in the majority of the scene they are the same (exception for multi room and so on),
  105445. * this is easier to set here than in all the materials.
  105446. */
  105447. set environmentIntensity(value: number);
  105448. /** @hidden */
  105449. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105450. /**
  105451. * Default image processing configuration used either in the rendering
  105452. * Forward main pass or through the imageProcessingPostProcess if present.
  105453. * As in the majority of the scene they are the same (exception for multi camera),
  105454. * this is easier to reference from here than from all the materials and post process.
  105455. *
  105456. * No setter as we it is a shared configuration, you can set the values instead.
  105457. */
  105458. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105459. private _forceWireframe;
  105460. /**
  105461. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  105462. */
  105463. set forceWireframe(value: boolean);
  105464. get forceWireframe(): boolean;
  105465. private _forcePointsCloud;
  105466. /**
  105467. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  105468. */
  105469. set forcePointsCloud(value: boolean);
  105470. get forcePointsCloud(): boolean;
  105471. /**
  105472. * Gets or sets the active clipplane 1
  105473. */
  105474. clipPlane: Nullable<Plane>;
  105475. /**
  105476. * Gets or sets the active clipplane 2
  105477. */
  105478. clipPlane2: Nullable<Plane>;
  105479. /**
  105480. * Gets or sets the active clipplane 3
  105481. */
  105482. clipPlane3: Nullable<Plane>;
  105483. /**
  105484. * Gets or sets the active clipplane 4
  105485. */
  105486. clipPlane4: Nullable<Plane>;
  105487. /**
  105488. * Gets or sets a boolean indicating if animations are enabled
  105489. */
  105490. animationsEnabled: boolean;
  105491. private _animationPropertiesOverride;
  105492. /**
  105493. * Gets or sets the animation properties override
  105494. */
  105495. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105496. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105497. /**
  105498. * Gets or sets a boolean indicating if a constant deltatime has to be used
  105499. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  105500. */
  105501. useConstantAnimationDeltaTime: boolean;
  105502. /**
  105503. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  105504. * Please note that it requires to run a ray cast through the scene on every frame
  105505. */
  105506. constantlyUpdateMeshUnderPointer: boolean;
  105507. /**
  105508. * Defines the HTML cursor to use when hovering over interactive elements
  105509. */
  105510. hoverCursor: string;
  105511. /**
  105512. * Defines the HTML default cursor to use (empty by default)
  105513. */
  105514. defaultCursor: string;
  105515. /**
  105516. * Defines wether cursors are handled by the scene.
  105517. */
  105518. doNotHandleCursors: boolean;
  105519. /**
  105520. * This is used to call preventDefault() on pointer down
  105521. * in order to block unwanted artifacts like system double clicks
  105522. */
  105523. preventDefaultOnPointerDown: boolean;
  105524. /**
  105525. * This is used to call preventDefault() on pointer up
  105526. * in order to block unwanted artifacts like system double clicks
  105527. */
  105528. preventDefaultOnPointerUp: boolean;
  105529. /**
  105530. * Gets or sets user defined metadata
  105531. */
  105532. metadata: any;
  105533. /**
  105534. * For internal use only. Please do not use.
  105535. */
  105536. reservedDataStore: any;
  105537. /**
  105538. * Gets the name of the plugin used to load this scene (null by default)
  105539. */
  105540. loadingPluginName: string;
  105541. /**
  105542. * Use this array to add regular expressions used to disable offline support for specific urls
  105543. */
  105544. disableOfflineSupportExceptionRules: RegExp[];
  105545. /**
  105546. * An event triggered when the scene is disposed.
  105547. */
  105548. onDisposeObservable: Observable<Scene>;
  105549. private _onDisposeObserver;
  105550. /** Sets a function to be executed when this scene is disposed. */
  105551. set onDispose(callback: () => void);
  105552. /**
  105553. * An event triggered before rendering the scene (right after animations and physics)
  105554. */
  105555. onBeforeRenderObservable: Observable<Scene>;
  105556. private _onBeforeRenderObserver;
  105557. /** Sets a function to be executed before rendering this scene */
  105558. set beforeRender(callback: Nullable<() => void>);
  105559. /**
  105560. * An event triggered after rendering the scene
  105561. */
  105562. onAfterRenderObservable: Observable<Scene>;
  105563. /**
  105564. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  105565. */
  105566. onAfterRenderCameraObservable: Observable<Camera>;
  105567. private _onAfterRenderObserver;
  105568. /** Sets a function to be executed after rendering this scene */
  105569. set afterRender(callback: Nullable<() => void>);
  105570. /**
  105571. * An event triggered before animating the scene
  105572. */
  105573. onBeforeAnimationsObservable: Observable<Scene>;
  105574. /**
  105575. * An event triggered after animations processing
  105576. */
  105577. onAfterAnimationsObservable: Observable<Scene>;
  105578. /**
  105579. * An event triggered before draw calls are ready to be sent
  105580. */
  105581. onBeforeDrawPhaseObservable: Observable<Scene>;
  105582. /**
  105583. * An event triggered after draw calls have been sent
  105584. */
  105585. onAfterDrawPhaseObservable: Observable<Scene>;
  105586. /**
  105587. * An event triggered when the scene is ready
  105588. */
  105589. onReadyObservable: Observable<Scene>;
  105590. /**
  105591. * An event triggered before rendering a camera
  105592. */
  105593. onBeforeCameraRenderObservable: Observable<Camera>;
  105594. private _onBeforeCameraRenderObserver;
  105595. /** Sets a function to be executed before rendering a camera*/
  105596. set beforeCameraRender(callback: () => void);
  105597. /**
  105598. * An event triggered after rendering a camera
  105599. */
  105600. onAfterCameraRenderObservable: Observable<Camera>;
  105601. private _onAfterCameraRenderObserver;
  105602. /** Sets a function to be executed after rendering a camera*/
  105603. set afterCameraRender(callback: () => void);
  105604. /**
  105605. * An event triggered when active meshes evaluation is about to start
  105606. */
  105607. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  105608. /**
  105609. * An event triggered when active meshes evaluation is done
  105610. */
  105611. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  105612. /**
  105613. * An event triggered when particles rendering is about to start
  105614. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105615. */
  105616. onBeforeParticlesRenderingObservable: Observable<Scene>;
  105617. /**
  105618. * An event triggered when particles rendering is done
  105619. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105620. */
  105621. onAfterParticlesRenderingObservable: Observable<Scene>;
  105622. /**
  105623. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  105624. */
  105625. onDataLoadedObservable: Observable<Scene>;
  105626. /**
  105627. * An event triggered when a camera is created
  105628. */
  105629. onNewCameraAddedObservable: Observable<Camera>;
  105630. /**
  105631. * An event triggered when a camera is removed
  105632. */
  105633. onCameraRemovedObservable: Observable<Camera>;
  105634. /**
  105635. * An event triggered when a light is created
  105636. */
  105637. onNewLightAddedObservable: Observable<Light>;
  105638. /**
  105639. * An event triggered when a light is removed
  105640. */
  105641. onLightRemovedObservable: Observable<Light>;
  105642. /**
  105643. * An event triggered when a geometry is created
  105644. */
  105645. onNewGeometryAddedObservable: Observable<Geometry>;
  105646. /**
  105647. * An event triggered when a geometry is removed
  105648. */
  105649. onGeometryRemovedObservable: Observable<Geometry>;
  105650. /**
  105651. * An event triggered when a transform node is created
  105652. */
  105653. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  105654. /**
  105655. * An event triggered when a transform node is removed
  105656. */
  105657. onTransformNodeRemovedObservable: Observable<TransformNode>;
  105658. /**
  105659. * An event triggered when a mesh is created
  105660. */
  105661. onNewMeshAddedObservable: Observable<AbstractMesh>;
  105662. /**
  105663. * An event triggered when a mesh is removed
  105664. */
  105665. onMeshRemovedObservable: Observable<AbstractMesh>;
  105666. /**
  105667. * An event triggered when a skeleton is created
  105668. */
  105669. onNewSkeletonAddedObservable: Observable<Skeleton>;
  105670. /**
  105671. * An event triggered when a skeleton is removed
  105672. */
  105673. onSkeletonRemovedObservable: Observable<Skeleton>;
  105674. /**
  105675. * An event triggered when a material is created
  105676. */
  105677. onNewMaterialAddedObservable: Observable<Material>;
  105678. /**
  105679. * An event triggered when a material is removed
  105680. */
  105681. onMaterialRemovedObservable: Observable<Material>;
  105682. /**
  105683. * An event triggered when a texture is created
  105684. */
  105685. onNewTextureAddedObservable: Observable<BaseTexture>;
  105686. /**
  105687. * An event triggered when a texture is removed
  105688. */
  105689. onTextureRemovedObservable: Observable<BaseTexture>;
  105690. /**
  105691. * An event triggered when render targets are about to be rendered
  105692. * Can happen multiple times per frame.
  105693. */
  105694. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  105695. /**
  105696. * An event triggered when render targets were rendered.
  105697. * Can happen multiple times per frame.
  105698. */
  105699. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  105700. /**
  105701. * An event triggered before calculating deterministic simulation step
  105702. */
  105703. onBeforeStepObservable: Observable<Scene>;
  105704. /**
  105705. * An event triggered after calculating deterministic simulation step
  105706. */
  105707. onAfterStepObservable: Observable<Scene>;
  105708. /**
  105709. * An event triggered when the activeCamera property is updated
  105710. */
  105711. onActiveCameraChanged: Observable<Scene>;
  105712. /**
  105713. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  105714. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105715. * 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)
  105716. */
  105717. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105718. /**
  105719. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  105720. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105721. * 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)
  105722. */
  105723. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105724. /**
  105725. * This Observable will when a mesh has been imported into the scene.
  105726. */
  105727. onMeshImportedObservable: Observable<AbstractMesh>;
  105728. /**
  105729. * This Observable will when an animation file has been imported into the scene.
  105730. */
  105731. onAnimationFileImportedObservable: Observable<Scene>;
  105732. /**
  105733. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  105734. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  105735. */
  105736. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  105737. /** @hidden */
  105738. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  105739. /**
  105740. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  105741. */
  105742. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  105743. /**
  105744. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  105745. */
  105746. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  105747. /**
  105748. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  105749. */
  105750. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  105751. /** Callback called when a pointer move is detected */
  105752. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105753. /** Callback called when a pointer down is detected */
  105754. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105755. /** Callback called when a pointer up is detected */
  105756. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  105757. /** Callback called when a pointer pick is detected */
  105758. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  105759. /**
  105760. * 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).
  105761. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  105762. */
  105763. onPrePointerObservable: Observable<PointerInfoPre>;
  105764. /**
  105765. * Observable event triggered each time an input event is received from the rendering canvas
  105766. */
  105767. onPointerObservable: Observable<PointerInfo>;
  105768. /**
  105769. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  105770. */
  105771. get unTranslatedPointer(): Vector2;
  105772. /**
  105773. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  105774. */
  105775. static get DragMovementThreshold(): number;
  105776. static set DragMovementThreshold(value: number);
  105777. /**
  105778. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  105779. */
  105780. static get LongPressDelay(): number;
  105781. static set LongPressDelay(value: number);
  105782. /**
  105783. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  105784. */
  105785. static get DoubleClickDelay(): number;
  105786. static set DoubleClickDelay(value: number);
  105787. /** If you need to check double click without raising a single click at first click, enable this flag */
  105788. static get ExclusiveDoubleClickMode(): boolean;
  105789. static set ExclusiveDoubleClickMode(value: boolean);
  105790. /** @hidden */
  105791. _mirroredCameraPosition: Nullable<Vector3>;
  105792. /**
  105793. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  105794. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  105795. */
  105796. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  105797. /**
  105798. * Observable event triggered each time an keyboard event is received from the hosting window
  105799. */
  105800. onKeyboardObservable: Observable<KeyboardInfo>;
  105801. private _useRightHandedSystem;
  105802. /**
  105803. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  105804. */
  105805. set useRightHandedSystem(value: boolean);
  105806. get useRightHandedSystem(): boolean;
  105807. private _timeAccumulator;
  105808. private _currentStepId;
  105809. private _currentInternalStep;
  105810. /**
  105811. * Sets the step Id used by deterministic lock step
  105812. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105813. * @param newStepId defines the step Id
  105814. */
  105815. setStepId(newStepId: number): void;
  105816. /**
  105817. * Gets the step Id used by deterministic lock step
  105818. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105819. * @returns the step Id
  105820. */
  105821. getStepId(): number;
  105822. /**
  105823. * Gets the internal step used by deterministic lock step
  105824. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105825. * @returns the internal step
  105826. */
  105827. getInternalStep(): number;
  105828. private _fogEnabled;
  105829. /**
  105830. * Gets or sets a boolean indicating if fog is enabled on this scene
  105831. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105832. * (Default is true)
  105833. */
  105834. set fogEnabled(value: boolean);
  105835. get fogEnabled(): boolean;
  105836. private _fogMode;
  105837. /**
  105838. * Gets or sets the fog mode to use
  105839. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105840. * | mode | value |
  105841. * | --- | --- |
  105842. * | FOGMODE_NONE | 0 |
  105843. * | FOGMODE_EXP | 1 |
  105844. * | FOGMODE_EXP2 | 2 |
  105845. * | FOGMODE_LINEAR | 3 |
  105846. */
  105847. set fogMode(value: number);
  105848. get fogMode(): number;
  105849. /**
  105850. * Gets or sets the fog color to use
  105851. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105852. * (Default is Color3(0.2, 0.2, 0.3))
  105853. */
  105854. fogColor: Color3;
  105855. /**
  105856. * Gets or sets the fog density to use
  105857. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105858. * (Default is 0.1)
  105859. */
  105860. fogDensity: number;
  105861. /**
  105862. * Gets or sets the fog start distance to use
  105863. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105864. * (Default is 0)
  105865. */
  105866. fogStart: number;
  105867. /**
  105868. * Gets or sets the fog end distance to use
  105869. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105870. * (Default is 1000)
  105871. */
  105872. fogEnd: number;
  105873. private _shadowsEnabled;
  105874. /**
  105875. * Gets or sets a boolean indicating if shadows are enabled on this scene
  105876. */
  105877. set shadowsEnabled(value: boolean);
  105878. get shadowsEnabled(): boolean;
  105879. private _lightsEnabled;
  105880. /**
  105881. * Gets or sets a boolean indicating if lights are enabled on this scene
  105882. */
  105883. set lightsEnabled(value: boolean);
  105884. get lightsEnabled(): boolean;
  105885. /** All of the active cameras added to this scene. */
  105886. activeCameras: Camera[];
  105887. /** @hidden */
  105888. _activeCamera: Nullable<Camera>;
  105889. /** Gets or sets the current active camera */
  105890. get activeCamera(): Nullable<Camera>;
  105891. set activeCamera(value: Nullable<Camera>);
  105892. private _defaultMaterial;
  105893. /** The default material used on meshes when no material is affected */
  105894. get defaultMaterial(): Material;
  105895. /** The default material used on meshes when no material is affected */
  105896. set defaultMaterial(value: Material);
  105897. private _texturesEnabled;
  105898. /**
  105899. * Gets or sets a boolean indicating if textures are enabled on this scene
  105900. */
  105901. set texturesEnabled(value: boolean);
  105902. get texturesEnabled(): boolean;
  105903. /**
  105904. * Gets or sets a boolean indicating if particles are enabled on this scene
  105905. */
  105906. particlesEnabled: boolean;
  105907. /**
  105908. * Gets or sets a boolean indicating if sprites are enabled on this scene
  105909. */
  105910. spritesEnabled: boolean;
  105911. private _skeletonsEnabled;
  105912. /**
  105913. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  105914. */
  105915. set skeletonsEnabled(value: boolean);
  105916. get skeletonsEnabled(): boolean;
  105917. /**
  105918. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  105919. */
  105920. lensFlaresEnabled: boolean;
  105921. /**
  105922. * Gets or sets a boolean indicating if collisions are enabled on this scene
  105923. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105924. */
  105925. collisionsEnabled: boolean;
  105926. private _collisionCoordinator;
  105927. /** @hidden */
  105928. get collisionCoordinator(): ICollisionCoordinator;
  105929. /**
  105930. * Defines the gravity applied to this scene (used only for collisions)
  105931. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105932. */
  105933. gravity: Vector3;
  105934. /**
  105935. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  105936. */
  105937. postProcessesEnabled: boolean;
  105938. /**
  105939. * The list of postprocesses added to the scene
  105940. */
  105941. postProcesses: PostProcess[];
  105942. /**
  105943. * Gets the current postprocess manager
  105944. */
  105945. postProcessManager: PostProcessManager;
  105946. /**
  105947. * Gets or sets a boolean indicating if render targets are enabled on this scene
  105948. */
  105949. renderTargetsEnabled: boolean;
  105950. /**
  105951. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  105952. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  105953. */
  105954. dumpNextRenderTargets: boolean;
  105955. /**
  105956. * The list of user defined render targets added to the scene
  105957. */
  105958. customRenderTargets: RenderTargetTexture[];
  105959. /**
  105960. * Defines if texture loading must be delayed
  105961. * If true, textures will only be loaded when they need to be rendered
  105962. */
  105963. useDelayedTextureLoading: boolean;
  105964. /**
  105965. * Gets the list of meshes imported to the scene through SceneLoader
  105966. */
  105967. importedMeshesFiles: String[];
  105968. /**
  105969. * Gets or sets a boolean indicating if probes are enabled on this scene
  105970. */
  105971. probesEnabled: boolean;
  105972. /**
  105973. * Gets or sets the current offline provider to use to store scene data
  105974. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  105975. */
  105976. offlineProvider: IOfflineProvider;
  105977. /**
  105978. * Gets or sets the action manager associated with the scene
  105979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105980. */
  105981. actionManager: AbstractActionManager;
  105982. private _meshesForIntersections;
  105983. /**
  105984. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  105985. */
  105986. proceduralTexturesEnabled: boolean;
  105987. private _engine;
  105988. private _totalVertices;
  105989. /** @hidden */
  105990. _activeIndices: PerfCounter;
  105991. /** @hidden */
  105992. _activeParticles: PerfCounter;
  105993. /** @hidden */
  105994. _activeBones: PerfCounter;
  105995. private _animationRatio;
  105996. /** @hidden */
  105997. _animationTimeLast: number;
  105998. /** @hidden */
  105999. _animationTime: number;
  106000. /**
  106001. * Gets or sets a general scale for animation speed
  106002. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106003. */
  106004. animationTimeScale: number;
  106005. /** @hidden */
  106006. _cachedMaterial: Nullable<Material>;
  106007. /** @hidden */
  106008. _cachedEffect: Nullable<Effect>;
  106009. /** @hidden */
  106010. _cachedVisibility: Nullable<number>;
  106011. private _renderId;
  106012. private _frameId;
  106013. private _executeWhenReadyTimeoutId;
  106014. private _intermediateRendering;
  106015. private _viewUpdateFlag;
  106016. private _projectionUpdateFlag;
  106017. /** @hidden */
  106018. _toBeDisposed: Nullable<IDisposable>[];
  106019. private _activeRequests;
  106020. /** @hidden */
  106021. _pendingData: any[];
  106022. private _isDisposed;
  106023. /**
  106024. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106025. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106026. */
  106027. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106028. private _activeMeshes;
  106029. private _processedMaterials;
  106030. private _renderTargets;
  106031. /** @hidden */
  106032. _activeParticleSystems: SmartArray<IParticleSystem>;
  106033. private _activeSkeletons;
  106034. private _softwareSkinnedMeshes;
  106035. private _renderingManager;
  106036. /** @hidden */
  106037. _activeAnimatables: Animatable[];
  106038. private _transformMatrix;
  106039. private _sceneUbo;
  106040. /** @hidden */
  106041. _viewMatrix: Matrix;
  106042. private _projectionMatrix;
  106043. /** @hidden */
  106044. _forcedViewPosition: Nullable<Vector3>;
  106045. /** @hidden */
  106046. _frustumPlanes: Plane[];
  106047. /**
  106048. * Gets the list of frustum planes (built from the active camera)
  106049. */
  106050. get frustumPlanes(): Plane[];
  106051. /**
  106052. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106053. * This is useful if there are more lights that the maximum simulteanous authorized
  106054. */
  106055. requireLightSorting: boolean;
  106056. /** @hidden */
  106057. readonly useMaterialMeshMap: boolean;
  106058. /** @hidden */
  106059. readonly useClonedMeshhMap: boolean;
  106060. private _externalData;
  106061. private _uid;
  106062. /**
  106063. * @hidden
  106064. * Backing store of defined scene components.
  106065. */
  106066. _components: ISceneComponent[];
  106067. /**
  106068. * @hidden
  106069. * Backing store of defined scene components.
  106070. */
  106071. _serializableComponents: ISceneSerializableComponent[];
  106072. /**
  106073. * List of components to register on the next registration step.
  106074. */
  106075. private _transientComponents;
  106076. /**
  106077. * Registers the transient components if needed.
  106078. */
  106079. private _registerTransientComponents;
  106080. /**
  106081. * @hidden
  106082. * Add a component to the scene.
  106083. * Note that the ccomponent could be registered on th next frame if this is called after
  106084. * the register component stage.
  106085. * @param component Defines the component to add to the scene
  106086. */
  106087. _addComponent(component: ISceneComponent): void;
  106088. /**
  106089. * @hidden
  106090. * Gets a component from the scene.
  106091. * @param name defines the name of the component to retrieve
  106092. * @returns the component or null if not present
  106093. */
  106094. _getComponent(name: string): Nullable<ISceneComponent>;
  106095. /**
  106096. * @hidden
  106097. * Defines the actions happening before camera updates.
  106098. */
  106099. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  106100. /**
  106101. * @hidden
  106102. * Defines the actions happening before clear the canvas.
  106103. */
  106104. _beforeClearStage: Stage<SimpleStageAction>;
  106105. /**
  106106. * @hidden
  106107. * Defines the actions when collecting render targets for the frame.
  106108. */
  106109. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106110. /**
  106111. * @hidden
  106112. * Defines the actions happening for one camera in the frame.
  106113. */
  106114. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106115. /**
  106116. * @hidden
  106117. * Defines the actions happening during the per mesh ready checks.
  106118. */
  106119. _isReadyForMeshStage: Stage<MeshStageAction>;
  106120. /**
  106121. * @hidden
  106122. * Defines the actions happening before evaluate active mesh checks.
  106123. */
  106124. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  106125. /**
  106126. * @hidden
  106127. * Defines the actions happening during the evaluate sub mesh checks.
  106128. */
  106129. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  106130. /**
  106131. * @hidden
  106132. * Defines the actions happening during the active mesh stage.
  106133. */
  106134. _activeMeshStage: Stage<ActiveMeshStageAction>;
  106135. /**
  106136. * @hidden
  106137. * Defines the actions happening during the per camera render target step.
  106138. */
  106139. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  106140. /**
  106141. * @hidden
  106142. * Defines the actions happening just before the active camera is drawing.
  106143. */
  106144. _beforeCameraDrawStage: Stage<CameraStageAction>;
  106145. /**
  106146. * @hidden
  106147. * Defines the actions happening just before a render target is drawing.
  106148. */
  106149. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106150. /**
  106151. * @hidden
  106152. * Defines the actions happening just before a rendering group is drawing.
  106153. */
  106154. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106155. /**
  106156. * @hidden
  106157. * Defines the actions happening just before a mesh is drawing.
  106158. */
  106159. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106160. /**
  106161. * @hidden
  106162. * Defines the actions happening just after a mesh has been drawn.
  106163. */
  106164. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106165. /**
  106166. * @hidden
  106167. * Defines the actions happening just after a rendering group has been drawn.
  106168. */
  106169. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106170. /**
  106171. * @hidden
  106172. * Defines the actions happening just after the active camera has been drawn.
  106173. */
  106174. _afterCameraDrawStage: Stage<CameraStageAction>;
  106175. /**
  106176. * @hidden
  106177. * Defines the actions happening just after a render target has been drawn.
  106178. */
  106179. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106180. /**
  106181. * @hidden
  106182. * Defines the actions happening just after rendering all cameras and computing intersections.
  106183. */
  106184. _afterRenderStage: Stage<SimpleStageAction>;
  106185. /**
  106186. * @hidden
  106187. * Defines the actions happening when a pointer move event happens.
  106188. */
  106189. _pointerMoveStage: Stage<PointerMoveStageAction>;
  106190. /**
  106191. * @hidden
  106192. * Defines the actions happening when a pointer down event happens.
  106193. */
  106194. _pointerDownStage: Stage<PointerUpDownStageAction>;
  106195. /**
  106196. * @hidden
  106197. * Defines the actions happening when a pointer up event happens.
  106198. */
  106199. _pointerUpStage: Stage<PointerUpDownStageAction>;
  106200. /**
  106201. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  106202. */
  106203. private geometriesByUniqueId;
  106204. /**
  106205. * Creates a new Scene
  106206. * @param engine defines the engine to use to render this scene
  106207. * @param options defines the scene options
  106208. */
  106209. constructor(engine: Engine, options?: SceneOptions);
  106210. /**
  106211. * Gets a string idenfifying the name of the class
  106212. * @returns "Scene" string
  106213. */
  106214. getClassName(): string;
  106215. private _defaultMeshCandidates;
  106216. /**
  106217. * @hidden
  106218. */
  106219. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106220. private _defaultSubMeshCandidates;
  106221. /**
  106222. * @hidden
  106223. */
  106224. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106225. /**
  106226. * Sets the default candidate providers for the scene.
  106227. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  106228. * and getCollidingSubMeshCandidates to their default function
  106229. */
  106230. setDefaultCandidateProviders(): void;
  106231. /**
  106232. * Gets the mesh that is currently under the pointer
  106233. */
  106234. get meshUnderPointer(): Nullable<AbstractMesh>;
  106235. /**
  106236. * Gets or sets the current on-screen X position of the pointer
  106237. */
  106238. get pointerX(): number;
  106239. set pointerX(value: number);
  106240. /**
  106241. * Gets or sets the current on-screen Y position of the pointer
  106242. */
  106243. get pointerY(): number;
  106244. set pointerY(value: number);
  106245. /**
  106246. * Gets the cached material (ie. the latest rendered one)
  106247. * @returns the cached material
  106248. */
  106249. getCachedMaterial(): Nullable<Material>;
  106250. /**
  106251. * Gets the cached effect (ie. the latest rendered one)
  106252. * @returns the cached effect
  106253. */
  106254. getCachedEffect(): Nullable<Effect>;
  106255. /**
  106256. * Gets the cached visibility state (ie. the latest rendered one)
  106257. * @returns the cached visibility state
  106258. */
  106259. getCachedVisibility(): Nullable<number>;
  106260. /**
  106261. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  106262. * @param material defines the current material
  106263. * @param effect defines the current effect
  106264. * @param visibility defines the current visibility state
  106265. * @returns true if one parameter is not cached
  106266. */
  106267. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  106268. /**
  106269. * Gets the engine associated with the scene
  106270. * @returns an Engine
  106271. */
  106272. getEngine(): Engine;
  106273. /**
  106274. * Gets the total number of vertices rendered per frame
  106275. * @returns the total number of vertices rendered per frame
  106276. */
  106277. getTotalVertices(): number;
  106278. /**
  106279. * Gets the performance counter for total vertices
  106280. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106281. */
  106282. get totalVerticesPerfCounter(): PerfCounter;
  106283. /**
  106284. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  106285. * @returns the total number of active indices rendered per frame
  106286. */
  106287. getActiveIndices(): number;
  106288. /**
  106289. * Gets the performance counter for active indices
  106290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106291. */
  106292. get totalActiveIndicesPerfCounter(): PerfCounter;
  106293. /**
  106294. * Gets the total number of active particles rendered per frame
  106295. * @returns the total number of active particles rendered per frame
  106296. */
  106297. getActiveParticles(): number;
  106298. /**
  106299. * Gets the performance counter for active particles
  106300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106301. */
  106302. get activeParticlesPerfCounter(): PerfCounter;
  106303. /**
  106304. * Gets the total number of active bones rendered per frame
  106305. * @returns the total number of active bones rendered per frame
  106306. */
  106307. getActiveBones(): number;
  106308. /**
  106309. * Gets the performance counter for active bones
  106310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106311. */
  106312. get activeBonesPerfCounter(): PerfCounter;
  106313. /**
  106314. * Gets the array of active meshes
  106315. * @returns an array of AbstractMesh
  106316. */
  106317. getActiveMeshes(): SmartArray<AbstractMesh>;
  106318. /**
  106319. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  106320. * @returns a number
  106321. */
  106322. getAnimationRatio(): number;
  106323. /**
  106324. * Gets an unique Id for the current render phase
  106325. * @returns a number
  106326. */
  106327. getRenderId(): number;
  106328. /**
  106329. * Gets an unique Id for the current frame
  106330. * @returns a number
  106331. */
  106332. getFrameId(): number;
  106333. /** Call this function if you want to manually increment the render Id*/
  106334. incrementRenderId(): void;
  106335. private _createUbo;
  106336. /**
  106337. * Use this method to simulate a pointer move on a mesh
  106338. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106339. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106340. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106341. * @returns the current scene
  106342. */
  106343. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106344. /**
  106345. * Use this method to simulate a pointer down on a mesh
  106346. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106347. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106348. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106349. * @returns the current scene
  106350. */
  106351. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106352. /**
  106353. * Use this method to simulate a pointer up on a mesh
  106354. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106355. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106356. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106357. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  106358. * @returns the current scene
  106359. */
  106360. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  106361. /**
  106362. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  106363. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  106364. * @returns true if the pointer was captured
  106365. */
  106366. isPointerCaptured(pointerId?: number): boolean;
  106367. /**
  106368. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  106369. * @param attachUp defines if you want to attach events to pointerup
  106370. * @param attachDown defines if you want to attach events to pointerdown
  106371. * @param attachMove defines if you want to attach events to pointermove
  106372. */
  106373. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  106374. /** Detaches all event handlers*/
  106375. detachControl(): void;
  106376. /**
  106377. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  106378. * Delay loaded resources are not taking in account
  106379. * @return true if all required resources are ready
  106380. */
  106381. isReady(): boolean;
  106382. /** Resets all cached information relative to material (including effect and visibility) */
  106383. resetCachedMaterial(): void;
  106384. /**
  106385. * Registers a function to be called before every frame render
  106386. * @param func defines the function to register
  106387. */
  106388. registerBeforeRender(func: () => void): void;
  106389. /**
  106390. * Unregisters a function called before every frame render
  106391. * @param func defines the function to unregister
  106392. */
  106393. unregisterBeforeRender(func: () => void): void;
  106394. /**
  106395. * Registers a function to be called after every frame render
  106396. * @param func defines the function to register
  106397. */
  106398. registerAfterRender(func: () => void): void;
  106399. /**
  106400. * Unregisters a function called after every frame render
  106401. * @param func defines the function to unregister
  106402. */
  106403. unregisterAfterRender(func: () => void): void;
  106404. private _executeOnceBeforeRender;
  106405. /**
  106406. * The provided function will run before render once and will be disposed afterwards.
  106407. * A timeout delay can be provided so that the function will be executed in N ms.
  106408. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  106409. * @param func The function to be executed.
  106410. * @param timeout optional delay in ms
  106411. */
  106412. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  106413. /** @hidden */
  106414. _addPendingData(data: any): void;
  106415. /** @hidden */
  106416. _removePendingData(data: any): void;
  106417. /**
  106418. * Returns the number of items waiting to be loaded
  106419. * @returns the number of items waiting to be loaded
  106420. */
  106421. getWaitingItemsCount(): number;
  106422. /**
  106423. * Returns a boolean indicating if the scene is still loading data
  106424. */
  106425. get isLoading(): boolean;
  106426. /**
  106427. * Registers a function to be executed when the scene is ready
  106428. * @param {Function} func - the function to be executed
  106429. */
  106430. executeWhenReady(func: () => void): void;
  106431. /**
  106432. * Returns a promise that resolves when the scene is ready
  106433. * @returns A promise that resolves when the scene is ready
  106434. */
  106435. whenReadyAsync(): Promise<void>;
  106436. /** @hidden */
  106437. _checkIsReady(): void;
  106438. /**
  106439. * Gets all animatable attached to the scene
  106440. */
  106441. get animatables(): Animatable[];
  106442. /**
  106443. * Resets the last animation time frame.
  106444. * Useful to override when animations start running when loading a scene for the first time.
  106445. */
  106446. resetLastAnimationTimeFrame(): void;
  106447. /**
  106448. * Gets the current view matrix
  106449. * @returns a Matrix
  106450. */
  106451. getViewMatrix(): Matrix;
  106452. /**
  106453. * Gets the current projection matrix
  106454. * @returns a Matrix
  106455. */
  106456. getProjectionMatrix(): Matrix;
  106457. /**
  106458. * Gets the current transform matrix
  106459. * @returns a Matrix made of View * Projection
  106460. */
  106461. getTransformMatrix(): Matrix;
  106462. /**
  106463. * Sets the current transform matrix
  106464. * @param viewL defines the View matrix to use
  106465. * @param projectionL defines the Projection matrix to use
  106466. * @param viewR defines the right View matrix to use (if provided)
  106467. * @param projectionR defines the right Projection matrix to use (if provided)
  106468. */
  106469. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  106470. /**
  106471. * Gets the uniform buffer used to store scene data
  106472. * @returns a UniformBuffer
  106473. */
  106474. getSceneUniformBuffer(): UniformBuffer;
  106475. /**
  106476. * Gets an unique (relatively to the current scene) Id
  106477. * @returns an unique number for the scene
  106478. */
  106479. getUniqueId(): number;
  106480. /**
  106481. * Add a mesh to the list of scene's meshes
  106482. * @param newMesh defines the mesh to add
  106483. * @param recursive if all child meshes should also be added to the scene
  106484. */
  106485. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  106486. /**
  106487. * Remove a mesh for the list of scene's meshes
  106488. * @param toRemove defines the mesh to remove
  106489. * @param recursive if all child meshes should also be removed from the scene
  106490. * @returns the index where the mesh was in the mesh list
  106491. */
  106492. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  106493. /**
  106494. * Add a transform node to the list of scene's transform nodes
  106495. * @param newTransformNode defines the transform node to add
  106496. */
  106497. addTransformNode(newTransformNode: TransformNode): void;
  106498. /**
  106499. * Remove a transform node for the list of scene's transform nodes
  106500. * @param toRemove defines the transform node to remove
  106501. * @returns the index where the transform node was in the transform node list
  106502. */
  106503. removeTransformNode(toRemove: TransformNode): number;
  106504. /**
  106505. * Remove a skeleton for the list of scene's skeletons
  106506. * @param toRemove defines the skeleton to remove
  106507. * @returns the index where the skeleton was in the skeleton list
  106508. */
  106509. removeSkeleton(toRemove: Skeleton): number;
  106510. /**
  106511. * Remove a morph target for the list of scene's morph targets
  106512. * @param toRemove defines the morph target to remove
  106513. * @returns the index where the morph target was in the morph target list
  106514. */
  106515. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  106516. /**
  106517. * Remove a light for the list of scene's lights
  106518. * @param toRemove defines the light to remove
  106519. * @returns the index where the light was in the light list
  106520. */
  106521. removeLight(toRemove: Light): number;
  106522. /**
  106523. * Remove a camera for the list of scene's cameras
  106524. * @param toRemove defines the camera to remove
  106525. * @returns the index where the camera was in the camera list
  106526. */
  106527. removeCamera(toRemove: Camera): number;
  106528. /**
  106529. * Remove a particle system for the list of scene's particle systems
  106530. * @param toRemove defines the particle system to remove
  106531. * @returns the index where the particle system was in the particle system list
  106532. */
  106533. removeParticleSystem(toRemove: IParticleSystem): number;
  106534. /**
  106535. * Remove a animation for the list of scene's animations
  106536. * @param toRemove defines the animation to remove
  106537. * @returns the index where the animation was in the animation list
  106538. */
  106539. removeAnimation(toRemove: Animation): number;
  106540. /**
  106541. * Will stop the animation of the given target
  106542. * @param target - the target
  106543. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  106544. * @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)
  106545. */
  106546. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  106547. /**
  106548. * Removes the given animation group from this scene.
  106549. * @param toRemove The animation group to remove
  106550. * @returns The index of the removed animation group
  106551. */
  106552. removeAnimationGroup(toRemove: AnimationGroup): number;
  106553. /**
  106554. * Removes the given multi-material from this scene.
  106555. * @param toRemove The multi-material to remove
  106556. * @returns The index of the removed multi-material
  106557. */
  106558. removeMultiMaterial(toRemove: MultiMaterial): number;
  106559. /**
  106560. * Removes the given material from this scene.
  106561. * @param toRemove The material to remove
  106562. * @returns The index of the removed material
  106563. */
  106564. removeMaterial(toRemove: Material): number;
  106565. /**
  106566. * Removes the given action manager from this scene.
  106567. * @param toRemove The action manager to remove
  106568. * @returns The index of the removed action manager
  106569. */
  106570. removeActionManager(toRemove: AbstractActionManager): number;
  106571. /**
  106572. * Removes the given texture from this scene.
  106573. * @param toRemove The texture to remove
  106574. * @returns The index of the removed texture
  106575. */
  106576. removeTexture(toRemove: BaseTexture): number;
  106577. /**
  106578. * Adds the given light to this scene
  106579. * @param newLight The light to add
  106580. */
  106581. addLight(newLight: Light): void;
  106582. /**
  106583. * Sorts the list list based on light priorities
  106584. */
  106585. sortLightsByPriority(): void;
  106586. /**
  106587. * Adds the given camera to this scene
  106588. * @param newCamera The camera to add
  106589. */
  106590. addCamera(newCamera: Camera): void;
  106591. /**
  106592. * Adds the given skeleton to this scene
  106593. * @param newSkeleton The skeleton to add
  106594. */
  106595. addSkeleton(newSkeleton: Skeleton): void;
  106596. /**
  106597. * Adds the given particle system to this scene
  106598. * @param newParticleSystem The particle system to add
  106599. */
  106600. addParticleSystem(newParticleSystem: IParticleSystem): void;
  106601. /**
  106602. * Adds the given animation to this scene
  106603. * @param newAnimation The animation to add
  106604. */
  106605. addAnimation(newAnimation: Animation): void;
  106606. /**
  106607. * Adds the given animation group to this scene.
  106608. * @param newAnimationGroup The animation group to add
  106609. */
  106610. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  106611. /**
  106612. * Adds the given multi-material to this scene
  106613. * @param newMultiMaterial The multi-material to add
  106614. */
  106615. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  106616. /**
  106617. * Adds the given material to this scene
  106618. * @param newMaterial The material to add
  106619. */
  106620. addMaterial(newMaterial: Material): void;
  106621. /**
  106622. * Adds the given morph target to this scene
  106623. * @param newMorphTargetManager The morph target to add
  106624. */
  106625. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  106626. /**
  106627. * Adds the given geometry to this scene
  106628. * @param newGeometry The geometry to add
  106629. */
  106630. addGeometry(newGeometry: Geometry): void;
  106631. /**
  106632. * Adds the given action manager to this scene
  106633. * @param newActionManager The action manager to add
  106634. */
  106635. addActionManager(newActionManager: AbstractActionManager): void;
  106636. /**
  106637. * Adds the given texture to this scene.
  106638. * @param newTexture The texture to add
  106639. */
  106640. addTexture(newTexture: BaseTexture): void;
  106641. /**
  106642. * Switch active camera
  106643. * @param newCamera defines the new active camera
  106644. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  106645. */
  106646. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  106647. /**
  106648. * sets the active camera of the scene using its ID
  106649. * @param id defines the camera's ID
  106650. * @return the new active camera or null if none found.
  106651. */
  106652. setActiveCameraByID(id: string): Nullable<Camera>;
  106653. /**
  106654. * sets the active camera of the scene using its name
  106655. * @param name defines the camera's name
  106656. * @returns the new active camera or null if none found.
  106657. */
  106658. setActiveCameraByName(name: string): Nullable<Camera>;
  106659. /**
  106660. * get an animation group using its name
  106661. * @param name defines the material's name
  106662. * @return the animation group or null if none found.
  106663. */
  106664. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  106665. /**
  106666. * Get a material using its unique id
  106667. * @param uniqueId defines the material's unique id
  106668. * @return the material or null if none found.
  106669. */
  106670. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  106671. /**
  106672. * get a material using its id
  106673. * @param id defines the material's ID
  106674. * @return the material or null if none found.
  106675. */
  106676. getMaterialByID(id: string): Nullable<Material>;
  106677. /**
  106678. * Gets a the last added material using a given id
  106679. * @param id defines the material's ID
  106680. * @return the last material with the given id or null if none found.
  106681. */
  106682. getLastMaterialByID(id: string): Nullable<Material>;
  106683. /**
  106684. * Gets a material using its name
  106685. * @param name defines the material's name
  106686. * @return the material or null if none found.
  106687. */
  106688. getMaterialByName(name: string): Nullable<Material>;
  106689. /**
  106690. * Get a texture using its unique id
  106691. * @param uniqueId defines the texture's unique id
  106692. * @return the texture or null if none found.
  106693. */
  106694. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  106695. /**
  106696. * Gets a camera using its id
  106697. * @param id defines the id to look for
  106698. * @returns the camera or null if not found
  106699. */
  106700. getCameraByID(id: string): Nullable<Camera>;
  106701. /**
  106702. * Gets a camera using its unique id
  106703. * @param uniqueId defines the unique id to look for
  106704. * @returns the camera or null if not found
  106705. */
  106706. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  106707. /**
  106708. * Gets a camera using its name
  106709. * @param name defines the camera's name
  106710. * @return the camera or null if none found.
  106711. */
  106712. getCameraByName(name: string): Nullable<Camera>;
  106713. /**
  106714. * Gets a bone using its id
  106715. * @param id defines the bone's id
  106716. * @return the bone or null if not found
  106717. */
  106718. getBoneByID(id: string): Nullable<Bone>;
  106719. /**
  106720. * Gets a bone using its id
  106721. * @param name defines the bone's name
  106722. * @return the bone or null if not found
  106723. */
  106724. getBoneByName(name: string): Nullable<Bone>;
  106725. /**
  106726. * Gets a light node using its name
  106727. * @param name defines the the light's name
  106728. * @return the light or null if none found.
  106729. */
  106730. getLightByName(name: string): Nullable<Light>;
  106731. /**
  106732. * Gets a light node using its id
  106733. * @param id defines the light's id
  106734. * @return the light or null if none found.
  106735. */
  106736. getLightByID(id: string): Nullable<Light>;
  106737. /**
  106738. * Gets a light node using its scene-generated unique ID
  106739. * @param uniqueId defines the light's unique id
  106740. * @return the light or null if none found.
  106741. */
  106742. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  106743. /**
  106744. * Gets a particle system by id
  106745. * @param id defines the particle system id
  106746. * @return the corresponding system or null if none found
  106747. */
  106748. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  106749. /**
  106750. * Gets a geometry using its ID
  106751. * @param id defines the geometry's id
  106752. * @return the geometry or null if none found.
  106753. */
  106754. getGeometryByID(id: string): Nullable<Geometry>;
  106755. private _getGeometryByUniqueID;
  106756. /**
  106757. * Add a new geometry to this scene
  106758. * @param geometry defines the geometry to be added to the scene.
  106759. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  106760. * @return a boolean defining if the geometry was added or not
  106761. */
  106762. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  106763. /**
  106764. * Removes an existing geometry
  106765. * @param geometry defines the geometry to be removed from the scene
  106766. * @return a boolean defining if the geometry was removed or not
  106767. */
  106768. removeGeometry(geometry: Geometry): boolean;
  106769. /**
  106770. * Gets the list of geometries attached to the scene
  106771. * @returns an array of Geometry
  106772. */
  106773. getGeometries(): Geometry[];
  106774. /**
  106775. * Gets the first added mesh found of a given ID
  106776. * @param id defines the id to search for
  106777. * @return the mesh found or null if not found at all
  106778. */
  106779. getMeshByID(id: string): Nullable<AbstractMesh>;
  106780. /**
  106781. * Gets a list of meshes using their id
  106782. * @param id defines the id to search for
  106783. * @returns a list of meshes
  106784. */
  106785. getMeshesByID(id: string): Array<AbstractMesh>;
  106786. /**
  106787. * Gets the first added transform node found of a given ID
  106788. * @param id defines the id to search for
  106789. * @return the found transform node or null if not found at all.
  106790. */
  106791. getTransformNodeByID(id: string): Nullable<TransformNode>;
  106792. /**
  106793. * Gets a transform node with its auto-generated unique id
  106794. * @param uniqueId efines the unique id to search for
  106795. * @return the found transform node or null if not found at all.
  106796. */
  106797. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  106798. /**
  106799. * Gets a list of transform nodes using their id
  106800. * @param id defines the id to search for
  106801. * @returns a list of transform nodes
  106802. */
  106803. getTransformNodesByID(id: string): Array<TransformNode>;
  106804. /**
  106805. * Gets a mesh with its auto-generated unique id
  106806. * @param uniqueId defines the unique id to search for
  106807. * @return the found mesh or null if not found at all.
  106808. */
  106809. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  106810. /**
  106811. * Gets a the last added mesh using a given id
  106812. * @param id defines the id to search for
  106813. * @return the found mesh or null if not found at all.
  106814. */
  106815. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  106816. /**
  106817. * Gets a the last added node (Mesh, Camera, Light) using a given id
  106818. * @param id defines the id to search for
  106819. * @return the found node or null if not found at all
  106820. */
  106821. getLastEntryByID(id: string): Nullable<Node>;
  106822. /**
  106823. * Gets a node (Mesh, Camera, Light) using a given id
  106824. * @param id defines the id to search for
  106825. * @return the found node or null if not found at all
  106826. */
  106827. getNodeByID(id: string): Nullable<Node>;
  106828. /**
  106829. * Gets a node (Mesh, Camera, Light) using a given name
  106830. * @param name defines the name to search for
  106831. * @return the found node or null if not found at all.
  106832. */
  106833. getNodeByName(name: string): Nullable<Node>;
  106834. /**
  106835. * Gets a mesh using a given name
  106836. * @param name defines the name to search for
  106837. * @return the found mesh or null if not found at all.
  106838. */
  106839. getMeshByName(name: string): Nullable<AbstractMesh>;
  106840. /**
  106841. * Gets a transform node using a given name
  106842. * @param name defines the name to search for
  106843. * @return the found transform node or null if not found at all.
  106844. */
  106845. getTransformNodeByName(name: string): Nullable<TransformNode>;
  106846. /**
  106847. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  106848. * @param id defines the id to search for
  106849. * @return the found skeleton or null if not found at all.
  106850. */
  106851. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  106852. /**
  106853. * Gets a skeleton using a given auto generated unique id
  106854. * @param uniqueId defines the unique id to search for
  106855. * @return the found skeleton or null if not found at all.
  106856. */
  106857. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  106858. /**
  106859. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  106860. * @param id defines the id to search for
  106861. * @return the found skeleton or null if not found at all.
  106862. */
  106863. getSkeletonById(id: string): Nullable<Skeleton>;
  106864. /**
  106865. * Gets a skeleton using a given name
  106866. * @param name defines the name to search for
  106867. * @return the found skeleton or null if not found at all.
  106868. */
  106869. getSkeletonByName(name: string): Nullable<Skeleton>;
  106870. /**
  106871. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  106872. * @param id defines the id to search for
  106873. * @return the found morph target manager or null if not found at all.
  106874. */
  106875. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  106876. /**
  106877. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  106878. * @param id defines the id to search for
  106879. * @return the found morph target or null if not found at all.
  106880. */
  106881. getMorphTargetById(id: string): Nullable<MorphTarget>;
  106882. /**
  106883. * Gets a boolean indicating if the given mesh is active
  106884. * @param mesh defines the mesh to look for
  106885. * @returns true if the mesh is in the active list
  106886. */
  106887. isActiveMesh(mesh: AbstractMesh): boolean;
  106888. /**
  106889. * Return a unique id as a string which can serve as an identifier for the scene
  106890. */
  106891. get uid(): string;
  106892. /**
  106893. * Add an externaly attached data from its key.
  106894. * This method call will fail and return false, if such key already exists.
  106895. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  106896. * @param key the unique key that identifies the data
  106897. * @param data the data object to associate to the key for this Engine instance
  106898. * @return true if no such key were already present and the data was added successfully, false otherwise
  106899. */
  106900. addExternalData<T>(key: string, data: T): boolean;
  106901. /**
  106902. * Get an externaly attached data from its key
  106903. * @param key the unique key that identifies the data
  106904. * @return the associated data, if present (can be null), or undefined if not present
  106905. */
  106906. getExternalData<T>(key: string): Nullable<T>;
  106907. /**
  106908. * Get an externaly attached data from its key, create it using a factory if it's not already present
  106909. * @param key the unique key that identifies the data
  106910. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  106911. * @return the associated data, can be null if the factory returned null.
  106912. */
  106913. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  106914. /**
  106915. * Remove an externaly attached data from the Engine instance
  106916. * @param key the unique key that identifies the data
  106917. * @return true if the data was successfully removed, false if it doesn't exist
  106918. */
  106919. removeExternalData(key: string): boolean;
  106920. private _evaluateSubMesh;
  106921. /**
  106922. * Clear the processed materials smart array preventing retention point in material dispose.
  106923. */
  106924. freeProcessedMaterials(): void;
  106925. private _preventFreeActiveMeshesAndRenderingGroups;
  106926. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  106927. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  106928. * when disposing several meshes in a row or a hierarchy of meshes.
  106929. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  106930. */
  106931. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  106932. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  106933. /**
  106934. * Clear the active meshes smart array preventing retention point in mesh dispose.
  106935. */
  106936. freeActiveMeshes(): void;
  106937. /**
  106938. * Clear the info related to rendering groups preventing retention points during dispose.
  106939. */
  106940. freeRenderingGroups(): void;
  106941. /** @hidden */
  106942. _isInIntermediateRendering(): boolean;
  106943. /**
  106944. * Lambda returning the list of potentially active meshes.
  106945. */
  106946. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  106947. /**
  106948. * Lambda returning the list of potentially active sub meshes.
  106949. */
  106950. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  106951. /**
  106952. * Lambda returning the list of potentially intersecting sub meshes.
  106953. */
  106954. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  106955. /**
  106956. * Lambda returning the list of potentially colliding sub meshes.
  106957. */
  106958. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  106959. private _activeMeshesFrozen;
  106960. private _skipEvaluateActiveMeshesCompletely;
  106961. /**
  106962. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  106963. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  106964. * @returns the current scene
  106965. */
  106966. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  106967. /**
  106968. * Use this function to restart evaluating active meshes on every frame
  106969. * @returns the current scene
  106970. */
  106971. unfreezeActiveMeshes(): Scene;
  106972. private _evaluateActiveMeshes;
  106973. private _activeMesh;
  106974. /**
  106975. * Update the transform matrix to update from the current active camera
  106976. * @param force defines a boolean used to force the update even if cache is up to date
  106977. */
  106978. updateTransformMatrix(force?: boolean): void;
  106979. private _bindFrameBuffer;
  106980. /** @hidden */
  106981. _allowPostProcessClearColor: boolean;
  106982. /** @hidden */
  106983. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  106984. private _processSubCameras;
  106985. private _checkIntersections;
  106986. /** @hidden */
  106987. _advancePhysicsEngineStep(step: number): void;
  106988. /**
  106989. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  106990. */
  106991. getDeterministicFrameTime: () => number;
  106992. /** @hidden */
  106993. _animate(): void;
  106994. /** Execute all animations (for a frame) */
  106995. animate(): void;
  106996. /**
  106997. * Render the scene
  106998. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  106999. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  107000. */
  107001. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107002. /**
  107003. * Freeze all materials
  107004. * A frozen material will not be updatable but should be faster to render
  107005. */
  107006. freezeMaterials(): void;
  107007. /**
  107008. * Unfreeze all materials
  107009. * A frozen material will not be updatable but should be faster to render
  107010. */
  107011. unfreezeMaterials(): void;
  107012. /**
  107013. * Releases all held ressources
  107014. */
  107015. dispose(): void;
  107016. /**
  107017. * Gets if the scene is already disposed
  107018. */
  107019. get isDisposed(): boolean;
  107020. /**
  107021. * Call this function to reduce memory footprint of the scene.
  107022. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107023. */
  107024. clearCachedVertexData(): void;
  107025. /**
  107026. * This function will remove the local cached buffer data from texture.
  107027. * It will save memory but will prevent the texture from being rebuilt
  107028. */
  107029. cleanCachedTextureBuffer(): void;
  107030. /**
  107031. * Get the world extend vectors with an optional filter
  107032. *
  107033. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107034. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107035. */
  107036. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107037. min: Vector3;
  107038. max: Vector3;
  107039. };
  107040. /**
  107041. * Creates a ray that can be used to pick in the scene
  107042. * @param x defines the x coordinate of the origin (on-screen)
  107043. * @param y defines the y coordinate of the origin (on-screen)
  107044. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107045. * @param camera defines the camera to use for the picking
  107046. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107047. * @returns a Ray
  107048. */
  107049. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107050. /**
  107051. * Creates a ray that can be used to pick in the scene
  107052. * @param x defines the x coordinate of the origin (on-screen)
  107053. * @param y defines the y coordinate of the origin (on-screen)
  107054. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107055. * @param result defines the ray where to store the picking ray
  107056. * @param camera defines the camera to use for the picking
  107057. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107058. * @returns the current scene
  107059. */
  107060. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107061. /**
  107062. * Creates a ray that can be used to pick in the scene
  107063. * @param x defines the x coordinate of the origin (on-screen)
  107064. * @param y defines the y coordinate of the origin (on-screen)
  107065. * @param camera defines the camera to use for the picking
  107066. * @returns a Ray
  107067. */
  107068. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107069. /**
  107070. * Creates a ray that can be used to pick in the scene
  107071. * @param x defines the x coordinate of the origin (on-screen)
  107072. * @param y defines the y coordinate of the origin (on-screen)
  107073. * @param result defines the ray where to store the picking ray
  107074. * @param camera defines the camera to use for the picking
  107075. * @returns the current scene
  107076. */
  107077. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  107078. /** Launch a ray to try to pick a mesh in the scene
  107079. * @param x position on screen
  107080. * @param y position on screen
  107081. * @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
  107082. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  107083. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107084. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107085. * @returns a PickingInfo
  107086. */
  107087. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107088. /** Use the given ray to pick a mesh in the scene
  107089. * @param ray The ray to use to pick meshes
  107090. * @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
  107091. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  107092. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107093. * @returns a PickingInfo
  107094. */
  107095. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107096. /**
  107097. * Launch a ray to try to pick a mesh in the scene
  107098. * @param x X position on screen
  107099. * @param y Y position on screen
  107100. * @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
  107101. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107102. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107103. * @returns an array of PickingInfo
  107104. */
  107105. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107106. /**
  107107. * Launch a ray to try to pick a mesh in the scene
  107108. * @param ray Ray to use
  107109. * @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
  107110. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107111. * @returns an array of PickingInfo
  107112. */
  107113. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107114. /**
  107115. * Force the value of meshUnderPointer
  107116. * @param mesh defines the mesh to use
  107117. */
  107118. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107119. /**
  107120. * Gets the mesh under the pointer
  107121. * @returns a Mesh or null if no mesh is under the pointer
  107122. */
  107123. getPointerOverMesh(): Nullable<AbstractMesh>;
  107124. /** @hidden */
  107125. _rebuildGeometries(): void;
  107126. /** @hidden */
  107127. _rebuildTextures(): void;
  107128. private _getByTags;
  107129. /**
  107130. * Get a list of meshes by tags
  107131. * @param tagsQuery defines the tags query to use
  107132. * @param forEach defines a predicate used to filter results
  107133. * @returns an array of Mesh
  107134. */
  107135. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  107136. /**
  107137. * Get a list of cameras by tags
  107138. * @param tagsQuery defines the tags query to use
  107139. * @param forEach defines a predicate used to filter results
  107140. * @returns an array of Camera
  107141. */
  107142. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  107143. /**
  107144. * Get a list of lights by tags
  107145. * @param tagsQuery defines the tags query to use
  107146. * @param forEach defines a predicate used to filter results
  107147. * @returns an array of Light
  107148. */
  107149. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  107150. /**
  107151. * Get a list of materials by tags
  107152. * @param tagsQuery defines the tags query to use
  107153. * @param forEach defines a predicate used to filter results
  107154. * @returns an array of Material
  107155. */
  107156. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  107157. /**
  107158. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  107159. * This allowed control for front to back rendering or reversly depending of the special needs.
  107160. *
  107161. * @param renderingGroupId The rendering group id corresponding to its index
  107162. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  107163. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  107164. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  107165. */
  107166. 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;
  107167. /**
  107168. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  107169. *
  107170. * @param renderingGroupId The rendering group id corresponding to its index
  107171. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107172. * @param depth Automatically clears depth between groups if true and autoClear is true.
  107173. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  107174. */
  107175. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  107176. /**
  107177. * Gets the current auto clear configuration for one rendering group of the rendering
  107178. * manager.
  107179. * @param index the rendering group index to get the information for
  107180. * @returns The auto clear setup for the requested rendering group
  107181. */
  107182. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  107183. private _blockMaterialDirtyMechanism;
  107184. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  107185. get blockMaterialDirtyMechanism(): boolean;
  107186. set blockMaterialDirtyMechanism(value: boolean);
  107187. /**
  107188. * Will flag all materials as dirty to trigger new shader compilation
  107189. * @param flag defines the flag used to specify which material part must be marked as dirty
  107190. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  107191. */
  107192. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107193. /** @hidden */
  107194. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  107195. /** @hidden */
  107196. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107197. /** @hidden */
  107198. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  107199. /** @hidden */
  107200. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  107201. /** @hidden */
  107202. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107203. /** @hidden */
  107204. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107205. }
  107206. }
  107207. declare module BABYLON {
  107208. /**
  107209. * Set of assets to keep when moving a scene into an asset container.
  107210. */
  107211. export class KeepAssets extends AbstractScene {
  107212. }
  107213. /**
  107214. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  107215. */
  107216. export class InstantiatedEntries {
  107217. /**
  107218. * List of new root nodes (eg. nodes with no parent)
  107219. */
  107220. rootNodes: TransformNode[];
  107221. /**
  107222. * List of new skeletons
  107223. */
  107224. skeletons: Skeleton[];
  107225. /**
  107226. * List of new animation groups
  107227. */
  107228. animationGroups: AnimationGroup[];
  107229. }
  107230. /**
  107231. * Container with a set of assets that can be added or removed from a scene.
  107232. */
  107233. export class AssetContainer extends AbstractScene {
  107234. /**
  107235. * The scene the AssetContainer belongs to.
  107236. */
  107237. scene: Scene;
  107238. /**
  107239. * Instantiates an AssetContainer.
  107240. * @param scene The scene the AssetContainer belongs to.
  107241. */
  107242. constructor(scene: Scene);
  107243. /**
  107244. * Instantiate or clone all meshes and add the new ones to the scene.
  107245. * Skeletons and animation groups will all be cloned
  107246. * @param nameFunction defines an optional function used to get new names for clones
  107247. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  107248. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  107249. */
  107250. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  107251. /**
  107252. * Adds all the assets from the container to the scene.
  107253. */
  107254. addAllToScene(): void;
  107255. /**
  107256. * Removes all the assets in the container from the scene
  107257. */
  107258. removeAllFromScene(): void;
  107259. /**
  107260. * Disposes all the assets in the container
  107261. */
  107262. dispose(): void;
  107263. private _moveAssets;
  107264. /**
  107265. * Removes all the assets contained in the scene and adds them to the container.
  107266. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  107267. */
  107268. moveAllFromScene(keepAssets?: KeepAssets): void;
  107269. /**
  107270. * 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.
  107271. * @returns the root mesh
  107272. */
  107273. createRootMesh(): Mesh;
  107274. /**
  107275. * Merge animations from this asset container into a scene
  107276. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107277. * @param animatables set of animatables to retarget to a node from the scene
  107278. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  107279. */
  107280. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  107281. }
  107282. }
  107283. declare module BABYLON {
  107284. /**
  107285. * Defines how the parser contract is defined.
  107286. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  107287. */
  107288. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  107289. /**
  107290. * Defines how the individual parser contract is defined.
  107291. * These parser can parse an individual asset
  107292. */
  107293. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  107294. /**
  107295. * Base class of the scene acting as a container for the different elements composing a scene.
  107296. * This class is dynamically extended by the different components of the scene increasing
  107297. * flexibility and reducing coupling
  107298. */
  107299. export abstract class AbstractScene {
  107300. /**
  107301. * Stores the list of available parsers in the application.
  107302. */
  107303. private static _BabylonFileParsers;
  107304. /**
  107305. * Stores the list of available individual parsers in the application.
  107306. */
  107307. private static _IndividualBabylonFileParsers;
  107308. /**
  107309. * Adds a parser in the list of available ones
  107310. * @param name Defines the name of the parser
  107311. * @param parser Defines the parser to add
  107312. */
  107313. static AddParser(name: string, parser: BabylonFileParser): void;
  107314. /**
  107315. * Gets a general parser from the list of avaialble ones
  107316. * @param name Defines the name of the parser
  107317. * @returns the requested parser or null
  107318. */
  107319. static GetParser(name: string): Nullable<BabylonFileParser>;
  107320. /**
  107321. * Adds n individual parser in the list of available ones
  107322. * @param name Defines the name of the parser
  107323. * @param parser Defines the parser to add
  107324. */
  107325. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  107326. /**
  107327. * Gets an individual parser from the list of avaialble ones
  107328. * @param name Defines the name of the parser
  107329. * @returns the requested parser or null
  107330. */
  107331. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  107332. /**
  107333. * Parser json data and populate both a scene and its associated container object
  107334. * @param jsonData Defines the data to parse
  107335. * @param scene Defines the scene to parse the data for
  107336. * @param container Defines the container attached to the parsing sequence
  107337. * @param rootUrl Defines the root url of the data
  107338. */
  107339. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  107340. /**
  107341. * Gets the list of root nodes (ie. nodes with no parent)
  107342. */
  107343. rootNodes: Node[];
  107344. /** All of the cameras added to this scene
  107345. * @see http://doc.babylonjs.com/babylon101/cameras
  107346. */
  107347. cameras: Camera[];
  107348. /**
  107349. * All of the lights added to this scene
  107350. * @see http://doc.babylonjs.com/babylon101/lights
  107351. */
  107352. lights: Light[];
  107353. /**
  107354. * All of the (abstract) meshes added to this scene
  107355. */
  107356. meshes: AbstractMesh[];
  107357. /**
  107358. * The list of skeletons added to the scene
  107359. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107360. */
  107361. skeletons: Skeleton[];
  107362. /**
  107363. * All of the particle systems added to this scene
  107364. * @see http://doc.babylonjs.com/babylon101/particles
  107365. */
  107366. particleSystems: IParticleSystem[];
  107367. /**
  107368. * Gets a list of Animations associated with the scene
  107369. */
  107370. animations: Animation[];
  107371. /**
  107372. * All of the animation groups added to this scene
  107373. * @see http://doc.babylonjs.com/how_to/group
  107374. */
  107375. animationGroups: AnimationGroup[];
  107376. /**
  107377. * All of the multi-materials added to this scene
  107378. * @see http://doc.babylonjs.com/how_to/multi_materials
  107379. */
  107380. multiMaterials: MultiMaterial[];
  107381. /**
  107382. * All of the materials added to this scene
  107383. * In the context of a Scene, it is not supposed to be modified manually.
  107384. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  107385. * Note also that the order of the Material within the array is not significant and might change.
  107386. * @see http://doc.babylonjs.com/babylon101/materials
  107387. */
  107388. materials: Material[];
  107389. /**
  107390. * The list of morph target managers added to the scene
  107391. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  107392. */
  107393. morphTargetManagers: MorphTargetManager[];
  107394. /**
  107395. * The list of geometries used in the scene.
  107396. */
  107397. geometries: Geometry[];
  107398. /**
  107399. * All of the tranform nodes added to this scene
  107400. * In the context of a Scene, it is not supposed to be modified manually.
  107401. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  107402. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  107403. * @see http://doc.babylonjs.com/how_to/transformnode
  107404. */
  107405. transformNodes: TransformNode[];
  107406. /**
  107407. * ActionManagers available on the scene.
  107408. */
  107409. actionManagers: AbstractActionManager[];
  107410. /**
  107411. * Textures to keep.
  107412. */
  107413. textures: BaseTexture[];
  107414. /**
  107415. * Environment texture for the scene
  107416. */
  107417. environmentTexture: Nullable<BaseTexture>;
  107418. /**
  107419. * @returns all meshes, lights, cameras, transformNodes and bones
  107420. */
  107421. getNodes(): Array<Node>;
  107422. }
  107423. }
  107424. declare module BABYLON {
  107425. /**
  107426. * Interface used to define options for Sound class
  107427. */
  107428. export interface ISoundOptions {
  107429. /**
  107430. * Does the sound autoplay once loaded.
  107431. */
  107432. autoplay?: boolean;
  107433. /**
  107434. * Does the sound loop after it finishes playing once.
  107435. */
  107436. loop?: boolean;
  107437. /**
  107438. * Sound's volume
  107439. */
  107440. volume?: number;
  107441. /**
  107442. * Is it a spatial sound?
  107443. */
  107444. spatialSound?: boolean;
  107445. /**
  107446. * Maximum distance to hear that sound
  107447. */
  107448. maxDistance?: number;
  107449. /**
  107450. * Uses user defined attenuation function
  107451. */
  107452. useCustomAttenuation?: boolean;
  107453. /**
  107454. * Define the roll off factor of spatial sounds.
  107455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107456. */
  107457. rolloffFactor?: number;
  107458. /**
  107459. * Define the reference distance the sound should be heard perfectly.
  107460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107461. */
  107462. refDistance?: number;
  107463. /**
  107464. * Define the distance attenuation model the sound will follow.
  107465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107466. */
  107467. distanceModel?: string;
  107468. /**
  107469. * Defines the playback speed (1 by default)
  107470. */
  107471. playbackRate?: number;
  107472. /**
  107473. * Defines if the sound is from a streaming source
  107474. */
  107475. streaming?: boolean;
  107476. /**
  107477. * Defines an optional length (in seconds) inside the sound file
  107478. */
  107479. length?: number;
  107480. /**
  107481. * Defines an optional offset (in seconds) inside the sound file
  107482. */
  107483. offset?: number;
  107484. /**
  107485. * If true, URLs will not be required to state the audio file codec to use.
  107486. */
  107487. skipCodecCheck?: boolean;
  107488. }
  107489. /**
  107490. * Defines a sound that can be played in the application.
  107491. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  107492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107493. */
  107494. export class Sound {
  107495. /**
  107496. * The name of the sound in the scene.
  107497. */
  107498. name: string;
  107499. /**
  107500. * Does the sound autoplay once loaded.
  107501. */
  107502. autoplay: boolean;
  107503. /**
  107504. * Does the sound loop after it finishes playing once.
  107505. */
  107506. loop: boolean;
  107507. /**
  107508. * Does the sound use a custom attenuation curve to simulate the falloff
  107509. * happening when the source gets further away from the camera.
  107510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107511. */
  107512. useCustomAttenuation: boolean;
  107513. /**
  107514. * The sound track id this sound belongs to.
  107515. */
  107516. soundTrackId: number;
  107517. /**
  107518. * Is this sound currently played.
  107519. */
  107520. isPlaying: boolean;
  107521. /**
  107522. * Is this sound currently paused.
  107523. */
  107524. isPaused: boolean;
  107525. /**
  107526. * Does this sound enables spatial sound.
  107527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107528. */
  107529. spatialSound: boolean;
  107530. /**
  107531. * Define the reference distance the sound should be heard perfectly.
  107532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107533. */
  107534. refDistance: number;
  107535. /**
  107536. * Define the roll off factor of spatial sounds.
  107537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107538. */
  107539. rolloffFactor: number;
  107540. /**
  107541. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  107542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107543. */
  107544. maxDistance: number;
  107545. /**
  107546. * Define the distance attenuation model the sound will follow.
  107547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107548. */
  107549. distanceModel: string;
  107550. /**
  107551. * @hidden
  107552. * Back Compat
  107553. **/
  107554. onended: () => any;
  107555. /**
  107556. * Observable event when the current playing sound finishes.
  107557. */
  107558. onEndedObservable: Observable<Sound>;
  107559. private _panningModel;
  107560. private _playbackRate;
  107561. private _streaming;
  107562. private _startTime;
  107563. private _startOffset;
  107564. private _position;
  107565. /** @hidden */
  107566. _positionInEmitterSpace: boolean;
  107567. private _localDirection;
  107568. private _volume;
  107569. private _isReadyToPlay;
  107570. private _isDirectional;
  107571. private _readyToPlayCallback;
  107572. private _audioBuffer;
  107573. private _soundSource;
  107574. private _streamingSource;
  107575. private _soundPanner;
  107576. private _soundGain;
  107577. private _inputAudioNode;
  107578. private _outputAudioNode;
  107579. private _coneInnerAngle;
  107580. private _coneOuterAngle;
  107581. private _coneOuterGain;
  107582. private _scene;
  107583. private _connectedTransformNode;
  107584. private _customAttenuationFunction;
  107585. private _registerFunc;
  107586. private _isOutputConnected;
  107587. private _htmlAudioElement;
  107588. private _urlType;
  107589. private _length?;
  107590. private _offset?;
  107591. /** @hidden */
  107592. static _SceneComponentInitialization: (scene: Scene) => void;
  107593. /**
  107594. * Create a sound and attach it to a scene
  107595. * @param name Name of your sound
  107596. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  107597. * @param scene defines the scene the sound belongs to
  107598. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  107599. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  107600. */
  107601. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  107602. /**
  107603. * Release the sound and its associated resources
  107604. */
  107605. dispose(): void;
  107606. /**
  107607. * Gets if the sounds is ready to be played or not.
  107608. * @returns true if ready, otherwise false
  107609. */
  107610. isReady(): boolean;
  107611. private _soundLoaded;
  107612. /**
  107613. * Sets the data of the sound from an audiobuffer
  107614. * @param audioBuffer The audioBuffer containing the data
  107615. */
  107616. setAudioBuffer(audioBuffer: AudioBuffer): void;
  107617. /**
  107618. * Updates the current sounds options such as maxdistance, loop...
  107619. * @param options A JSON object containing values named as the object properties
  107620. */
  107621. updateOptions(options: ISoundOptions): void;
  107622. private _createSpatialParameters;
  107623. private _updateSpatialParameters;
  107624. /**
  107625. * Switch the panning model to HRTF:
  107626. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107628. */
  107629. switchPanningModelToHRTF(): void;
  107630. /**
  107631. * Switch the panning model to Equal Power:
  107632. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107634. */
  107635. switchPanningModelToEqualPower(): void;
  107636. private _switchPanningModel;
  107637. /**
  107638. * Connect this sound to a sound track audio node like gain...
  107639. * @param soundTrackAudioNode the sound track audio node to connect to
  107640. */
  107641. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  107642. /**
  107643. * Transform this sound into a directional source
  107644. * @param coneInnerAngle Size of the inner cone in degree
  107645. * @param coneOuterAngle Size of the outer cone in degree
  107646. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  107647. */
  107648. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  107649. /**
  107650. * Gets or sets the inner angle for the directional cone.
  107651. */
  107652. get directionalConeInnerAngle(): number;
  107653. /**
  107654. * Gets or sets the inner angle for the directional cone.
  107655. */
  107656. set directionalConeInnerAngle(value: number);
  107657. /**
  107658. * Gets or sets the outer angle for the directional cone.
  107659. */
  107660. get directionalConeOuterAngle(): number;
  107661. /**
  107662. * Gets or sets the outer angle for the directional cone.
  107663. */
  107664. set directionalConeOuterAngle(value: number);
  107665. /**
  107666. * Sets the position of the emitter if spatial sound is enabled
  107667. * @param newPosition Defines the new posisiton
  107668. */
  107669. setPosition(newPosition: Vector3): void;
  107670. /**
  107671. * Sets the local direction of the emitter if spatial sound is enabled
  107672. * @param newLocalDirection Defines the new local direction
  107673. */
  107674. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  107675. private _updateDirection;
  107676. /** @hidden */
  107677. updateDistanceFromListener(): void;
  107678. /**
  107679. * Sets a new custom attenuation function for the sound.
  107680. * @param callback Defines the function used for the attenuation
  107681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107682. */
  107683. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  107684. /**
  107685. * Play the sound
  107686. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  107687. * @param offset (optional) Start the sound at a specific time in seconds
  107688. * @param length (optional) Sound duration (in seconds)
  107689. */
  107690. play(time?: number, offset?: number, length?: number): void;
  107691. private _onended;
  107692. /**
  107693. * Stop the sound
  107694. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  107695. */
  107696. stop(time?: number): void;
  107697. /**
  107698. * Put the sound in pause
  107699. */
  107700. pause(): void;
  107701. /**
  107702. * Sets a dedicated volume for this sounds
  107703. * @param newVolume Define the new volume of the sound
  107704. * @param time Define time for gradual change to new volume
  107705. */
  107706. setVolume(newVolume: number, time?: number): void;
  107707. /**
  107708. * Set the sound play back rate
  107709. * @param newPlaybackRate Define the playback rate the sound should be played at
  107710. */
  107711. setPlaybackRate(newPlaybackRate: number): void;
  107712. /**
  107713. * Gets the volume of the sound.
  107714. * @returns the volume of the sound
  107715. */
  107716. getVolume(): number;
  107717. /**
  107718. * Attach the sound to a dedicated mesh
  107719. * @param transformNode The transform node to connect the sound with
  107720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107721. */
  107722. attachToMesh(transformNode: TransformNode): void;
  107723. /**
  107724. * Detach the sound from the previously attached mesh
  107725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107726. */
  107727. detachFromMesh(): void;
  107728. private _onRegisterAfterWorldMatrixUpdate;
  107729. /**
  107730. * Clone the current sound in the scene.
  107731. * @returns the new sound clone
  107732. */
  107733. clone(): Nullable<Sound>;
  107734. /**
  107735. * Gets the current underlying audio buffer containing the data
  107736. * @returns the audio buffer
  107737. */
  107738. getAudioBuffer(): Nullable<AudioBuffer>;
  107739. /**
  107740. * Serializes the Sound in a JSON representation
  107741. * @returns the JSON representation of the sound
  107742. */
  107743. serialize(): any;
  107744. /**
  107745. * Parse a JSON representation of a sound to innstantiate in a given scene
  107746. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  107747. * @param scene Define the scene the new parsed sound should be created in
  107748. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  107749. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  107750. * @returns the newly parsed sound
  107751. */
  107752. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  107753. }
  107754. }
  107755. declare module BABYLON {
  107756. /**
  107757. * This defines an action helpful to play a defined sound on a triggered action.
  107758. */
  107759. export class PlaySoundAction extends Action {
  107760. private _sound;
  107761. /**
  107762. * Instantiate the action
  107763. * @param triggerOptions defines the trigger options
  107764. * @param sound defines the sound to play
  107765. * @param condition defines the trigger related conditions
  107766. */
  107767. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107768. /** @hidden */
  107769. _prepare(): void;
  107770. /**
  107771. * Execute the action and play the sound.
  107772. */
  107773. execute(): void;
  107774. /**
  107775. * Serializes the actions and its related information.
  107776. * @param parent defines the object to serialize in
  107777. * @returns the serialized object
  107778. */
  107779. serialize(parent: any): any;
  107780. }
  107781. /**
  107782. * This defines an action helpful to stop a defined sound on a triggered action.
  107783. */
  107784. export class StopSoundAction extends Action {
  107785. private _sound;
  107786. /**
  107787. * Instantiate the action
  107788. * @param triggerOptions defines the trigger options
  107789. * @param sound defines the sound to stop
  107790. * @param condition defines the trigger related conditions
  107791. */
  107792. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107793. /** @hidden */
  107794. _prepare(): void;
  107795. /**
  107796. * Execute the action and stop the sound.
  107797. */
  107798. execute(): void;
  107799. /**
  107800. * Serializes the actions and its related information.
  107801. * @param parent defines the object to serialize in
  107802. * @returns the serialized object
  107803. */
  107804. serialize(parent: any): any;
  107805. }
  107806. }
  107807. declare module BABYLON {
  107808. /**
  107809. * This defines an action responsible to change the value of a property
  107810. * by interpolating between its current value and the newly set one once triggered.
  107811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  107812. */
  107813. export class InterpolateValueAction extends Action {
  107814. /**
  107815. * Defines the path of the property where the value should be interpolated
  107816. */
  107817. propertyPath: string;
  107818. /**
  107819. * Defines the target value at the end of the interpolation.
  107820. */
  107821. value: any;
  107822. /**
  107823. * Defines the time it will take for the property to interpolate to the value.
  107824. */
  107825. duration: number;
  107826. /**
  107827. * Defines if the other scene animations should be stopped when the action has been triggered
  107828. */
  107829. stopOtherAnimations?: boolean;
  107830. /**
  107831. * Defines a callback raised once the interpolation animation has been done.
  107832. */
  107833. onInterpolationDone?: () => void;
  107834. /**
  107835. * Observable triggered once the interpolation animation has been done.
  107836. */
  107837. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  107838. private _target;
  107839. private _effectiveTarget;
  107840. private _property;
  107841. /**
  107842. * Instantiate the action
  107843. * @param triggerOptions defines the trigger options
  107844. * @param target defines the object containing the value to interpolate
  107845. * @param propertyPath defines the path to the property in the target object
  107846. * @param value defines the target value at the end of the interpolation
  107847. * @param duration deines the time it will take for the property to interpolate to the value.
  107848. * @param condition defines the trigger related conditions
  107849. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  107850. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  107851. */
  107852. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  107853. /** @hidden */
  107854. _prepare(): void;
  107855. /**
  107856. * Execute the action starts the value interpolation.
  107857. */
  107858. execute(): void;
  107859. /**
  107860. * Serializes the actions and its related information.
  107861. * @param parent defines the object to serialize in
  107862. * @returns the serialized object
  107863. */
  107864. serialize(parent: any): any;
  107865. }
  107866. }
  107867. declare module BABYLON {
  107868. /**
  107869. * Options allowed during the creation of a sound track.
  107870. */
  107871. export interface ISoundTrackOptions {
  107872. /**
  107873. * The volume the sound track should take during creation
  107874. */
  107875. volume?: number;
  107876. /**
  107877. * Define if the sound track is the main sound track of the scene
  107878. */
  107879. mainTrack?: boolean;
  107880. }
  107881. /**
  107882. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  107883. * It will be also used in a future release to apply effects on a specific track.
  107884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  107885. */
  107886. export class SoundTrack {
  107887. /**
  107888. * The unique identifier of the sound track in the scene.
  107889. */
  107890. id: number;
  107891. /**
  107892. * The list of sounds included in the sound track.
  107893. */
  107894. soundCollection: Array<Sound>;
  107895. private _outputAudioNode;
  107896. private _scene;
  107897. private _connectedAnalyser;
  107898. private _options;
  107899. private _isInitialized;
  107900. /**
  107901. * Creates a new sound track.
  107902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  107903. * @param scene Define the scene the sound track belongs to
  107904. * @param options
  107905. */
  107906. constructor(scene: Scene, options?: ISoundTrackOptions);
  107907. private _initializeSoundTrackAudioGraph;
  107908. /**
  107909. * Release the sound track and its associated resources
  107910. */
  107911. dispose(): void;
  107912. /**
  107913. * Adds a sound to this sound track
  107914. * @param sound define the cound to add
  107915. * @ignoreNaming
  107916. */
  107917. AddSound(sound: Sound): void;
  107918. /**
  107919. * Removes a sound to this sound track
  107920. * @param sound define the cound to remove
  107921. * @ignoreNaming
  107922. */
  107923. RemoveSound(sound: Sound): void;
  107924. /**
  107925. * Set a global volume for the full sound track.
  107926. * @param newVolume Define the new volume of the sound track
  107927. */
  107928. setVolume(newVolume: number): void;
  107929. /**
  107930. * Switch the panning model to HRTF:
  107931. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107933. */
  107934. switchPanningModelToHRTF(): void;
  107935. /**
  107936. * Switch the panning model to Equal Power:
  107937. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107939. */
  107940. switchPanningModelToEqualPower(): void;
  107941. /**
  107942. * Connect the sound track to an audio analyser allowing some amazing
  107943. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107944. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107945. * @param analyser The analyser to connect to the engine
  107946. */
  107947. connectToAnalyser(analyser: Analyser): void;
  107948. }
  107949. }
  107950. declare module BABYLON {
  107951. interface AbstractScene {
  107952. /**
  107953. * The list of sounds used in the scene.
  107954. */
  107955. sounds: Nullable<Array<Sound>>;
  107956. }
  107957. interface Scene {
  107958. /**
  107959. * @hidden
  107960. * Backing field
  107961. */
  107962. _mainSoundTrack: SoundTrack;
  107963. /**
  107964. * The main sound track played by the scene.
  107965. * It cotains your primary collection of sounds.
  107966. */
  107967. mainSoundTrack: SoundTrack;
  107968. /**
  107969. * The list of sound tracks added to the scene
  107970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107971. */
  107972. soundTracks: Nullable<Array<SoundTrack>>;
  107973. /**
  107974. * Gets a sound using a given name
  107975. * @param name defines the name to search for
  107976. * @return the found sound or null if not found at all.
  107977. */
  107978. getSoundByName(name: string): Nullable<Sound>;
  107979. /**
  107980. * Gets or sets if audio support is enabled
  107981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107982. */
  107983. audioEnabled: boolean;
  107984. /**
  107985. * Gets or sets if audio will be output to headphones
  107986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107987. */
  107988. headphone: boolean;
  107989. /**
  107990. * Gets or sets custom audio listener position provider
  107991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107992. */
  107993. audioListenerPositionProvider: Nullable<() => Vector3>;
  107994. /**
  107995. * Gets or sets a refresh rate when using 3D audio positioning
  107996. */
  107997. audioPositioningRefreshRate: number;
  107998. }
  107999. /**
  108000. * Defines the sound scene component responsible to manage any sounds
  108001. * in a given scene.
  108002. */
  108003. export class AudioSceneComponent implements ISceneSerializableComponent {
  108004. /**
  108005. * The component name helpfull to identify the component in the list of scene components.
  108006. */
  108007. readonly name: string;
  108008. /**
  108009. * The scene the component belongs to.
  108010. */
  108011. scene: Scene;
  108012. private _audioEnabled;
  108013. /**
  108014. * Gets whether audio is enabled or not.
  108015. * Please use related enable/disable method to switch state.
  108016. */
  108017. get audioEnabled(): boolean;
  108018. private _headphone;
  108019. /**
  108020. * Gets whether audio is outputing to headphone or not.
  108021. * Please use the according Switch methods to change output.
  108022. */
  108023. get headphone(): boolean;
  108024. /**
  108025. * Gets or sets a refresh rate when using 3D audio positioning
  108026. */
  108027. audioPositioningRefreshRate: number;
  108028. private _audioListenerPositionProvider;
  108029. /**
  108030. * Gets the current audio listener position provider
  108031. */
  108032. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108033. /**
  108034. * Sets a custom listener position for all sounds in the scene
  108035. * By default, this is the position of the first active camera
  108036. */
  108037. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108038. /**
  108039. * Creates a new instance of the component for the given scene
  108040. * @param scene Defines the scene to register the component in
  108041. */
  108042. constructor(scene: Scene);
  108043. /**
  108044. * Registers the component in a given scene
  108045. */
  108046. register(): void;
  108047. /**
  108048. * Rebuilds the elements related to this component in case of
  108049. * context lost for instance.
  108050. */
  108051. rebuild(): void;
  108052. /**
  108053. * Serializes the component data to the specified json object
  108054. * @param serializationObject The object to serialize to
  108055. */
  108056. serialize(serializationObject: any): void;
  108057. /**
  108058. * Adds all the elements from the container to the scene
  108059. * @param container the container holding the elements
  108060. */
  108061. addFromContainer(container: AbstractScene): void;
  108062. /**
  108063. * Removes all the elements in the container from the scene
  108064. * @param container contains the elements to remove
  108065. * @param dispose if the removed element should be disposed (default: false)
  108066. */
  108067. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108068. /**
  108069. * Disposes the component and the associated ressources.
  108070. */
  108071. dispose(): void;
  108072. /**
  108073. * Disables audio in the associated scene.
  108074. */
  108075. disableAudio(): void;
  108076. /**
  108077. * Enables audio in the associated scene.
  108078. */
  108079. enableAudio(): void;
  108080. /**
  108081. * Switch audio to headphone output.
  108082. */
  108083. switchAudioModeForHeadphones(): void;
  108084. /**
  108085. * Switch audio to normal speakers.
  108086. */
  108087. switchAudioModeForNormalSpeakers(): void;
  108088. private _cachedCameraDirection;
  108089. private _cachedCameraPosition;
  108090. private _lastCheck;
  108091. private _afterRender;
  108092. }
  108093. }
  108094. declare module BABYLON {
  108095. /**
  108096. * Wraps one or more Sound objects and selects one with random weight for playback.
  108097. */
  108098. export class WeightedSound {
  108099. /** When true a Sound will be selected and played when the current playing Sound completes. */
  108100. loop: boolean;
  108101. private _coneInnerAngle;
  108102. private _coneOuterAngle;
  108103. private _volume;
  108104. /** A Sound is currently playing. */
  108105. isPlaying: boolean;
  108106. /** A Sound is currently paused. */
  108107. isPaused: boolean;
  108108. private _sounds;
  108109. private _weights;
  108110. private _currentIndex?;
  108111. /**
  108112. * Creates a new WeightedSound from the list of sounds given.
  108113. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  108114. * @param sounds Array of Sounds that will be selected from.
  108115. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  108116. */
  108117. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  108118. /**
  108119. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  108120. */
  108121. get directionalConeInnerAngle(): number;
  108122. /**
  108123. * The size of cone in degress for a directional sound in which there will be no attenuation.
  108124. */
  108125. set directionalConeInnerAngle(value: number);
  108126. /**
  108127. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108128. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108129. */
  108130. get directionalConeOuterAngle(): number;
  108131. /**
  108132. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108133. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108134. */
  108135. set directionalConeOuterAngle(value: number);
  108136. /**
  108137. * Playback volume.
  108138. */
  108139. get volume(): number;
  108140. /**
  108141. * Playback volume.
  108142. */
  108143. set volume(value: number);
  108144. private _onended;
  108145. /**
  108146. * Suspend playback
  108147. */
  108148. pause(): void;
  108149. /**
  108150. * Stop playback
  108151. */
  108152. stop(): void;
  108153. /**
  108154. * Start playback.
  108155. * @param startOffset Position the clip head at a specific time in seconds.
  108156. */
  108157. play(startOffset?: number): void;
  108158. }
  108159. }
  108160. declare module BABYLON {
  108161. /**
  108162. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  108163. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108164. */
  108165. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  108166. /**
  108167. * Gets the name of the behavior.
  108168. */
  108169. get name(): string;
  108170. /**
  108171. * The easing function used by animations
  108172. */
  108173. static EasingFunction: BackEase;
  108174. /**
  108175. * The easing mode used by animations
  108176. */
  108177. static EasingMode: number;
  108178. /**
  108179. * The duration of the animation, in milliseconds
  108180. */
  108181. transitionDuration: number;
  108182. /**
  108183. * Length of the distance animated by the transition when lower radius is reached
  108184. */
  108185. lowerRadiusTransitionRange: number;
  108186. /**
  108187. * Length of the distance animated by the transition when upper radius is reached
  108188. */
  108189. upperRadiusTransitionRange: number;
  108190. private _autoTransitionRange;
  108191. /**
  108192. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108193. */
  108194. get autoTransitionRange(): boolean;
  108195. /**
  108196. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108197. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  108198. */
  108199. set autoTransitionRange(value: boolean);
  108200. private _attachedCamera;
  108201. private _onAfterCheckInputsObserver;
  108202. private _onMeshTargetChangedObserver;
  108203. /**
  108204. * Initializes the behavior.
  108205. */
  108206. init(): void;
  108207. /**
  108208. * Attaches the behavior to its arc rotate camera.
  108209. * @param camera Defines the camera to attach the behavior to
  108210. */
  108211. attach(camera: ArcRotateCamera): void;
  108212. /**
  108213. * Detaches the behavior from its current arc rotate camera.
  108214. */
  108215. detach(): void;
  108216. private _radiusIsAnimating;
  108217. private _radiusBounceTransition;
  108218. private _animatables;
  108219. private _cachedWheelPrecision;
  108220. /**
  108221. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  108222. * @param radiusLimit The limit to check against.
  108223. * @return Bool to indicate if at limit.
  108224. */
  108225. private _isRadiusAtLimit;
  108226. /**
  108227. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  108228. * @param radiusDelta The delta by which to animate to. Can be negative.
  108229. */
  108230. private _applyBoundRadiusAnimation;
  108231. /**
  108232. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  108233. */
  108234. protected _clearAnimationLocks(): void;
  108235. /**
  108236. * Stops and removes all animations that have been applied to the camera
  108237. */
  108238. stopAllAnimations(): void;
  108239. }
  108240. }
  108241. declare module BABYLON {
  108242. /**
  108243. * 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.
  108244. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  108245. */
  108246. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  108247. /**
  108248. * Gets the name of the behavior.
  108249. */
  108250. get name(): string;
  108251. private _mode;
  108252. private _radiusScale;
  108253. private _positionScale;
  108254. private _defaultElevation;
  108255. private _elevationReturnTime;
  108256. private _elevationReturnWaitTime;
  108257. private _zoomStopsAnimation;
  108258. private _framingTime;
  108259. /**
  108260. * The easing function used by animations
  108261. */
  108262. static EasingFunction: ExponentialEase;
  108263. /**
  108264. * The easing mode used by animations
  108265. */
  108266. static EasingMode: number;
  108267. /**
  108268. * Sets the current mode used by the behavior
  108269. */
  108270. set mode(mode: number);
  108271. /**
  108272. * Gets current mode used by the behavior.
  108273. */
  108274. get mode(): number;
  108275. /**
  108276. * Sets the scale applied to the radius (1 by default)
  108277. */
  108278. set radiusScale(radius: number);
  108279. /**
  108280. * Gets the scale applied to the radius
  108281. */
  108282. get radiusScale(): number;
  108283. /**
  108284. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108285. */
  108286. set positionScale(scale: number);
  108287. /**
  108288. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108289. */
  108290. get positionScale(): number;
  108291. /**
  108292. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108293. * behaviour is triggered, in radians.
  108294. */
  108295. set defaultElevation(elevation: number);
  108296. /**
  108297. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108298. * behaviour is triggered, in radians.
  108299. */
  108300. get defaultElevation(): number;
  108301. /**
  108302. * Sets the time (in milliseconds) taken to return to the default beta position.
  108303. * Negative value indicates camera should not return to default.
  108304. */
  108305. set elevationReturnTime(speed: number);
  108306. /**
  108307. * Gets the time (in milliseconds) taken to return to the default beta position.
  108308. * Negative value indicates camera should not return to default.
  108309. */
  108310. get elevationReturnTime(): number;
  108311. /**
  108312. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108313. */
  108314. set elevationReturnWaitTime(time: number);
  108315. /**
  108316. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108317. */
  108318. get elevationReturnWaitTime(): number;
  108319. /**
  108320. * Sets the flag that indicates if user zooming should stop animation.
  108321. */
  108322. set zoomStopsAnimation(flag: boolean);
  108323. /**
  108324. * Gets the flag that indicates if user zooming should stop animation.
  108325. */
  108326. get zoomStopsAnimation(): boolean;
  108327. /**
  108328. * Sets the transition time when framing the mesh, in milliseconds
  108329. */
  108330. set framingTime(time: number);
  108331. /**
  108332. * Gets the transition time when framing the mesh, in milliseconds
  108333. */
  108334. get framingTime(): number;
  108335. /**
  108336. * Define if the behavior should automatically change the configured
  108337. * camera limits and sensibilities.
  108338. */
  108339. autoCorrectCameraLimitsAndSensibility: boolean;
  108340. private _onPrePointerObservableObserver;
  108341. private _onAfterCheckInputsObserver;
  108342. private _onMeshTargetChangedObserver;
  108343. private _attachedCamera;
  108344. private _isPointerDown;
  108345. private _lastInteractionTime;
  108346. /**
  108347. * Initializes the behavior.
  108348. */
  108349. init(): void;
  108350. /**
  108351. * Attaches the behavior to its arc rotate camera.
  108352. * @param camera Defines the camera to attach the behavior to
  108353. */
  108354. attach(camera: ArcRotateCamera): void;
  108355. /**
  108356. * Detaches the behavior from its current arc rotate camera.
  108357. */
  108358. detach(): void;
  108359. private _animatables;
  108360. private _betaIsAnimating;
  108361. private _betaTransition;
  108362. private _radiusTransition;
  108363. private _vectorTransition;
  108364. /**
  108365. * Targets the given mesh and updates zoom level accordingly.
  108366. * @param mesh The mesh to target.
  108367. * @param radius Optional. If a cached radius position already exists, overrides default.
  108368. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108369. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108370. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108371. */
  108372. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108373. /**
  108374. * Targets the given mesh with its children and updates zoom level accordingly.
  108375. * @param mesh The mesh to target.
  108376. * @param radius Optional. If a cached radius position already exists, overrides default.
  108377. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108378. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108379. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108380. */
  108381. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108382. /**
  108383. * Targets the given meshes with their children and updates zoom level accordingly.
  108384. * @param meshes The mesh to target.
  108385. * @param radius Optional. If a cached radius position already exists, overrides default.
  108386. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108387. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108388. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108389. */
  108390. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108391. /**
  108392. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  108393. * @param minimumWorld Determines the smaller position of the bounding box extend
  108394. * @param maximumWorld Determines the bigger position of the bounding box extend
  108395. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108396. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108397. */
  108398. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108399. /**
  108400. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  108401. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  108402. * frustum width.
  108403. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  108404. * to fully enclose the mesh in the viewing frustum.
  108405. */
  108406. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  108407. /**
  108408. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  108409. * is automatically returned to its default position (expected to be above ground plane).
  108410. */
  108411. private _maintainCameraAboveGround;
  108412. /**
  108413. * Returns the frustum slope based on the canvas ratio and camera FOV
  108414. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  108415. */
  108416. private _getFrustumSlope;
  108417. /**
  108418. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  108419. */
  108420. private _clearAnimationLocks;
  108421. /**
  108422. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  108423. */
  108424. private _applyUserInteraction;
  108425. /**
  108426. * Stops and removes all animations that have been applied to the camera
  108427. */
  108428. stopAllAnimations(): void;
  108429. /**
  108430. * Gets a value indicating if the user is moving the camera
  108431. */
  108432. get isUserIsMoving(): boolean;
  108433. /**
  108434. * The camera can move all the way towards the mesh.
  108435. */
  108436. static IgnoreBoundsSizeMode: number;
  108437. /**
  108438. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  108439. */
  108440. static FitFrustumSidesMode: number;
  108441. }
  108442. }
  108443. declare module BABYLON {
  108444. /**
  108445. * Base class for Camera Pointer Inputs.
  108446. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  108447. * for example usage.
  108448. */
  108449. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  108450. /**
  108451. * Defines the camera the input is attached to.
  108452. */
  108453. abstract camera: Camera;
  108454. /**
  108455. * Whether keyboard modifier keys are pressed at time of last mouse event.
  108456. */
  108457. protected _altKey: boolean;
  108458. protected _ctrlKey: boolean;
  108459. protected _metaKey: boolean;
  108460. protected _shiftKey: boolean;
  108461. /**
  108462. * Which mouse buttons were pressed at time of last mouse event.
  108463. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  108464. */
  108465. protected _buttonsPressed: number;
  108466. /**
  108467. * Defines the buttons associated with the input to handle camera move.
  108468. */
  108469. buttons: number[];
  108470. /**
  108471. * Attach the input controls to a specific dom element to get the input from.
  108472. * @param element Defines the element the controls should be listened from
  108473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108474. */
  108475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108476. /**
  108477. * Detach the current controls from the specified dom element.
  108478. * @param element Defines the element to stop listening the inputs from
  108479. */
  108480. detachControl(element: Nullable<HTMLElement>): void;
  108481. /**
  108482. * Gets the class name of the current input.
  108483. * @returns the class name
  108484. */
  108485. getClassName(): string;
  108486. /**
  108487. * Get the friendly name associated with the input class.
  108488. * @returns the input friendly name
  108489. */
  108490. getSimpleName(): string;
  108491. /**
  108492. * Called on pointer POINTERDOUBLETAP event.
  108493. * Override this method to provide functionality on POINTERDOUBLETAP event.
  108494. */
  108495. protected onDoubleTap(type: string): void;
  108496. /**
  108497. * Called on pointer POINTERMOVE event if only a single touch is active.
  108498. * Override this method to provide functionality.
  108499. */
  108500. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108501. /**
  108502. * Called on pointer POINTERMOVE event if multiple touches are active.
  108503. * Override this method to provide functionality.
  108504. */
  108505. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108506. /**
  108507. * Called on JS contextmenu event.
  108508. * Override this method to provide functionality.
  108509. */
  108510. protected onContextMenu(evt: PointerEvent): void;
  108511. /**
  108512. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108513. * press.
  108514. * Override this method to provide functionality.
  108515. */
  108516. protected onButtonDown(evt: PointerEvent): void;
  108517. /**
  108518. * Called each time a new POINTERUP event occurs. Ie, for each button
  108519. * release.
  108520. * Override this method to provide functionality.
  108521. */
  108522. protected onButtonUp(evt: PointerEvent): void;
  108523. /**
  108524. * Called when window becomes inactive.
  108525. * Override this method to provide functionality.
  108526. */
  108527. protected onLostFocus(): void;
  108528. private _pointerInput;
  108529. private _observer;
  108530. private _onLostFocus;
  108531. private pointA;
  108532. private pointB;
  108533. }
  108534. }
  108535. declare module BABYLON {
  108536. /**
  108537. * Manage the pointers inputs to control an arc rotate camera.
  108538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108539. */
  108540. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  108541. /**
  108542. * Defines the camera the input is attached to.
  108543. */
  108544. camera: ArcRotateCamera;
  108545. /**
  108546. * Gets the class name of the current input.
  108547. * @returns the class name
  108548. */
  108549. getClassName(): string;
  108550. /**
  108551. * Defines the buttons associated with the input to handle camera move.
  108552. */
  108553. buttons: number[];
  108554. /**
  108555. * Defines the pointer angular sensibility along the X axis or how fast is
  108556. * the camera rotating.
  108557. */
  108558. angularSensibilityX: number;
  108559. /**
  108560. * Defines the pointer angular sensibility along the Y axis or how fast is
  108561. * the camera rotating.
  108562. */
  108563. angularSensibilityY: number;
  108564. /**
  108565. * Defines the pointer pinch precision or how fast is the camera zooming.
  108566. */
  108567. pinchPrecision: number;
  108568. /**
  108569. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108570. * from 0.
  108571. * It defines the percentage of current camera.radius to use as delta when
  108572. * pinch zoom is used.
  108573. */
  108574. pinchDeltaPercentage: number;
  108575. /**
  108576. * Defines the pointer panning sensibility or how fast is the camera moving.
  108577. */
  108578. panningSensibility: number;
  108579. /**
  108580. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  108581. */
  108582. multiTouchPanning: boolean;
  108583. /**
  108584. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  108585. * zoom (pinch) through multitouch.
  108586. */
  108587. multiTouchPanAndZoom: boolean;
  108588. /**
  108589. * Revers pinch action direction.
  108590. */
  108591. pinchInwards: boolean;
  108592. private _isPanClick;
  108593. private _twoFingerActivityCount;
  108594. private _isPinching;
  108595. /**
  108596. * Called on pointer POINTERMOVE event if only a single touch is active.
  108597. */
  108598. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108599. /**
  108600. * Called on pointer POINTERDOUBLETAP event.
  108601. */
  108602. protected onDoubleTap(type: string): void;
  108603. /**
  108604. * Called on pointer POINTERMOVE event if multiple touches are active.
  108605. */
  108606. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108607. /**
  108608. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108609. * press.
  108610. */
  108611. protected onButtonDown(evt: PointerEvent): void;
  108612. /**
  108613. * Called each time a new POINTERUP event occurs. Ie, for each button
  108614. * release.
  108615. */
  108616. protected onButtonUp(evt: PointerEvent): void;
  108617. /**
  108618. * Called when window becomes inactive.
  108619. */
  108620. protected onLostFocus(): void;
  108621. }
  108622. }
  108623. declare module BABYLON {
  108624. /**
  108625. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  108626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108627. */
  108628. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  108629. /**
  108630. * Defines the camera the input is attached to.
  108631. */
  108632. camera: ArcRotateCamera;
  108633. /**
  108634. * Defines the list of key codes associated with the up action (increase alpha)
  108635. */
  108636. keysUp: number[];
  108637. /**
  108638. * Defines the list of key codes associated with the down action (decrease alpha)
  108639. */
  108640. keysDown: number[];
  108641. /**
  108642. * Defines the list of key codes associated with the left action (increase beta)
  108643. */
  108644. keysLeft: number[];
  108645. /**
  108646. * Defines the list of key codes associated with the right action (decrease beta)
  108647. */
  108648. keysRight: number[];
  108649. /**
  108650. * Defines the list of key codes associated with the reset action.
  108651. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  108652. */
  108653. keysReset: number[];
  108654. /**
  108655. * Defines the panning sensibility of the inputs.
  108656. * (How fast is the camera paning)
  108657. */
  108658. panningSensibility: number;
  108659. /**
  108660. * Defines the zooming sensibility of the inputs.
  108661. * (How fast is the camera zooming)
  108662. */
  108663. zoomingSensibility: number;
  108664. /**
  108665. * Defines wether maintaining the alt key down switch the movement mode from
  108666. * orientation to zoom.
  108667. */
  108668. useAltToZoom: boolean;
  108669. /**
  108670. * Rotation speed of the camera
  108671. */
  108672. angularSpeed: number;
  108673. private _keys;
  108674. private _ctrlPressed;
  108675. private _altPressed;
  108676. private _onCanvasBlurObserver;
  108677. private _onKeyboardObserver;
  108678. private _engine;
  108679. private _scene;
  108680. /**
  108681. * Attach the input controls to a specific dom element to get the input from.
  108682. * @param element Defines the element the controls should be listened from
  108683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108684. */
  108685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108686. /**
  108687. * Detach the current controls from the specified dom element.
  108688. * @param element Defines the element to stop listening the inputs from
  108689. */
  108690. detachControl(element: Nullable<HTMLElement>): void;
  108691. /**
  108692. * Update the current camera state depending on the inputs that have been used this frame.
  108693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108694. */
  108695. checkInputs(): void;
  108696. /**
  108697. * Gets the class name of the current intput.
  108698. * @returns the class name
  108699. */
  108700. getClassName(): string;
  108701. /**
  108702. * Get the friendly name associated with the input class.
  108703. * @returns the input friendly name
  108704. */
  108705. getSimpleName(): string;
  108706. }
  108707. }
  108708. declare module BABYLON {
  108709. /**
  108710. * Manage the mouse wheel inputs to control an arc rotate camera.
  108711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108712. */
  108713. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  108714. /**
  108715. * Defines the camera the input is attached to.
  108716. */
  108717. camera: ArcRotateCamera;
  108718. /**
  108719. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108720. */
  108721. wheelPrecision: number;
  108722. /**
  108723. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108724. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108725. */
  108726. wheelDeltaPercentage: number;
  108727. private _wheel;
  108728. private _observer;
  108729. private computeDeltaFromMouseWheelLegacyEvent;
  108730. /**
  108731. * Attach the input controls to a specific dom element to get the input from.
  108732. * @param element Defines the element the controls should be listened from
  108733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108734. */
  108735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108736. /**
  108737. * Detach the current controls from the specified dom element.
  108738. * @param element Defines the element to stop listening the inputs from
  108739. */
  108740. detachControl(element: Nullable<HTMLElement>): void;
  108741. /**
  108742. * Gets the class name of the current intput.
  108743. * @returns the class name
  108744. */
  108745. getClassName(): string;
  108746. /**
  108747. * Get the friendly name associated with the input class.
  108748. * @returns the input friendly name
  108749. */
  108750. getSimpleName(): string;
  108751. }
  108752. }
  108753. declare module BABYLON {
  108754. /**
  108755. * Default Inputs manager for the ArcRotateCamera.
  108756. * It groups all the default supported inputs for ease of use.
  108757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108758. */
  108759. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  108760. /**
  108761. * Instantiates a new ArcRotateCameraInputsManager.
  108762. * @param camera Defines the camera the inputs belong to
  108763. */
  108764. constructor(camera: ArcRotateCamera);
  108765. /**
  108766. * Add mouse wheel input support to the input manager.
  108767. * @returns the current input manager
  108768. */
  108769. addMouseWheel(): ArcRotateCameraInputsManager;
  108770. /**
  108771. * Add pointers input support to the input manager.
  108772. * @returns the current input manager
  108773. */
  108774. addPointers(): ArcRotateCameraInputsManager;
  108775. /**
  108776. * Add keyboard input support to the input manager.
  108777. * @returns the current input manager
  108778. */
  108779. addKeyboard(): ArcRotateCameraInputsManager;
  108780. }
  108781. }
  108782. declare module BABYLON {
  108783. /**
  108784. * This represents an orbital type of camera.
  108785. *
  108786. * 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.
  108787. * 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.
  108788. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  108789. */
  108790. export class ArcRotateCamera extends TargetCamera {
  108791. /**
  108792. * Defines the rotation angle of the camera along the longitudinal axis.
  108793. */
  108794. alpha: number;
  108795. /**
  108796. * Defines the rotation angle of the camera along the latitudinal axis.
  108797. */
  108798. beta: number;
  108799. /**
  108800. * Defines the radius of the camera from it s target point.
  108801. */
  108802. radius: number;
  108803. protected _target: Vector3;
  108804. protected _targetHost: Nullable<AbstractMesh>;
  108805. /**
  108806. * Defines the target point of the camera.
  108807. * The camera looks towards it form the radius distance.
  108808. */
  108809. get target(): Vector3;
  108810. set target(value: Vector3);
  108811. /**
  108812. * Define the current local position of the camera in the scene
  108813. */
  108814. get position(): Vector3;
  108815. set position(newPosition: Vector3);
  108816. protected _upVector: Vector3;
  108817. protected _upToYMatrix: Matrix;
  108818. protected _YToUpMatrix: Matrix;
  108819. /**
  108820. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  108821. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  108822. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  108823. */
  108824. set upVector(vec: Vector3);
  108825. get upVector(): Vector3;
  108826. /**
  108827. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  108828. */
  108829. setMatUp(): void;
  108830. /**
  108831. * Current inertia value on the longitudinal axis.
  108832. * The bigger this number the longer it will take for the camera to stop.
  108833. */
  108834. inertialAlphaOffset: number;
  108835. /**
  108836. * Current inertia value on the latitudinal axis.
  108837. * The bigger this number the longer it will take for the camera to stop.
  108838. */
  108839. inertialBetaOffset: number;
  108840. /**
  108841. * Current inertia value on the radius axis.
  108842. * The bigger this number the longer it will take for the camera to stop.
  108843. */
  108844. inertialRadiusOffset: number;
  108845. /**
  108846. * Minimum allowed angle on the longitudinal axis.
  108847. * This can help limiting how the Camera is able to move in the scene.
  108848. */
  108849. lowerAlphaLimit: Nullable<number>;
  108850. /**
  108851. * Maximum allowed angle on the longitudinal axis.
  108852. * This can help limiting how the Camera is able to move in the scene.
  108853. */
  108854. upperAlphaLimit: Nullable<number>;
  108855. /**
  108856. * Minimum allowed angle on the latitudinal axis.
  108857. * This can help limiting how the Camera is able to move in the scene.
  108858. */
  108859. lowerBetaLimit: number;
  108860. /**
  108861. * Maximum allowed angle on the latitudinal axis.
  108862. * This can help limiting how the Camera is able to move in the scene.
  108863. */
  108864. upperBetaLimit: number;
  108865. /**
  108866. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  108867. * This can help limiting how the Camera is able to move in the scene.
  108868. */
  108869. lowerRadiusLimit: Nullable<number>;
  108870. /**
  108871. * Maximum allowed distance of the camera to the target (The camera can not get further).
  108872. * This can help limiting how the Camera is able to move in the scene.
  108873. */
  108874. upperRadiusLimit: Nullable<number>;
  108875. /**
  108876. * Defines the current inertia value used during panning of the camera along the X axis.
  108877. */
  108878. inertialPanningX: number;
  108879. /**
  108880. * Defines the current inertia value used during panning of the camera along the Y axis.
  108881. */
  108882. inertialPanningY: number;
  108883. /**
  108884. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  108885. * Basically if your fingers moves away from more than this distance you will be considered
  108886. * in pinch mode.
  108887. */
  108888. pinchToPanMaxDistance: number;
  108889. /**
  108890. * Defines the maximum distance the camera can pan.
  108891. * This could help keeping the cammera always in your scene.
  108892. */
  108893. panningDistanceLimit: Nullable<number>;
  108894. /**
  108895. * Defines the target of the camera before paning.
  108896. */
  108897. panningOriginTarget: Vector3;
  108898. /**
  108899. * Defines the value of the inertia used during panning.
  108900. * 0 would mean stop inertia and one would mean no decelleration at all.
  108901. */
  108902. panningInertia: number;
  108903. /**
  108904. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  108905. */
  108906. get angularSensibilityX(): number;
  108907. set angularSensibilityX(value: number);
  108908. /**
  108909. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  108910. */
  108911. get angularSensibilityY(): number;
  108912. set angularSensibilityY(value: number);
  108913. /**
  108914. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  108915. */
  108916. get pinchPrecision(): number;
  108917. set pinchPrecision(value: number);
  108918. /**
  108919. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  108920. * It will be used instead of pinchDeltaPrecision if different from 0.
  108921. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  108922. */
  108923. get pinchDeltaPercentage(): number;
  108924. set pinchDeltaPercentage(value: number);
  108925. /**
  108926. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  108927. */
  108928. get panningSensibility(): number;
  108929. set panningSensibility(value: number);
  108930. /**
  108931. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  108932. */
  108933. get keysUp(): number[];
  108934. set keysUp(value: number[]);
  108935. /**
  108936. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  108937. */
  108938. get keysDown(): number[];
  108939. set keysDown(value: number[]);
  108940. /**
  108941. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  108942. */
  108943. get keysLeft(): number[];
  108944. set keysLeft(value: number[]);
  108945. /**
  108946. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  108947. */
  108948. get keysRight(): number[];
  108949. set keysRight(value: number[]);
  108950. /**
  108951. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108952. */
  108953. get wheelPrecision(): number;
  108954. set wheelPrecision(value: number);
  108955. /**
  108956. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  108957. * It will be used instead of pinchDeltaPrecision if different from 0.
  108958. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  108959. */
  108960. get wheelDeltaPercentage(): number;
  108961. set wheelDeltaPercentage(value: number);
  108962. /**
  108963. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  108964. */
  108965. zoomOnFactor: number;
  108966. /**
  108967. * Defines a screen offset for the camera position.
  108968. */
  108969. targetScreenOffset: Vector2;
  108970. /**
  108971. * Allows the camera to be completely reversed.
  108972. * If false the camera can not arrive upside down.
  108973. */
  108974. allowUpsideDown: boolean;
  108975. /**
  108976. * Define if double tap/click is used to restore the previously saved state of the camera.
  108977. */
  108978. useInputToRestoreState: boolean;
  108979. /** @hidden */
  108980. _viewMatrix: Matrix;
  108981. /** @hidden */
  108982. _useCtrlForPanning: boolean;
  108983. /** @hidden */
  108984. _panningMouseButton: number;
  108985. /**
  108986. * Defines the input associated to the camera.
  108987. */
  108988. inputs: ArcRotateCameraInputsManager;
  108989. /** @hidden */
  108990. _reset: () => void;
  108991. /**
  108992. * Defines the allowed panning axis.
  108993. */
  108994. panningAxis: Vector3;
  108995. protected _localDirection: Vector3;
  108996. protected _transformedDirection: Vector3;
  108997. private _bouncingBehavior;
  108998. /**
  108999. * Gets the bouncing behavior of the camera if it has been enabled.
  109000. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109001. */
  109002. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109003. /**
  109004. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109005. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109006. */
  109007. get useBouncingBehavior(): boolean;
  109008. set useBouncingBehavior(value: boolean);
  109009. private _framingBehavior;
  109010. /**
  109011. * Gets the framing behavior of the camera if it has been enabled.
  109012. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109013. */
  109014. get framingBehavior(): Nullable<FramingBehavior>;
  109015. /**
  109016. * Defines if the framing behavior of the camera is enabled on the camera.
  109017. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109018. */
  109019. get useFramingBehavior(): boolean;
  109020. set useFramingBehavior(value: boolean);
  109021. private _autoRotationBehavior;
  109022. /**
  109023. * Gets the auto rotation behavior of the camera if it has been enabled.
  109024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109025. */
  109026. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109027. /**
  109028. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109029. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109030. */
  109031. get useAutoRotationBehavior(): boolean;
  109032. set useAutoRotationBehavior(value: boolean);
  109033. /**
  109034. * Observable triggered when the mesh target has been changed on the camera.
  109035. */
  109036. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109037. /**
  109038. * Event raised when the camera is colliding with a mesh.
  109039. */
  109040. onCollide: (collidedMesh: AbstractMesh) => void;
  109041. /**
  109042. * Defines whether the camera should check collision with the objects oh the scene.
  109043. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109044. */
  109045. checkCollisions: boolean;
  109046. /**
  109047. * Defines the collision radius of the camera.
  109048. * This simulates a sphere around the camera.
  109049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109050. */
  109051. collisionRadius: Vector3;
  109052. protected _collider: Collider;
  109053. protected _previousPosition: Vector3;
  109054. protected _collisionVelocity: Vector3;
  109055. protected _newPosition: Vector3;
  109056. protected _previousAlpha: number;
  109057. protected _previousBeta: number;
  109058. protected _previousRadius: number;
  109059. protected _collisionTriggered: boolean;
  109060. protected _targetBoundingCenter: Nullable<Vector3>;
  109061. private _computationVector;
  109062. /**
  109063. * Instantiates a new ArcRotateCamera in a given scene
  109064. * @param name Defines the name of the camera
  109065. * @param alpha Defines the camera rotation along the logitudinal axis
  109066. * @param beta Defines the camera rotation along the latitudinal axis
  109067. * @param radius Defines the camera distance from its target
  109068. * @param target Defines the camera target
  109069. * @param scene Defines the scene the camera belongs to
  109070. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109071. */
  109072. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109073. /** @hidden */
  109074. _initCache(): void;
  109075. /** @hidden */
  109076. _updateCache(ignoreParentClass?: boolean): void;
  109077. protected _getTargetPosition(): Vector3;
  109078. private _storedAlpha;
  109079. private _storedBeta;
  109080. private _storedRadius;
  109081. private _storedTarget;
  109082. private _storedTargetScreenOffset;
  109083. /**
  109084. * Stores the current state of the camera (alpha, beta, radius and target)
  109085. * @returns the camera itself
  109086. */
  109087. storeState(): Camera;
  109088. /**
  109089. * @hidden
  109090. * Restored camera state. You must call storeState() first
  109091. */
  109092. _restoreStateValues(): boolean;
  109093. /** @hidden */
  109094. _isSynchronizedViewMatrix(): boolean;
  109095. /**
  109096. * Attached controls to the current camera.
  109097. * @param element Defines the element the controls should be listened from
  109098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109099. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  109100. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  109101. */
  109102. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  109103. /**
  109104. * Detach the current controls from the camera.
  109105. * The camera will stop reacting to inputs.
  109106. * @param element Defines the element to stop listening the inputs from
  109107. */
  109108. detachControl(element: HTMLElement): void;
  109109. /** @hidden */
  109110. _checkInputs(): void;
  109111. protected _checkLimits(): void;
  109112. /**
  109113. * Rebuilds angles (alpha, beta) and radius from the give position and target
  109114. */
  109115. rebuildAnglesAndRadius(): void;
  109116. /**
  109117. * Use a position to define the current camera related information like alpha, beta and radius
  109118. * @param position Defines the position to set the camera at
  109119. */
  109120. setPosition(position: Vector3): void;
  109121. /**
  109122. * Defines the target the camera should look at.
  109123. * This will automatically adapt alpha beta and radius to fit within the new target.
  109124. * @param target Defines the new target as a Vector or a mesh
  109125. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  109126. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  109127. */
  109128. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  109129. /** @hidden */
  109130. _getViewMatrix(): Matrix;
  109131. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  109132. /**
  109133. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  109134. * @param meshes Defines the mesh to zoom on
  109135. * @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)
  109136. */
  109137. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  109138. /**
  109139. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  109140. * The target will be changed but the radius
  109141. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  109142. * @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)
  109143. */
  109144. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  109145. min: Vector3;
  109146. max: Vector3;
  109147. distance: number;
  109148. }, doNotUpdateMaxZ?: boolean): void;
  109149. /**
  109150. * @override
  109151. * Override Camera.createRigCamera
  109152. */
  109153. createRigCamera(name: string, cameraIndex: number): Camera;
  109154. /**
  109155. * @hidden
  109156. * @override
  109157. * Override Camera._updateRigCameras
  109158. */
  109159. _updateRigCameras(): void;
  109160. /**
  109161. * Destroy the camera and release the current resources hold by it.
  109162. */
  109163. dispose(): void;
  109164. /**
  109165. * Gets the current object class name.
  109166. * @return the class name
  109167. */
  109168. getClassName(): string;
  109169. }
  109170. }
  109171. declare module BABYLON {
  109172. /**
  109173. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  109174. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109175. */
  109176. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  109177. /**
  109178. * Gets the name of the behavior.
  109179. */
  109180. get name(): string;
  109181. private _zoomStopsAnimation;
  109182. private _idleRotationSpeed;
  109183. private _idleRotationWaitTime;
  109184. private _idleRotationSpinupTime;
  109185. /**
  109186. * Sets the flag that indicates if user zooming should stop animation.
  109187. */
  109188. set zoomStopsAnimation(flag: boolean);
  109189. /**
  109190. * Gets the flag that indicates if user zooming should stop animation.
  109191. */
  109192. get zoomStopsAnimation(): boolean;
  109193. /**
  109194. * Sets the default speed at which the camera rotates around the model.
  109195. */
  109196. set idleRotationSpeed(speed: number);
  109197. /**
  109198. * Gets the default speed at which the camera rotates around the model.
  109199. */
  109200. get idleRotationSpeed(): number;
  109201. /**
  109202. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  109203. */
  109204. set idleRotationWaitTime(time: number);
  109205. /**
  109206. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  109207. */
  109208. get idleRotationWaitTime(): number;
  109209. /**
  109210. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109211. */
  109212. set idleRotationSpinupTime(time: number);
  109213. /**
  109214. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109215. */
  109216. get idleRotationSpinupTime(): number;
  109217. /**
  109218. * Gets a value indicating if the camera is currently rotating because of this behavior
  109219. */
  109220. get rotationInProgress(): boolean;
  109221. private _onPrePointerObservableObserver;
  109222. private _onAfterCheckInputsObserver;
  109223. private _attachedCamera;
  109224. private _isPointerDown;
  109225. private _lastFrameTime;
  109226. private _lastInteractionTime;
  109227. private _cameraRotationSpeed;
  109228. /**
  109229. * Initializes the behavior.
  109230. */
  109231. init(): void;
  109232. /**
  109233. * Attaches the behavior to its arc rotate camera.
  109234. * @param camera Defines the camera to attach the behavior to
  109235. */
  109236. attach(camera: ArcRotateCamera): void;
  109237. /**
  109238. * Detaches the behavior from its current arc rotate camera.
  109239. */
  109240. detach(): void;
  109241. /**
  109242. * Returns true if user is scrolling.
  109243. * @return true if user is scrolling.
  109244. */
  109245. private _userIsZooming;
  109246. private _lastFrameRadius;
  109247. private _shouldAnimationStopForInteraction;
  109248. /**
  109249. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109250. */
  109251. private _applyUserInteraction;
  109252. private _userIsMoving;
  109253. }
  109254. }
  109255. declare module BABYLON {
  109256. /**
  109257. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  109258. */
  109259. export class AttachToBoxBehavior implements Behavior<Mesh> {
  109260. private ui;
  109261. /**
  109262. * The name of the behavior
  109263. */
  109264. name: string;
  109265. /**
  109266. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  109267. */
  109268. distanceAwayFromFace: number;
  109269. /**
  109270. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  109271. */
  109272. distanceAwayFromBottomOfFace: number;
  109273. private _faceVectors;
  109274. private _target;
  109275. private _scene;
  109276. private _onRenderObserver;
  109277. private _tmpMatrix;
  109278. private _tmpVector;
  109279. /**
  109280. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  109281. * @param ui The transform node that should be attched to the mesh
  109282. */
  109283. constructor(ui: TransformNode);
  109284. /**
  109285. * Initializes the behavior
  109286. */
  109287. init(): void;
  109288. private _closestFace;
  109289. private _zeroVector;
  109290. private _lookAtTmpMatrix;
  109291. private _lookAtToRef;
  109292. /**
  109293. * Attaches the AttachToBoxBehavior to the passed in mesh
  109294. * @param target The mesh that the specified node will be attached to
  109295. */
  109296. attach(target: Mesh): void;
  109297. /**
  109298. * Detaches the behavior from the mesh
  109299. */
  109300. detach(): void;
  109301. }
  109302. }
  109303. declare module BABYLON {
  109304. /**
  109305. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  109306. */
  109307. export class FadeInOutBehavior implements Behavior<Mesh> {
  109308. /**
  109309. * Time in milliseconds to delay before fading in (Default: 0)
  109310. */
  109311. delay: number;
  109312. /**
  109313. * Time in milliseconds for the mesh to fade in (Default: 300)
  109314. */
  109315. fadeInTime: number;
  109316. private _millisecondsPerFrame;
  109317. private _hovered;
  109318. private _hoverValue;
  109319. private _ownerNode;
  109320. /**
  109321. * Instatiates the FadeInOutBehavior
  109322. */
  109323. constructor();
  109324. /**
  109325. * The name of the behavior
  109326. */
  109327. get name(): string;
  109328. /**
  109329. * Initializes the behavior
  109330. */
  109331. init(): void;
  109332. /**
  109333. * Attaches the fade behavior on the passed in mesh
  109334. * @param ownerNode The mesh that will be faded in/out once attached
  109335. */
  109336. attach(ownerNode: Mesh): void;
  109337. /**
  109338. * Detaches the behavior from the mesh
  109339. */
  109340. detach(): void;
  109341. /**
  109342. * Triggers the mesh to begin fading in or out
  109343. * @param value if the object should fade in or out (true to fade in)
  109344. */
  109345. fadeIn(value: boolean): void;
  109346. private _update;
  109347. private _setAllVisibility;
  109348. }
  109349. }
  109350. declare module BABYLON {
  109351. /**
  109352. * Class containing a set of static utilities functions for managing Pivots
  109353. * @hidden
  109354. */
  109355. export class PivotTools {
  109356. private static _PivotCached;
  109357. private static _OldPivotPoint;
  109358. private static _PivotTranslation;
  109359. private static _PivotTmpVector;
  109360. /** @hidden */
  109361. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  109362. /** @hidden */
  109363. static _RestorePivotPoint(mesh: AbstractMesh): void;
  109364. }
  109365. }
  109366. declare module BABYLON {
  109367. /**
  109368. * Class containing static functions to help procedurally build meshes
  109369. */
  109370. export class PlaneBuilder {
  109371. /**
  109372. * Creates a plane mesh
  109373. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109374. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109375. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109379. * @param name defines the name of the mesh
  109380. * @param options defines the options used to create the mesh
  109381. * @param scene defines the hosting scene
  109382. * @returns the plane mesh
  109383. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109384. */
  109385. static CreatePlane(name: string, options: {
  109386. size?: number;
  109387. width?: number;
  109388. height?: number;
  109389. sideOrientation?: number;
  109390. frontUVs?: Vector4;
  109391. backUVs?: Vector4;
  109392. updatable?: boolean;
  109393. sourcePlane?: Plane;
  109394. }, scene?: Nullable<Scene>): Mesh;
  109395. }
  109396. }
  109397. declare module BABYLON {
  109398. /**
  109399. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  109400. */
  109401. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  109402. private static _AnyMouseID;
  109403. /**
  109404. * Abstract mesh the behavior is set on
  109405. */
  109406. attachedNode: AbstractMesh;
  109407. private _dragPlane;
  109408. private _scene;
  109409. private _pointerObserver;
  109410. private _beforeRenderObserver;
  109411. private static _planeScene;
  109412. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  109413. /**
  109414. * 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)
  109415. */
  109416. maxDragAngle: number;
  109417. /**
  109418. * @hidden
  109419. */
  109420. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  109421. /**
  109422. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109423. */
  109424. currentDraggingPointerID: number;
  109425. /**
  109426. * The last position where the pointer hit the drag plane in world space
  109427. */
  109428. lastDragPosition: Vector3;
  109429. /**
  109430. * If the behavior is currently in a dragging state
  109431. */
  109432. dragging: boolean;
  109433. /**
  109434. * 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)
  109435. */
  109436. dragDeltaRatio: number;
  109437. /**
  109438. * If the drag plane orientation should be updated during the dragging (Default: true)
  109439. */
  109440. updateDragPlane: boolean;
  109441. private _debugMode;
  109442. private _moving;
  109443. /**
  109444. * Fires each time the attached mesh is dragged with the pointer
  109445. * * delta between last drag position and current drag position in world space
  109446. * * dragDistance along the drag axis
  109447. * * dragPlaneNormal normal of the current drag plane used during the drag
  109448. * * dragPlanePoint in world space where the drag intersects the drag plane
  109449. */
  109450. onDragObservable: Observable<{
  109451. delta: Vector3;
  109452. dragPlanePoint: Vector3;
  109453. dragPlaneNormal: Vector3;
  109454. dragDistance: number;
  109455. pointerId: number;
  109456. }>;
  109457. /**
  109458. * Fires each time a drag begins (eg. mouse down on mesh)
  109459. */
  109460. onDragStartObservable: Observable<{
  109461. dragPlanePoint: Vector3;
  109462. pointerId: number;
  109463. }>;
  109464. /**
  109465. * Fires each time a drag ends (eg. mouse release after drag)
  109466. */
  109467. onDragEndObservable: Observable<{
  109468. dragPlanePoint: Vector3;
  109469. pointerId: number;
  109470. }>;
  109471. /**
  109472. * If the attached mesh should be moved when dragged
  109473. */
  109474. moveAttached: boolean;
  109475. /**
  109476. * If the drag behavior will react to drag events (Default: true)
  109477. */
  109478. enabled: boolean;
  109479. /**
  109480. * If pointer events should start and release the drag (Default: true)
  109481. */
  109482. startAndReleaseDragOnPointerEvents: boolean;
  109483. /**
  109484. * If camera controls should be detached during the drag
  109485. */
  109486. detachCameraControls: boolean;
  109487. /**
  109488. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  109489. */
  109490. useObjectOrienationForDragging: boolean;
  109491. private _options;
  109492. /**
  109493. * Gets the options used by the behavior
  109494. */
  109495. get options(): {
  109496. dragAxis?: Vector3;
  109497. dragPlaneNormal?: Vector3;
  109498. };
  109499. /**
  109500. * Sets the options used by the behavior
  109501. */
  109502. set options(options: {
  109503. dragAxis?: Vector3;
  109504. dragPlaneNormal?: Vector3;
  109505. });
  109506. /**
  109507. * Creates a pointer drag behavior that can be attached to a mesh
  109508. * @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)
  109509. */
  109510. constructor(options?: {
  109511. dragAxis?: Vector3;
  109512. dragPlaneNormal?: Vector3;
  109513. });
  109514. /**
  109515. * Predicate to determine if it is valid to move the object to a new position when it is moved
  109516. */
  109517. validateDrag: (targetPosition: Vector3) => boolean;
  109518. /**
  109519. * The name of the behavior
  109520. */
  109521. get name(): string;
  109522. /**
  109523. * Initializes the behavior
  109524. */
  109525. init(): void;
  109526. private _tmpVector;
  109527. private _alternatePickedPoint;
  109528. private _worldDragAxis;
  109529. private _targetPosition;
  109530. private _attachedElement;
  109531. /**
  109532. * Attaches the drag behavior the passed in mesh
  109533. * @param ownerNode The mesh that will be dragged around once attached
  109534. * @param predicate Predicate to use for pick filtering
  109535. */
  109536. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  109537. /**
  109538. * Force relase the drag action by code.
  109539. */
  109540. releaseDrag(): void;
  109541. private _startDragRay;
  109542. private _lastPointerRay;
  109543. /**
  109544. * Simulates the start of a pointer drag event on the behavior
  109545. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  109546. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  109547. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  109548. */
  109549. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  109550. private _startDrag;
  109551. private _dragDelta;
  109552. private _moveDrag;
  109553. private _pickWithRayOnDragPlane;
  109554. private _pointA;
  109555. private _pointB;
  109556. private _pointC;
  109557. private _lineA;
  109558. private _lineB;
  109559. private _localAxis;
  109560. private _lookAt;
  109561. private _updateDragPlanePosition;
  109562. /**
  109563. * Detaches the behavior from the mesh
  109564. */
  109565. detach(): void;
  109566. }
  109567. }
  109568. declare module BABYLON {
  109569. /**
  109570. * A behavior that when attached to a mesh will allow the mesh to be scaled
  109571. */
  109572. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  109573. private _dragBehaviorA;
  109574. private _dragBehaviorB;
  109575. private _startDistance;
  109576. private _initialScale;
  109577. private _targetScale;
  109578. private _ownerNode;
  109579. private _sceneRenderObserver;
  109580. /**
  109581. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  109582. */
  109583. constructor();
  109584. /**
  109585. * The name of the behavior
  109586. */
  109587. get name(): string;
  109588. /**
  109589. * Initializes the behavior
  109590. */
  109591. init(): void;
  109592. private _getCurrentDistance;
  109593. /**
  109594. * Attaches the scale behavior the passed in mesh
  109595. * @param ownerNode The mesh that will be scaled around once attached
  109596. */
  109597. attach(ownerNode: Mesh): void;
  109598. /**
  109599. * Detaches the behavior from the mesh
  109600. */
  109601. detach(): void;
  109602. }
  109603. }
  109604. declare module BABYLON {
  109605. /**
  109606. * 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
  109607. */
  109608. export class SixDofDragBehavior implements Behavior<Mesh> {
  109609. private static _virtualScene;
  109610. private _ownerNode;
  109611. private _sceneRenderObserver;
  109612. private _scene;
  109613. private _targetPosition;
  109614. private _virtualOriginMesh;
  109615. private _virtualDragMesh;
  109616. private _pointerObserver;
  109617. private _moving;
  109618. private _startingOrientation;
  109619. /**
  109620. * 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)
  109621. */
  109622. private zDragFactor;
  109623. /**
  109624. * If the object should rotate to face the drag origin
  109625. */
  109626. rotateDraggedObject: boolean;
  109627. /**
  109628. * If the behavior is currently in a dragging state
  109629. */
  109630. dragging: boolean;
  109631. /**
  109632. * 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)
  109633. */
  109634. dragDeltaRatio: number;
  109635. /**
  109636. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109637. */
  109638. currentDraggingPointerID: number;
  109639. /**
  109640. * If camera controls should be detached during the drag
  109641. */
  109642. detachCameraControls: boolean;
  109643. /**
  109644. * Fires each time a drag starts
  109645. */
  109646. onDragStartObservable: Observable<{}>;
  109647. /**
  109648. * Fires each time a drag ends (eg. mouse release after drag)
  109649. */
  109650. onDragEndObservable: Observable<{}>;
  109651. /**
  109652. * 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
  109653. */
  109654. constructor();
  109655. /**
  109656. * The name of the behavior
  109657. */
  109658. get name(): string;
  109659. /**
  109660. * Initializes the behavior
  109661. */
  109662. init(): void;
  109663. /**
  109664. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  109665. */
  109666. private get _pointerCamera();
  109667. /**
  109668. * Attaches the scale behavior the passed in mesh
  109669. * @param ownerNode The mesh that will be scaled around once attached
  109670. */
  109671. attach(ownerNode: Mesh): void;
  109672. /**
  109673. * Detaches the behavior from the mesh
  109674. */
  109675. detach(): void;
  109676. }
  109677. }
  109678. declare module BABYLON {
  109679. /**
  109680. * Class used to apply inverse kinematics to bones
  109681. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  109682. */
  109683. export class BoneIKController {
  109684. private static _tmpVecs;
  109685. private static _tmpQuat;
  109686. private static _tmpMats;
  109687. /**
  109688. * Gets or sets the target mesh
  109689. */
  109690. targetMesh: AbstractMesh;
  109691. /** Gets or sets the mesh used as pole */
  109692. poleTargetMesh: AbstractMesh;
  109693. /**
  109694. * Gets or sets the bone used as pole
  109695. */
  109696. poleTargetBone: Nullable<Bone>;
  109697. /**
  109698. * Gets or sets the target position
  109699. */
  109700. targetPosition: Vector3;
  109701. /**
  109702. * Gets or sets the pole target position
  109703. */
  109704. poleTargetPosition: Vector3;
  109705. /**
  109706. * Gets or sets the pole target local offset
  109707. */
  109708. poleTargetLocalOffset: Vector3;
  109709. /**
  109710. * Gets or sets the pole angle
  109711. */
  109712. poleAngle: number;
  109713. /**
  109714. * Gets or sets the mesh associated with the controller
  109715. */
  109716. mesh: AbstractMesh;
  109717. /**
  109718. * 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)
  109719. */
  109720. slerpAmount: number;
  109721. private _bone1Quat;
  109722. private _bone1Mat;
  109723. private _bone2Ang;
  109724. private _bone1;
  109725. private _bone2;
  109726. private _bone1Length;
  109727. private _bone2Length;
  109728. private _maxAngle;
  109729. private _maxReach;
  109730. private _rightHandedSystem;
  109731. private _bendAxis;
  109732. private _slerping;
  109733. private _adjustRoll;
  109734. /**
  109735. * Gets or sets maximum allowed angle
  109736. */
  109737. get maxAngle(): number;
  109738. set maxAngle(value: number);
  109739. /**
  109740. * Creates a new BoneIKController
  109741. * @param mesh defines the mesh to control
  109742. * @param bone defines the bone to control
  109743. * @param options defines options to set up the controller
  109744. */
  109745. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  109746. targetMesh?: AbstractMesh;
  109747. poleTargetMesh?: AbstractMesh;
  109748. poleTargetBone?: Bone;
  109749. poleTargetLocalOffset?: Vector3;
  109750. poleAngle?: number;
  109751. bendAxis?: Vector3;
  109752. maxAngle?: number;
  109753. slerpAmount?: number;
  109754. });
  109755. private _setMaxAngle;
  109756. /**
  109757. * Force the controller to update the bones
  109758. */
  109759. update(): void;
  109760. }
  109761. }
  109762. declare module BABYLON {
  109763. /**
  109764. * Class used to make a bone look toward a point in space
  109765. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  109766. */
  109767. export class BoneLookController {
  109768. private static _tmpVecs;
  109769. private static _tmpQuat;
  109770. private static _tmpMats;
  109771. /**
  109772. * The target Vector3 that the bone will look at
  109773. */
  109774. target: Vector3;
  109775. /**
  109776. * The mesh that the bone is attached to
  109777. */
  109778. mesh: AbstractMesh;
  109779. /**
  109780. * The bone that will be looking to the target
  109781. */
  109782. bone: Bone;
  109783. /**
  109784. * The up axis of the coordinate system that is used when the bone is rotated
  109785. */
  109786. upAxis: Vector3;
  109787. /**
  109788. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  109789. */
  109790. upAxisSpace: Space;
  109791. /**
  109792. * Used to make an adjustment to the yaw of the bone
  109793. */
  109794. adjustYaw: number;
  109795. /**
  109796. * Used to make an adjustment to the pitch of the bone
  109797. */
  109798. adjustPitch: number;
  109799. /**
  109800. * Used to make an adjustment to the roll of the bone
  109801. */
  109802. adjustRoll: number;
  109803. /**
  109804. * 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)
  109805. */
  109806. slerpAmount: number;
  109807. private _minYaw;
  109808. private _maxYaw;
  109809. private _minPitch;
  109810. private _maxPitch;
  109811. private _minYawSin;
  109812. private _minYawCos;
  109813. private _maxYawSin;
  109814. private _maxYawCos;
  109815. private _midYawConstraint;
  109816. private _minPitchTan;
  109817. private _maxPitchTan;
  109818. private _boneQuat;
  109819. private _slerping;
  109820. private _transformYawPitch;
  109821. private _transformYawPitchInv;
  109822. private _firstFrameSkipped;
  109823. private _yawRange;
  109824. private _fowardAxis;
  109825. /**
  109826. * Gets or sets the minimum yaw angle that the bone can look to
  109827. */
  109828. get minYaw(): number;
  109829. set minYaw(value: number);
  109830. /**
  109831. * Gets or sets the maximum yaw angle that the bone can look to
  109832. */
  109833. get maxYaw(): number;
  109834. set maxYaw(value: number);
  109835. /**
  109836. * Gets or sets the minimum pitch angle that the bone can look to
  109837. */
  109838. get minPitch(): number;
  109839. set minPitch(value: number);
  109840. /**
  109841. * Gets or sets the maximum pitch angle that the bone can look to
  109842. */
  109843. get maxPitch(): number;
  109844. set maxPitch(value: number);
  109845. /**
  109846. * Create a BoneLookController
  109847. * @param mesh the mesh that the bone belongs to
  109848. * @param bone the bone that will be looking to the target
  109849. * @param target the target Vector3 to look at
  109850. * @param options optional settings:
  109851. * * maxYaw: the maximum angle the bone will yaw to
  109852. * * minYaw: the minimum angle the bone will yaw to
  109853. * * maxPitch: the maximum angle the bone will pitch to
  109854. * * minPitch: the minimum angle the bone will yaw to
  109855. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  109856. * * upAxis: the up axis of the coordinate system
  109857. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  109858. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  109859. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  109860. * * adjustYaw: used to make an adjustment to the yaw of the bone
  109861. * * adjustPitch: used to make an adjustment to the pitch of the bone
  109862. * * adjustRoll: used to make an adjustment to the roll of the bone
  109863. **/
  109864. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  109865. maxYaw?: number;
  109866. minYaw?: number;
  109867. maxPitch?: number;
  109868. minPitch?: number;
  109869. slerpAmount?: number;
  109870. upAxis?: Vector3;
  109871. upAxisSpace?: Space;
  109872. yawAxis?: Vector3;
  109873. pitchAxis?: Vector3;
  109874. adjustYaw?: number;
  109875. adjustPitch?: number;
  109876. adjustRoll?: number;
  109877. });
  109878. /**
  109879. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  109880. */
  109881. update(): void;
  109882. private _getAngleDiff;
  109883. private _getAngleBetween;
  109884. private _isAngleBetween;
  109885. }
  109886. }
  109887. declare module BABYLON {
  109888. /**
  109889. * Manage the gamepad inputs to control an arc rotate camera.
  109890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109891. */
  109892. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  109893. /**
  109894. * Defines the camera the input is attached to.
  109895. */
  109896. camera: ArcRotateCamera;
  109897. /**
  109898. * Defines the gamepad the input is gathering event from.
  109899. */
  109900. gamepad: Nullable<Gamepad>;
  109901. /**
  109902. * Defines the gamepad rotation sensiblity.
  109903. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109904. */
  109905. gamepadRotationSensibility: number;
  109906. /**
  109907. * Defines the gamepad move sensiblity.
  109908. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109909. */
  109910. gamepadMoveSensibility: number;
  109911. private _yAxisScale;
  109912. /**
  109913. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  109914. */
  109915. get invertYAxis(): boolean;
  109916. set invertYAxis(value: boolean);
  109917. private _onGamepadConnectedObserver;
  109918. private _onGamepadDisconnectedObserver;
  109919. /**
  109920. * Attach the input controls to a specific dom element to get the input from.
  109921. * @param element Defines the element the controls should be listened from
  109922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109923. */
  109924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109925. /**
  109926. * Detach the current controls from the specified dom element.
  109927. * @param element Defines the element to stop listening the inputs from
  109928. */
  109929. detachControl(element: Nullable<HTMLElement>): void;
  109930. /**
  109931. * Update the current camera state depending on the inputs that have been used this frame.
  109932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109933. */
  109934. checkInputs(): void;
  109935. /**
  109936. * Gets the class name of the current intput.
  109937. * @returns the class name
  109938. */
  109939. getClassName(): string;
  109940. /**
  109941. * Get the friendly name associated with the input class.
  109942. * @returns the input friendly name
  109943. */
  109944. getSimpleName(): string;
  109945. }
  109946. }
  109947. declare module BABYLON {
  109948. interface ArcRotateCameraInputsManager {
  109949. /**
  109950. * Add orientation input support to the input manager.
  109951. * @returns the current input manager
  109952. */
  109953. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  109954. }
  109955. /**
  109956. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  109957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109958. */
  109959. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  109960. /**
  109961. * Defines the camera the input is attached to.
  109962. */
  109963. camera: ArcRotateCamera;
  109964. /**
  109965. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  109966. */
  109967. alphaCorrection: number;
  109968. /**
  109969. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  109970. */
  109971. gammaCorrection: number;
  109972. private _alpha;
  109973. private _gamma;
  109974. private _dirty;
  109975. private _deviceOrientationHandler;
  109976. /**
  109977. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  109978. */
  109979. constructor();
  109980. /**
  109981. * Attach the input controls to a specific dom element to get the input from.
  109982. * @param element Defines the element the controls should be listened from
  109983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109984. */
  109985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109986. /** @hidden */
  109987. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  109988. /**
  109989. * Update the current camera state depending on the inputs that have been used this frame.
  109990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109991. */
  109992. checkInputs(): void;
  109993. /**
  109994. * Detach the current controls from the specified dom element.
  109995. * @param element Defines the element to stop listening the inputs from
  109996. */
  109997. detachControl(element: Nullable<HTMLElement>): void;
  109998. /**
  109999. * Gets the class name of the current intput.
  110000. * @returns the class name
  110001. */
  110002. getClassName(): string;
  110003. /**
  110004. * Get the friendly name associated with the input class.
  110005. * @returns the input friendly name
  110006. */
  110007. getSimpleName(): string;
  110008. }
  110009. }
  110010. declare module BABYLON {
  110011. /**
  110012. * Listen to mouse events to control the camera.
  110013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110014. */
  110015. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110016. /**
  110017. * Defines the camera the input is attached to.
  110018. */
  110019. camera: FlyCamera;
  110020. /**
  110021. * Defines if touch is enabled. (Default is true.)
  110022. */
  110023. touchEnabled: boolean;
  110024. /**
  110025. * Defines the buttons associated with the input to handle camera rotation.
  110026. */
  110027. buttons: number[];
  110028. /**
  110029. * Assign buttons for Yaw control.
  110030. */
  110031. buttonsYaw: number[];
  110032. /**
  110033. * Assign buttons for Pitch control.
  110034. */
  110035. buttonsPitch: number[];
  110036. /**
  110037. * Assign buttons for Roll control.
  110038. */
  110039. buttonsRoll: number[];
  110040. /**
  110041. * Detect if any button is being pressed while mouse is moved.
  110042. * -1 = Mouse locked.
  110043. * 0 = Left button.
  110044. * 1 = Middle Button.
  110045. * 2 = Right Button.
  110046. */
  110047. activeButton: number;
  110048. /**
  110049. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110050. * Higher values reduce its sensitivity.
  110051. */
  110052. angularSensibility: number;
  110053. private _mousemoveCallback;
  110054. private _observer;
  110055. private _rollObserver;
  110056. private previousPosition;
  110057. private noPreventDefault;
  110058. private element;
  110059. /**
  110060. * Listen to mouse events to control the camera.
  110061. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110063. */
  110064. constructor(touchEnabled?: boolean);
  110065. /**
  110066. * Attach the mouse control to the HTML DOM element.
  110067. * @param element Defines the element that listens to the input events.
  110068. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110069. */
  110070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110071. /**
  110072. * Detach the current controls from the specified dom element.
  110073. * @param element Defines the element to stop listening the inputs from
  110074. */
  110075. detachControl(element: Nullable<HTMLElement>): void;
  110076. /**
  110077. * Gets the class name of the current input.
  110078. * @returns the class name.
  110079. */
  110080. getClassName(): string;
  110081. /**
  110082. * Get the friendly name associated with the input class.
  110083. * @returns the input's friendly name.
  110084. */
  110085. getSimpleName(): string;
  110086. private _pointerInput;
  110087. private _onMouseMove;
  110088. /**
  110089. * Rotate camera by mouse offset.
  110090. */
  110091. private rotateCamera;
  110092. }
  110093. }
  110094. declare module BABYLON {
  110095. /**
  110096. * Default Inputs manager for the FlyCamera.
  110097. * It groups all the default supported inputs for ease of use.
  110098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110099. */
  110100. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  110101. /**
  110102. * Instantiates a new FlyCameraInputsManager.
  110103. * @param camera Defines the camera the inputs belong to.
  110104. */
  110105. constructor(camera: FlyCamera);
  110106. /**
  110107. * Add keyboard input support to the input manager.
  110108. * @returns the new FlyCameraKeyboardMoveInput().
  110109. */
  110110. addKeyboard(): FlyCameraInputsManager;
  110111. /**
  110112. * Add mouse input support to the input manager.
  110113. * @param touchEnabled Enable touch screen support.
  110114. * @returns the new FlyCameraMouseInput().
  110115. */
  110116. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  110117. }
  110118. }
  110119. declare module BABYLON {
  110120. /**
  110121. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110122. * such as in a 3D Space Shooter or a Flight Simulator.
  110123. */
  110124. export class FlyCamera extends TargetCamera {
  110125. /**
  110126. * Define the collision ellipsoid of the camera.
  110127. * This is helpful for simulating a camera body, like a player's body.
  110128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  110129. */
  110130. ellipsoid: Vector3;
  110131. /**
  110132. * Define an offset for the position of the ellipsoid around the camera.
  110133. * This can be helpful if the camera is attached away from the player's body center,
  110134. * such as at its head.
  110135. */
  110136. ellipsoidOffset: Vector3;
  110137. /**
  110138. * Enable or disable collisions of the camera with the rest of the scene objects.
  110139. */
  110140. checkCollisions: boolean;
  110141. /**
  110142. * Enable or disable gravity on the camera.
  110143. */
  110144. applyGravity: boolean;
  110145. /**
  110146. * Define the current direction the camera is moving to.
  110147. */
  110148. cameraDirection: Vector3;
  110149. /**
  110150. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  110151. * This overrides and empties cameraRotation.
  110152. */
  110153. rotationQuaternion: Quaternion;
  110154. /**
  110155. * Track Roll to maintain the wanted Rolling when looking around.
  110156. */
  110157. _trackRoll: number;
  110158. /**
  110159. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  110160. */
  110161. rollCorrect: number;
  110162. /**
  110163. * Mimic a banked turn, Rolling the camera when Yawing.
  110164. * It's recommended to use rollCorrect = 10 for faster banking correction.
  110165. */
  110166. bankedTurn: boolean;
  110167. /**
  110168. * Limit in radians for how much Roll banking will add. (Default: 90°)
  110169. */
  110170. bankedTurnLimit: number;
  110171. /**
  110172. * Value of 0 disables the banked Roll.
  110173. * Value of 1 is equal to the Yaw angle in radians.
  110174. */
  110175. bankedTurnMultiplier: number;
  110176. /**
  110177. * The inputs manager loads all the input sources, such as keyboard and mouse.
  110178. */
  110179. inputs: FlyCameraInputsManager;
  110180. /**
  110181. * Gets the input sensibility for mouse input.
  110182. * Higher values reduce sensitivity.
  110183. */
  110184. get angularSensibility(): number;
  110185. /**
  110186. * Sets the input sensibility for a mouse input.
  110187. * Higher values reduce sensitivity.
  110188. */
  110189. set angularSensibility(value: number);
  110190. /**
  110191. * Get the keys for camera movement forward.
  110192. */
  110193. get keysForward(): number[];
  110194. /**
  110195. * Set the keys for camera movement forward.
  110196. */
  110197. set keysForward(value: number[]);
  110198. /**
  110199. * Get the keys for camera movement backward.
  110200. */
  110201. get keysBackward(): number[];
  110202. set keysBackward(value: number[]);
  110203. /**
  110204. * Get the keys for camera movement up.
  110205. */
  110206. get keysUp(): number[];
  110207. /**
  110208. * Set the keys for camera movement up.
  110209. */
  110210. set keysUp(value: number[]);
  110211. /**
  110212. * Get the keys for camera movement down.
  110213. */
  110214. get keysDown(): number[];
  110215. /**
  110216. * Set the keys for camera movement down.
  110217. */
  110218. set keysDown(value: number[]);
  110219. /**
  110220. * Get the keys for camera movement left.
  110221. */
  110222. get keysLeft(): number[];
  110223. /**
  110224. * Set the keys for camera movement left.
  110225. */
  110226. set keysLeft(value: number[]);
  110227. /**
  110228. * Set the keys for camera movement right.
  110229. */
  110230. get keysRight(): number[];
  110231. /**
  110232. * Set the keys for camera movement right.
  110233. */
  110234. set keysRight(value: number[]);
  110235. /**
  110236. * Event raised when the camera collides with a mesh in the scene.
  110237. */
  110238. onCollide: (collidedMesh: AbstractMesh) => void;
  110239. private _collider;
  110240. private _needMoveForGravity;
  110241. private _oldPosition;
  110242. private _diffPosition;
  110243. private _newPosition;
  110244. /** @hidden */
  110245. _localDirection: Vector3;
  110246. /** @hidden */
  110247. _transformedDirection: Vector3;
  110248. /**
  110249. * Instantiates a FlyCamera.
  110250. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110251. * such as in a 3D Space Shooter or a Flight Simulator.
  110252. * @param name Define the name of the camera in the scene.
  110253. * @param position Define the starting position of the camera in the scene.
  110254. * @param scene Define the scene the camera belongs to.
  110255. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  110256. */
  110257. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110258. /**
  110259. * Attach a control to the HTML DOM element.
  110260. * @param element Defines the element that listens to the input events.
  110261. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  110262. */
  110263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110264. /**
  110265. * Detach a control from the HTML DOM element.
  110266. * The camera will stop reacting to that input.
  110267. * @param element Defines the element that listens to the input events.
  110268. */
  110269. detachControl(element: HTMLElement): void;
  110270. private _collisionMask;
  110271. /**
  110272. * Get the mask that the camera ignores in collision events.
  110273. */
  110274. get collisionMask(): number;
  110275. /**
  110276. * Set the mask that the camera ignores in collision events.
  110277. */
  110278. set collisionMask(mask: number);
  110279. /** @hidden */
  110280. _collideWithWorld(displacement: Vector3): void;
  110281. /** @hidden */
  110282. private _onCollisionPositionChange;
  110283. /** @hidden */
  110284. _checkInputs(): void;
  110285. /** @hidden */
  110286. _decideIfNeedsToMove(): boolean;
  110287. /** @hidden */
  110288. _updatePosition(): void;
  110289. /**
  110290. * Restore the Roll to its target value at the rate specified.
  110291. * @param rate - Higher means slower restoring.
  110292. * @hidden
  110293. */
  110294. restoreRoll(rate: number): void;
  110295. /**
  110296. * Destroy the camera and release the current resources held by it.
  110297. */
  110298. dispose(): void;
  110299. /**
  110300. * Get the current object class name.
  110301. * @returns the class name.
  110302. */
  110303. getClassName(): string;
  110304. }
  110305. }
  110306. declare module BABYLON {
  110307. /**
  110308. * Listen to keyboard events to control the camera.
  110309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110310. */
  110311. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  110312. /**
  110313. * Defines the camera the input is attached to.
  110314. */
  110315. camera: FlyCamera;
  110316. /**
  110317. * The list of keyboard keys used to control the forward move of the camera.
  110318. */
  110319. keysForward: number[];
  110320. /**
  110321. * The list of keyboard keys used to control the backward move of the camera.
  110322. */
  110323. keysBackward: number[];
  110324. /**
  110325. * The list of keyboard keys used to control the forward move of the camera.
  110326. */
  110327. keysUp: number[];
  110328. /**
  110329. * The list of keyboard keys used to control the backward move of the camera.
  110330. */
  110331. keysDown: number[];
  110332. /**
  110333. * The list of keyboard keys used to control the right strafe move of the camera.
  110334. */
  110335. keysRight: number[];
  110336. /**
  110337. * The list of keyboard keys used to control the left strafe move of the camera.
  110338. */
  110339. keysLeft: number[];
  110340. private _keys;
  110341. private _onCanvasBlurObserver;
  110342. private _onKeyboardObserver;
  110343. private _engine;
  110344. private _scene;
  110345. /**
  110346. * Attach the input controls to a specific dom element to get the input from.
  110347. * @param element Defines the element the controls should be listened from
  110348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110349. */
  110350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110351. /**
  110352. * Detach the current controls from the specified dom element.
  110353. * @param element Defines the element to stop listening the inputs from
  110354. */
  110355. detachControl(element: Nullable<HTMLElement>): void;
  110356. /**
  110357. * Gets the class name of the current intput.
  110358. * @returns the class name
  110359. */
  110360. getClassName(): string;
  110361. /** @hidden */
  110362. _onLostFocus(e: FocusEvent): void;
  110363. /**
  110364. * Get the friendly name associated with the input class.
  110365. * @returns the input friendly name
  110366. */
  110367. getSimpleName(): string;
  110368. /**
  110369. * Update the current camera state depending on the inputs that have been used this frame.
  110370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110371. */
  110372. checkInputs(): void;
  110373. }
  110374. }
  110375. declare module BABYLON {
  110376. /**
  110377. * Manage the mouse wheel inputs to control a follow camera.
  110378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110379. */
  110380. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  110381. /**
  110382. * Defines the camera the input is attached to.
  110383. */
  110384. camera: FollowCamera;
  110385. /**
  110386. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  110387. */
  110388. axisControlRadius: boolean;
  110389. /**
  110390. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  110391. */
  110392. axisControlHeight: boolean;
  110393. /**
  110394. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  110395. */
  110396. axisControlRotation: boolean;
  110397. /**
  110398. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  110399. * relation to mouseWheel events.
  110400. */
  110401. wheelPrecision: number;
  110402. /**
  110403. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110404. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110405. */
  110406. wheelDeltaPercentage: number;
  110407. private _wheel;
  110408. private _observer;
  110409. /**
  110410. * Attach the input controls to a specific dom element to get the input from.
  110411. * @param element Defines the element the controls should be listened from
  110412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110413. */
  110414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110415. /**
  110416. * Detach the current controls from the specified dom element.
  110417. * @param element Defines the element to stop listening the inputs from
  110418. */
  110419. detachControl(element: Nullable<HTMLElement>): void;
  110420. /**
  110421. * Gets the class name of the current intput.
  110422. * @returns the class name
  110423. */
  110424. getClassName(): string;
  110425. /**
  110426. * Get the friendly name associated with the input class.
  110427. * @returns the input friendly name
  110428. */
  110429. getSimpleName(): string;
  110430. }
  110431. }
  110432. declare module BABYLON {
  110433. /**
  110434. * Manage the pointers inputs to control an follow camera.
  110435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110436. */
  110437. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  110438. /**
  110439. * Defines the camera the input is attached to.
  110440. */
  110441. camera: FollowCamera;
  110442. /**
  110443. * Gets the class name of the current input.
  110444. * @returns the class name
  110445. */
  110446. getClassName(): string;
  110447. /**
  110448. * Defines the pointer angular sensibility along the X axis or how fast is
  110449. * the camera rotating.
  110450. * A negative number will reverse the axis direction.
  110451. */
  110452. angularSensibilityX: number;
  110453. /**
  110454. * Defines the pointer angular sensibility along the Y axis or how fast is
  110455. * the camera rotating.
  110456. * A negative number will reverse the axis direction.
  110457. */
  110458. angularSensibilityY: number;
  110459. /**
  110460. * Defines the pointer pinch precision or how fast is the camera zooming.
  110461. * A negative number will reverse the axis direction.
  110462. */
  110463. pinchPrecision: number;
  110464. /**
  110465. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110466. * from 0.
  110467. * It defines the percentage of current camera.radius to use as delta when
  110468. * pinch zoom is used.
  110469. */
  110470. pinchDeltaPercentage: number;
  110471. /**
  110472. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  110473. */
  110474. axisXControlRadius: boolean;
  110475. /**
  110476. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  110477. */
  110478. axisXControlHeight: boolean;
  110479. /**
  110480. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  110481. */
  110482. axisXControlRotation: boolean;
  110483. /**
  110484. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  110485. */
  110486. axisYControlRadius: boolean;
  110487. /**
  110488. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  110489. */
  110490. axisYControlHeight: boolean;
  110491. /**
  110492. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  110493. */
  110494. axisYControlRotation: boolean;
  110495. /**
  110496. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  110497. */
  110498. axisPinchControlRadius: boolean;
  110499. /**
  110500. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  110501. */
  110502. axisPinchControlHeight: boolean;
  110503. /**
  110504. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  110505. */
  110506. axisPinchControlRotation: boolean;
  110507. /**
  110508. * Log error messages if basic misconfiguration has occurred.
  110509. */
  110510. warningEnable: boolean;
  110511. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110512. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110513. private _warningCounter;
  110514. private _warning;
  110515. }
  110516. }
  110517. declare module BABYLON {
  110518. /**
  110519. * Default Inputs manager for the FollowCamera.
  110520. * It groups all the default supported inputs for ease of use.
  110521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110522. */
  110523. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  110524. /**
  110525. * Instantiates a new FollowCameraInputsManager.
  110526. * @param camera Defines the camera the inputs belong to
  110527. */
  110528. constructor(camera: FollowCamera);
  110529. /**
  110530. * Add keyboard input support to the input manager.
  110531. * @returns the current input manager
  110532. */
  110533. addKeyboard(): FollowCameraInputsManager;
  110534. /**
  110535. * Add mouse wheel input support to the input manager.
  110536. * @returns the current input manager
  110537. */
  110538. addMouseWheel(): FollowCameraInputsManager;
  110539. /**
  110540. * Add pointers input support to the input manager.
  110541. * @returns the current input manager
  110542. */
  110543. addPointers(): FollowCameraInputsManager;
  110544. /**
  110545. * Add orientation input support to the input manager.
  110546. * @returns the current input manager
  110547. */
  110548. addVRDeviceOrientation(): FollowCameraInputsManager;
  110549. }
  110550. }
  110551. declare module BABYLON {
  110552. /**
  110553. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  110554. * an arc rotate version arcFollowCamera are available.
  110555. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110556. */
  110557. export class FollowCamera extends TargetCamera {
  110558. /**
  110559. * Distance the follow camera should follow an object at
  110560. */
  110561. radius: number;
  110562. /**
  110563. * Minimum allowed distance of the camera to the axis of rotation
  110564. * (The camera can not get closer).
  110565. * This can help limiting how the Camera is able to move in the scene.
  110566. */
  110567. lowerRadiusLimit: Nullable<number>;
  110568. /**
  110569. * Maximum allowed distance of the camera to the axis of rotation
  110570. * (The camera can not get further).
  110571. * This can help limiting how the Camera is able to move in the scene.
  110572. */
  110573. upperRadiusLimit: Nullable<number>;
  110574. /**
  110575. * Define a rotation offset between the camera and the object it follows
  110576. */
  110577. rotationOffset: number;
  110578. /**
  110579. * Minimum allowed angle to camera position relative to target object.
  110580. * This can help limiting how the Camera is able to move in the scene.
  110581. */
  110582. lowerRotationOffsetLimit: Nullable<number>;
  110583. /**
  110584. * Maximum allowed angle to camera position relative to target object.
  110585. * This can help limiting how the Camera is able to move in the scene.
  110586. */
  110587. upperRotationOffsetLimit: Nullable<number>;
  110588. /**
  110589. * Define a height offset between the camera and the object it follows.
  110590. * It can help following an object from the top (like a car chaing a plane)
  110591. */
  110592. heightOffset: number;
  110593. /**
  110594. * Minimum allowed height of camera position relative to target object.
  110595. * This can help limiting how the Camera is able to move in the scene.
  110596. */
  110597. lowerHeightOffsetLimit: Nullable<number>;
  110598. /**
  110599. * Maximum allowed height of camera position relative to target object.
  110600. * This can help limiting how the Camera is able to move in the scene.
  110601. */
  110602. upperHeightOffsetLimit: Nullable<number>;
  110603. /**
  110604. * Define how fast the camera can accelerate to follow it s target.
  110605. */
  110606. cameraAcceleration: number;
  110607. /**
  110608. * Define the speed limit of the camera following an object.
  110609. */
  110610. maxCameraSpeed: number;
  110611. /**
  110612. * Define the target of the camera.
  110613. */
  110614. lockedTarget: Nullable<AbstractMesh>;
  110615. /**
  110616. * Defines the input associated with the camera.
  110617. */
  110618. inputs: FollowCameraInputsManager;
  110619. /**
  110620. * Instantiates the follow camera.
  110621. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110622. * @param name Define the name of the camera in the scene
  110623. * @param position Define the position of the camera
  110624. * @param scene Define the scene the camera belong to
  110625. * @param lockedTarget Define the target of the camera
  110626. */
  110627. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  110628. private _follow;
  110629. /**
  110630. * Attached controls to the current camera.
  110631. * @param element Defines the element the controls should be listened from
  110632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110633. */
  110634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110635. /**
  110636. * Detach the current controls from the camera.
  110637. * The camera will stop reacting to inputs.
  110638. * @param element Defines the element to stop listening the inputs from
  110639. */
  110640. detachControl(element: HTMLElement): void;
  110641. /** @hidden */
  110642. _checkInputs(): void;
  110643. private _checkLimits;
  110644. /**
  110645. * Gets the camera class name.
  110646. * @returns the class name
  110647. */
  110648. getClassName(): string;
  110649. }
  110650. /**
  110651. * Arc Rotate version of the follow camera.
  110652. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  110653. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110654. */
  110655. export class ArcFollowCamera extends TargetCamera {
  110656. /** The longitudinal angle of the camera */
  110657. alpha: number;
  110658. /** The latitudinal angle of the camera */
  110659. beta: number;
  110660. /** The radius of the camera from its target */
  110661. radius: number;
  110662. /** Define the camera target (the messh it should follow) */
  110663. target: Nullable<AbstractMesh>;
  110664. private _cartesianCoordinates;
  110665. /**
  110666. * Instantiates a new ArcFollowCamera
  110667. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110668. * @param name Define the name of the camera
  110669. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  110670. * @param beta Define the rotation angle of the camera around the elevation axis
  110671. * @param radius Define the radius of the camera from its target point
  110672. * @param target Define the target of the camera
  110673. * @param scene Define the scene the camera belongs to
  110674. */
  110675. constructor(name: string,
  110676. /** The longitudinal angle of the camera */
  110677. alpha: number,
  110678. /** The latitudinal angle of the camera */
  110679. beta: number,
  110680. /** The radius of the camera from its target */
  110681. radius: number,
  110682. /** Define the camera target (the messh it should follow) */
  110683. target: Nullable<AbstractMesh>, scene: Scene);
  110684. private _follow;
  110685. /** @hidden */
  110686. _checkInputs(): void;
  110687. /**
  110688. * Returns the class name of the object.
  110689. * It is mostly used internally for serialization purposes.
  110690. */
  110691. getClassName(): string;
  110692. }
  110693. }
  110694. declare module BABYLON {
  110695. /**
  110696. * Manage the keyboard inputs to control the movement of a follow camera.
  110697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110698. */
  110699. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  110700. /**
  110701. * Defines the camera the input is attached to.
  110702. */
  110703. camera: FollowCamera;
  110704. /**
  110705. * Defines the list of key codes associated with the up action (increase heightOffset)
  110706. */
  110707. keysHeightOffsetIncr: number[];
  110708. /**
  110709. * Defines the list of key codes associated with the down action (decrease heightOffset)
  110710. */
  110711. keysHeightOffsetDecr: number[];
  110712. /**
  110713. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  110714. */
  110715. keysHeightOffsetModifierAlt: boolean;
  110716. /**
  110717. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  110718. */
  110719. keysHeightOffsetModifierCtrl: boolean;
  110720. /**
  110721. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  110722. */
  110723. keysHeightOffsetModifierShift: boolean;
  110724. /**
  110725. * Defines the list of key codes associated with the left action (increase rotationOffset)
  110726. */
  110727. keysRotationOffsetIncr: number[];
  110728. /**
  110729. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  110730. */
  110731. keysRotationOffsetDecr: number[];
  110732. /**
  110733. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  110734. */
  110735. keysRotationOffsetModifierAlt: boolean;
  110736. /**
  110737. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  110738. */
  110739. keysRotationOffsetModifierCtrl: boolean;
  110740. /**
  110741. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  110742. */
  110743. keysRotationOffsetModifierShift: boolean;
  110744. /**
  110745. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  110746. */
  110747. keysRadiusIncr: number[];
  110748. /**
  110749. * Defines the list of key codes associated with the zoom-out action (increase radius)
  110750. */
  110751. keysRadiusDecr: number[];
  110752. /**
  110753. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  110754. */
  110755. keysRadiusModifierAlt: boolean;
  110756. /**
  110757. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  110758. */
  110759. keysRadiusModifierCtrl: boolean;
  110760. /**
  110761. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  110762. */
  110763. keysRadiusModifierShift: boolean;
  110764. /**
  110765. * Defines the rate of change of heightOffset.
  110766. */
  110767. heightSensibility: number;
  110768. /**
  110769. * Defines the rate of change of rotationOffset.
  110770. */
  110771. rotationSensibility: number;
  110772. /**
  110773. * Defines the rate of change of radius.
  110774. */
  110775. radiusSensibility: number;
  110776. private _keys;
  110777. private _ctrlPressed;
  110778. private _altPressed;
  110779. private _shiftPressed;
  110780. private _onCanvasBlurObserver;
  110781. private _onKeyboardObserver;
  110782. private _engine;
  110783. private _scene;
  110784. /**
  110785. * Attach the input controls to a specific dom element to get the input from.
  110786. * @param element Defines the element the controls should be listened from
  110787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110788. */
  110789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110790. /**
  110791. * Detach the current controls from the specified dom element.
  110792. * @param element Defines the element to stop listening the inputs from
  110793. */
  110794. detachControl(element: Nullable<HTMLElement>): void;
  110795. /**
  110796. * Update the current camera state depending on the inputs that have been used this frame.
  110797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110798. */
  110799. checkInputs(): void;
  110800. /**
  110801. * Gets the class name of the current input.
  110802. * @returns the class name
  110803. */
  110804. getClassName(): string;
  110805. /**
  110806. * Get the friendly name associated with the input class.
  110807. * @returns the input friendly name
  110808. */
  110809. getSimpleName(): string;
  110810. /**
  110811. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110812. * allow modification of the heightOffset value.
  110813. */
  110814. private _modifierHeightOffset;
  110815. /**
  110816. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110817. * allow modification of the rotationOffset value.
  110818. */
  110819. private _modifierRotationOffset;
  110820. /**
  110821. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110822. * allow modification of the radius value.
  110823. */
  110824. private _modifierRadius;
  110825. }
  110826. }
  110827. declare module BABYLON {
  110828. interface FreeCameraInputsManager {
  110829. /**
  110830. * @hidden
  110831. */
  110832. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  110833. /**
  110834. * Add orientation input support to the input manager.
  110835. * @returns the current input manager
  110836. */
  110837. addDeviceOrientation(): FreeCameraInputsManager;
  110838. }
  110839. /**
  110840. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  110841. * Screen rotation is taken into account.
  110842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110843. */
  110844. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  110845. private _camera;
  110846. private _screenOrientationAngle;
  110847. private _constantTranform;
  110848. private _screenQuaternion;
  110849. private _alpha;
  110850. private _beta;
  110851. private _gamma;
  110852. /**
  110853. * Can be used to detect if a device orientation sensor is available on a device
  110854. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  110855. * @returns a promise that will resolve on orientation change
  110856. */
  110857. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  110858. /**
  110859. * @hidden
  110860. */
  110861. _onDeviceOrientationChangedObservable: Observable<void>;
  110862. /**
  110863. * Instantiates a new input
  110864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110865. */
  110866. constructor();
  110867. /**
  110868. * Define the camera controlled by the input.
  110869. */
  110870. get camera(): FreeCamera;
  110871. set camera(camera: FreeCamera);
  110872. /**
  110873. * Attach the input controls to a specific dom element to get the input from.
  110874. * @param element Defines the element the controls should be listened from
  110875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110876. */
  110877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110878. private _orientationChanged;
  110879. private _deviceOrientation;
  110880. /**
  110881. * Detach the current controls from the specified dom element.
  110882. * @param element Defines the element to stop listening the inputs from
  110883. */
  110884. detachControl(element: Nullable<HTMLElement>): void;
  110885. /**
  110886. * Update the current camera state depending on the inputs that have been used this frame.
  110887. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110888. */
  110889. checkInputs(): void;
  110890. /**
  110891. * Gets the class name of the current intput.
  110892. * @returns the class name
  110893. */
  110894. getClassName(): string;
  110895. /**
  110896. * Get the friendly name associated with the input class.
  110897. * @returns the input friendly name
  110898. */
  110899. getSimpleName(): string;
  110900. }
  110901. }
  110902. declare module BABYLON {
  110903. /**
  110904. * Manage the gamepad inputs to control a free camera.
  110905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110906. */
  110907. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  110908. /**
  110909. * Define the camera the input is attached to.
  110910. */
  110911. camera: FreeCamera;
  110912. /**
  110913. * Define the Gamepad controlling the input
  110914. */
  110915. gamepad: Nullable<Gamepad>;
  110916. /**
  110917. * Defines the gamepad rotation sensiblity.
  110918. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110919. */
  110920. gamepadAngularSensibility: number;
  110921. /**
  110922. * Defines the gamepad move sensiblity.
  110923. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110924. */
  110925. gamepadMoveSensibility: number;
  110926. private _yAxisScale;
  110927. /**
  110928. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110929. */
  110930. get invertYAxis(): boolean;
  110931. set invertYAxis(value: boolean);
  110932. private _onGamepadConnectedObserver;
  110933. private _onGamepadDisconnectedObserver;
  110934. private _cameraTransform;
  110935. private _deltaTransform;
  110936. private _vector3;
  110937. private _vector2;
  110938. /**
  110939. * Attach the input controls to a specific dom element to get the input from.
  110940. * @param element Defines the element the controls should be listened from
  110941. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110942. */
  110943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110944. /**
  110945. * Detach the current controls from the specified dom element.
  110946. * @param element Defines the element to stop listening the inputs from
  110947. */
  110948. detachControl(element: Nullable<HTMLElement>): void;
  110949. /**
  110950. * Update the current camera state depending on the inputs that have been used this frame.
  110951. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110952. */
  110953. checkInputs(): void;
  110954. /**
  110955. * Gets the class name of the current intput.
  110956. * @returns the class name
  110957. */
  110958. getClassName(): string;
  110959. /**
  110960. * Get the friendly name associated with the input class.
  110961. * @returns the input friendly name
  110962. */
  110963. getSimpleName(): string;
  110964. }
  110965. }
  110966. declare module BABYLON {
  110967. /**
  110968. * Defines the potential axis of a Joystick
  110969. */
  110970. export enum JoystickAxis {
  110971. /** X axis */
  110972. X = 0,
  110973. /** Y axis */
  110974. Y = 1,
  110975. /** Z axis */
  110976. Z = 2
  110977. }
  110978. /**
  110979. * Class used to define virtual joystick (used in touch mode)
  110980. */
  110981. export class VirtualJoystick {
  110982. /**
  110983. * Gets or sets a boolean indicating that left and right values must be inverted
  110984. */
  110985. reverseLeftRight: boolean;
  110986. /**
  110987. * Gets or sets a boolean indicating that up and down values must be inverted
  110988. */
  110989. reverseUpDown: boolean;
  110990. /**
  110991. * Gets the offset value for the position (ie. the change of the position value)
  110992. */
  110993. deltaPosition: Vector3;
  110994. /**
  110995. * Gets a boolean indicating if the virtual joystick was pressed
  110996. */
  110997. pressed: boolean;
  110998. /**
  110999. * Canvas the virtual joystick will render onto, default z-index of this is 5
  111000. */
  111001. static Canvas: Nullable<HTMLCanvasElement>;
  111002. private static _globalJoystickIndex;
  111003. private static vjCanvasContext;
  111004. private static vjCanvasWidth;
  111005. private static vjCanvasHeight;
  111006. private static halfWidth;
  111007. private _action;
  111008. private _axisTargetedByLeftAndRight;
  111009. private _axisTargetedByUpAndDown;
  111010. private _joystickSensibility;
  111011. private _inversedSensibility;
  111012. private _joystickPointerID;
  111013. private _joystickColor;
  111014. private _joystickPointerPos;
  111015. private _joystickPreviousPointerPos;
  111016. private _joystickPointerStartPos;
  111017. private _deltaJoystickVector;
  111018. private _leftJoystick;
  111019. private _touches;
  111020. private _onPointerDownHandlerRef;
  111021. private _onPointerMoveHandlerRef;
  111022. private _onPointerUpHandlerRef;
  111023. private _onResize;
  111024. /**
  111025. * Creates a new virtual joystick
  111026. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111027. */
  111028. constructor(leftJoystick?: boolean);
  111029. /**
  111030. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111031. * @param newJoystickSensibility defines the new sensibility
  111032. */
  111033. setJoystickSensibility(newJoystickSensibility: number): void;
  111034. private _onPointerDown;
  111035. private _onPointerMove;
  111036. private _onPointerUp;
  111037. /**
  111038. * Change the color of the virtual joystick
  111039. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111040. */
  111041. setJoystickColor(newColor: string): void;
  111042. /**
  111043. * Defines a callback to call when the joystick is touched
  111044. * @param action defines the callback
  111045. */
  111046. setActionOnTouch(action: () => any): void;
  111047. /**
  111048. * Defines which axis you'd like to control for left & right
  111049. * @param axis defines the axis to use
  111050. */
  111051. setAxisForLeftRight(axis: JoystickAxis): void;
  111052. /**
  111053. * Defines which axis you'd like to control for up & down
  111054. * @param axis defines the axis to use
  111055. */
  111056. setAxisForUpDown(axis: JoystickAxis): void;
  111057. private _drawVirtualJoystick;
  111058. /**
  111059. * Release internal HTML canvas
  111060. */
  111061. releaseCanvas(): void;
  111062. }
  111063. }
  111064. declare module BABYLON {
  111065. interface FreeCameraInputsManager {
  111066. /**
  111067. * Add virtual joystick input support to the input manager.
  111068. * @returns the current input manager
  111069. */
  111070. addVirtualJoystick(): FreeCameraInputsManager;
  111071. }
  111072. /**
  111073. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  111074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111075. */
  111076. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  111077. /**
  111078. * Defines the camera the input is attached to.
  111079. */
  111080. camera: FreeCamera;
  111081. private _leftjoystick;
  111082. private _rightjoystick;
  111083. /**
  111084. * Gets the left stick of the virtual joystick.
  111085. * @returns The virtual Joystick
  111086. */
  111087. getLeftJoystick(): VirtualJoystick;
  111088. /**
  111089. * Gets the right stick of the virtual joystick.
  111090. * @returns The virtual Joystick
  111091. */
  111092. getRightJoystick(): VirtualJoystick;
  111093. /**
  111094. * Update the current camera state depending on the inputs that have been used this frame.
  111095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111096. */
  111097. checkInputs(): void;
  111098. /**
  111099. * Attach the input controls to a specific dom element to get the input from.
  111100. * @param element Defines the element the controls should be listened from
  111101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111102. */
  111103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111104. /**
  111105. * Detach the current controls from the specified dom element.
  111106. * @param element Defines the element to stop listening the inputs from
  111107. */
  111108. detachControl(element: Nullable<HTMLElement>): void;
  111109. /**
  111110. * Gets the class name of the current intput.
  111111. * @returns the class name
  111112. */
  111113. getClassName(): string;
  111114. /**
  111115. * Get the friendly name associated with the input class.
  111116. * @returns the input friendly name
  111117. */
  111118. getSimpleName(): string;
  111119. }
  111120. }
  111121. declare module BABYLON {
  111122. /**
  111123. * This represents a FPS type of camera controlled by touch.
  111124. * This is like a universal camera minus the Gamepad controls.
  111125. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111126. */
  111127. export class TouchCamera extends FreeCamera {
  111128. /**
  111129. * Defines the touch sensibility for rotation.
  111130. * The higher the faster.
  111131. */
  111132. get touchAngularSensibility(): number;
  111133. set touchAngularSensibility(value: number);
  111134. /**
  111135. * Defines the touch sensibility for move.
  111136. * The higher the faster.
  111137. */
  111138. get touchMoveSensibility(): number;
  111139. set touchMoveSensibility(value: number);
  111140. /**
  111141. * Instantiates a new touch camera.
  111142. * This represents a FPS type of camera controlled by touch.
  111143. * This is like a universal camera minus the Gamepad controls.
  111144. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111145. * @param name Define the name of the camera in the scene
  111146. * @param position Define the start position of the camera in the scene
  111147. * @param scene Define the scene the camera belongs to
  111148. */
  111149. constructor(name: string, position: Vector3, scene: Scene);
  111150. /**
  111151. * Gets the current object class name.
  111152. * @return the class name
  111153. */
  111154. getClassName(): string;
  111155. /** @hidden */
  111156. _setupInputs(): void;
  111157. }
  111158. }
  111159. declare module BABYLON {
  111160. /**
  111161. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  111162. * being tilted forward or back and left or right.
  111163. */
  111164. export class DeviceOrientationCamera extends FreeCamera {
  111165. private _initialQuaternion;
  111166. private _quaternionCache;
  111167. private _tmpDragQuaternion;
  111168. private _disablePointerInputWhenUsingDeviceOrientation;
  111169. /**
  111170. * Creates a new device orientation camera
  111171. * @param name The name of the camera
  111172. * @param position The start position camera
  111173. * @param scene The scene the camera belongs to
  111174. */
  111175. constructor(name: string, position: Vector3, scene: Scene);
  111176. /**
  111177. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  111178. */
  111179. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  111180. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  111181. private _dragFactor;
  111182. /**
  111183. * Enabled turning on the y axis when the orientation sensor is active
  111184. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  111185. */
  111186. enableHorizontalDragging(dragFactor?: number): void;
  111187. /**
  111188. * Gets the current instance class name ("DeviceOrientationCamera").
  111189. * This helps avoiding instanceof at run time.
  111190. * @returns the class name
  111191. */
  111192. getClassName(): string;
  111193. /**
  111194. * @hidden
  111195. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  111196. */
  111197. _checkInputs(): void;
  111198. /**
  111199. * Reset the camera to its default orientation on the specified axis only.
  111200. * @param axis The axis to reset
  111201. */
  111202. resetToCurrentRotation(axis?: Axis): void;
  111203. }
  111204. }
  111205. declare module BABYLON {
  111206. /**
  111207. * Defines supported buttons for XBox360 compatible gamepads
  111208. */
  111209. export enum Xbox360Button {
  111210. /** A */
  111211. A = 0,
  111212. /** B */
  111213. B = 1,
  111214. /** X */
  111215. X = 2,
  111216. /** Y */
  111217. Y = 3,
  111218. /** Start */
  111219. Start = 4,
  111220. /** Back */
  111221. Back = 5,
  111222. /** Left button */
  111223. LB = 6,
  111224. /** Right button */
  111225. RB = 7,
  111226. /** Left stick */
  111227. LeftStick = 8,
  111228. /** Right stick */
  111229. RightStick = 9
  111230. }
  111231. /** Defines values for XBox360 DPad */
  111232. export enum Xbox360Dpad {
  111233. /** Up */
  111234. Up = 0,
  111235. /** Down */
  111236. Down = 1,
  111237. /** Left */
  111238. Left = 2,
  111239. /** Right */
  111240. Right = 3
  111241. }
  111242. /**
  111243. * Defines a XBox360 gamepad
  111244. */
  111245. export class Xbox360Pad extends Gamepad {
  111246. private _leftTrigger;
  111247. private _rightTrigger;
  111248. private _onlefttriggerchanged;
  111249. private _onrighttriggerchanged;
  111250. private _onbuttondown;
  111251. private _onbuttonup;
  111252. private _ondpaddown;
  111253. private _ondpadup;
  111254. /** Observable raised when a button is pressed */
  111255. onButtonDownObservable: Observable<Xbox360Button>;
  111256. /** Observable raised when a button is released */
  111257. onButtonUpObservable: Observable<Xbox360Button>;
  111258. /** Observable raised when a pad is pressed */
  111259. onPadDownObservable: Observable<Xbox360Dpad>;
  111260. /** Observable raised when a pad is released */
  111261. onPadUpObservable: Observable<Xbox360Dpad>;
  111262. private _buttonA;
  111263. private _buttonB;
  111264. private _buttonX;
  111265. private _buttonY;
  111266. private _buttonBack;
  111267. private _buttonStart;
  111268. private _buttonLB;
  111269. private _buttonRB;
  111270. private _buttonLeftStick;
  111271. private _buttonRightStick;
  111272. private _dPadUp;
  111273. private _dPadDown;
  111274. private _dPadLeft;
  111275. private _dPadRight;
  111276. private _isXboxOnePad;
  111277. /**
  111278. * Creates a new XBox360 gamepad object
  111279. * @param id defines the id of this gamepad
  111280. * @param index defines its index
  111281. * @param gamepad defines the internal HTML gamepad object
  111282. * @param xboxOne defines if it is a XBox One gamepad
  111283. */
  111284. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  111285. /**
  111286. * Defines the callback to call when left trigger is pressed
  111287. * @param callback defines the callback to use
  111288. */
  111289. onlefttriggerchanged(callback: (value: number) => void): void;
  111290. /**
  111291. * Defines the callback to call when right trigger is pressed
  111292. * @param callback defines the callback to use
  111293. */
  111294. onrighttriggerchanged(callback: (value: number) => void): void;
  111295. /**
  111296. * Gets the left trigger value
  111297. */
  111298. get leftTrigger(): number;
  111299. /**
  111300. * Sets the left trigger value
  111301. */
  111302. set leftTrigger(newValue: number);
  111303. /**
  111304. * Gets the right trigger value
  111305. */
  111306. get rightTrigger(): number;
  111307. /**
  111308. * Sets the right trigger value
  111309. */
  111310. set rightTrigger(newValue: number);
  111311. /**
  111312. * Defines the callback to call when a button is pressed
  111313. * @param callback defines the callback to use
  111314. */
  111315. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  111316. /**
  111317. * Defines the callback to call when a button is released
  111318. * @param callback defines the callback to use
  111319. */
  111320. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  111321. /**
  111322. * Defines the callback to call when a pad is pressed
  111323. * @param callback defines the callback to use
  111324. */
  111325. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  111326. /**
  111327. * Defines the callback to call when a pad is released
  111328. * @param callback defines the callback to use
  111329. */
  111330. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  111331. private _setButtonValue;
  111332. private _setDPadValue;
  111333. /**
  111334. * Gets the value of the `A` button
  111335. */
  111336. get buttonA(): number;
  111337. /**
  111338. * Sets the value of the `A` button
  111339. */
  111340. set buttonA(value: number);
  111341. /**
  111342. * Gets the value of the `B` button
  111343. */
  111344. get buttonB(): number;
  111345. /**
  111346. * Sets the value of the `B` button
  111347. */
  111348. set buttonB(value: number);
  111349. /**
  111350. * Gets the value of the `X` button
  111351. */
  111352. get buttonX(): number;
  111353. /**
  111354. * Sets the value of the `X` button
  111355. */
  111356. set buttonX(value: number);
  111357. /**
  111358. * Gets the value of the `Y` button
  111359. */
  111360. get buttonY(): number;
  111361. /**
  111362. * Sets the value of the `Y` button
  111363. */
  111364. set buttonY(value: number);
  111365. /**
  111366. * Gets the value of the `Start` button
  111367. */
  111368. get buttonStart(): number;
  111369. /**
  111370. * Sets the value of the `Start` button
  111371. */
  111372. set buttonStart(value: number);
  111373. /**
  111374. * Gets the value of the `Back` button
  111375. */
  111376. get buttonBack(): number;
  111377. /**
  111378. * Sets the value of the `Back` button
  111379. */
  111380. set buttonBack(value: number);
  111381. /**
  111382. * Gets the value of the `Left` button
  111383. */
  111384. get buttonLB(): number;
  111385. /**
  111386. * Sets the value of the `Left` button
  111387. */
  111388. set buttonLB(value: number);
  111389. /**
  111390. * Gets the value of the `Right` button
  111391. */
  111392. get buttonRB(): number;
  111393. /**
  111394. * Sets the value of the `Right` button
  111395. */
  111396. set buttonRB(value: number);
  111397. /**
  111398. * Gets the value of the Left joystick
  111399. */
  111400. get buttonLeftStick(): number;
  111401. /**
  111402. * Sets the value of the Left joystick
  111403. */
  111404. set buttonLeftStick(value: number);
  111405. /**
  111406. * Gets the value of the Right joystick
  111407. */
  111408. get buttonRightStick(): number;
  111409. /**
  111410. * Sets the value of the Right joystick
  111411. */
  111412. set buttonRightStick(value: number);
  111413. /**
  111414. * Gets the value of D-pad up
  111415. */
  111416. get dPadUp(): number;
  111417. /**
  111418. * Sets the value of D-pad up
  111419. */
  111420. set dPadUp(value: number);
  111421. /**
  111422. * Gets the value of D-pad down
  111423. */
  111424. get dPadDown(): number;
  111425. /**
  111426. * Sets the value of D-pad down
  111427. */
  111428. set dPadDown(value: number);
  111429. /**
  111430. * Gets the value of D-pad left
  111431. */
  111432. get dPadLeft(): number;
  111433. /**
  111434. * Sets the value of D-pad left
  111435. */
  111436. set dPadLeft(value: number);
  111437. /**
  111438. * Gets the value of D-pad right
  111439. */
  111440. get dPadRight(): number;
  111441. /**
  111442. * Sets the value of D-pad right
  111443. */
  111444. set dPadRight(value: number);
  111445. /**
  111446. * Force the gamepad to synchronize with device values
  111447. */
  111448. update(): void;
  111449. /**
  111450. * Disposes the gamepad
  111451. */
  111452. dispose(): void;
  111453. }
  111454. }
  111455. declare module BABYLON {
  111456. /**
  111457. * Defines supported buttons for DualShock compatible gamepads
  111458. */
  111459. export enum DualShockButton {
  111460. /** Cross */
  111461. Cross = 0,
  111462. /** Circle */
  111463. Circle = 1,
  111464. /** Square */
  111465. Square = 2,
  111466. /** Triangle */
  111467. Triangle = 3,
  111468. /** Options */
  111469. Options = 4,
  111470. /** Share */
  111471. Share = 5,
  111472. /** L1 */
  111473. L1 = 6,
  111474. /** R1 */
  111475. R1 = 7,
  111476. /** Left stick */
  111477. LeftStick = 8,
  111478. /** Right stick */
  111479. RightStick = 9
  111480. }
  111481. /** Defines values for DualShock DPad */
  111482. export enum DualShockDpad {
  111483. /** Up */
  111484. Up = 0,
  111485. /** Down */
  111486. Down = 1,
  111487. /** Left */
  111488. Left = 2,
  111489. /** Right */
  111490. Right = 3
  111491. }
  111492. /**
  111493. * Defines a DualShock gamepad
  111494. */
  111495. export class DualShockPad extends Gamepad {
  111496. private _leftTrigger;
  111497. private _rightTrigger;
  111498. private _onlefttriggerchanged;
  111499. private _onrighttriggerchanged;
  111500. private _onbuttondown;
  111501. private _onbuttonup;
  111502. private _ondpaddown;
  111503. private _ondpadup;
  111504. /** Observable raised when a button is pressed */
  111505. onButtonDownObservable: Observable<DualShockButton>;
  111506. /** Observable raised when a button is released */
  111507. onButtonUpObservable: Observable<DualShockButton>;
  111508. /** Observable raised when a pad is pressed */
  111509. onPadDownObservable: Observable<DualShockDpad>;
  111510. /** Observable raised when a pad is released */
  111511. onPadUpObservable: Observable<DualShockDpad>;
  111512. private _buttonCross;
  111513. private _buttonCircle;
  111514. private _buttonSquare;
  111515. private _buttonTriangle;
  111516. private _buttonShare;
  111517. private _buttonOptions;
  111518. private _buttonL1;
  111519. private _buttonR1;
  111520. private _buttonLeftStick;
  111521. private _buttonRightStick;
  111522. private _dPadUp;
  111523. private _dPadDown;
  111524. private _dPadLeft;
  111525. private _dPadRight;
  111526. /**
  111527. * Creates a new DualShock gamepad object
  111528. * @param id defines the id of this gamepad
  111529. * @param index defines its index
  111530. * @param gamepad defines the internal HTML gamepad object
  111531. */
  111532. constructor(id: string, index: number, gamepad: any);
  111533. /**
  111534. * Defines the callback to call when left trigger is pressed
  111535. * @param callback defines the callback to use
  111536. */
  111537. onlefttriggerchanged(callback: (value: number) => void): void;
  111538. /**
  111539. * Defines the callback to call when right trigger is pressed
  111540. * @param callback defines the callback to use
  111541. */
  111542. onrighttriggerchanged(callback: (value: number) => void): void;
  111543. /**
  111544. * Gets the left trigger value
  111545. */
  111546. get leftTrigger(): number;
  111547. /**
  111548. * Sets the left trigger value
  111549. */
  111550. set leftTrigger(newValue: number);
  111551. /**
  111552. * Gets the right trigger value
  111553. */
  111554. get rightTrigger(): number;
  111555. /**
  111556. * Sets the right trigger value
  111557. */
  111558. set rightTrigger(newValue: number);
  111559. /**
  111560. * Defines the callback to call when a button is pressed
  111561. * @param callback defines the callback to use
  111562. */
  111563. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  111564. /**
  111565. * Defines the callback to call when a button is released
  111566. * @param callback defines the callback to use
  111567. */
  111568. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  111569. /**
  111570. * Defines the callback to call when a pad is pressed
  111571. * @param callback defines the callback to use
  111572. */
  111573. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  111574. /**
  111575. * Defines the callback to call when a pad is released
  111576. * @param callback defines the callback to use
  111577. */
  111578. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  111579. private _setButtonValue;
  111580. private _setDPadValue;
  111581. /**
  111582. * Gets the value of the `Cross` button
  111583. */
  111584. get buttonCross(): number;
  111585. /**
  111586. * Sets the value of the `Cross` button
  111587. */
  111588. set buttonCross(value: number);
  111589. /**
  111590. * Gets the value of the `Circle` button
  111591. */
  111592. get buttonCircle(): number;
  111593. /**
  111594. * Sets the value of the `Circle` button
  111595. */
  111596. set buttonCircle(value: number);
  111597. /**
  111598. * Gets the value of the `Square` button
  111599. */
  111600. get buttonSquare(): number;
  111601. /**
  111602. * Sets the value of the `Square` button
  111603. */
  111604. set buttonSquare(value: number);
  111605. /**
  111606. * Gets the value of the `Triangle` button
  111607. */
  111608. get buttonTriangle(): number;
  111609. /**
  111610. * Sets the value of the `Triangle` button
  111611. */
  111612. set buttonTriangle(value: number);
  111613. /**
  111614. * Gets the value of the `Options` button
  111615. */
  111616. get buttonOptions(): number;
  111617. /**
  111618. * Sets the value of the `Options` button
  111619. */
  111620. set buttonOptions(value: number);
  111621. /**
  111622. * Gets the value of the `Share` button
  111623. */
  111624. get buttonShare(): number;
  111625. /**
  111626. * Sets the value of the `Share` button
  111627. */
  111628. set buttonShare(value: number);
  111629. /**
  111630. * Gets the value of the `L1` button
  111631. */
  111632. get buttonL1(): number;
  111633. /**
  111634. * Sets the value of the `L1` button
  111635. */
  111636. set buttonL1(value: number);
  111637. /**
  111638. * Gets the value of the `R1` button
  111639. */
  111640. get buttonR1(): number;
  111641. /**
  111642. * Sets the value of the `R1` button
  111643. */
  111644. set buttonR1(value: number);
  111645. /**
  111646. * Gets the value of the Left joystick
  111647. */
  111648. get buttonLeftStick(): number;
  111649. /**
  111650. * Sets the value of the Left joystick
  111651. */
  111652. set buttonLeftStick(value: number);
  111653. /**
  111654. * Gets the value of the Right joystick
  111655. */
  111656. get buttonRightStick(): number;
  111657. /**
  111658. * Sets the value of the Right joystick
  111659. */
  111660. set buttonRightStick(value: number);
  111661. /**
  111662. * Gets the value of D-pad up
  111663. */
  111664. get dPadUp(): number;
  111665. /**
  111666. * Sets the value of D-pad up
  111667. */
  111668. set dPadUp(value: number);
  111669. /**
  111670. * Gets the value of D-pad down
  111671. */
  111672. get dPadDown(): number;
  111673. /**
  111674. * Sets the value of D-pad down
  111675. */
  111676. set dPadDown(value: number);
  111677. /**
  111678. * Gets the value of D-pad left
  111679. */
  111680. get dPadLeft(): number;
  111681. /**
  111682. * Sets the value of D-pad left
  111683. */
  111684. set dPadLeft(value: number);
  111685. /**
  111686. * Gets the value of D-pad right
  111687. */
  111688. get dPadRight(): number;
  111689. /**
  111690. * Sets the value of D-pad right
  111691. */
  111692. set dPadRight(value: number);
  111693. /**
  111694. * Force the gamepad to synchronize with device values
  111695. */
  111696. update(): void;
  111697. /**
  111698. * Disposes the gamepad
  111699. */
  111700. dispose(): void;
  111701. }
  111702. }
  111703. declare module BABYLON {
  111704. /**
  111705. * Manager for handling gamepads
  111706. */
  111707. export class GamepadManager {
  111708. private _scene?;
  111709. private _babylonGamepads;
  111710. private _oneGamepadConnected;
  111711. /** @hidden */
  111712. _isMonitoring: boolean;
  111713. private _gamepadEventSupported;
  111714. private _gamepadSupport?;
  111715. /**
  111716. * observable to be triggered when the gamepad controller has been connected
  111717. */
  111718. onGamepadConnectedObservable: Observable<Gamepad>;
  111719. /**
  111720. * observable to be triggered when the gamepad controller has been disconnected
  111721. */
  111722. onGamepadDisconnectedObservable: Observable<Gamepad>;
  111723. private _onGamepadConnectedEvent;
  111724. private _onGamepadDisconnectedEvent;
  111725. /**
  111726. * Initializes the gamepad manager
  111727. * @param _scene BabylonJS scene
  111728. */
  111729. constructor(_scene?: Scene | undefined);
  111730. /**
  111731. * The gamepads in the game pad manager
  111732. */
  111733. get gamepads(): Gamepad[];
  111734. /**
  111735. * Get the gamepad controllers based on type
  111736. * @param type The type of gamepad controller
  111737. * @returns Nullable gamepad
  111738. */
  111739. getGamepadByType(type?: number): Nullable<Gamepad>;
  111740. /**
  111741. * Disposes the gamepad manager
  111742. */
  111743. dispose(): void;
  111744. private _addNewGamepad;
  111745. private _startMonitoringGamepads;
  111746. private _stopMonitoringGamepads;
  111747. /** @hidden */
  111748. _checkGamepadsStatus(): void;
  111749. private _updateGamepadObjects;
  111750. }
  111751. }
  111752. declare module BABYLON {
  111753. interface Scene {
  111754. /** @hidden */
  111755. _gamepadManager: Nullable<GamepadManager>;
  111756. /**
  111757. * Gets the gamepad manager associated with the scene
  111758. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  111759. */
  111760. gamepadManager: GamepadManager;
  111761. }
  111762. /**
  111763. * Interface representing a free camera inputs manager
  111764. */
  111765. interface FreeCameraInputsManager {
  111766. /**
  111767. * Adds gamepad input support to the FreeCameraInputsManager.
  111768. * @returns the FreeCameraInputsManager
  111769. */
  111770. addGamepad(): FreeCameraInputsManager;
  111771. }
  111772. /**
  111773. * Interface representing an arc rotate camera inputs manager
  111774. */
  111775. interface ArcRotateCameraInputsManager {
  111776. /**
  111777. * Adds gamepad input support to the ArcRotateCamera InputManager.
  111778. * @returns the camera inputs manager
  111779. */
  111780. addGamepad(): ArcRotateCameraInputsManager;
  111781. }
  111782. /**
  111783. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  111784. */
  111785. export class GamepadSystemSceneComponent implements ISceneComponent {
  111786. /**
  111787. * The component name helpfull to identify the component in the list of scene components.
  111788. */
  111789. readonly name: string;
  111790. /**
  111791. * The scene the component belongs to.
  111792. */
  111793. scene: Scene;
  111794. /**
  111795. * Creates a new instance of the component for the given scene
  111796. * @param scene Defines the scene to register the component in
  111797. */
  111798. constructor(scene: Scene);
  111799. /**
  111800. * Registers the component in a given scene
  111801. */
  111802. register(): void;
  111803. /**
  111804. * Rebuilds the elements related to this component in case of
  111805. * context lost for instance.
  111806. */
  111807. rebuild(): void;
  111808. /**
  111809. * Disposes the component and the associated ressources
  111810. */
  111811. dispose(): void;
  111812. private _beforeCameraUpdate;
  111813. }
  111814. }
  111815. declare module BABYLON {
  111816. /**
  111817. * 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,
  111818. * which still works and will still be found in many Playgrounds.
  111819. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111820. */
  111821. export class UniversalCamera extends TouchCamera {
  111822. /**
  111823. * Defines the gamepad rotation sensiblity.
  111824. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111825. */
  111826. get gamepadAngularSensibility(): number;
  111827. set gamepadAngularSensibility(value: number);
  111828. /**
  111829. * Defines the gamepad move sensiblity.
  111830. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111831. */
  111832. get gamepadMoveSensibility(): number;
  111833. set gamepadMoveSensibility(value: number);
  111834. /**
  111835. * 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,
  111836. * which still works and will still be found in many Playgrounds.
  111837. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111838. * @param name Define the name of the camera in the scene
  111839. * @param position Define the start position of the camera in the scene
  111840. * @param scene Define the scene the camera belongs to
  111841. */
  111842. constructor(name: string, position: Vector3, scene: Scene);
  111843. /**
  111844. * Gets the current object class name.
  111845. * @return the class name
  111846. */
  111847. getClassName(): string;
  111848. }
  111849. }
  111850. declare module BABYLON {
  111851. /**
  111852. * This represents a FPS type of camera. This is only here for back compat purpose.
  111853. * Please use the UniversalCamera instead as both are identical.
  111854. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111855. */
  111856. export class GamepadCamera extends UniversalCamera {
  111857. /**
  111858. * Instantiates a new Gamepad Camera
  111859. * This represents a FPS type of camera. This is only here for back compat purpose.
  111860. * Please use the UniversalCamera instead as both are identical.
  111861. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111862. * @param name Define the name of the camera in the scene
  111863. * @param position Define the start position of the camera in the scene
  111864. * @param scene Define the scene the camera belongs to
  111865. */
  111866. constructor(name: string, position: Vector3, scene: Scene);
  111867. /**
  111868. * Gets the current object class name.
  111869. * @return the class name
  111870. */
  111871. getClassName(): string;
  111872. }
  111873. }
  111874. declare module BABYLON {
  111875. /** @hidden */
  111876. export var passPixelShader: {
  111877. name: string;
  111878. shader: string;
  111879. };
  111880. }
  111881. declare module BABYLON {
  111882. /** @hidden */
  111883. export var passCubePixelShader: {
  111884. name: string;
  111885. shader: string;
  111886. };
  111887. }
  111888. declare module BABYLON {
  111889. /**
  111890. * PassPostProcess which produces an output the same as it's input
  111891. */
  111892. export class PassPostProcess extends PostProcess {
  111893. /**
  111894. * Creates the PassPostProcess
  111895. * @param name The name of the effect.
  111896. * @param options The required width/height ratio to downsize to before computing the render pass.
  111897. * @param camera The camera to apply the render pass to.
  111898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111899. * @param engine The engine which the post process will be applied. (default: current engine)
  111900. * @param reusable If the post process can be reused on the same frame. (default: false)
  111901. * @param textureType The type of texture to be used when performing the post processing.
  111902. * @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)
  111903. */
  111904. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111905. }
  111906. /**
  111907. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  111908. */
  111909. export class PassCubePostProcess extends PostProcess {
  111910. private _face;
  111911. /**
  111912. * Gets or sets the cube face to display.
  111913. * * 0 is +X
  111914. * * 1 is -X
  111915. * * 2 is +Y
  111916. * * 3 is -Y
  111917. * * 4 is +Z
  111918. * * 5 is -Z
  111919. */
  111920. get face(): number;
  111921. set face(value: number);
  111922. /**
  111923. * Creates the PassCubePostProcess
  111924. * @param name The name of the effect.
  111925. * @param options The required width/height ratio to downsize to before computing the render pass.
  111926. * @param camera The camera to apply the render pass to.
  111927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111928. * @param engine The engine which the post process will be applied. (default: current engine)
  111929. * @param reusable If the post process can be reused on the same frame. (default: false)
  111930. * @param textureType The type of texture to be used when performing the post processing.
  111931. * @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)
  111932. */
  111933. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111934. }
  111935. }
  111936. declare module BABYLON {
  111937. /** @hidden */
  111938. export var anaglyphPixelShader: {
  111939. name: string;
  111940. shader: string;
  111941. };
  111942. }
  111943. declare module BABYLON {
  111944. /**
  111945. * Postprocess used to generate anaglyphic rendering
  111946. */
  111947. export class AnaglyphPostProcess extends PostProcess {
  111948. private _passedProcess;
  111949. /**
  111950. * Creates a new AnaglyphPostProcess
  111951. * @param name defines postprocess name
  111952. * @param options defines creation options or target ratio scale
  111953. * @param rigCameras defines cameras using this postprocess
  111954. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  111955. * @param engine defines hosting engine
  111956. * @param reusable defines if the postprocess will be reused multiple times per frame
  111957. */
  111958. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  111959. }
  111960. }
  111961. declare module BABYLON {
  111962. /**
  111963. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  111964. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  111965. */
  111966. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  111967. /**
  111968. * Creates a new AnaglyphArcRotateCamera
  111969. * @param name defines camera name
  111970. * @param alpha defines alpha angle (in radians)
  111971. * @param beta defines beta angle (in radians)
  111972. * @param radius defines radius
  111973. * @param target defines camera target
  111974. * @param interaxialDistance defines distance between each color axis
  111975. * @param scene defines the hosting scene
  111976. */
  111977. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  111978. /**
  111979. * Gets camera class name
  111980. * @returns AnaglyphArcRotateCamera
  111981. */
  111982. getClassName(): string;
  111983. }
  111984. }
  111985. declare module BABYLON {
  111986. /**
  111987. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  111988. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  111989. */
  111990. export class AnaglyphFreeCamera extends FreeCamera {
  111991. /**
  111992. * Creates a new AnaglyphFreeCamera
  111993. * @param name defines camera name
  111994. * @param position defines initial position
  111995. * @param interaxialDistance defines distance between each color axis
  111996. * @param scene defines the hosting scene
  111997. */
  111998. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  111999. /**
  112000. * Gets camera class name
  112001. * @returns AnaglyphFreeCamera
  112002. */
  112003. getClassName(): string;
  112004. }
  112005. }
  112006. declare module BABYLON {
  112007. /**
  112008. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112009. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112010. */
  112011. export class AnaglyphGamepadCamera extends GamepadCamera {
  112012. /**
  112013. * Creates a new AnaglyphGamepadCamera
  112014. * @param name defines camera name
  112015. * @param position defines initial position
  112016. * @param interaxialDistance defines distance between each color axis
  112017. * @param scene defines the hosting scene
  112018. */
  112019. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112020. /**
  112021. * Gets camera class name
  112022. * @returns AnaglyphGamepadCamera
  112023. */
  112024. getClassName(): string;
  112025. }
  112026. }
  112027. declare module BABYLON {
  112028. /**
  112029. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112030. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112031. */
  112032. export class AnaglyphUniversalCamera extends UniversalCamera {
  112033. /**
  112034. * Creates a new AnaglyphUniversalCamera
  112035. * @param name defines camera name
  112036. * @param position defines initial position
  112037. * @param interaxialDistance defines distance between each color axis
  112038. * @param scene defines the hosting scene
  112039. */
  112040. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112041. /**
  112042. * Gets camera class name
  112043. * @returns AnaglyphUniversalCamera
  112044. */
  112045. getClassName(): string;
  112046. }
  112047. }
  112048. declare module BABYLON {
  112049. /** @hidden */
  112050. export var stereoscopicInterlacePixelShader: {
  112051. name: string;
  112052. shader: string;
  112053. };
  112054. }
  112055. declare module BABYLON {
  112056. /**
  112057. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112058. */
  112059. export class StereoscopicInterlacePostProcess extends PostProcess {
  112060. private _stepSize;
  112061. private _passedProcess;
  112062. /**
  112063. * Initializes a StereoscopicInterlacePostProcess
  112064. * @param name The name of the effect.
  112065. * @param rigCameras The rig cameras to be appled to the post process
  112066. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112068. * @param engine The engine which the post process will be applied. (default: current engine)
  112069. * @param reusable If the post process can be reused on the same frame. (default: false)
  112070. */
  112071. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112072. }
  112073. }
  112074. declare module BABYLON {
  112075. /**
  112076. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  112077. * @see http://doc.babylonjs.com/features/cameras
  112078. */
  112079. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  112080. /**
  112081. * Creates a new StereoscopicArcRotateCamera
  112082. * @param name defines camera name
  112083. * @param alpha defines alpha angle (in radians)
  112084. * @param beta defines beta angle (in radians)
  112085. * @param radius defines radius
  112086. * @param target defines camera target
  112087. * @param interaxialDistance defines distance between each color axis
  112088. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112089. * @param scene defines the hosting scene
  112090. */
  112091. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112092. /**
  112093. * Gets camera class name
  112094. * @returns StereoscopicArcRotateCamera
  112095. */
  112096. getClassName(): string;
  112097. }
  112098. }
  112099. declare module BABYLON {
  112100. /**
  112101. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  112102. * @see http://doc.babylonjs.com/features/cameras
  112103. */
  112104. export class StereoscopicFreeCamera extends FreeCamera {
  112105. /**
  112106. * Creates a new StereoscopicFreeCamera
  112107. * @param name defines camera name
  112108. * @param position defines initial position
  112109. * @param interaxialDistance defines distance between each color axis
  112110. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112111. * @param scene defines the hosting scene
  112112. */
  112113. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112114. /**
  112115. * Gets camera class name
  112116. * @returns StereoscopicFreeCamera
  112117. */
  112118. getClassName(): string;
  112119. }
  112120. }
  112121. declare module BABYLON {
  112122. /**
  112123. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  112124. * @see http://doc.babylonjs.com/features/cameras
  112125. */
  112126. export class StereoscopicGamepadCamera extends GamepadCamera {
  112127. /**
  112128. * Creates a new StereoscopicGamepadCamera
  112129. * @param name defines camera name
  112130. * @param position defines initial position
  112131. * @param interaxialDistance defines distance between each color axis
  112132. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112133. * @param scene defines the hosting scene
  112134. */
  112135. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112136. /**
  112137. * Gets camera class name
  112138. * @returns StereoscopicGamepadCamera
  112139. */
  112140. getClassName(): string;
  112141. }
  112142. }
  112143. declare module BABYLON {
  112144. /**
  112145. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  112146. * @see http://doc.babylonjs.com/features/cameras
  112147. */
  112148. export class StereoscopicUniversalCamera extends UniversalCamera {
  112149. /**
  112150. * Creates a new StereoscopicUniversalCamera
  112151. * @param name defines camera name
  112152. * @param position defines initial position
  112153. * @param interaxialDistance defines distance between each color axis
  112154. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112155. * @param scene defines the hosting scene
  112156. */
  112157. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112158. /**
  112159. * Gets camera class name
  112160. * @returns StereoscopicUniversalCamera
  112161. */
  112162. getClassName(): string;
  112163. }
  112164. }
  112165. declare module BABYLON {
  112166. /**
  112167. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  112168. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112169. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112170. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112171. */
  112172. export class VirtualJoysticksCamera extends FreeCamera {
  112173. /**
  112174. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  112175. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112176. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112177. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112178. * @param name Define the name of the camera in the scene
  112179. * @param position Define the start position of the camera in the scene
  112180. * @param scene Define the scene the camera belongs to
  112181. */
  112182. constructor(name: string, position: Vector3, scene: Scene);
  112183. /**
  112184. * Gets the current object class name.
  112185. * @return the class name
  112186. */
  112187. getClassName(): string;
  112188. }
  112189. }
  112190. declare module BABYLON {
  112191. /**
  112192. * This represents all the required metrics to create a VR camera.
  112193. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  112194. */
  112195. export class VRCameraMetrics {
  112196. /**
  112197. * Define the horizontal resolution off the screen.
  112198. */
  112199. hResolution: number;
  112200. /**
  112201. * Define the vertical resolution off the screen.
  112202. */
  112203. vResolution: number;
  112204. /**
  112205. * Define the horizontal screen size.
  112206. */
  112207. hScreenSize: number;
  112208. /**
  112209. * Define the vertical screen size.
  112210. */
  112211. vScreenSize: number;
  112212. /**
  112213. * Define the vertical screen center position.
  112214. */
  112215. vScreenCenter: number;
  112216. /**
  112217. * Define the distance of the eyes to the screen.
  112218. */
  112219. eyeToScreenDistance: number;
  112220. /**
  112221. * Define the distance between both lenses
  112222. */
  112223. lensSeparationDistance: number;
  112224. /**
  112225. * Define the distance between both viewer's eyes.
  112226. */
  112227. interpupillaryDistance: number;
  112228. /**
  112229. * Define the distortion factor of the VR postprocess.
  112230. * Please, touch with care.
  112231. */
  112232. distortionK: number[];
  112233. /**
  112234. * Define the chromatic aberration correction factors for the VR post process.
  112235. */
  112236. chromaAbCorrection: number[];
  112237. /**
  112238. * Define the scale factor of the post process.
  112239. * The smaller the better but the slower.
  112240. */
  112241. postProcessScaleFactor: number;
  112242. /**
  112243. * Define an offset for the lens center.
  112244. */
  112245. lensCenterOffset: number;
  112246. /**
  112247. * Define if the current vr camera should compensate the distortion of the lense or not.
  112248. */
  112249. compensateDistortion: boolean;
  112250. /**
  112251. * Defines if multiview should be enabled when rendering (Default: false)
  112252. */
  112253. multiviewEnabled: boolean;
  112254. /**
  112255. * Gets the rendering aspect ratio based on the provided resolutions.
  112256. */
  112257. get aspectRatio(): number;
  112258. /**
  112259. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  112260. */
  112261. get aspectRatioFov(): number;
  112262. /**
  112263. * @hidden
  112264. */
  112265. get leftHMatrix(): Matrix;
  112266. /**
  112267. * @hidden
  112268. */
  112269. get rightHMatrix(): Matrix;
  112270. /**
  112271. * @hidden
  112272. */
  112273. get leftPreViewMatrix(): Matrix;
  112274. /**
  112275. * @hidden
  112276. */
  112277. get rightPreViewMatrix(): Matrix;
  112278. /**
  112279. * Get the default VRMetrics based on the most generic setup.
  112280. * @returns the default vr metrics
  112281. */
  112282. static GetDefault(): VRCameraMetrics;
  112283. }
  112284. }
  112285. declare module BABYLON {
  112286. /** @hidden */
  112287. export var vrDistortionCorrectionPixelShader: {
  112288. name: string;
  112289. shader: string;
  112290. };
  112291. }
  112292. declare module BABYLON {
  112293. /**
  112294. * VRDistortionCorrectionPostProcess used for mobile VR
  112295. */
  112296. export class VRDistortionCorrectionPostProcess extends PostProcess {
  112297. private _isRightEye;
  112298. private _distortionFactors;
  112299. private _postProcessScaleFactor;
  112300. private _lensCenterOffset;
  112301. private _scaleIn;
  112302. private _scaleFactor;
  112303. private _lensCenter;
  112304. /**
  112305. * Initializes the VRDistortionCorrectionPostProcess
  112306. * @param name The name of the effect.
  112307. * @param camera The camera to apply the render pass to.
  112308. * @param isRightEye If this is for the right eye distortion
  112309. * @param vrMetrics All the required metrics for the VR camera
  112310. */
  112311. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  112312. }
  112313. }
  112314. declare module BABYLON {
  112315. /**
  112316. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  112317. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112318. */
  112319. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  112320. /**
  112321. * Creates a new VRDeviceOrientationArcRotateCamera
  112322. * @param name defines camera name
  112323. * @param alpha defines the camera rotation along the logitudinal axis
  112324. * @param beta defines the camera rotation along the latitudinal axis
  112325. * @param radius defines the camera distance from its target
  112326. * @param target defines the camera target
  112327. * @param scene defines the scene the camera belongs to
  112328. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112329. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112330. */
  112331. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112332. /**
  112333. * Gets camera class name
  112334. * @returns VRDeviceOrientationArcRotateCamera
  112335. */
  112336. getClassName(): string;
  112337. }
  112338. }
  112339. declare module BABYLON {
  112340. /**
  112341. * Camera used to simulate VR rendering (based on FreeCamera)
  112342. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112343. */
  112344. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  112345. /**
  112346. * Creates a new VRDeviceOrientationFreeCamera
  112347. * @param name defines camera name
  112348. * @param position defines the start position of the camera
  112349. * @param scene defines the scene the camera belongs to
  112350. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112351. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112352. */
  112353. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112354. /**
  112355. * Gets camera class name
  112356. * @returns VRDeviceOrientationFreeCamera
  112357. */
  112358. getClassName(): string;
  112359. }
  112360. }
  112361. declare module BABYLON {
  112362. /**
  112363. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  112364. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112365. */
  112366. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  112367. /**
  112368. * Creates a new VRDeviceOrientationGamepadCamera
  112369. * @param name defines camera name
  112370. * @param position defines the start position of the camera
  112371. * @param scene defines the scene the camera belongs to
  112372. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112373. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112374. */
  112375. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112376. /**
  112377. * Gets camera class name
  112378. * @returns VRDeviceOrientationGamepadCamera
  112379. */
  112380. getClassName(): string;
  112381. }
  112382. }
  112383. declare module BABYLON {
  112384. /** @hidden */
  112385. export var imageProcessingPixelShader: {
  112386. name: string;
  112387. shader: string;
  112388. };
  112389. }
  112390. declare module BABYLON {
  112391. /**
  112392. * ImageProcessingPostProcess
  112393. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  112394. */
  112395. export class ImageProcessingPostProcess extends PostProcess {
  112396. /**
  112397. * Default configuration related to image processing available in the PBR Material.
  112398. */
  112399. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112400. /**
  112401. * Gets the image processing configuration used either in this material.
  112402. */
  112403. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  112404. /**
  112405. * Sets the Default image processing configuration used either in the this material.
  112406. *
  112407. * If sets to null, the scene one is in use.
  112408. */
  112409. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  112410. /**
  112411. * Keep track of the image processing observer to allow dispose and replace.
  112412. */
  112413. private _imageProcessingObserver;
  112414. /**
  112415. * Attaches a new image processing configuration to the PBR Material.
  112416. * @param configuration
  112417. */
  112418. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  112419. /**
  112420. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112421. */
  112422. get colorCurves(): Nullable<ColorCurves>;
  112423. /**
  112424. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112425. */
  112426. set colorCurves(value: Nullable<ColorCurves>);
  112427. /**
  112428. * Gets wether the color curves effect is enabled.
  112429. */
  112430. get colorCurvesEnabled(): boolean;
  112431. /**
  112432. * Sets wether the color curves effect is enabled.
  112433. */
  112434. set colorCurvesEnabled(value: boolean);
  112435. /**
  112436. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112437. */
  112438. get colorGradingTexture(): Nullable<BaseTexture>;
  112439. /**
  112440. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112441. */
  112442. set colorGradingTexture(value: Nullable<BaseTexture>);
  112443. /**
  112444. * Gets wether the color grading effect is enabled.
  112445. */
  112446. get colorGradingEnabled(): boolean;
  112447. /**
  112448. * Gets wether the color grading effect is enabled.
  112449. */
  112450. set colorGradingEnabled(value: boolean);
  112451. /**
  112452. * Gets exposure used in the effect.
  112453. */
  112454. get exposure(): number;
  112455. /**
  112456. * Sets exposure used in the effect.
  112457. */
  112458. set exposure(value: number);
  112459. /**
  112460. * Gets wether tonemapping is enabled or not.
  112461. */
  112462. get toneMappingEnabled(): boolean;
  112463. /**
  112464. * Sets wether tonemapping is enabled or not
  112465. */
  112466. set toneMappingEnabled(value: boolean);
  112467. /**
  112468. * Gets the type of tone mapping effect.
  112469. */
  112470. get toneMappingType(): number;
  112471. /**
  112472. * Sets the type of tone mapping effect.
  112473. */
  112474. set toneMappingType(value: number);
  112475. /**
  112476. * Gets contrast used in the effect.
  112477. */
  112478. get contrast(): number;
  112479. /**
  112480. * Sets contrast used in the effect.
  112481. */
  112482. set contrast(value: number);
  112483. /**
  112484. * Gets Vignette stretch size.
  112485. */
  112486. get vignetteStretch(): number;
  112487. /**
  112488. * Sets Vignette stretch size.
  112489. */
  112490. set vignetteStretch(value: number);
  112491. /**
  112492. * Gets Vignette centre X Offset.
  112493. */
  112494. get vignetteCentreX(): number;
  112495. /**
  112496. * Sets Vignette centre X Offset.
  112497. */
  112498. set vignetteCentreX(value: number);
  112499. /**
  112500. * Gets Vignette centre Y Offset.
  112501. */
  112502. get vignetteCentreY(): number;
  112503. /**
  112504. * Sets Vignette centre Y Offset.
  112505. */
  112506. set vignetteCentreY(value: number);
  112507. /**
  112508. * Gets Vignette weight or intensity of the vignette effect.
  112509. */
  112510. get vignetteWeight(): number;
  112511. /**
  112512. * Sets Vignette weight or intensity of the vignette effect.
  112513. */
  112514. set vignetteWeight(value: number);
  112515. /**
  112516. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112517. * if vignetteEnabled is set to true.
  112518. */
  112519. get vignetteColor(): Color4;
  112520. /**
  112521. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112522. * if vignetteEnabled is set to true.
  112523. */
  112524. set vignetteColor(value: Color4);
  112525. /**
  112526. * Gets Camera field of view used by the Vignette effect.
  112527. */
  112528. get vignetteCameraFov(): number;
  112529. /**
  112530. * Sets Camera field of view used by the Vignette effect.
  112531. */
  112532. set vignetteCameraFov(value: number);
  112533. /**
  112534. * Gets the vignette blend mode allowing different kind of effect.
  112535. */
  112536. get vignetteBlendMode(): number;
  112537. /**
  112538. * Sets the vignette blend mode allowing different kind of effect.
  112539. */
  112540. set vignetteBlendMode(value: number);
  112541. /**
  112542. * Gets wether the vignette effect is enabled.
  112543. */
  112544. get vignetteEnabled(): boolean;
  112545. /**
  112546. * Sets wether the vignette effect is enabled.
  112547. */
  112548. set vignetteEnabled(value: boolean);
  112549. private _fromLinearSpace;
  112550. /**
  112551. * Gets wether the input of the processing is in Gamma or Linear Space.
  112552. */
  112553. get fromLinearSpace(): boolean;
  112554. /**
  112555. * Sets wether the input of the processing is in Gamma or Linear Space.
  112556. */
  112557. set fromLinearSpace(value: boolean);
  112558. /**
  112559. * Defines cache preventing GC.
  112560. */
  112561. private _defines;
  112562. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  112563. /**
  112564. * "ImageProcessingPostProcess"
  112565. * @returns "ImageProcessingPostProcess"
  112566. */
  112567. getClassName(): string;
  112568. protected _updateParameters(): void;
  112569. dispose(camera?: Camera): void;
  112570. }
  112571. }
  112572. declare module BABYLON {
  112573. /**
  112574. * Class containing static functions to help procedurally build meshes
  112575. */
  112576. export class GroundBuilder {
  112577. /**
  112578. * Creates a ground mesh
  112579. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  112580. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  112581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112582. * @param name defines the name of the mesh
  112583. * @param options defines the options used to create the mesh
  112584. * @param scene defines the hosting scene
  112585. * @returns the ground mesh
  112586. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  112587. */
  112588. static CreateGround(name: string, options: {
  112589. width?: number;
  112590. height?: number;
  112591. subdivisions?: number;
  112592. subdivisionsX?: number;
  112593. subdivisionsY?: number;
  112594. updatable?: boolean;
  112595. }, scene: any): Mesh;
  112596. /**
  112597. * Creates a tiled ground mesh
  112598. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  112599. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  112600. * * 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
  112601. * * 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
  112602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112603. * @param name defines the name of the mesh
  112604. * @param options defines the options used to create the mesh
  112605. * @param scene defines the hosting scene
  112606. * @returns the tiled ground mesh
  112607. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  112608. */
  112609. static CreateTiledGround(name: string, options: {
  112610. xmin: number;
  112611. zmin: number;
  112612. xmax: number;
  112613. zmax: number;
  112614. subdivisions?: {
  112615. w: number;
  112616. h: number;
  112617. };
  112618. precision?: {
  112619. w: number;
  112620. h: number;
  112621. };
  112622. updatable?: boolean;
  112623. }, scene?: Nullable<Scene>): Mesh;
  112624. /**
  112625. * Creates a ground mesh from a height map
  112626. * * The parameter `url` sets the URL of the height map image resource.
  112627. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  112628. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  112629. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  112630. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  112631. * * 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.
  112632. * * 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).
  112633. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  112634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112635. * @param name defines the name of the mesh
  112636. * @param url defines the url to the height map
  112637. * @param options defines the options used to create the mesh
  112638. * @param scene defines the hosting scene
  112639. * @returns the ground mesh
  112640. * @see https://doc.babylonjs.com/babylon101/height_map
  112641. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  112642. */
  112643. static CreateGroundFromHeightMap(name: string, url: string, options: {
  112644. width?: number;
  112645. height?: number;
  112646. subdivisions?: number;
  112647. minHeight?: number;
  112648. maxHeight?: number;
  112649. colorFilter?: Color3;
  112650. alphaFilter?: number;
  112651. updatable?: boolean;
  112652. onReady?: (mesh: GroundMesh) => void;
  112653. }, scene?: Nullable<Scene>): GroundMesh;
  112654. }
  112655. }
  112656. declare module BABYLON {
  112657. /**
  112658. * Class containing static functions to help procedurally build meshes
  112659. */
  112660. export class TorusBuilder {
  112661. /**
  112662. * Creates a torus mesh
  112663. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  112664. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  112665. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  112666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112669. * @param name defines the name of the mesh
  112670. * @param options defines the options used to create the mesh
  112671. * @param scene defines the hosting scene
  112672. * @returns the torus mesh
  112673. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  112674. */
  112675. static CreateTorus(name: string, options: {
  112676. diameter?: number;
  112677. thickness?: number;
  112678. tessellation?: number;
  112679. updatable?: boolean;
  112680. sideOrientation?: number;
  112681. frontUVs?: Vector4;
  112682. backUVs?: Vector4;
  112683. }, scene: any): Mesh;
  112684. }
  112685. }
  112686. declare module BABYLON {
  112687. /**
  112688. * Class containing static functions to help procedurally build meshes
  112689. */
  112690. export class CylinderBuilder {
  112691. /**
  112692. * Creates a cylinder or a cone mesh
  112693. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  112694. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  112695. * * 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.
  112696. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  112697. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  112698. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  112699. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  112700. * * 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).
  112701. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  112702. * * 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).
  112703. * * 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
  112704. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  112705. * * 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
  112706. * * 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.
  112707. * * If `enclose` is false, a ring surface is one element.
  112708. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  112709. * * 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
  112710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112713. * @param name defines the name of the mesh
  112714. * @param options defines the options used to create the mesh
  112715. * @param scene defines the hosting scene
  112716. * @returns the cylinder mesh
  112717. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  112718. */
  112719. static CreateCylinder(name: string, options: {
  112720. height?: number;
  112721. diameterTop?: number;
  112722. diameterBottom?: number;
  112723. diameter?: number;
  112724. tessellation?: number;
  112725. subdivisions?: number;
  112726. arc?: number;
  112727. faceColors?: Color4[];
  112728. faceUV?: Vector4[];
  112729. updatable?: boolean;
  112730. hasRings?: boolean;
  112731. enclose?: boolean;
  112732. cap?: number;
  112733. sideOrientation?: number;
  112734. frontUVs?: Vector4;
  112735. backUVs?: Vector4;
  112736. }, scene: any): Mesh;
  112737. }
  112738. }
  112739. declare module BABYLON {
  112740. /**
  112741. * States of the webXR experience
  112742. */
  112743. export enum WebXRState {
  112744. /**
  112745. * Transitioning to being in XR mode
  112746. */
  112747. ENTERING_XR = 0,
  112748. /**
  112749. * Transitioning to non XR mode
  112750. */
  112751. EXITING_XR = 1,
  112752. /**
  112753. * In XR mode and presenting
  112754. */
  112755. IN_XR = 2,
  112756. /**
  112757. * Not entered XR mode
  112758. */
  112759. NOT_IN_XR = 3
  112760. }
  112761. /**
  112762. * Abstraction of the XR render target
  112763. */
  112764. export interface WebXRRenderTarget extends IDisposable {
  112765. /**
  112766. * xrpresent context of the canvas which can be used to display/mirror xr content
  112767. */
  112768. canvasContext: WebGLRenderingContext;
  112769. /**
  112770. * xr layer for the canvas
  112771. */
  112772. xrLayer: Nullable<XRWebGLLayer>;
  112773. /**
  112774. * Initializes the xr layer for the session
  112775. * @param xrSession xr session
  112776. * @returns a promise that will resolve once the XR Layer has been created
  112777. */
  112778. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  112779. }
  112780. }
  112781. declare module BABYLON {
  112782. /**
  112783. * COnfiguration object for WebXR output canvas
  112784. */
  112785. export class WebXRManagedOutputCanvasOptions {
  112786. /**
  112787. * Options for this XR Layer output
  112788. */
  112789. canvasOptions: XRWebGLLayerOptions;
  112790. /**
  112791. * CSS styling for a newly created canvas (if not provided)
  112792. */
  112793. newCanvasCssStyle?: string;
  112794. /**
  112795. * Get the default values of the configuration object
  112796. * @returns default values of this configuration object
  112797. */
  112798. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  112799. }
  112800. /**
  112801. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  112802. */
  112803. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  112804. private configuration;
  112805. private _engine;
  112806. private _canvas;
  112807. /**
  112808. * xrpresent context of the canvas which can be used to display/mirror xr content
  112809. */
  112810. canvasContext: WebGLRenderingContext;
  112811. /**
  112812. * xr layer for the canvas
  112813. */
  112814. xrLayer: Nullable<XRWebGLLayer>;
  112815. /**
  112816. * Initializes the xr layer for the session
  112817. * @param xrSession xr session
  112818. * @returns a promise that will resolve once the XR Layer has been created
  112819. */
  112820. initializeXRLayerAsync(xrSession: any): any;
  112821. /**
  112822. * Initializes the canvas to be added/removed upon entering/exiting xr
  112823. * @param engine the Babylon engine
  112824. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  112825. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  112826. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  112827. */
  112828. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  112829. /**
  112830. * Disposes of the object
  112831. */
  112832. dispose(): void;
  112833. private _setManagedOutputCanvas;
  112834. private _addCanvas;
  112835. private _removeCanvas;
  112836. }
  112837. }
  112838. declare module BABYLON {
  112839. /**
  112840. * Manages an XRSession to work with Babylon's engine
  112841. * @see https://doc.babylonjs.com/how_to/webxr
  112842. */
  112843. export class WebXRSessionManager implements IDisposable {
  112844. /** The scene which the session should be created for */
  112845. scene: Scene;
  112846. /**
  112847. * Fires every time a new xrFrame arrives which can be used to update the camera
  112848. */
  112849. onXRFrameObservable: Observable<XRFrame>;
  112850. /**
  112851. * Fires when the xr session is ended either by the device or manually done
  112852. */
  112853. onXRSessionEnded: Observable<any>;
  112854. /**
  112855. * Fires when the xr session is ended either by the device or manually done
  112856. */
  112857. onXRSessionInit: Observable<XRSession>;
  112858. /**
  112859. * Underlying xr session
  112860. */
  112861. session: XRSession;
  112862. /**
  112863. * Type of reference space used when creating the session
  112864. */
  112865. referenceSpace: XRReferenceSpace;
  112866. /**
  112867. * Current XR frame
  112868. */
  112869. currentFrame: Nullable<XRFrame>;
  112870. /** WebXR timestamp updated every frame */
  112871. currentTimestamp: number;
  112872. private _xrNavigator;
  112873. private baseLayer;
  112874. private _rttProvider;
  112875. private _sessionEnded;
  112876. /**
  112877. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  112878. * @param scene The scene which the session should be created for
  112879. */
  112880. constructor(
  112881. /** The scene which the session should be created for */
  112882. scene: Scene);
  112883. /**
  112884. * Initializes the manager
  112885. * After initialization enterXR can be called to start an XR session
  112886. * @returns Promise which resolves after it is initialized
  112887. */
  112888. initializeAsync(): Promise<void>;
  112889. /**
  112890. * Initializes an xr session
  112891. * @param xrSessionMode mode to initialize
  112892. * @param optionalFeatures defines optional values to pass to the session builder
  112893. * @returns a promise which will resolve once the session has been initialized
  112894. */
  112895. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  112896. /**
  112897. * Sets the reference space on the xr session
  112898. * @param referenceSpace space to set
  112899. * @returns a promise that will resolve once the reference space has been set
  112900. */
  112901. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  112902. /**
  112903. * Updates the render state of the session
  112904. * @param state state to set
  112905. * @returns a promise that resolves once the render state has been updated
  112906. */
  112907. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  112908. /**
  112909. * Starts rendering to the xr layer
  112910. * @returns a promise that will resolve once rendering has started
  112911. */
  112912. startRenderingToXRAsync(): Promise<void>;
  112913. /**
  112914. * Gets the correct render target texture to be rendered this frame for this eye
  112915. * @param eye the eye for which to get the render target
  112916. * @returns the render target for the specified eye
  112917. */
  112918. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  112919. /**
  112920. * Stops the xrSession and restores the renderloop
  112921. * @returns Promise which resolves after it exits XR
  112922. */
  112923. exitXRAsync(): Promise<void>;
  112924. /**
  112925. * Checks if a session would be supported for the creation options specified
  112926. * @param sessionMode session mode to check if supported eg. immersive-vr
  112927. * @returns true if supported
  112928. */
  112929. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  112930. /**
  112931. * Creates a WebXRRenderTarget object for the XR session
  112932. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  112933. * @param options optional options to provide when creating a new render target
  112934. * @returns a WebXR render target to which the session can render
  112935. */
  112936. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  112937. /**
  112938. * @hidden
  112939. * Converts the render layer of xrSession to a render target
  112940. * @param session session to create render target for
  112941. * @param scene scene the new render target should be created for
  112942. * @param baseLayer the webgl layer to create the render target for
  112943. */
  112944. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  112945. /**
  112946. * Disposes of the session manager
  112947. */
  112948. dispose(): void;
  112949. /**
  112950. * Gets a promise returning true when fullfiled if the given session mode is supported
  112951. * @param sessionMode defines the session to test
  112952. * @returns a promise
  112953. */
  112954. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  112955. }
  112956. }
  112957. declare module BABYLON {
  112958. /**
  112959. * WebXR Camera which holds the views for the xrSession
  112960. * @see https://doc.babylonjs.com/how_to/webxr
  112961. */
  112962. export class WebXRCamera extends FreeCamera {
  112963. /**
  112964. * Is the camera in debug mode. Used when using an emulator
  112965. */
  112966. debugMode: boolean;
  112967. /**
  112968. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  112969. * @param name the name of the camera
  112970. * @param scene the scene to add the camera to
  112971. */
  112972. constructor(name: string, scene: Scene);
  112973. private _updateNumberOfRigCameras;
  112974. /** @hidden */
  112975. _updateForDualEyeDebugging(): void;
  112976. /**
  112977. * Updates the cameras position from the current pose information of the XR session
  112978. * @param xrSessionManager the session containing pose information
  112979. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  112980. */
  112981. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  112982. }
  112983. }
  112984. declare module BABYLON {
  112985. /**
  112986. * Defining the interface required for a (webxr) feature
  112987. */
  112988. export interface IWebXRFeature extends IDisposable {
  112989. /**
  112990. * Attach the feature to the session
  112991. * Will usually be called by the features manager
  112992. *
  112993. * @returns true if successful.
  112994. */
  112995. attach(): boolean;
  112996. /**
  112997. * Detach the feature from the session
  112998. * Will usually be called by the features manager
  112999. *
  113000. * @returns true if successful.
  113001. */
  113002. detach(): boolean;
  113003. }
  113004. /**
  113005. * Defining the constructor of a feature. Used to register the modules.
  113006. */
  113007. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113008. /**
  113009. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113010. * It is mainly used in AR sessions.
  113011. *
  113012. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113013. */
  113014. export class WebXRFeaturesManager implements IDisposable {
  113015. private _xrSessionManager;
  113016. private static readonly _AvailableFeatures;
  113017. /**
  113018. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113019. * Mainly used internally.
  113020. *
  113021. * @param featureName the name of the feature to register
  113022. * @param constructorFunction the function used to construct the module
  113023. * @param version the (babylon) version of the module
  113024. * @param stable is that a stable version of this module
  113025. */
  113026. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113027. /**
  113028. * Returns a constructor of a specific feature.
  113029. *
  113030. * @param featureName the name of the feature to construct
  113031. * @param version the version of the feature to load
  113032. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113033. * @param options optional options provided to the module.
  113034. * @returns a function that, when called, will return a new instance of this feature
  113035. */
  113036. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113037. /**
  113038. * Return the latest unstable version of this feature
  113039. * @param featureName the name of the feature to search
  113040. * @returns the version number. if not found will return -1
  113041. */
  113042. static GetLatestVersionOfFeature(featureName: string): number;
  113043. /**
  113044. * Return the latest stable version of this feature
  113045. * @param featureName the name of the feature to search
  113046. * @returns the version number. if not found will return -1
  113047. */
  113048. static GetStableVersionOfFeature(featureName: string): number;
  113049. /**
  113050. * Can be used to return the list of features currently registered
  113051. *
  113052. * @returns an Array of available features
  113053. */
  113054. static GetAvailableFeatures(): string[];
  113055. /**
  113056. * Gets the versions available for a specific feature
  113057. * @param featureName the name of the feature
  113058. * @returns an array with the available versions
  113059. */
  113060. static GetAvailableVersions(featureName: string): string[];
  113061. private _features;
  113062. /**
  113063. * constructs a new features manages.
  113064. *
  113065. * @param _xrSessionManager an instance of WebXRSessionManager
  113066. */
  113067. constructor(_xrSessionManager: WebXRSessionManager);
  113068. /**
  113069. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  113070. *
  113071. * @param featureName the name of the feature to load or the class of the feature
  113072. * @param version optional version to load. if not provided the latest version will be enabled
  113073. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  113074. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  113075. * @returns a new constructed feature or throws an error if feature not found.
  113076. */
  113077. enableFeature(featureName: string | {
  113078. Name: string;
  113079. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  113080. /**
  113081. * Used to disable an already-enabled feature
  113082. * @param featureName the feature to disable
  113083. * @returns true if disable was successful
  113084. */
  113085. disableFeature(featureName: string | {
  113086. Name: string;
  113087. }): boolean;
  113088. /**
  113089. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  113090. * Can be used during a session to start a feature
  113091. * @param featureName the name of feature to attach
  113092. */
  113093. attachFeature(featureName: string): void;
  113094. /**
  113095. * Can be used inside a session or when the session ends to detach a specific feature
  113096. * @param featureName the name of the feature to detach
  113097. */
  113098. detachFeature(featureName: string): void;
  113099. /**
  113100. * Get the list of enabled features
  113101. * @returns an array of enabled features
  113102. */
  113103. getEnabledFeatures(): string[];
  113104. /**
  113105. * get the implementation of an enabled feature.
  113106. * @param featureName the name of the feature to load
  113107. * @returns the feature class, if found
  113108. */
  113109. getEnabledFeature(featureName: string): IWebXRFeature;
  113110. /**
  113111. * dispose this features manager
  113112. */
  113113. dispose(): void;
  113114. }
  113115. }
  113116. declare module BABYLON {
  113117. /**
  113118. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  113119. * @see https://doc.babylonjs.com/how_to/webxr
  113120. */
  113121. export class WebXRExperienceHelper implements IDisposable {
  113122. private scene;
  113123. /**
  113124. * 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
  113125. */
  113126. container: AbstractMesh;
  113127. /**
  113128. * Camera used to render xr content
  113129. */
  113130. camera: WebXRCamera;
  113131. /**
  113132. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  113133. */
  113134. state: WebXRState;
  113135. private _setState;
  113136. private static _TmpVector;
  113137. /**
  113138. * Fires when the state of the experience helper has changed
  113139. */
  113140. onStateChangedObservable: Observable<WebXRState>;
  113141. /** Session manager used to keep track of xr session */
  113142. sessionManager: WebXRSessionManager;
  113143. /** A features manager for this xr session */
  113144. featuresManager: WebXRFeaturesManager;
  113145. private _nonVRCamera;
  113146. private _originalSceneAutoClear;
  113147. private _supported;
  113148. /**
  113149. * Creates the experience helper
  113150. * @param scene the scene to attach the experience helper to
  113151. * @returns a promise for the experience helper
  113152. */
  113153. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  113154. /**
  113155. * Creates a WebXRExperienceHelper
  113156. * @param scene The scene the helper should be created in
  113157. */
  113158. private constructor();
  113159. /**
  113160. * Exits XR mode and returns the scene to its original state
  113161. * @returns promise that resolves after xr mode has exited
  113162. */
  113163. exitXRAsync(): Promise<void>;
  113164. /**
  113165. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  113166. * @param sessionMode options for the XR session
  113167. * @param referenceSpaceType frame of reference of the XR session
  113168. * @param renderTarget the output canvas that will be used to enter XR mode
  113169. * @returns promise that resolves after xr mode has entered
  113170. */
  113171. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  113172. /**
  113173. * Updates the global position of the camera by moving the camera's container
  113174. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  113175. * @param position The desired global position of the camera
  113176. */
  113177. setPositionOfCameraUsingContainer(position: Vector3): void;
  113178. /**
  113179. * Rotates the xr camera by rotating the camera's container around the camera's position
  113180. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  113181. * @param rotation the desired quaternion rotation to apply to the camera
  113182. */
  113183. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  113184. /**
  113185. * Disposes of the experience helper
  113186. */
  113187. dispose(): void;
  113188. }
  113189. }
  113190. declare module BABYLON {
  113191. /**
  113192. * Represents an XR input
  113193. */
  113194. export class WebXRController {
  113195. private scene;
  113196. /** The underlying input source for the controller */
  113197. inputSource: XRInputSource;
  113198. private parentContainer;
  113199. /**
  113200. * 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
  113201. */
  113202. grip?: AbstractMesh;
  113203. /**
  113204. * Pointer which can be used to select objects or attach a visible laser to
  113205. */
  113206. pointer: AbstractMesh;
  113207. private _gamepadMode;
  113208. /**
  113209. * If available, this is the gamepad object related to this controller.
  113210. * Using this object it is possible to get click events and trackpad changes of the
  113211. * webxr controller that is currently being used.
  113212. */
  113213. gamepadController?: WebVRController;
  113214. /**
  113215. * Event that fires when the controller is removed/disposed
  113216. */
  113217. onDisposeObservable: Observable<{}>;
  113218. private _tmpQuaternion;
  113219. private _tmpVector;
  113220. /**
  113221. * Creates the controller
  113222. * @see https://doc.babylonjs.com/how_to/webxr
  113223. * @param scene the scene which the controller should be associated to
  113224. * @param inputSource the underlying input source for the controller
  113225. * @param parentContainer parent that the controller meshes should be children of
  113226. */
  113227. constructor(scene: Scene,
  113228. /** The underlying input source for the controller */
  113229. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  113230. /**
  113231. * Updates the controller pose based on the given XRFrame
  113232. * @param xrFrame xr frame to update the pose with
  113233. * @param referenceSpace reference space to use
  113234. */
  113235. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  113236. /**
  113237. * Gets a world space ray coming from the controller
  113238. * @param result the resulting ray
  113239. */
  113240. getWorldPointerRayToRef(result: Ray): void;
  113241. /**
  113242. * Get the scene associated with this controller
  113243. * @returns the scene object
  113244. */
  113245. getScene(): Scene;
  113246. /**
  113247. * Disposes of the object
  113248. */
  113249. dispose(): void;
  113250. }
  113251. }
  113252. declare module BABYLON {
  113253. /**
  113254. * XR input used to track XR inputs such as controllers/rays
  113255. */
  113256. export class WebXRInput implements IDisposable {
  113257. /**
  113258. * Base experience the input listens to
  113259. */
  113260. baseExperience: WebXRExperienceHelper;
  113261. /**
  113262. * XR controllers being tracked
  113263. */
  113264. controllers: Array<WebXRController>;
  113265. private _frameObserver;
  113266. private _stateObserver;
  113267. /**
  113268. * Event when a controller has been connected/added
  113269. */
  113270. onControllerAddedObservable: Observable<WebXRController>;
  113271. /**
  113272. * Event when a controller has been removed/disconnected
  113273. */
  113274. onControllerRemovedObservable: Observable<WebXRController>;
  113275. /**
  113276. * Initializes the WebXRInput
  113277. * @param baseExperience experience helper which the input should be created for
  113278. */
  113279. constructor(
  113280. /**
  113281. * Base experience the input listens to
  113282. */
  113283. baseExperience: WebXRExperienceHelper);
  113284. private _onInputSourcesChange;
  113285. private _addAndRemoveControllers;
  113286. /**
  113287. * Disposes of the object
  113288. */
  113289. dispose(): void;
  113290. }
  113291. }
  113292. declare module BABYLON {
  113293. /**
  113294. * Class used to represent data loading progression
  113295. */
  113296. export class SceneLoaderProgressEvent {
  113297. /** defines if data length to load can be evaluated */
  113298. readonly lengthComputable: boolean;
  113299. /** defines the loaded data length */
  113300. readonly loaded: number;
  113301. /** defines the data length to load */
  113302. readonly total: number;
  113303. /**
  113304. * Create a new progress event
  113305. * @param lengthComputable defines if data length to load can be evaluated
  113306. * @param loaded defines the loaded data length
  113307. * @param total defines the data length to load
  113308. */
  113309. constructor(
  113310. /** defines if data length to load can be evaluated */
  113311. lengthComputable: boolean,
  113312. /** defines the loaded data length */
  113313. loaded: number,
  113314. /** defines the data length to load */
  113315. total: number);
  113316. /**
  113317. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  113318. * @param event defines the source event
  113319. * @returns a new SceneLoaderProgressEvent
  113320. */
  113321. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  113322. }
  113323. /**
  113324. * Interface used by SceneLoader plugins to define supported file extensions
  113325. */
  113326. export interface ISceneLoaderPluginExtensions {
  113327. /**
  113328. * Defines the list of supported extensions
  113329. */
  113330. [extension: string]: {
  113331. isBinary: boolean;
  113332. };
  113333. }
  113334. /**
  113335. * Interface used by SceneLoader plugin factory
  113336. */
  113337. export interface ISceneLoaderPluginFactory {
  113338. /**
  113339. * Defines the name of the factory
  113340. */
  113341. name: string;
  113342. /**
  113343. * Function called to create a new plugin
  113344. * @return the new plugin
  113345. */
  113346. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  113347. /**
  113348. * The callback that returns true if the data can be directly loaded.
  113349. * @param data string containing the file data
  113350. * @returns if the data can be loaded directly
  113351. */
  113352. canDirectLoad?(data: string): boolean;
  113353. }
  113354. /**
  113355. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  113356. */
  113357. export interface ISceneLoaderPluginBase {
  113358. /**
  113359. * The friendly name of this plugin.
  113360. */
  113361. name: string;
  113362. /**
  113363. * The file extensions supported by this plugin.
  113364. */
  113365. extensions: string | ISceneLoaderPluginExtensions;
  113366. /**
  113367. * The callback called when loading from a url.
  113368. * @param scene scene loading this url
  113369. * @param url url to load
  113370. * @param onSuccess callback called when the file successfully loads
  113371. * @param onProgress callback called while file is loading (if the server supports this mode)
  113372. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113373. * @param onError callback called when the file fails to load
  113374. * @returns a file request object
  113375. */
  113376. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113377. /**
  113378. * The callback called when loading from a file object.
  113379. * @param scene scene loading this file
  113380. * @param file defines the file to load
  113381. * @param onSuccess defines the callback to call when data is loaded
  113382. * @param onProgress defines the callback to call during loading process
  113383. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  113384. * @param onError defines the callback to call when an error occurs
  113385. * @returns a file request object
  113386. */
  113387. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113388. /**
  113389. * The callback that returns true if the data can be directly loaded.
  113390. * @param data string containing the file data
  113391. * @returns if the data can be loaded directly
  113392. */
  113393. canDirectLoad?(data: string): boolean;
  113394. /**
  113395. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  113396. * @param scene scene loading this data
  113397. * @param data string containing the data
  113398. * @returns data to pass to the plugin
  113399. */
  113400. directLoad?(scene: Scene, data: string): any;
  113401. /**
  113402. * The callback that allows custom handling of the root url based on the response url.
  113403. * @param rootUrl the original root url
  113404. * @param responseURL the response url if available
  113405. * @returns the new root url
  113406. */
  113407. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  113408. }
  113409. /**
  113410. * Interface used to define a SceneLoader plugin
  113411. */
  113412. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  113413. /**
  113414. * Import meshes into a scene.
  113415. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113416. * @param scene The scene to import into
  113417. * @param data The data to import
  113418. * @param rootUrl The root url for scene and resources
  113419. * @param meshes The meshes array to import into
  113420. * @param particleSystems The particle systems array to import into
  113421. * @param skeletons The skeletons array to import into
  113422. * @param onError The callback when import fails
  113423. * @returns True if successful or false otherwise
  113424. */
  113425. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  113426. /**
  113427. * Load into a scene.
  113428. * @param scene The scene to load into
  113429. * @param data The data to import
  113430. * @param rootUrl The root url for scene and resources
  113431. * @param onError The callback when import fails
  113432. * @returns True if successful or false otherwise
  113433. */
  113434. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  113435. /**
  113436. * Load into an asset container.
  113437. * @param scene The scene to load into
  113438. * @param data The data to import
  113439. * @param rootUrl The root url for scene and resources
  113440. * @param onError The callback when import fails
  113441. * @returns The loaded asset container
  113442. */
  113443. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  113444. }
  113445. /**
  113446. * Interface used to define an async SceneLoader plugin
  113447. */
  113448. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  113449. /**
  113450. * Import meshes into a scene.
  113451. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113452. * @param scene The scene to import into
  113453. * @param data The data to import
  113454. * @param rootUrl The root url for scene and resources
  113455. * @param onProgress The callback when the load progresses
  113456. * @param fileName Defines the name of the file to load
  113457. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  113458. */
  113459. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  113460. meshes: AbstractMesh[];
  113461. particleSystems: IParticleSystem[];
  113462. skeletons: Skeleton[];
  113463. animationGroups: AnimationGroup[];
  113464. }>;
  113465. /**
  113466. * Load into a scene.
  113467. * @param scene The scene to load into
  113468. * @param data The data to import
  113469. * @param rootUrl The root url for scene and resources
  113470. * @param onProgress The callback when the load progresses
  113471. * @param fileName Defines the name of the file to load
  113472. * @returns Nothing
  113473. */
  113474. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  113475. /**
  113476. * Load into an asset container.
  113477. * @param scene The scene to load into
  113478. * @param data The data to import
  113479. * @param rootUrl The root url for scene and resources
  113480. * @param onProgress The callback when the load progresses
  113481. * @param fileName Defines the name of the file to load
  113482. * @returns The loaded asset container
  113483. */
  113484. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  113485. }
  113486. /**
  113487. * Mode that determines how to handle old animation groups before loading new ones.
  113488. */
  113489. export enum SceneLoaderAnimationGroupLoadingMode {
  113490. /**
  113491. * Reset all old animations to initial state then dispose them.
  113492. */
  113493. Clean = 0,
  113494. /**
  113495. * Stop all old animations.
  113496. */
  113497. Stop = 1,
  113498. /**
  113499. * Restart old animations from first frame.
  113500. */
  113501. Sync = 2,
  113502. /**
  113503. * Old animations remains untouched.
  113504. */
  113505. NoSync = 3
  113506. }
  113507. /**
  113508. * Class used to load scene from various file formats using registered plugins
  113509. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  113510. */
  113511. export class SceneLoader {
  113512. /**
  113513. * No logging while loading
  113514. */
  113515. static readonly NO_LOGGING: number;
  113516. /**
  113517. * Minimal logging while loading
  113518. */
  113519. static readonly MINIMAL_LOGGING: number;
  113520. /**
  113521. * Summary logging while loading
  113522. */
  113523. static readonly SUMMARY_LOGGING: number;
  113524. /**
  113525. * Detailled logging while loading
  113526. */
  113527. static readonly DETAILED_LOGGING: number;
  113528. /**
  113529. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  113530. */
  113531. static get ForceFullSceneLoadingForIncremental(): boolean;
  113532. static set ForceFullSceneLoadingForIncremental(value: boolean);
  113533. /**
  113534. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  113535. */
  113536. static get ShowLoadingScreen(): boolean;
  113537. static set ShowLoadingScreen(value: boolean);
  113538. /**
  113539. * Defines the current logging level (while loading the scene)
  113540. * @ignorenaming
  113541. */
  113542. static get loggingLevel(): number;
  113543. static set loggingLevel(value: number);
  113544. /**
  113545. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  113546. */
  113547. static get CleanBoneMatrixWeights(): boolean;
  113548. static set CleanBoneMatrixWeights(value: boolean);
  113549. /**
  113550. * Event raised when a plugin is used to load a scene
  113551. */
  113552. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  113553. private static _registeredPlugins;
  113554. private static _getDefaultPlugin;
  113555. private static _getPluginForExtension;
  113556. private static _getPluginForDirectLoad;
  113557. private static _getPluginForFilename;
  113558. private static _getDirectLoad;
  113559. private static _loadData;
  113560. private static _getFileInfo;
  113561. /**
  113562. * Gets a plugin that can load the given extension
  113563. * @param extension defines the extension to load
  113564. * @returns a plugin or null if none works
  113565. */
  113566. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  113567. /**
  113568. * Gets a boolean indicating that the given extension can be loaded
  113569. * @param extension defines the extension to load
  113570. * @returns true if the extension is supported
  113571. */
  113572. static IsPluginForExtensionAvailable(extension: string): boolean;
  113573. /**
  113574. * Adds a new plugin to the list of registered plugins
  113575. * @param plugin defines the plugin to add
  113576. */
  113577. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  113578. /**
  113579. * Import meshes into a scene
  113580. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113581. * @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)
  113582. * @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)
  113583. * @param scene the instance of BABYLON.Scene to append to
  113584. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  113585. * @param onProgress a callback with a progress event for each file being loaded
  113586. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113587. * @param pluginExtension the extension used to determine the plugin
  113588. * @returns The loaded plugin
  113589. */
  113590. 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>;
  113591. /**
  113592. * Import meshes into a scene
  113593. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113594. * @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)
  113595. * @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)
  113596. * @param scene the instance of BABYLON.Scene to append to
  113597. * @param onProgress a callback with a progress event for each file being loaded
  113598. * @param pluginExtension the extension used to determine the plugin
  113599. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  113600. */
  113601. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  113602. meshes: AbstractMesh[];
  113603. particleSystems: IParticleSystem[];
  113604. skeletons: Skeleton[];
  113605. animationGroups: AnimationGroup[];
  113606. }>;
  113607. /**
  113608. * Load a scene
  113609. * @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)
  113610. * @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)
  113611. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113612. * @param onSuccess a callback with the scene when import succeeds
  113613. * @param onProgress a callback with a progress event for each file being loaded
  113614. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113615. * @param pluginExtension the extension used to determine the plugin
  113616. * @returns The loaded plugin
  113617. */
  113618. 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>;
  113619. /**
  113620. * Load a scene
  113621. * @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)
  113622. * @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)
  113623. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113624. * @param onProgress a callback with a progress event for each file being loaded
  113625. * @param pluginExtension the extension used to determine the plugin
  113626. * @returns The loaded scene
  113627. */
  113628. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113629. /**
  113630. * Append a scene
  113631. * @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)
  113632. * @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)
  113633. * @param scene is the instance of BABYLON.Scene to append to
  113634. * @param onSuccess a callback with the scene when import succeeds
  113635. * @param onProgress a callback with a progress event for each file being loaded
  113636. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113637. * @param pluginExtension the extension used to determine the plugin
  113638. * @returns The loaded plugin
  113639. */
  113640. 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>;
  113641. /**
  113642. * Append a scene
  113643. * @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)
  113644. * @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)
  113645. * @param scene is the instance of BABYLON.Scene to append to
  113646. * @param onProgress a callback with a progress event for each file being loaded
  113647. * @param pluginExtension the extension used to determine the plugin
  113648. * @returns The given scene
  113649. */
  113650. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113651. /**
  113652. * Load a scene into an asset container
  113653. * @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)
  113654. * @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)
  113655. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113656. * @param onSuccess a callback with the scene when import succeeds
  113657. * @param onProgress a callback with a progress event for each file being loaded
  113658. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113659. * @param pluginExtension the extension used to determine the plugin
  113660. * @returns The loaded plugin
  113661. */
  113662. 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>;
  113663. /**
  113664. * Load a scene into an asset container
  113665. * @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)
  113666. * @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)
  113667. * @param scene is the instance of Scene to append to
  113668. * @param onProgress a callback with a progress event for each file being loaded
  113669. * @param pluginExtension the extension used to determine the plugin
  113670. * @returns The loaded asset container
  113671. */
  113672. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  113673. /**
  113674. * Import animations from a file into a scene
  113675. * @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)
  113676. * @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)
  113677. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113678. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113679. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113680. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113681. * @param onSuccess a callback with the scene when import succeeds
  113682. * @param onProgress a callback with a progress event for each file being loaded
  113683. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113684. */
  113685. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  113686. /**
  113687. * Import animations from a file into a scene
  113688. * @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)
  113689. * @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)
  113690. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113691. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113692. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113693. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113694. * @param onSuccess a callback with the scene when import succeeds
  113695. * @param onProgress a callback with a progress event for each file being loaded
  113696. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113697. * @returns the updated scene with imported animations
  113698. */
  113699. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  113700. }
  113701. }
  113702. declare module BABYLON {
  113703. /**
  113704. * Generic Controller
  113705. */
  113706. export class GenericController extends WebVRController {
  113707. /**
  113708. * Base Url for the controller model.
  113709. */
  113710. static readonly MODEL_BASE_URL: string;
  113711. /**
  113712. * File name for the controller model.
  113713. */
  113714. static readonly MODEL_FILENAME: string;
  113715. /**
  113716. * Creates a new GenericController from a gamepad
  113717. * @param vrGamepad the gamepad that the controller should be created from
  113718. */
  113719. constructor(vrGamepad: any);
  113720. /**
  113721. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113722. * @param scene scene in which to add meshes
  113723. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113724. */
  113725. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113726. /**
  113727. * Called once for each button that changed state since the last frame
  113728. * @param buttonIdx Which button index changed
  113729. * @param state New state of the button
  113730. * @param changes Which properties on the state changed since last frame
  113731. */
  113732. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113733. }
  113734. }
  113735. declare module BABYLON {
  113736. /**
  113737. * Defines the WindowsMotionController object that the state of the windows motion controller
  113738. */
  113739. export class WindowsMotionController extends WebVRController {
  113740. /**
  113741. * The base url used to load the left and right controller models
  113742. */
  113743. static MODEL_BASE_URL: string;
  113744. /**
  113745. * The name of the left controller model file
  113746. */
  113747. static MODEL_LEFT_FILENAME: string;
  113748. /**
  113749. * The name of the right controller model file
  113750. */
  113751. static MODEL_RIGHT_FILENAME: string;
  113752. /**
  113753. * The controller name prefix for this controller type
  113754. */
  113755. static readonly GAMEPAD_ID_PREFIX: string;
  113756. /**
  113757. * The controller id pattern for this controller type
  113758. */
  113759. private static readonly GAMEPAD_ID_PATTERN;
  113760. private _loadedMeshInfo;
  113761. protected readonly _mapping: {
  113762. buttons: string[];
  113763. buttonMeshNames: {
  113764. 'trigger': string;
  113765. 'menu': string;
  113766. 'grip': string;
  113767. 'thumbstick': string;
  113768. 'trackpad': string;
  113769. };
  113770. buttonObservableNames: {
  113771. 'trigger': string;
  113772. 'menu': string;
  113773. 'grip': string;
  113774. 'thumbstick': string;
  113775. 'trackpad': string;
  113776. };
  113777. axisMeshNames: string[];
  113778. pointingPoseMeshName: string;
  113779. };
  113780. /**
  113781. * Fired when the trackpad on this controller is clicked
  113782. */
  113783. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113784. /**
  113785. * Fired when the trackpad on this controller is modified
  113786. */
  113787. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113788. /**
  113789. * The current x and y values of this controller's trackpad
  113790. */
  113791. trackpad: StickValues;
  113792. /**
  113793. * Creates a new WindowsMotionController from a gamepad
  113794. * @param vrGamepad the gamepad that the controller should be created from
  113795. */
  113796. constructor(vrGamepad: any);
  113797. /**
  113798. * Fired when the trigger on this controller is modified
  113799. */
  113800. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113801. /**
  113802. * Fired when the menu button on this controller is modified
  113803. */
  113804. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113805. /**
  113806. * Fired when the grip button on this controller is modified
  113807. */
  113808. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113809. /**
  113810. * Fired when the thumbstick button on this controller is modified
  113811. */
  113812. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113813. /**
  113814. * Fired when the touchpad button on this controller is modified
  113815. */
  113816. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113817. /**
  113818. * Fired when the touchpad values on this controller are modified
  113819. */
  113820. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  113821. protected _updateTrackpad(): void;
  113822. /**
  113823. * Called once per frame by the engine.
  113824. */
  113825. update(): void;
  113826. /**
  113827. * Called once for each button that changed state since the last frame
  113828. * @param buttonIdx Which button index changed
  113829. * @param state New state of the button
  113830. * @param changes Which properties on the state changed since last frame
  113831. */
  113832. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113833. /**
  113834. * Moves the buttons on the controller mesh based on their current state
  113835. * @param buttonName the name of the button to move
  113836. * @param buttonValue the value of the button which determines the buttons new position
  113837. */
  113838. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  113839. /**
  113840. * Moves the axis on the controller mesh based on its current state
  113841. * @param axis the index of the axis
  113842. * @param axisValue the value of the axis which determines the meshes new position
  113843. * @hidden
  113844. */
  113845. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  113846. /**
  113847. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113848. * @param scene scene in which to add meshes
  113849. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113850. */
  113851. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  113852. /**
  113853. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  113854. * can be transformed by button presses and axes values, based on this._mapping.
  113855. *
  113856. * @param scene scene in which the meshes exist
  113857. * @param meshes list of meshes that make up the controller model to process
  113858. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  113859. */
  113860. private processModel;
  113861. private createMeshInfo;
  113862. /**
  113863. * Gets the ray of the controller in the direction the controller is pointing
  113864. * @param length the length the resulting ray should be
  113865. * @returns a ray in the direction the controller is pointing
  113866. */
  113867. getForwardRay(length?: number): Ray;
  113868. /**
  113869. * Disposes of the controller
  113870. */
  113871. dispose(): void;
  113872. }
  113873. /**
  113874. * This class represents a new windows motion controller in XR.
  113875. */
  113876. export class XRWindowsMotionController extends WindowsMotionController {
  113877. /**
  113878. * Changing the original WIndowsMotionController mapping to fir the new mapping
  113879. */
  113880. protected readonly _mapping: {
  113881. buttons: string[];
  113882. buttonMeshNames: {
  113883. 'trigger': string;
  113884. 'menu': string;
  113885. 'grip': string;
  113886. 'thumbstick': string;
  113887. 'trackpad': string;
  113888. };
  113889. buttonObservableNames: {
  113890. 'trigger': string;
  113891. 'menu': string;
  113892. 'grip': string;
  113893. 'thumbstick': string;
  113894. 'trackpad': string;
  113895. };
  113896. axisMeshNames: string[];
  113897. pointingPoseMeshName: string;
  113898. };
  113899. /**
  113900. * Construct a new XR-Based windows motion controller
  113901. *
  113902. * @param gamepadInfo the gamepad object from the browser
  113903. */
  113904. constructor(gamepadInfo: any);
  113905. /**
  113906. * holds the thumbstick values (X,Y)
  113907. */
  113908. thumbstickValues: StickValues;
  113909. /**
  113910. * Fired when the thumbstick on this controller is clicked
  113911. */
  113912. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  113913. /**
  113914. * Fired when the thumbstick on this controller is modified
  113915. */
  113916. onThumbstickValuesChangedObservable: Observable<StickValues>;
  113917. /**
  113918. * Fired when the touchpad button on this controller is modified
  113919. */
  113920. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113921. /**
  113922. * Fired when the touchpad values on this controller are modified
  113923. */
  113924. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113925. /**
  113926. * Fired when the thumbstick button on this controller is modified
  113927. * here to prevent breaking changes
  113928. */
  113929. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113930. /**
  113931. * updating the thumbstick(!) and not the trackpad.
  113932. * This is named this way due to the difference between WebVR and XR and to avoid
  113933. * changing the parent class.
  113934. */
  113935. protected _updateTrackpad(): void;
  113936. /**
  113937. * Disposes the class with joy
  113938. */
  113939. dispose(): void;
  113940. }
  113941. }
  113942. declare module BABYLON {
  113943. /**
  113944. * Oculus Touch Controller
  113945. */
  113946. export class OculusTouchController extends WebVRController {
  113947. /**
  113948. * Base Url for the controller model.
  113949. */
  113950. static MODEL_BASE_URL: string;
  113951. /**
  113952. * File name for the left controller model.
  113953. */
  113954. static MODEL_LEFT_FILENAME: string;
  113955. /**
  113956. * File name for the right controller model.
  113957. */
  113958. static MODEL_RIGHT_FILENAME: string;
  113959. /**
  113960. * Base Url for the Quest controller model.
  113961. */
  113962. static QUEST_MODEL_BASE_URL: string;
  113963. /**
  113964. * @hidden
  113965. * If the controllers are running on a device that needs the updated Quest controller models
  113966. */
  113967. static _IsQuest: boolean;
  113968. /**
  113969. * Fired when the secondary trigger on this controller is modified
  113970. */
  113971. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  113972. /**
  113973. * Fired when the thumb rest on this controller is modified
  113974. */
  113975. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  113976. /**
  113977. * Creates a new OculusTouchController from a gamepad
  113978. * @param vrGamepad the gamepad that the controller should be created from
  113979. */
  113980. constructor(vrGamepad: any);
  113981. /**
  113982. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113983. * @param scene scene in which to add meshes
  113984. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113985. */
  113986. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113987. /**
  113988. * Fired when the A button on this controller is modified
  113989. */
  113990. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113991. /**
  113992. * Fired when the B button on this controller is modified
  113993. */
  113994. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113995. /**
  113996. * Fired when the X button on this controller is modified
  113997. */
  113998. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113999. /**
  114000. * Fired when the Y button on this controller is modified
  114001. */
  114002. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114003. /**
  114004. * Called once for each button that changed state since the last frame
  114005. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  114006. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  114007. * 2) secondary trigger (same)
  114008. * 3) A (right) X (left), touch, pressed = value
  114009. * 4) B / Y
  114010. * 5) thumb rest
  114011. * @param buttonIdx Which button index changed
  114012. * @param state New state of the button
  114013. * @param changes Which properties on the state changed since last frame
  114014. */
  114015. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114016. }
  114017. }
  114018. declare module BABYLON {
  114019. /**
  114020. * Vive Controller
  114021. */
  114022. export class ViveController extends WebVRController {
  114023. /**
  114024. * Base Url for the controller model.
  114025. */
  114026. static MODEL_BASE_URL: string;
  114027. /**
  114028. * File name for the controller model.
  114029. */
  114030. static MODEL_FILENAME: string;
  114031. /**
  114032. * Creates a new ViveController from a gamepad
  114033. * @param vrGamepad the gamepad that the controller should be created from
  114034. */
  114035. constructor(vrGamepad: any);
  114036. /**
  114037. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114038. * @param scene scene in which to add meshes
  114039. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114040. */
  114041. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114042. /**
  114043. * Fired when the left button on this controller is modified
  114044. */
  114045. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114046. /**
  114047. * Fired when the right button on this controller is modified
  114048. */
  114049. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114050. /**
  114051. * Fired when the menu button on this controller is modified
  114052. */
  114053. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114054. /**
  114055. * Called once for each button that changed state since the last frame
  114056. * Vive mapping:
  114057. * 0: touchpad
  114058. * 1: trigger
  114059. * 2: left AND right buttons
  114060. * 3: menu button
  114061. * @param buttonIdx Which button index changed
  114062. * @param state New state of the button
  114063. * @param changes Which properties on the state changed since last frame
  114064. */
  114065. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114066. }
  114067. }
  114068. declare module BABYLON {
  114069. /**
  114070. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  114071. */
  114072. export class WebXRControllerModelLoader {
  114073. /**
  114074. * an observable that triggers when a new model (the mesh itself) was initialized.
  114075. * To know when the mesh was loaded use the controller's own modelLoaded() method
  114076. */
  114077. onControllerModelLoaded: Observable<WebXRController>;
  114078. /**
  114079. * Creates the WebXRControllerModelLoader
  114080. * @param input xr input that creates the controllers
  114081. */
  114082. constructor(input: WebXRInput);
  114083. }
  114084. }
  114085. declare module BABYLON {
  114086. /**
  114087. * Handles pointer input automatically for the pointer of XR controllers
  114088. */
  114089. export class WebXRControllerPointerSelection {
  114090. private static _idCounter;
  114091. private _tmpRay;
  114092. /**
  114093. * Creates a WebXRControllerPointerSelection
  114094. * @param input input manager to setup pointer selection
  114095. */
  114096. constructor(input: WebXRInput);
  114097. private _convertNormalToDirectionOfRay;
  114098. private _updatePointerDistance;
  114099. }
  114100. }
  114101. declare module BABYLON {
  114102. /**
  114103. * Enables teleportation
  114104. */
  114105. export class WebXRControllerTeleportation {
  114106. private _teleportationFillColor;
  114107. private _teleportationBorderColor;
  114108. private _tmpRay;
  114109. private _tmpVector;
  114110. /**
  114111. * when set to true (default) teleportation will wait for thumbstick changes.
  114112. * When set to false teleportation will be disabled.
  114113. *
  114114. * If set to false while teleporting results can be unexpected.
  114115. */
  114116. enabled: boolean;
  114117. /**
  114118. * Creates a WebXRControllerTeleportation
  114119. * @param input input manager to add teleportation to
  114120. * @param floorMeshes floormeshes which can be teleported to
  114121. */
  114122. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  114123. }
  114124. }
  114125. declare module BABYLON {
  114126. /**
  114127. * Button which can be used to enter a different mode of XR
  114128. */
  114129. export class WebXREnterExitUIButton {
  114130. /** button element */
  114131. element: HTMLElement;
  114132. /** XR initialization options for the button */
  114133. sessionMode: XRSessionMode;
  114134. /** Reference space type */
  114135. referenceSpaceType: XRReferenceSpaceType;
  114136. /**
  114137. * Creates a WebXREnterExitUIButton
  114138. * @param element button element
  114139. * @param sessionMode XR initialization session mode
  114140. * @param referenceSpaceType the type of reference space to be used
  114141. */
  114142. constructor(
  114143. /** button element */
  114144. element: HTMLElement,
  114145. /** XR initialization options for the button */
  114146. sessionMode: XRSessionMode,
  114147. /** Reference space type */
  114148. referenceSpaceType: XRReferenceSpaceType);
  114149. /**
  114150. * Overwritable function which can be used to update the button's visuals when the state changes
  114151. * @param activeButton the current active button in the UI
  114152. */
  114153. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  114154. }
  114155. /**
  114156. * Options to create the webXR UI
  114157. */
  114158. export class WebXREnterExitUIOptions {
  114159. /**
  114160. * Context to enter xr with
  114161. */
  114162. renderTarget?: Nullable<WebXRRenderTarget>;
  114163. /**
  114164. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  114165. */
  114166. customButtons?: Array<WebXREnterExitUIButton>;
  114167. /**
  114168. * A session mode to use when creating the default button.
  114169. * Default is immersive-vr
  114170. */
  114171. sessionMode?: XRSessionMode;
  114172. /**
  114173. * A reference space type to use when creating the default button.
  114174. * Default is local-floor
  114175. */
  114176. referenceSpaceType?: XRReferenceSpaceType;
  114177. }
  114178. /**
  114179. * UI to allow the user to enter/exit XR mode
  114180. */
  114181. export class WebXREnterExitUI implements IDisposable {
  114182. private scene;
  114183. /** version of the options passed to this UI */
  114184. options: WebXREnterExitUIOptions;
  114185. private _overlay;
  114186. private _buttons;
  114187. private _activeButton;
  114188. /**
  114189. * Fired every time the active button is changed.
  114190. *
  114191. * When xr is entered via a button that launches xr that button will be the callback parameter
  114192. *
  114193. * When exiting xr the callback parameter will be null)
  114194. */
  114195. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  114196. /**
  114197. * Creates UI to allow the user to enter/exit XR mode
  114198. * @param scene the scene to add the ui to
  114199. * @param helper the xr experience helper to enter/exit xr with
  114200. * @param options options to configure the UI
  114201. * @returns the created ui
  114202. */
  114203. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  114204. /**
  114205. *
  114206. * @param scene babylon scene object to use
  114207. * @param options (read-only) version of the options passed to this UI
  114208. */
  114209. private constructor();
  114210. private _updateButtons;
  114211. /**
  114212. * Disposes of the object
  114213. */
  114214. dispose(): void;
  114215. }
  114216. }
  114217. declare module BABYLON {
  114218. /**
  114219. * Options for the default xr helper
  114220. */
  114221. export class WebXRDefaultExperienceOptions {
  114222. /**
  114223. * Floor meshes that should be used for teleporting
  114224. */
  114225. floorMeshes: Array<AbstractMesh>;
  114226. /**
  114227. * Enable or disable default UI to enter XR
  114228. */
  114229. disableDefaultUI?: boolean;
  114230. /**
  114231. * optional configuration for the output canvas
  114232. */
  114233. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  114234. /**
  114235. * optional UI options. This can be used among other to change session mode and reference space type
  114236. */
  114237. uiOptions?: WebXREnterExitUIOptions;
  114238. }
  114239. /**
  114240. * Default experience which provides a similar setup to the previous webVRExperience
  114241. */
  114242. export class WebXRDefaultExperience {
  114243. /**
  114244. * Base experience
  114245. */
  114246. baseExperience: WebXRExperienceHelper;
  114247. /**
  114248. * Input experience extension
  114249. */
  114250. input: WebXRInput;
  114251. /**
  114252. * Loads the controller models
  114253. */
  114254. controllerModelLoader: WebXRControllerModelLoader;
  114255. /**
  114256. * Enables laser pointer and selection
  114257. */
  114258. pointerSelection: WebXRControllerPointerSelection;
  114259. /**
  114260. * Enables teleportation
  114261. */
  114262. teleportation: WebXRControllerTeleportation;
  114263. /**
  114264. * Enables ui for entering/exiting xr
  114265. */
  114266. enterExitUI: WebXREnterExitUI;
  114267. /**
  114268. * Default target xr should render to
  114269. */
  114270. renderTarget: WebXRRenderTarget;
  114271. /**
  114272. * Creates the default xr experience
  114273. * @param scene scene
  114274. * @param options options for basic configuration
  114275. * @returns resulting WebXRDefaultExperience
  114276. */
  114277. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114278. private constructor();
  114279. /**
  114280. * DIsposes of the experience helper
  114281. */
  114282. dispose(): void;
  114283. }
  114284. }
  114285. declare module BABYLON {
  114286. /**
  114287. * Options to modify the vr teleportation behavior.
  114288. */
  114289. export interface VRTeleportationOptions {
  114290. /**
  114291. * The name of the mesh which should be used as the teleportation floor. (default: null)
  114292. */
  114293. floorMeshName?: string;
  114294. /**
  114295. * A list of meshes to be used as the teleportation floor. (default: empty)
  114296. */
  114297. floorMeshes?: Mesh[];
  114298. /**
  114299. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  114300. */
  114301. teleportationMode?: number;
  114302. /**
  114303. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  114304. */
  114305. teleportationTime?: number;
  114306. /**
  114307. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  114308. */
  114309. teleportationSpeed?: number;
  114310. /**
  114311. * The easing function used in the animation or null for Linear. (default CircleEase)
  114312. */
  114313. easingFunction?: EasingFunction;
  114314. }
  114315. /**
  114316. * Options to modify the vr experience helper's behavior.
  114317. */
  114318. export interface VRExperienceHelperOptions extends WebVROptions {
  114319. /**
  114320. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  114321. */
  114322. createDeviceOrientationCamera?: boolean;
  114323. /**
  114324. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  114325. */
  114326. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  114327. /**
  114328. * Uses the main button on the controller to toggle the laser casted. (default: true)
  114329. */
  114330. laserToggle?: boolean;
  114331. /**
  114332. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  114333. */
  114334. floorMeshes?: Mesh[];
  114335. /**
  114336. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  114337. */
  114338. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  114339. /**
  114340. * Defines if WebXR should be used instead of WebVR (if available)
  114341. */
  114342. useXR?: boolean;
  114343. }
  114344. /**
  114345. * Event containing information after VR has been entered
  114346. */
  114347. export class OnAfterEnteringVRObservableEvent {
  114348. /**
  114349. * If entering vr was successful
  114350. */
  114351. success: boolean;
  114352. }
  114353. /**
  114354. * Helps to quickly add VR support to an existing scene.
  114355. * See http://doc.babylonjs.com/how_to/webvr_helper
  114356. */
  114357. export class VRExperienceHelper {
  114358. /** Options to modify the vr experience helper's behavior. */
  114359. webVROptions: VRExperienceHelperOptions;
  114360. private _scene;
  114361. private _position;
  114362. private _btnVR;
  114363. private _btnVRDisplayed;
  114364. private _webVRsupported;
  114365. private _webVRready;
  114366. private _webVRrequesting;
  114367. private _webVRpresenting;
  114368. private _hasEnteredVR;
  114369. private _fullscreenVRpresenting;
  114370. private _inputElement;
  114371. private _webVRCamera;
  114372. private _vrDeviceOrientationCamera;
  114373. private _deviceOrientationCamera;
  114374. private _existingCamera;
  114375. private _onKeyDown;
  114376. private _onVrDisplayPresentChange;
  114377. private _onVRDisplayChanged;
  114378. private _onVRRequestPresentStart;
  114379. private _onVRRequestPresentComplete;
  114380. /**
  114381. * 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)
  114382. */
  114383. enableGazeEvenWhenNoPointerLock: boolean;
  114384. /**
  114385. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  114386. */
  114387. exitVROnDoubleTap: boolean;
  114388. /**
  114389. * Observable raised right before entering VR.
  114390. */
  114391. onEnteringVRObservable: Observable<VRExperienceHelper>;
  114392. /**
  114393. * Observable raised when entering VR has completed.
  114394. */
  114395. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  114396. /**
  114397. * Observable raised when exiting VR.
  114398. */
  114399. onExitingVRObservable: Observable<VRExperienceHelper>;
  114400. /**
  114401. * Observable raised when controller mesh is loaded.
  114402. */
  114403. onControllerMeshLoadedObservable: Observable<WebVRController>;
  114404. /** Return this.onEnteringVRObservable
  114405. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  114406. */
  114407. get onEnteringVR(): Observable<VRExperienceHelper>;
  114408. /** Return this.onExitingVRObservable
  114409. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  114410. */
  114411. get onExitingVR(): Observable<VRExperienceHelper>;
  114412. /** Return this.onControllerMeshLoadedObservable
  114413. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  114414. */
  114415. get onControllerMeshLoaded(): Observable<WebVRController>;
  114416. private _rayLength;
  114417. private _useCustomVRButton;
  114418. private _teleportationRequested;
  114419. private _teleportActive;
  114420. private _floorMeshName;
  114421. private _floorMeshesCollection;
  114422. private _teleportationMode;
  114423. private _teleportationTime;
  114424. private _teleportationSpeed;
  114425. private _teleportationEasing;
  114426. private _rotationAllowed;
  114427. private _teleportBackwardsVector;
  114428. private _teleportationTarget;
  114429. private _isDefaultTeleportationTarget;
  114430. private _postProcessMove;
  114431. private _teleportationFillColor;
  114432. private _teleportationBorderColor;
  114433. private _rotationAngle;
  114434. private _haloCenter;
  114435. private _cameraGazer;
  114436. private _padSensibilityUp;
  114437. private _padSensibilityDown;
  114438. private _leftController;
  114439. private _rightController;
  114440. /**
  114441. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  114442. */
  114443. onNewMeshSelected: Observable<AbstractMesh>;
  114444. /**
  114445. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  114446. * This observable will provide the mesh and the controller used to select the mesh
  114447. */
  114448. onMeshSelectedWithController: Observable<{
  114449. mesh: AbstractMesh;
  114450. controller: WebVRController;
  114451. }>;
  114452. /**
  114453. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  114454. */
  114455. onNewMeshPicked: Observable<PickingInfo>;
  114456. private _circleEase;
  114457. /**
  114458. * Observable raised before camera teleportation
  114459. */
  114460. onBeforeCameraTeleport: Observable<Vector3>;
  114461. /**
  114462. * Observable raised after camera teleportation
  114463. */
  114464. onAfterCameraTeleport: Observable<Vector3>;
  114465. /**
  114466. * Observable raised when current selected mesh gets unselected
  114467. */
  114468. onSelectedMeshUnselected: Observable<AbstractMesh>;
  114469. private _raySelectionPredicate;
  114470. /**
  114471. * To be optionaly changed by user to define custom ray selection
  114472. */
  114473. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  114474. /**
  114475. * To be optionaly changed by user to define custom selection logic (after ray selection)
  114476. */
  114477. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114478. /**
  114479. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  114480. */
  114481. teleportationEnabled: boolean;
  114482. private _defaultHeight;
  114483. private _teleportationInitialized;
  114484. private _interactionsEnabled;
  114485. private _interactionsRequested;
  114486. private _displayGaze;
  114487. private _displayLaserPointer;
  114488. /**
  114489. * The mesh used to display where the user is going to teleport.
  114490. */
  114491. get teleportationTarget(): Mesh;
  114492. /**
  114493. * Sets the mesh to be used to display where the user is going to teleport.
  114494. */
  114495. set teleportationTarget(value: Mesh);
  114496. /**
  114497. * 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
  114498. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  114499. * See http://doc.babylonjs.com/resources/baking_transformations
  114500. */
  114501. get gazeTrackerMesh(): Mesh;
  114502. set gazeTrackerMesh(value: Mesh);
  114503. /**
  114504. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  114505. */
  114506. updateGazeTrackerScale: boolean;
  114507. /**
  114508. * If the gaze trackers color should be updated when selecting meshes
  114509. */
  114510. updateGazeTrackerColor: boolean;
  114511. /**
  114512. * If the controller laser color should be updated when selecting meshes
  114513. */
  114514. updateControllerLaserColor: boolean;
  114515. /**
  114516. * The gaze tracking mesh corresponding to the left controller
  114517. */
  114518. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  114519. /**
  114520. * The gaze tracking mesh corresponding to the right controller
  114521. */
  114522. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  114523. /**
  114524. * If the ray of the gaze should be displayed.
  114525. */
  114526. get displayGaze(): boolean;
  114527. /**
  114528. * Sets if the ray of the gaze should be displayed.
  114529. */
  114530. set displayGaze(value: boolean);
  114531. /**
  114532. * If the ray of the LaserPointer should be displayed.
  114533. */
  114534. get displayLaserPointer(): boolean;
  114535. /**
  114536. * Sets if the ray of the LaserPointer should be displayed.
  114537. */
  114538. set displayLaserPointer(value: boolean);
  114539. /**
  114540. * The deviceOrientationCamera used as the camera when not in VR.
  114541. */
  114542. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  114543. /**
  114544. * Based on the current WebVR support, returns the current VR camera used.
  114545. */
  114546. get currentVRCamera(): Nullable<Camera>;
  114547. /**
  114548. * The webVRCamera which is used when in VR.
  114549. */
  114550. get webVRCamera(): WebVRFreeCamera;
  114551. /**
  114552. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  114553. */
  114554. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  114555. /**
  114556. * The html button that is used to trigger entering into VR.
  114557. */
  114558. get vrButton(): Nullable<HTMLButtonElement>;
  114559. private get _teleportationRequestInitiated();
  114560. /**
  114561. * Defines wether or not Pointer lock should be requested when switching to
  114562. * full screen.
  114563. */
  114564. requestPointerLockOnFullScreen: boolean;
  114565. /**
  114566. * If asking to force XR, this will be populated with the default xr experience
  114567. */
  114568. xr: WebXRDefaultExperience;
  114569. /**
  114570. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  114571. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  114572. */
  114573. xrTestDone: boolean;
  114574. /**
  114575. * Instantiates a VRExperienceHelper.
  114576. * Helps to quickly add VR support to an existing scene.
  114577. * @param scene The scene the VRExperienceHelper belongs to.
  114578. * @param webVROptions Options to modify the vr experience helper's behavior.
  114579. */
  114580. constructor(scene: Scene,
  114581. /** Options to modify the vr experience helper's behavior. */
  114582. webVROptions?: VRExperienceHelperOptions);
  114583. private completeVRInit;
  114584. private _onDefaultMeshLoaded;
  114585. private _onResize;
  114586. private _onFullscreenChange;
  114587. /**
  114588. * Gets a value indicating if we are currently in VR mode.
  114589. */
  114590. get isInVRMode(): boolean;
  114591. private onVrDisplayPresentChange;
  114592. private onVRDisplayChanged;
  114593. private moveButtonToBottomRight;
  114594. private displayVRButton;
  114595. private updateButtonVisibility;
  114596. private _cachedAngularSensibility;
  114597. /**
  114598. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  114599. * Otherwise, will use the fullscreen API.
  114600. */
  114601. enterVR(): void;
  114602. /**
  114603. * Attempt to exit VR, or fullscreen.
  114604. */
  114605. exitVR(): void;
  114606. /**
  114607. * The position of the vr experience helper.
  114608. */
  114609. get position(): Vector3;
  114610. /**
  114611. * Sets the position of the vr experience helper.
  114612. */
  114613. set position(value: Vector3);
  114614. /**
  114615. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  114616. */
  114617. enableInteractions(): void;
  114618. private get _noControllerIsActive();
  114619. private beforeRender;
  114620. private _isTeleportationFloor;
  114621. /**
  114622. * Adds a floor mesh to be used for teleportation.
  114623. * @param floorMesh the mesh to be used for teleportation.
  114624. */
  114625. addFloorMesh(floorMesh: Mesh): void;
  114626. /**
  114627. * Removes a floor mesh from being used for teleportation.
  114628. * @param floorMesh the mesh to be removed.
  114629. */
  114630. removeFloorMesh(floorMesh: Mesh): void;
  114631. /**
  114632. * Enables interactions and teleportation using the VR controllers and gaze.
  114633. * @param vrTeleportationOptions options to modify teleportation behavior.
  114634. */
  114635. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  114636. private _onNewGamepadConnected;
  114637. private _tryEnableInteractionOnController;
  114638. private _onNewGamepadDisconnected;
  114639. private _enableInteractionOnController;
  114640. private _checkTeleportWithRay;
  114641. private _checkRotate;
  114642. private _checkTeleportBackwards;
  114643. private _enableTeleportationOnController;
  114644. private _createTeleportationCircles;
  114645. private _displayTeleportationTarget;
  114646. private _hideTeleportationTarget;
  114647. private _rotateCamera;
  114648. private _moveTeleportationSelectorTo;
  114649. private _workingVector;
  114650. private _workingQuaternion;
  114651. private _workingMatrix;
  114652. /**
  114653. * Time Constant Teleportation Mode
  114654. */
  114655. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  114656. /**
  114657. * Speed Constant Teleportation Mode
  114658. */
  114659. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  114660. /**
  114661. * Teleports the users feet to the desired location
  114662. * @param location The location where the user's feet should be placed
  114663. */
  114664. teleportCamera(location: Vector3): void;
  114665. private _convertNormalToDirectionOfRay;
  114666. private _castRayAndSelectObject;
  114667. private _notifySelectedMeshUnselected;
  114668. /**
  114669. * Sets the color of the laser ray from the vr controllers.
  114670. * @param color new color for the ray.
  114671. */
  114672. changeLaserColor(color: Color3): void;
  114673. /**
  114674. * Sets the color of the ray from the vr headsets gaze.
  114675. * @param color new color for the ray.
  114676. */
  114677. changeGazeColor(color: Color3): void;
  114678. /**
  114679. * Exits VR and disposes of the vr experience helper
  114680. */
  114681. dispose(): void;
  114682. /**
  114683. * Gets the name of the VRExperienceHelper class
  114684. * @returns "VRExperienceHelper"
  114685. */
  114686. getClassName(): string;
  114687. }
  114688. }
  114689. declare module BABYLON {
  114690. /**
  114691. * Options used for hit testing
  114692. */
  114693. export interface IWebXRHitTestOptions {
  114694. /**
  114695. * Only test when user interacted with the scene. Default - hit test every frame
  114696. */
  114697. testOnPointerDownOnly?: boolean;
  114698. /**
  114699. * The node to use to transform the local results to world coordinates
  114700. */
  114701. worldParentNode?: TransformNode;
  114702. }
  114703. /**
  114704. * Interface defining the babylon result of raycasting/hit-test
  114705. */
  114706. export interface IWebXRHitResult {
  114707. /**
  114708. * The native hit test result
  114709. */
  114710. xrHitResult: XRHitResult;
  114711. /**
  114712. * Transformation matrix that can be applied to a node that will put it in the hit point location
  114713. */
  114714. transformationMatrix: Matrix;
  114715. }
  114716. /**
  114717. * The currently-working hit-test module.
  114718. * Hit test (or raycasting) is used to interact with the real world.
  114719. * For further information read here - https://github.com/immersive-web/hit-test
  114720. */
  114721. export class WebXRHitTestLegacy implements IWebXRFeature {
  114722. private _xrSessionManager;
  114723. /**
  114724. * options to use when constructing this feature
  114725. */
  114726. readonly options: IWebXRHitTestOptions;
  114727. /**
  114728. * The module's name
  114729. */
  114730. static readonly Name: string;
  114731. /**
  114732. * The (Babylon) version of this module.
  114733. * This is an integer representing the implementation version.
  114734. * This number does not correspond to the webxr specs version
  114735. */
  114736. static readonly Version: number;
  114737. /**
  114738. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  114739. * @param event the (select) event to use to select with
  114740. * @param referenceSpace the reference space to use for this hit test
  114741. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114742. */
  114743. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  114744. /**
  114745. * execute a hit test with an XR Ray
  114746. *
  114747. * @param xrSession a native xrSession that will execute this hit test
  114748. * @param xrRay the ray (position and direction) to use for raycasting
  114749. * @param referenceSpace native XR reference space to use for the hit-test
  114750. * @param filter filter function that will filter the results
  114751. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114752. */
  114753. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  114754. /**
  114755. * Triggered when new babylon (transformed) hit test results are available
  114756. */
  114757. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  114758. /**
  114759. * Creates a new instance of the (legacy version) hit test feature
  114760. * @param _xrSessionManager an instance of WebXRSessionManager
  114761. * @param options options to use when constructing this feature
  114762. */
  114763. constructor(_xrSessionManager: WebXRSessionManager,
  114764. /**
  114765. * options to use when constructing this feature
  114766. */
  114767. options?: IWebXRHitTestOptions);
  114768. private _onSelectEnabled;
  114769. private _xrFrameObserver;
  114770. private _attached;
  114771. /**
  114772. * Populated with the last native XR Hit Results
  114773. */
  114774. lastNativeXRHitResults: XRHitResult[];
  114775. /**
  114776. * attach this feature
  114777. * Will usually be called by the features manager
  114778. *
  114779. * @returns true if successful.
  114780. */
  114781. attach(): boolean;
  114782. /**
  114783. * detach this feature.
  114784. * Will usually be called by the features manager
  114785. *
  114786. * @returns true if successful.
  114787. */
  114788. detach(): boolean;
  114789. private _onHitTestResults;
  114790. private _onSelect;
  114791. /**
  114792. * Dispose this feature and all of the resources attached
  114793. */
  114794. dispose(): void;
  114795. }
  114796. }
  114797. declare module BABYLON {
  114798. /**
  114799. * Options used in the plane detector module
  114800. */
  114801. export interface IWebXRPlaneDetectorOptions {
  114802. /**
  114803. * The node to use to transform the local results to world coordinates
  114804. */
  114805. worldParentNode?: TransformNode;
  114806. }
  114807. /**
  114808. * A babylon interface for a webxr plane.
  114809. * A Plane is actually a polygon, built from N points in space
  114810. */
  114811. export interface IWebXRPlane {
  114812. /**
  114813. * a babylon-assigned ID for this polygon
  114814. */
  114815. id: number;
  114816. /**
  114817. * the native xr-plane object
  114818. */
  114819. xrPlane: XRPlane;
  114820. /**
  114821. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  114822. */
  114823. polygonDefinition: Array<Vector3>;
  114824. /**
  114825. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  114826. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  114827. */
  114828. transformationMatrix: Matrix;
  114829. }
  114830. /**
  114831. * The plane detector is used to detect planes in the real world when in AR
  114832. * For more information see https://github.com/immersive-web/real-world-geometry/
  114833. */
  114834. export class WebXRPlaneDetector implements IWebXRFeature {
  114835. private _xrSessionManager;
  114836. private _options;
  114837. /**
  114838. * The module's name
  114839. */
  114840. static readonly Name: string;
  114841. /**
  114842. * The (Babylon) version of this module.
  114843. * This is an integer representing the implementation version.
  114844. * This number does not correspond to the webxr specs version
  114845. */
  114846. static readonly Version: number;
  114847. /**
  114848. * Observers registered here will be executed when a new plane was added to the session
  114849. */
  114850. onPlaneAddedObservable: Observable<IWebXRPlane>;
  114851. /**
  114852. * Observers registered here will be executed when a plane is no longer detected in the session
  114853. */
  114854. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  114855. /**
  114856. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  114857. * This can execute N times every frame
  114858. */
  114859. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  114860. private _enabled;
  114861. private _attached;
  114862. private _detectedPlanes;
  114863. private _lastFrameDetected;
  114864. private _observerTracked;
  114865. /**
  114866. * construct a new Plane Detector
  114867. * @param _xrSessionManager an instance of xr Session manager
  114868. * @param _options configuration to use when constructing this feature
  114869. */
  114870. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  114871. /**
  114872. * attach this feature
  114873. * Will usually be called by the features manager
  114874. *
  114875. * @returns true if successful.
  114876. */
  114877. attach(): boolean;
  114878. /**
  114879. * detach this feature.
  114880. * Will usually be called by the features manager
  114881. *
  114882. * @returns true if successful.
  114883. */
  114884. detach(): boolean;
  114885. /**
  114886. * Dispose this feature and all of the resources attached
  114887. */
  114888. dispose(): void;
  114889. private _updatePlaneWithXRPlane;
  114890. /**
  114891. * avoiding using Array.find for global support.
  114892. * @param xrPlane the plane to find in the array
  114893. */
  114894. private findIndexInPlaneArray;
  114895. }
  114896. }
  114897. declare module BABYLON {
  114898. /**
  114899. * Configuration options of the anchor system
  114900. */
  114901. export interface IWebXRAnchorSystemOptions {
  114902. /**
  114903. * a node that will be used to convert local to world coordinates
  114904. */
  114905. worldParentNode?: TransformNode;
  114906. /**
  114907. * should the anchor system use plane detection.
  114908. * If set to true, the plane-detection feature should be set using setPlaneDetector
  114909. */
  114910. usePlaneDetection?: boolean;
  114911. /**
  114912. * Should a new anchor be added every time a select event is triggered
  114913. */
  114914. addAnchorOnSelect?: boolean;
  114915. }
  114916. /**
  114917. * A babylon container for an XR Anchor
  114918. */
  114919. export interface IWebXRAnchor {
  114920. /**
  114921. * A babylon-assigned ID for this anchor
  114922. */
  114923. id: number;
  114924. /**
  114925. * The native anchor object
  114926. */
  114927. xrAnchor: XRAnchor;
  114928. /**
  114929. * Transformation matrix to apply to an object attached to this anchor
  114930. */
  114931. transformationMatrix: Matrix;
  114932. }
  114933. /**
  114934. * An implementation of the anchor system of WebXR.
  114935. * Note that the current documented implementation is not available in any browser. Future implementations
  114936. * will use the frame to create an anchor and not the session or a detected plane
  114937. * For further information see https://github.com/immersive-web/anchors/
  114938. */
  114939. export class WebXRAnchorSystem implements IWebXRFeature {
  114940. private _xrSessionManager;
  114941. private _options;
  114942. /**
  114943. * The module's name
  114944. */
  114945. static readonly Name: string;
  114946. /**
  114947. * The (Babylon) version of this module.
  114948. * This is an integer representing the implementation version.
  114949. * This number does not correspond to the webxr specs version
  114950. */
  114951. static readonly Version: number;
  114952. /**
  114953. * Observers registered here will be executed when a new anchor was added to the session
  114954. */
  114955. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  114956. /**
  114957. * Observers registered here will be executed when an existing anchor updates
  114958. * This can execute N times every frame
  114959. */
  114960. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  114961. /**
  114962. * Observers registered here will be executed when an anchor was removed from the session
  114963. */
  114964. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  114965. private _planeDetector;
  114966. private _hitTestModule;
  114967. private _enabled;
  114968. private _attached;
  114969. private _trackedAnchors;
  114970. private _lastFrameDetected;
  114971. private _observerTracked;
  114972. /**
  114973. * constructs a new anchor system
  114974. * @param _xrSessionManager an instance of WebXRSessionManager
  114975. * @param _options configuration object for this feature
  114976. */
  114977. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  114978. /**
  114979. * set the plane detector to use in order to create anchors from frames
  114980. * @param planeDetector the plane-detector module to use
  114981. * @param enable enable plane-anchors. default is true
  114982. */
  114983. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  114984. /**
  114985. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  114986. * @param hitTestModule the hit-test module to use.
  114987. */
  114988. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  114989. /**
  114990. * attach this feature
  114991. * Will usually be called by the features manager
  114992. *
  114993. * @returns true if successful.
  114994. */
  114995. attach(): boolean;
  114996. /**
  114997. * detach this feature.
  114998. * Will usually be called by the features manager
  114999. *
  115000. * @returns true if successful.
  115001. */
  115002. detach(): boolean;
  115003. /**
  115004. * Dispose this feature and all of the resources attached
  115005. */
  115006. dispose(): void;
  115007. private _onSelect;
  115008. /**
  115009. * Add anchor at a specific XR point.
  115010. *
  115011. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  115012. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  115013. * @returns a promise the fulfills when the anchor was created
  115014. */
  115015. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  115016. private _updateAnchorWithXRFrame;
  115017. /**
  115018. * avoiding using Array.find for global support.
  115019. * @param xrAnchor the plane to find in the array
  115020. */
  115021. private _findIndexInAnchorArray;
  115022. }
  115023. }
  115024. declare module BABYLON {
  115025. /**
  115026. * Options interface for the background remover plugin
  115027. */
  115028. export interface IWebXRBackgroundRemoverOptions {
  115029. /**
  115030. * don't disable the environment helper
  115031. */
  115032. ignoreEnvironmentHelper?: boolean;
  115033. /**
  115034. * flags to configure the removal of the environment helper.
  115035. * If not set, the entire background will be removed. If set, flags should be set as well.
  115036. */
  115037. environmentHelperRemovalFlags?: {
  115038. /**
  115039. * Should the skybox be removed (default false)
  115040. */
  115041. skyBox?: boolean;
  115042. /**
  115043. * Should the ground be removed (default false)
  115044. */
  115045. ground?: boolean;
  115046. };
  115047. /**
  115048. * Further background meshes to disable when entering AR
  115049. */
  115050. backgroundMeshes?: AbstractMesh[];
  115051. }
  115052. /**
  115053. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  115054. */
  115055. export class WebXRBackgroundRemover implements IWebXRFeature {
  115056. private _xrSessionManager;
  115057. /**
  115058. * read-only options to be used in this module
  115059. */
  115060. readonly options: IWebXRBackgroundRemoverOptions;
  115061. /**
  115062. * The module's name
  115063. */
  115064. static readonly Name: string;
  115065. /**
  115066. * The (Babylon) version of this module.
  115067. * This is an integer representing the implementation version.
  115068. * This number does not correspond to the webxr specs version
  115069. */
  115070. static readonly Version: number;
  115071. /**
  115072. * registered observers will be triggered when the background state changes
  115073. */
  115074. onBackgroundStateChangedObservable: Observable<boolean>;
  115075. /**
  115076. * constructs a new background remover module
  115077. * @param _xrSessionManager the session manager for this module
  115078. * @param options read-only options to be used in this module
  115079. */
  115080. constructor(_xrSessionManager: WebXRSessionManager,
  115081. /**
  115082. * read-only options to be used in this module
  115083. */
  115084. options?: IWebXRBackgroundRemoverOptions);
  115085. /**
  115086. * attach this feature
  115087. * Will usually be called by the features manager
  115088. *
  115089. * @returns true if successful.
  115090. */
  115091. attach(): boolean;
  115092. /**
  115093. * detach this feature.
  115094. * Will usually be called by the features manager
  115095. *
  115096. * @returns true if successful.
  115097. */
  115098. detach(): boolean;
  115099. private _setBackgroundState;
  115100. /**
  115101. * Dispose this feature and all of the resources attached
  115102. */
  115103. dispose(): void;
  115104. }
  115105. }
  115106. declare module BABYLON {
  115107. /**
  115108. * Contains an array of blocks representing the octree
  115109. */
  115110. export interface IOctreeContainer<T> {
  115111. /**
  115112. * Blocks within the octree
  115113. */
  115114. blocks: Array<OctreeBlock<T>>;
  115115. }
  115116. /**
  115117. * Class used to store a cell in an octree
  115118. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115119. */
  115120. export class OctreeBlock<T> {
  115121. /**
  115122. * Gets the content of the current block
  115123. */
  115124. entries: T[];
  115125. /**
  115126. * Gets the list of block children
  115127. */
  115128. blocks: Array<OctreeBlock<T>>;
  115129. private _depth;
  115130. private _maxDepth;
  115131. private _capacity;
  115132. private _minPoint;
  115133. private _maxPoint;
  115134. private _boundingVectors;
  115135. private _creationFunc;
  115136. /**
  115137. * Creates a new block
  115138. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  115139. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  115140. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115141. * @param depth defines the current depth of this block in the octree
  115142. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  115143. * @param creationFunc defines a callback to call when an element is added to the block
  115144. */
  115145. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  115146. /**
  115147. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115148. */
  115149. get capacity(): number;
  115150. /**
  115151. * Gets the minimum vector (in world space) of the block's bounding box
  115152. */
  115153. get minPoint(): Vector3;
  115154. /**
  115155. * Gets the maximum vector (in world space) of the block's bounding box
  115156. */
  115157. get maxPoint(): Vector3;
  115158. /**
  115159. * Add a new element to this block
  115160. * @param entry defines the element to add
  115161. */
  115162. addEntry(entry: T): void;
  115163. /**
  115164. * Remove an element from this block
  115165. * @param entry defines the element to remove
  115166. */
  115167. removeEntry(entry: T): void;
  115168. /**
  115169. * Add an array of elements to this block
  115170. * @param entries defines the array of elements to add
  115171. */
  115172. addEntries(entries: T[]): void;
  115173. /**
  115174. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  115175. * @param frustumPlanes defines the frustum planes to test
  115176. * @param selection defines the array to store current content if selection is positive
  115177. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115178. */
  115179. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115180. /**
  115181. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  115182. * @param sphereCenter defines the bounding sphere center
  115183. * @param sphereRadius defines the bounding sphere radius
  115184. * @param selection defines the array to store current content if selection is positive
  115185. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115186. */
  115187. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115188. /**
  115189. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  115190. * @param ray defines the ray to test with
  115191. * @param selection defines the array to store current content if selection is positive
  115192. */
  115193. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  115194. /**
  115195. * Subdivide the content into child blocks (this block will then be empty)
  115196. */
  115197. createInnerBlocks(): void;
  115198. /**
  115199. * @hidden
  115200. */
  115201. 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;
  115202. }
  115203. }
  115204. declare module BABYLON {
  115205. /**
  115206. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  115207. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115208. */
  115209. export class Octree<T> {
  115210. /** 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.) */
  115211. maxDepth: number;
  115212. /**
  115213. * Blocks within the octree containing objects
  115214. */
  115215. blocks: Array<OctreeBlock<T>>;
  115216. /**
  115217. * Content stored in the octree
  115218. */
  115219. dynamicContent: T[];
  115220. private _maxBlockCapacity;
  115221. private _selectionContent;
  115222. private _creationFunc;
  115223. /**
  115224. * Creates a octree
  115225. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115226. * @param creationFunc function to be used to instatiate the octree
  115227. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  115228. * @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.)
  115229. */
  115230. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  115231. /** 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.) */
  115232. maxDepth?: number);
  115233. /**
  115234. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  115235. * @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);
  115236. * @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);
  115237. * @param entries meshes to be added to the octree blocks
  115238. */
  115239. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  115240. /**
  115241. * Adds a mesh to the octree
  115242. * @param entry Mesh to add to the octree
  115243. */
  115244. addMesh(entry: T): void;
  115245. /**
  115246. * Remove an element from the octree
  115247. * @param entry defines the element to remove
  115248. */
  115249. removeMesh(entry: T): void;
  115250. /**
  115251. * Selects an array of meshes within the frustum
  115252. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  115253. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  115254. * @returns array of meshes within the frustum
  115255. */
  115256. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  115257. /**
  115258. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  115259. * @param sphereCenter defines the bounding sphere center
  115260. * @param sphereRadius defines the bounding sphere radius
  115261. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115262. * @returns an array of objects that intersect the sphere
  115263. */
  115264. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  115265. /**
  115266. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  115267. * @param ray defines the ray to test with
  115268. * @returns array of intersected objects
  115269. */
  115270. intersectsRay(ray: Ray): SmartArray<T>;
  115271. /**
  115272. * Adds a mesh into the octree block if it intersects the block
  115273. */
  115274. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  115275. /**
  115276. * Adds a submesh into the octree block if it intersects the block
  115277. */
  115278. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  115279. }
  115280. }
  115281. declare module BABYLON {
  115282. interface Scene {
  115283. /**
  115284. * @hidden
  115285. * Backing Filed
  115286. */
  115287. _selectionOctree: Octree<AbstractMesh>;
  115288. /**
  115289. * Gets the octree used to boost mesh selection (picking)
  115290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115291. */
  115292. selectionOctree: Octree<AbstractMesh>;
  115293. /**
  115294. * Creates or updates the octree used to boost selection (picking)
  115295. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115296. * @param maxCapacity defines the maximum capacity per leaf
  115297. * @param maxDepth defines the maximum depth of the octree
  115298. * @returns an octree of AbstractMesh
  115299. */
  115300. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  115301. }
  115302. interface AbstractMesh {
  115303. /**
  115304. * @hidden
  115305. * Backing Field
  115306. */
  115307. _submeshesOctree: Octree<SubMesh>;
  115308. /**
  115309. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  115310. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  115311. * @param maxCapacity defines the maximum size of each block (64 by default)
  115312. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  115313. * @returns the new octree
  115314. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  115315. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115316. */
  115317. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  115318. }
  115319. /**
  115320. * Defines the octree scene component responsible to manage any octrees
  115321. * in a given scene.
  115322. */
  115323. export class OctreeSceneComponent {
  115324. /**
  115325. * The component name help to identify the component in the list of scene components.
  115326. */
  115327. readonly name: string;
  115328. /**
  115329. * The scene the component belongs to.
  115330. */
  115331. scene: Scene;
  115332. /**
  115333. * Indicates if the meshes have been checked to make sure they are isEnabled()
  115334. */
  115335. readonly checksIsEnabled: boolean;
  115336. /**
  115337. * Creates a new instance of the component for the given scene
  115338. * @param scene Defines the scene to register the component in
  115339. */
  115340. constructor(scene: Scene);
  115341. /**
  115342. * Registers the component in a given scene
  115343. */
  115344. register(): void;
  115345. /**
  115346. * Return the list of active meshes
  115347. * @returns the list of active meshes
  115348. */
  115349. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  115350. /**
  115351. * Return the list of active sub meshes
  115352. * @param mesh The mesh to get the candidates sub meshes from
  115353. * @returns the list of active sub meshes
  115354. */
  115355. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  115356. private _tempRay;
  115357. /**
  115358. * Return the list of sub meshes intersecting with a given local ray
  115359. * @param mesh defines the mesh to find the submesh for
  115360. * @param localRay defines the ray in local space
  115361. * @returns the list of intersecting sub meshes
  115362. */
  115363. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  115364. /**
  115365. * Return the list of sub meshes colliding with a collider
  115366. * @param mesh defines the mesh to find the submesh for
  115367. * @param collider defines the collider to evaluate the collision against
  115368. * @returns the list of colliding sub meshes
  115369. */
  115370. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  115371. /**
  115372. * Rebuilds the elements related to this component in case of
  115373. * context lost for instance.
  115374. */
  115375. rebuild(): void;
  115376. /**
  115377. * Disposes the component and the associated ressources.
  115378. */
  115379. dispose(): void;
  115380. }
  115381. }
  115382. declare module BABYLON {
  115383. /**
  115384. * Renders a layer on top of an existing scene
  115385. */
  115386. export class UtilityLayerRenderer implements IDisposable {
  115387. /** the original scene that will be rendered on top of */
  115388. originalScene: Scene;
  115389. private _pointerCaptures;
  115390. private _lastPointerEvents;
  115391. private static _DefaultUtilityLayer;
  115392. private static _DefaultKeepDepthUtilityLayer;
  115393. private _sharedGizmoLight;
  115394. private _renderCamera;
  115395. /**
  115396. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  115397. * @returns the camera that is used when rendering the utility layer
  115398. */
  115399. getRenderCamera(): Nullable<Camera>;
  115400. /**
  115401. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  115402. * @param cam the camera that should be used when rendering the utility layer
  115403. */
  115404. setRenderCamera(cam: Nullable<Camera>): void;
  115405. /**
  115406. * @hidden
  115407. * Light which used by gizmos to get light shading
  115408. */
  115409. _getSharedGizmoLight(): HemisphericLight;
  115410. /**
  115411. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  115412. */
  115413. pickUtilitySceneFirst: boolean;
  115414. /**
  115415. * 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)
  115416. */
  115417. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  115418. /**
  115419. * 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)
  115420. */
  115421. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  115422. /**
  115423. * The scene that is rendered on top of the original scene
  115424. */
  115425. utilityLayerScene: Scene;
  115426. /**
  115427. * If the utility layer should automatically be rendered on top of existing scene
  115428. */
  115429. shouldRender: boolean;
  115430. /**
  115431. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  115432. */
  115433. onlyCheckPointerDownEvents: boolean;
  115434. /**
  115435. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  115436. */
  115437. processAllEvents: boolean;
  115438. /**
  115439. * Observable raised when the pointer move from the utility layer scene to the main scene
  115440. */
  115441. onPointerOutObservable: Observable<number>;
  115442. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  115443. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  115444. private _afterRenderObserver;
  115445. private _sceneDisposeObserver;
  115446. private _originalPointerObserver;
  115447. /**
  115448. * Instantiates a UtilityLayerRenderer
  115449. * @param originalScene the original scene that will be rendered on top of
  115450. * @param handleEvents boolean indicating if the utility layer should handle events
  115451. */
  115452. constructor(
  115453. /** the original scene that will be rendered on top of */
  115454. originalScene: Scene, handleEvents?: boolean);
  115455. private _notifyObservers;
  115456. /**
  115457. * Renders the utility layers scene on top of the original scene
  115458. */
  115459. render(): void;
  115460. /**
  115461. * Disposes of the renderer
  115462. */
  115463. dispose(): void;
  115464. private _updateCamera;
  115465. }
  115466. }
  115467. declare module BABYLON {
  115468. /**
  115469. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  115470. */
  115471. export class Gizmo implements IDisposable {
  115472. /** The utility layer the gizmo will be added to */
  115473. gizmoLayer: UtilityLayerRenderer;
  115474. /**
  115475. * The root mesh of the gizmo
  115476. */
  115477. _rootMesh: Mesh;
  115478. private _attachedMesh;
  115479. /**
  115480. * Ratio for the scale of the gizmo (Default: 1)
  115481. */
  115482. scaleRatio: number;
  115483. /**
  115484. * If a custom mesh has been set (Default: false)
  115485. */
  115486. protected _customMeshSet: boolean;
  115487. /**
  115488. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  115489. * * When set, interactions will be enabled
  115490. */
  115491. get attachedMesh(): Nullable<AbstractMesh>;
  115492. set attachedMesh(value: Nullable<AbstractMesh>);
  115493. /**
  115494. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115495. * @param mesh The mesh to replace the default mesh of the gizmo
  115496. */
  115497. setCustomMesh(mesh: Mesh): void;
  115498. /**
  115499. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  115500. */
  115501. updateGizmoRotationToMatchAttachedMesh: boolean;
  115502. /**
  115503. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  115504. */
  115505. updateGizmoPositionToMatchAttachedMesh: boolean;
  115506. /**
  115507. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  115508. */
  115509. updateScale: boolean;
  115510. protected _interactionsEnabled: boolean;
  115511. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115512. private _beforeRenderObserver;
  115513. private _tempVector;
  115514. /**
  115515. * Creates a gizmo
  115516. * @param gizmoLayer The utility layer the gizmo will be added to
  115517. */
  115518. constructor(
  115519. /** The utility layer the gizmo will be added to */
  115520. gizmoLayer?: UtilityLayerRenderer);
  115521. /**
  115522. * Updates the gizmo to match the attached mesh's position/rotation
  115523. */
  115524. protected _update(): void;
  115525. /**
  115526. * Disposes of the gizmo
  115527. */
  115528. dispose(): void;
  115529. }
  115530. }
  115531. declare module BABYLON {
  115532. /**
  115533. * Single plane drag gizmo
  115534. */
  115535. export class PlaneDragGizmo extends Gizmo {
  115536. /**
  115537. * Drag behavior responsible for the gizmos dragging interactions
  115538. */
  115539. dragBehavior: PointerDragBehavior;
  115540. private _pointerObserver;
  115541. /**
  115542. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115543. */
  115544. snapDistance: number;
  115545. /**
  115546. * Event that fires each time the gizmo snaps to a new location.
  115547. * * snapDistance is the the change in distance
  115548. */
  115549. onSnapObservable: Observable<{
  115550. snapDistance: number;
  115551. }>;
  115552. private _plane;
  115553. private _coloredMaterial;
  115554. private _hoverMaterial;
  115555. private _isEnabled;
  115556. private _parent;
  115557. /** @hidden */
  115558. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  115559. /** @hidden */
  115560. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115561. /**
  115562. * Creates a PlaneDragGizmo
  115563. * @param gizmoLayer The utility layer the gizmo will be added to
  115564. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  115565. * @param color The color of the gizmo
  115566. */
  115567. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115568. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115569. /**
  115570. * If the gizmo is enabled
  115571. */
  115572. set isEnabled(value: boolean);
  115573. get isEnabled(): boolean;
  115574. /**
  115575. * Disposes of the gizmo
  115576. */
  115577. dispose(): void;
  115578. }
  115579. }
  115580. declare module BABYLON {
  115581. /**
  115582. * Gizmo that enables dragging a mesh along 3 axis
  115583. */
  115584. export class PositionGizmo extends Gizmo {
  115585. /**
  115586. * Internal gizmo used for interactions on the x axis
  115587. */
  115588. xGizmo: AxisDragGizmo;
  115589. /**
  115590. * Internal gizmo used for interactions on the y axis
  115591. */
  115592. yGizmo: AxisDragGizmo;
  115593. /**
  115594. * Internal gizmo used for interactions on the z axis
  115595. */
  115596. zGizmo: AxisDragGizmo;
  115597. /**
  115598. * Internal gizmo used for interactions on the yz plane
  115599. */
  115600. xPlaneGizmo: PlaneDragGizmo;
  115601. /**
  115602. * Internal gizmo used for interactions on the xz plane
  115603. */
  115604. yPlaneGizmo: PlaneDragGizmo;
  115605. /**
  115606. * Internal gizmo used for interactions on the xy plane
  115607. */
  115608. zPlaneGizmo: PlaneDragGizmo;
  115609. /**
  115610. * private variables
  115611. */
  115612. private _meshAttached;
  115613. private _updateGizmoRotationToMatchAttachedMesh;
  115614. private _snapDistance;
  115615. private _scaleRatio;
  115616. /** Fires an event when any of it's sub gizmos are dragged */
  115617. onDragStartObservable: Observable<unknown>;
  115618. /** Fires an event when any of it's sub gizmos are released from dragging */
  115619. onDragEndObservable: Observable<unknown>;
  115620. /**
  115621. * If set to true, planar drag is enabled
  115622. */
  115623. private _planarGizmoEnabled;
  115624. get attachedMesh(): Nullable<AbstractMesh>;
  115625. set attachedMesh(mesh: Nullable<AbstractMesh>);
  115626. /**
  115627. * Creates a PositionGizmo
  115628. * @param gizmoLayer The utility layer the gizmo will be added to
  115629. */
  115630. constructor(gizmoLayer?: UtilityLayerRenderer);
  115631. /**
  115632. * If the planar drag gizmo is enabled
  115633. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  115634. */
  115635. set planarGizmoEnabled(value: boolean);
  115636. get planarGizmoEnabled(): boolean;
  115637. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  115638. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  115639. /**
  115640. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115641. */
  115642. set snapDistance(value: number);
  115643. get snapDistance(): number;
  115644. /**
  115645. * Ratio for the scale of the gizmo (Default: 1)
  115646. */
  115647. set scaleRatio(value: number);
  115648. get scaleRatio(): number;
  115649. /**
  115650. * Disposes of the gizmo
  115651. */
  115652. dispose(): void;
  115653. /**
  115654. * CustomMeshes are not supported by this gizmo
  115655. * @param mesh The mesh to replace the default mesh of the gizmo
  115656. */
  115657. setCustomMesh(mesh: Mesh): void;
  115658. }
  115659. }
  115660. declare module BABYLON {
  115661. /**
  115662. * Single axis drag gizmo
  115663. */
  115664. export class AxisDragGizmo extends Gizmo {
  115665. /**
  115666. * Drag behavior responsible for the gizmos dragging interactions
  115667. */
  115668. dragBehavior: PointerDragBehavior;
  115669. private _pointerObserver;
  115670. /**
  115671. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115672. */
  115673. snapDistance: number;
  115674. /**
  115675. * Event that fires each time the gizmo snaps to a new location.
  115676. * * snapDistance is the the change in distance
  115677. */
  115678. onSnapObservable: Observable<{
  115679. snapDistance: number;
  115680. }>;
  115681. private _isEnabled;
  115682. private _parent;
  115683. private _arrow;
  115684. private _coloredMaterial;
  115685. private _hoverMaterial;
  115686. /** @hidden */
  115687. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  115688. /** @hidden */
  115689. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115690. /**
  115691. * Creates an AxisDragGizmo
  115692. * @param gizmoLayer The utility layer the gizmo will be added to
  115693. * @param dragAxis The axis which the gizmo will be able to drag on
  115694. * @param color The color of the gizmo
  115695. */
  115696. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115697. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115698. /**
  115699. * If the gizmo is enabled
  115700. */
  115701. set isEnabled(value: boolean);
  115702. get isEnabled(): boolean;
  115703. /**
  115704. * Disposes of the gizmo
  115705. */
  115706. dispose(): void;
  115707. }
  115708. }
  115709. declare module BABYLON.Debug {
  115710. /**
  115711. * The Axes viewer will show 3 axes in a specific point in space
  115712. */
  115713. export class AxesViewer {
  115714. private _xAxis;
  115715. private _yAxis;
  115716. private _zAxis;
  115717. private _scaleLinesFactor;
  115718. private _instanced;
  115719. /**
  115720. * Gets the hosting scene
  115721. */
  115722. scene: Scene;
  115723. /**
  115724. * Gets or sets a number used to scale line length
  115725. */
  115726. scaleLines: number;
  115727. /** Gets the node hierarchy used to render x-axis */
  115728. get xAxis(): TransformNode;
  115729. /** Gets the node hierarchy used to render y-axis */
  115730. get yAxis(): TransformNode;
  115731. /** Gets the node hierarchy used to render z-axis */
  115732. get zAxis(): TransformNode;
  115733. /**
  115734. * Creates a new AxesViewer
  115735. * @param scene defines the hosting scene
  115736. * @param scaleLines defines a number used to scale line length (1 by default)
  115737. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  115738. * @param xAxis defines the node hierarchy used to render the x-axis
  115739. * @param yAxis defines the node hierarchy used to render the y-axis
  115740. * @param zAxis defines the node hierarchy used to render the z-axis
  115741. */
  115742. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  115743. /**
  115744. * Force the viewer to update
  115745. * @param position defines the position of the viewer
  115746. * @param xaxis defines the x axis of the viewer
  115747. * @param yaxis defines the y axis of the viewer
  115748. * @param zaxis defines the z axis of the viewer
  115749. */
  115750. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  115751. /**
  115752. * Creates an instance of this axes viewer.
  115753. * @returns a new axes viewer with instanced meshes
  115754. */
  115755. createInstance(): AxesViewer;
  115756. /** Releases resources */
  115757. dispose(): void;
  115758. private static _SetRenderingGroupId;
  115759. }
  115760. }
  115761. declare module BABYLON.Debug {
  115762. /**
  115763. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  115764. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  115765. */
  115766. export class BoneAxesViewer extends AxesViewer {
  115767. /**
  115768. * Gets or sets the target mesh where to display the axes viewer
  115769. */
  115770. mesh: Nullable<Mesh>;
  115771. /**
  115772. * Gets or sets the target bone where to display the axes viewer
  115773. */
  115774. bone: Nullable<Bone>;
  115775. /** Gets current position */
  115776. pos: Vector3;
  115777. /** Gets direction of X axis */
  115778. xaxis: Vector3;
  115779. /** Gets direction of Y axis */
  115780. yaxis: Vector3;
  115781. /** Gets direction of Z axis */
  115782. zaxis: Vector3;
  115783. /**
  115784. * Creates a new BoneAxesViewer
  115785. * @param scene defines the hosting scene
  115786. * @param bone defines the target bone
  115787. * @param mesh defines the target mesh
  115788. * @param scaleLines defines a scaling factor for line length (1 by default)
  115789. */
  115790. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  115791. /**
  115792. * Force the viewer to update
  115793. */
  115794. update(): void;
  115795. /** Releases resources */
  115796. dispose(): void;
  115797. }
  115798. }
  115799. declare module BABYLON {
  115800. /**
  115801. * Interface used to define scene explorer extensibility option
  115802. */
  115803. export interface IExplorerExtensibilityOption {
  115804. /**
  115805. * Define the option label
  115806. */
  115807. label: string;
  115808. /**
  115809. * Defines the action to execute on click
  115810. */
  115811. action: (entity: any) => void;
  115812. }
  115813. /**
  115814. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  115815. */
  115816. export interface IExplorerExtensibilityGroup {
  115817. /**
  115818. * Defines a predicate to test if a given type mut be extended
  115819. */
  115820. predicate: (entity: any) => boolean;
  115821. /**
  115822. * Gets the list of options added to a type
  115823. */
  115824. entries: IExplorerExtensibilityOption[];
  115825. }
  115826. /**
  115827. * Interface used to define the options to use to create the Inspector
  115828. */
  115829. export interface IInspectorOptions {
  115830. /**
  115831. * Display in overlay mode (default: false)
  115832. */
  115833. overlay?: boolean;
  115834. /**
  115835. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  115836. */
  115837. globalRoot?: HTMLElement;
  115838. /**
  115839. * Display the Scene explorer
  115840. */
  115841. showExplorer?: boolean;
  115842. /**
  115843. * Display the property inspector
  115844. */
  115845. showInspector?: boolean;
  115846. /**
  115847. * Display in embed mode (both panes on the right)
  115848. */
  115849. embedMode?: boolean;
  115850. /**
  115851. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  115852. */
  115853. handleResize?: boolean;
  115854. /**
  115855. * Allow the panes to popup (default: true)
  115856. */
  115857. enablePopup?: boolean;
  115858. /**
  115859. * Allow the panes to be closed by users (default: true)
  115860. */
  115861. enableClose?: boolean;
  115862. /**
  115863. * Optional list of extensibility entries
  115864. */
  115865. explorerExtensibility?: IExplorerExtensibilityGroup[];
  115866. /**
  115867. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  115868. */
  115869. inspectorURL?: string;
  115870. /**
  115871. * Optional initial tab (default to DebugLayerTab.Properties)
  115872. */
  115873. initialTab?: DebugLayerTab;
  115874. }
  115875. interface Scene {
  115876. /**
  115877. * @hidden
  115878. * Backing field
  115879. */
  115880. _debugLayer: DebugLayer;
  115881. /**
  115882. * Gets the debug layer (aka Inspector) associated with the scene
  115883. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115884. */
  115885. debugLayer: DebugLayer;
  115886. }
  115887. /**
  115888. * Enum of inspector action tab
  115889. */
  115890. export enum DebugLayerTab {
  115891. /**
  115892. * Properties tag (default)
  115893. */
  115894. Properties = 0,
  115895. /**
  115896. * Debug tab
  115897. */
  115898. Debug = 1,
  115899. /**
  115900. * Statistics tab
  115901. */
  115902. Statistics = 2,
  115903. /**
  115904. * Tools tab
  115905. */
  115906. Tools = 3,
  115907. /**
  115908. * Settings tab
  115909. */
  115910. Settings = 4
  115911. }
  115912. /**
  115913. * The debug layer (aka Inspector) is the go to tool in order to better understand
  115914. * what is happening in your scene
  115915. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115916. */
  115917. export class DebugLayer {
  115918. /**
  115919. * Define the url to get the inspector script from.
  115920. * By default it uses the babylonjs CDN.
  115921. * @ignoreNaming
  115922. */
  115923. static InspectorURL: string;
  115924. private _scene;
  115925. private BJSINSPECTOR;
  115926. private _onPropertyChangedObservable?;
  115927. /**
  115928. * Observable triggered when a property is changed through the inspector.
  115929. */
  115930. get onPropertyChangedObservable(): any;
  115931. /**
  115932. * Instantiates a new debug layer.
  115933. * The debug layer (aka Inspector) is the go to tool in order to better understand
  115934. * what is happening in your scene
  115935. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115936. * @param scene Defines the scene to inspect
  115937. */
  115938. constructor(scene: Scene);
  115939. /** Creates the inspector window. */
  115940. private _createInspector;
  115941. /**
  115942. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  115943. * @param entity defines the entity to select
  115944. * @param lineContainerTitle defines the specific block to highlight
  115945. */
  115946. select(entity: any, lineContainerTitle?: string): void;
  115947. /** Get the inspector from bundle or global */
  115948. private _getGlobalInspector;
  115949. /**
  115950. * Get if the inspector is visible or not.
  115951. * @returns true if visible otherwise, false
  115952. */
  115953. isVisible(): boolean;
  115954. /**
  115955. * Hide the inspector and close its window.
  115956. */
  115957. hide(): void;
  115958. /**
  115959. * Launch the debugLayer.
  115960. * @param config Define the configuration of the inspector
  115961. * @return a promise fulfilled when the debug layer is visible
  115962. */
  115963. show(config?: IInspectorOptions): Promise<DebugLayer>;
  115964. }
  115965. }
  115966. declare module BABYLON {
  115967. /**
  115968. * Class containing static functions to help procedurally build meshes
  115969. */
  115970. export class BoxBuilder {
  115971. /**
  115972. * Creates a box mesh
  115973. * * The parameter `size` sets the size (float) of each box side (default 1)
  115974. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115975. * * 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)
  115976. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115980. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115981. * @param name defines the name of the mesh
  115982. * @param options defines the options used to create the mesh
  115983. * @param scene defines the hosting scene
  115984. * @returns the box mesh
  115985. */
  115986. static CreateBox(name: string, options: {
  115987. size?: number;
  115988. width?: number;
  115989. height?: number;
  115990. depth?: number;
  115991. faceUV?: Vector4[];
  115992. faceColors?: Color4[];
  115993. sideOrientation?: number;
  115994. frontUVs?: Vector4;
  115995. backUVs?: Vector4;
  115996. wrap?: boolean;
  115997. topBaseAt?: number;
  115998. bottomBaseAt?: number;
  115999. updatable?: boolean;
  116000. }, scene?: Nullable<Scene>): Mesh;
  116001. }
  116002. }
  116003. declare module BABYLON {
  116004. /**
  116005. * Class containing static functions to help procedurally build meshes
  116006. */
  116007. export class SphereBuilder {
  116008. /**
  116009. * Creates a sphere mesh
  116010. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116011. * * 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`)
  116012. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116013. * * 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
  116014. * * 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)
  116015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116018. * @param name defines the name of the mesh
  116019. * @param options defines the options used to create the mesh
  116020. * @param scene defines the hosting scene
  116021. * @returns the sphere mesh
  116022. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116023. */
  116024. static CreateSphere(name: string, options: {
  116025. segments?: number;
  116026. diameter?: number;
  116027. diameterX?: number;
  116028. diameterY?: number;
  116029. diameterZ?: number;
  116030. arc?: number;
  116031. slice?: number;
  116032. sideOrientation?: number;
  116033. frontUVs?: Vector4;
  116034. backUVs?: Vector4;
  116035. updatable?: boolean;
  116036. }, scene?: Nullable<Scene>): Mesh;
  116037. }
  116038. }
  116039. declare module BABYLON.Debug {
  116040. /**
  116041. * Used to show the physics impostor around the specific mesh
  116042. */
  116043. export class PhysicsViewer {
  116044. /** @hidden */
  116045. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  116046. /** @hidden */
  116047. protected _meshes: Array<Nullable<AbstractMesh>>;
  116048. /** @hidden */
  116049. protected _scene: Nullable<Scene>;
  116050. /** @hidden */
  116051. protected _numMeshes: number;
  116052. /** @hidden */
  116053. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  116054. private _renderFunction;
  116055. private _utilityLayer;
  116056. private _debugBoxMesh;
  116057. private _debugSphereMesh;
  116058. private _debugCylinderMesh;
  116059. private _debugMaterial;
  116060. private _debugMeshMeshes;
  116061. /**
  116062. * Creates a new PhysicsViewer
  116063. * @param scene defines the hosting scene
  116064. */
  116065. constructor(scene: Scene);
  116066. /** @hidden */
  116067. protected _updateDebugMeshes(): void;
  116068. /**
  116069. * Renders a specified physic impostor
  116070. * @param impostor defines the impostor to render
  116071. * @param targetMesh defines the mesh represented by the impostor
  116072. * @returns the new debug mesh used to render the impostor
  116073. */
  116074. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  116075. /**
  116076. * Hides a specified physic impostor
  116077. * @param impostor defines the impostor to hide
  116078. */
  116079. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  116080. private _getDebugMaterial;
  116081. private _getDebugBoxMesh;
  116082. private _getDebugSphereMesh;
  116083. private _getDebugCylinderMesh;
  116084. private _getDebugMeshMesh;
  116085. private _getDebugMesh;
  116086. /** Releases all resources */
  116087. dispose(): void;
  116088. }
  116089. }
  116090. declare module BABYLON {
  116091. /**
  116092. * Class containing static functions to help procedurally build meshes
  116093. */
  116094. export class LinesBuilder {
  116095. /**
  116096. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116097. * * 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
  116098. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116099. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116100. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116101. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116102. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116103. * * 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
  116104. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116107. * @param name defines the name of the new line system
  116108. * @param options defines the options used to create the line system
  116109. * @param scene defines the hosting scene
  116110. * @returns a new line system mesh
  116111. */
  116112. static CreateLineSystem(name: string, options: {
  116113. lines: Vector3[][];
  116114. updatable?: boolean;
  116115. instance?: Nullable<LinesMesh>;
  116116. colors?: Nullable<Color4[][]>;
  116117. useVertexAlpha?: boolean;
  116118. }, scene: Nullable<Scene>): LinesMesh;
  116119. /**
  116120. * Creates a line mesh
  116121. * 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
  116122. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116123. * * The parameter `points` is an array successive Vector3
  116124. * * 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
  116125. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116126. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116127. * * When updating an instance, remember that only point positions can change, not the number of points
  116128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116130. * @param name defines the name of the new line system
  116131. * @param options defines the options used to create the line system
  116132. * @param scene defines the hosting scene
  116133. * @returns a new line mesh
  116134. */
  116135. static CreateLines(name: string, options: {
  116136. points: Vector3[];
  116137. updatable?: boolean;
  116138. instance?: Nullable<LinesMesh>;
  116139. colors?: Color4[];
  116140. useVertexAlpha?: boolean;
  116141. }, scene?: Nullable<Scene>): LinesMesh;
  116142. /**
  116143. * Creates a dashed line mesh
  116144. * * 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
  116145. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116146. * * The parameter `points` is an array successive Vector3
  116147. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116148. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116149. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116150. * * 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
  116151. * * When updating an instance, remember that only point positions can change, not the number of points
  116152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116153. * @param name defines the name of the mesh
  116154. * @param options defines the options used to create the mesh
  116155. * @param scene defines the hosting scene
  116156. * @returns the dashed line mesh
  116157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116158. */
  116159. static CreateDashedLines(name: string, options: {
  116160. points: Vector3[];
  116161. dashSize?: number;
  116162. gapSize?: number;
  116163. dashNb?: number;
  116164. updatable?: boolean;
  116165. instance?: LinesMesh;
  116166. }, scene?: Nullable<Scene>): LinesMesh;
  116167. }
  116168. }
  116169. declare module BABYLON {
  116170. /**
  116171. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116172. * in order to better appreciate the issue one might have.
  116173. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116174. */
  116175. export class RayHelper {
  116176. /**
  116177. * Defines the ray we are currently tryin to visualize.
  116178. */
  116179. ray: Nullable<Ray>;
  116180. private _renderPoints;
  116181. private _renderLine;
  116182. private _renderFunction;
  116183. private _scene;
  116184. private _updateToMeshFunction;
  116185. private _attachedToMesh;
  116186. private _meshSpaceDirection;
  116187. private _meshSpaceOrigin;
  116188. /**
  116189. * Helper function to create a colored helper in a scene in one line.
  116190. * @param ray Defines the ray we are currently tryin to visualize
  116191. * @param scene Defines the scene the ray is used in
  116192. * @param color Defines the color we want to see the ray in
  116193. * @returns The newly created ray helper.
  116194. */
  116195. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  116196. /**
  116197. * Instantiate a new ray helper.
  116198. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116199. * in order to better appreciate the issue one might have.
  116200. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116201. * @param ray Defines the ray we are currently tryin to visualize
  116202. */
  116203. constructor(ray: Ray);
  116204. /**
  116205. * Shows the ray we are willing to debug.
  116206. * @param scene Defines the scene the ray needs to be rendered in
  116207. * @param color Defines the color the ray needs to be rendered in
  116208. */
  116209. show(scene: Scene, color?: Color3): void;
  116210. /**
  116211. * Hides the ray we are debugging.
  116212. */
  116213. hide(): void;
  116214. private _render;
  116215. /**
  116216. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  116217. * @param mesh Defines the mesh we want the helper attached to
  116218. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  116219. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  116220. * @param length Defines the length of the ray
  116221. */
  116222. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  116223. /**
  116224. * Detach the ray helper from the mesh it has previously been attached to.
  116225. */
  116226. detachFromMesh(): void;
  116227. private _updateToMesh;
  116228. /**
  116229. * Dispose the helper and release its associated resources.
  116230. */
  116231. dispose(): void;
  116232. }
  116233. }
  116234. declare module BABYLON.Debug {
  116235. /**
  116236. * Class used to render a debug view of a given skeleton
  116237. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  116238. */
  116239. export class SkeletonViewer {
  116240. /** defines the skeleton to render */
  116241. skeleton: Skeleton;
  116242. /** defines the mesh attached to the skeleton */
  116243. mesh: AbstractMesh;
  116244. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116245. autoUpdateBonesMatrices: boolean;
  116246. /** defines the rendering group id to use with the viewer */
  116247. renderingGroupId: number;
  116248. /** Gets or sets the color used to render the skeleton */
  116249. color: Color3;
  116250. private _scene;
  116251. private _debugLines;
  116252. private _debugMesh;
  116253. private _isEnabled;
  116254. private _renderFunction;
  116255. private _utilityLayer;
  116256. /**
  116257. * Returns the mesh used to render the bones
  116258. */
  116259. get debugMesh(): Nullable<LinesMesh>;
  116260. /**
  116261. * Creates a new SkeletonViewer
  116262. * @param skeleton defines the skeleton to render
  116263. * @param mesh defines the mesh attached to the skeleton
  116264. * @param scene defines the hosting scene
  116265. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  116266. * @param renderingGroupId defines the rendering group id to use with the viewer
  116267. */
  116268. constructor(
  116269. /** defines the skeleton to render */
  116270. skeleton: Skeleton,
  116271. /** defines the mesh attached to the skeleton */
  116272. mesh: AbstractMesh, scene: Scene,
  116273. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116274. autoUpdateBonesMatrices?: boolean,
  116275. /** defines the rendering group id to use with the viewer */
  116276. renderingGroupId?: number);
  116277. /** Gets or sets a boolean indicating if the viewer is enabled */
  116278. set isEnabled(value: boolean);
  116279. get isEnabled(): boolean;
  116280. private _getBonePosition;
  116281. private _getLinesForBonesWithLength;
  116282. private _getLinesForBonesNoLength;
  116283. /** Update the viewer to sync with current skeleton state */
  116284. update(): void;
  116285. /** Release associated resources */
  116286. dispose(): void;
  116287. }
  116288. }
  116289. declare module BABYLON {
  116290. /**
  116291. * Options to create the null engine
  116292. */
  116293. export class NullEngineOptions {
  116294. /**
  116295. * Render width (Default: 512)
  116296. */
  116297. renderWidth: number;
  116298. /**
  116299. * Render height (Default: 256)
  116300. */
  116301. renderHeight: number;
  116302. /**
  116303. * Texture size (Default: 512)
  116304. */
  116305. textureSize: number;
  116306. /**
  116307. * If delta time between frames should be constant
  116308. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116309. */
  116310. deterministicLockstep: boolean;
  116311. /**
  116312. * Maximum about of steps between frames (Default: 4)
  116313. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116314. */
  116315. lockstepMaxSteps: number;
  116316. }
  116317. /**
  116318. * The null engine class provides support for headless version of babylon.js.
  116319. * This can be used in server side scenario or for testing purposes
  116320. */
  116321. export class NullEngine extends Engine {
  116322. private _options;
  116323. /**
  116324. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116325. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116326. * @returns true if engine is in deterministic lock step mode
  116327. */
  116328. isDeterministicLockStep(): boolean;
  116329. /**
  116330. * Gets the max steps when engine is running in deterministic lock step
  116331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116332. * @returns the max steps
  116333. */
  116334. getLockstepMaxSteps(): number;
  116335. /**
  116336. * Gets the current hardware scaling level.
  116337. * By default the hardware scaling level is computed from the window device ratio.
  116338. * 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.
  116339. * @returns a number indicating the current hardware scaling level
  116340. */
  116341. getHardwareScalingLevel(): number;
  116342. constructor(options?: NullEngineOptions);
  116343. /**
  116344. * Creates a vertex buffer
  116345. * @param vertices the data for the vertex buffer
  116346. * @returns the new WebGL static buffer
  116347. */
  116348. createVertexBuffer(vertices: FloatArray): DataBuffer;
  116349. /**
  116350. * Creates a new index buffer
  116351. * @param indices defines the content of the index buffer
  116352. * @param updatable defines if the index buffer must be updatable
  116353. * @returns a new webGL buffer
  116354. */
  116355. createIndexBuffer(indices: IndicesArray): DataBuffer;
  116356. /**
  116357. * Clear the current render buffer or the current render target (if any is set up)
  116358. * @param color defines the color to use
  116359. * @param backBuffer defines if the back buffer must be cleared
  116360. * @param depth defines if the depth buffer must be cleared
  116361. * @param stencil defines if the stencil buffer must be cleared
  116362. */
  116363. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116364. /**
  116365. * Gets the current render width
  116366. * @param useScreen defines if screen size must be used (or the current render target if any)
  116367. * @returns a number defining the current render width
  116368. */
  116369. getRenderWidth(useScreen?: boolean): number;
  116370. /**
  116371. * Gets the current render height
  116372. * @param useScreen defines if screen size must be used (or the current render target if any)
  116373. * @returns a number defining the current render height
  116374. */
  116375. getRenderHeight(useScreen?: boolean): number;
  116376. /**
  116377. * Set the WebGL's viewport
  116378. * @param viewport defines the viewport element to be used
  116379. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116380. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116381. */
  116382. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116383. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  116384. /**
  116385. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116386. * @param pipelineContext defines the pipeline context to use
  116387. * @param uniformsNames defines the list of uniform names
  116388. * @returns an array of webGL uniform locations
  116389. */
  116390. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116391. /**
  116392. * Gets the lsit of active attributes for a given webGL program
  116393. * @param pipelineContext defines the pipeline context to use
  116394. * @param attributesNames defines the list of attribute names to get
  116395. * @returns an array of indices indicating the offset of each attribute
  116396. */
  116397. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116398. /**
  116399. * Binds an effect to the webGL context
  116400. * @param effect defines the effect to bind
  116401. */
  116402. bindSamplers(effect: Effect): void;
  116403. /**
  116404. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116405. * @param effect defines the effect to activate
  116406. */
  116407. enableEffect(effect: Effect): void;
  116408. /**
  116409. * Set various states to the webGL context
  116410. * @param culling defines backface culling state
  116411. * @param zOffset defines the value to apply to zOffset (0 by default)
  116412. * @param force defines if states must be applied even if cache is up to date
  116413. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116414. */
  116415. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116416. /**
  116417. * Set the value of an uniform to an array of int32
  116418. * @param uniform defines the webGL uniform location where to store the value
  116419. * @param array defines the array of int32 to store
  116420. */
  116421. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  116422. /**
  116423. * Set the value of an uniform to an array of int32 (stored as vec2)
  116424. * @param uniform defines the webGL uniform location where to store the value
  116425. * @param array defines the array of int32 to store
  116426. */
  116427. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  116428. /**
  116429. * Set the value of an uniform to an array of int32 (stored as vec3)
  116430. * @param uniform defines the webGL uniform location where to store the value
  116431. * @param array defines the array of int32 to store
  116432. */
  116433. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  116434. /**
  116435. * Set the value of an uniform to an array of int32 (stored as vec4)
  116436. * @param uniform defines the webGL uniform location where to store the value
  116437. * @param array defines the array of int32 to store
  116438. */
  116439. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  116440. /**
  116441. * Set the value of an uniform to an array of float32
  116442. * @param uniform defines the webGL uniform location where to store the value
  116443. * @param array defines the array of float32 to store
  116444. */
  116445. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  116446. /**
  116447. * Set the value of an uniform to an array of float32 (stored as vec2)
  116448. * @param uniform defines the webGL uniform location where to store the value
  116449. * @param array defines the array of float32 to store
  116450. */
  116451. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  116452. /**
  116453. * Set the value of an uniform to an array of float32 (stored as vec3)
  116454. * @param uniform defines the webGL uniform location where to store the value
  116455. * @param array defines the array of float32 to store
  116456. */
  116457. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  116458. /**
  116459. * Set the value of an uniform to an array of float32 (stored as vec4)
  116460. * @param uniform defines the webGL uniform location where to store the value
  116461. * @param array defines the array of float32 to store
  116462. */
  116463. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  116464. /**
  116465. * Set the value of an uniform to an array of number
  116466. * @param uniform defines the webGL uniform location where to store the value
  116467. * @param array defines the array of number to store
  116468. */
  116469. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  116470. /**
  116471. * Set the value of an uniform to an array of number (stored as vec2)
  116472. * @param uniform defines the webGL uniform location where to store the value
  116473. * @param array defines the array of number to store
  116474. */
  116475. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  116476. /**
  116477. * Set the value of an uniform to an array of number (stored as vec3)
  116478. * @param uniform defines the webGL uniform location where to store the value
  116479. * @param array defines the array of number to store
  116480. */
  116481. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  116482. /**
  116483. * Set the value of an uniform to an array of number (stored as vec4)
  116484. * @param uniform defines the webGL uniform location where to store the value
  116485. * @param array defines the array of number to store
  116486. */
  116487. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  116488. /**
  116489. * Set the value of an uniform to an array of float32 (stored as matrices)
  116490. * @param uniform defines the webGL uniform location where to store the value
  116491. * @param matrices defines the array of float32 to store
  116492. */
  116493. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  116494. /**
  116495. * Set the value of an uniform to a matrix (3x3)
  116496. * @param uniform defines the webGL uniform location where to store the value
  116497. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116498. */
  116499. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116500. /**
  116501. * Set the value of an uniform to a matrix (2x2)
  116502. * @param uniform defines the webGL uniform location where to store the value
  116503. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116504. */
  116505. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116506. /**
  116507. * Set the value of an uniform to a number (float)
  116508. * @param uniform defines the webGL uniform location where to store the value
  116509. * @param value defines the float number to store
  116510. */
  116511. setFloat(uniform: WebGLUniformLocation, value: number): void;
  116512. /**
  116513. * Set the value of an uniform to a vec2
  116514. * @param uniform defines the webGL uniform location where to store the value
  116515. * @param x defines the 1st component of the value
  116516. * @param y defines the 2nd component of the value
  116517. */
  116518. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  116519. /**
  116520. * Set the value of an uniform to a vec3
  116521. * @param uniform defines the webGL uniform location where to store the value
  116522. * @param x defines the 1st component of the value
  116523. * @param y defines the 2nd component of the value
  116524. * @param z defines the 3rd component of the value
  116525. */
  116526. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  116527. /**
  116528. * Set the value of an uniform to a boolean
  116529. * @param uniform defines the webGL uniform location where to store the value
  116530. * @param bool defines the boolean to store
  116531. */
  116532. setBool(uniform: WebGLUniformLocation, bool: number): void;
  116533. /**
  116534. * Set the value of an uniform to a vec4
  116535. * @param uniform defines the webGL uniform location where to store the value
  116536. * @param x defines the 1st component of the value
  116537. * @param y defines the 2nd component of the value
  116538. * @param z defines the 3rd component of the value
  116539. * @param w defines the 4th component of the value
  116540. */
  116541. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  116542. /**
  116543. * Sets the current alpha mode
  116544. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116545. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116546. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116547. */
  116548. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116549. /**
  116550. * Bind webGl buffers directly to the webGL context
  116551. * @param vertexBuffers defines the vertex buffer to bind
  116552. * @param indexBuffer defines the index buffer to bind
  116553. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116554. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116555. * @param effect defines the effect associated with the vertex buffer
  116556. */
  116557. bindBuffers(vertexBuffers: {
  116558. [key: string]: VertexBuffer;
  116559. }, indexBuffer: DataBuffer, effect: Effect): void;
  116560. /**
  116561. * Force the entire cache to be cleared
  116562. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116563. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116564. */
  116565. wipeCaches(bruteForce?: boolean): void;
  116566. /**
  116567. * Send a draw order
  116568. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116569. * @param indexStart defines the starting index
  116570. * @param indexCount defines the number of index to draw
  116571. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116572. */
  116573. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116574. /**
  116575. * Draw a list of indexed primitives
  116576. * @param fillMode defines the primitive to use
  116577. * @param indexStart defines the starting index
  116578. * @param indexCount defines the number of index to draw
  116579. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116580. */
  116581. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116582. /**
  116583. * Draw a list of unindexed primitives
  116584. * @param fillMode defines the primitive to use
  116585. * @param verticesStart defines the index of first vertex to draw
  116586. * @param verticesCount defines the count of vertices to draw
  116587. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116588. */
  116589. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116590. /** @hidden */
  116591. _createTexture(): WebGLTexture;
  116592. /** @hidden */
  116593. _releaseTexture(texture: InternalTexture): void;
  116594. /**
  116595. * Usually called from Texture.ts.
  116596. * Passed information to create a WebGLTexture
  116597. * @param urlArg defines a value which contains one of the following:
  116598. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116599. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116600. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116601. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116602. * @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)
  116603. * @param scene needed for loading to the correct scene
  116604. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116605. * @param onLoad optional callback to be called upon successful completion
  116606. * @param onError optional callback to be called upon failure
  116607. * @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
  116608. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116609. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116610. * @param forcedExtension defines the extension to use to pick the right loader
  116611. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  116612. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116613. */
  116614. 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;
  116615. /**
  116616. * Creates a new render target texture
  116617. * @param size defines the size of the texture
  116618. * @param options defines the options used to create the texture
  116619. * @returns a new render target texture stored in an InternalTexture
  116620. */
  116621. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  116622. /**
  116623. * Update the sampling mode of a given texture
  116624. * @param samplingMode defines the required sampling mode
  116625. * @param texture defines the texture to update
  116626. */
  116627. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  116628. /**
  116629. * Binds the frame buffer to the specified texture.
  116630. * @param texture The texture to render to or null for the default canvas
  116631. * @param faceIndex The face of the texture to render to in case of cube texture
  116632. * @param requiredWidth The width of the target to render to
  116633. * @param requiredHeight The height of the target to render to
  116634. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116635. * @param depthStencilTexture The depth stencil texture to use to render
  116636. * @param lodLevel defines le lod level to bind to the frame buffer
  116637. */
  116638. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  116639. /**
  116640. * Unbind the current render target texture from the webGL context
  116641. * @param texture defines the render target texture to unbind
  116642. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116643. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116644. */
  116645. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116646. /**
  116647. * Creates a dynamic vertex buffer
  116648. * @param vertices the data for the dynamic vertex buffer
  116649. * @returns the new WebGL dynamic buffer
  116650. */
  116651. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  116652. /**
  116653. * Update the content of a dynamic texture
  116654. * @param texture defines the texture to update
  116655. * @param canvas defines the canvas containing the source
  116656. * @param invertY defines if data must be stored with Y axis inverted
  116657. * @param premulAlpha defines if alpha is stored as premultiplied
  116658. * @param format defines the format of the data
  116659. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  116660. */
  116661. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  116662. /**
  116663. * Gets a boolean indicating if all created effects are ready
  116664. * @returns true if all effects are ready
  116665. */
  116666. areAllEffectsReady(): boolean;
  116667. /**
  116668. * @hidden
  116669. * Get the current error code of the webGL context
  116670. * @returns the error code
  116671. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116672. */
  116673. getError(): number;
  116674. /** @hidden */
  116675. _getUnpackAlignement(): number;
  116676. /** @hidden */
  116677. _unpackFlipY(value: boolean): void;
  116678. /**
  116679. * Update a dynamic index buffer
  116680. * @param indexBuffer defines the target index buffer
  116681. * @param indices defines the data to update
  116682. * @param offset defines the offset in the target index buffer where update should start
  116683. */
  116684. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  116685. /**
  116686. * Updates a dynamic vertex buffer.
  116687. * @param vertexBuffer the vertex buffer to update
  116688. * @param vertices the data used to update the vertex buffer
  116689. * @param byteOffset the byte offset of the data (optional)
  116690. * @param byteLength the byte length of the data (optional)
  116691. */
  116692. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  116693. /** @hidden */
  116694. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  116695. /** @hidden */
  116696. _bindTexture(channel: number, texture: InternalTexture): void;
  116697. protected _deleteBuffer(buffer: WebGLBuffer): void;
  116698. /**
  116699. * 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
  116700. */
  116701. releaseEffects(): void;
  116702. displayLoadingUI(): void;
  116703. hideLoadingUI(): void;
  116704. /** @hidden */
  116705. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116706. /** @hidden */
  116707. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116708. /** @hidden */
  116709. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116710. /** @hidden */
  116711. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  116712. }
  116713. }
  116714. declare module BABYLON {
  116715. /** @hidden */
  116716. export class _OcclusionDataStorage {
  116717. /** @hidden */
  116718. occlusionInternalRetryCounter: number;
  116719. /** @hidden */
  116720. isOcclusionQueryInProgress: boolean;
  116721. /** @hidden */
  116722. isOccluded: boolean;
  116723. /** @hidden */
  116724. occlusionRetryCount: number;
  116725. /** @hidden */
  116726. occlusionType: number;
  116727. /** @hidden */
  116728. occlusionQueryAlgorithmType: number;
  116729. }
  116730. interface Engine {
  116731. /**
  116732. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  116733. * @return the new query
  116734. */
  116735. createQuery(): WebGLQuery;
  116736. /**
  116737. * Delete and release a webGL query
  116738. * @param query defines the query to delete
  116739. * @return the current engine
  116740. */
  116741. deleteQuery(query: WebGLQuery): Engine;
  116742. /**
  116743. * Check if a given query has resolved and got its value
  116744. * @param query defines the query to check
  116745. * @returns true if the query got its value
  116746. */
  116747. isQueryResultAvailable(query: WebGLQuery): boolean;
  116748. /**
  116749. * Gets the value of a given query
  116750. * @param query defines the query to check
  116751. * @returns the value of the query
  116752. */
  116753. getQueryResult(query: WebGLQuery): number;
  116754. /**
  116755. * Initiates an occlusion query
  116756. * @param algorithmType defines the algorithm to use
  116757. * @param query defines the query to use
  116758. * @returns the current engine
  116759. * @see http://doc.babylonjs.com/features/occlusionquery
  116760. */
  116761. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  116762. /**
  116763. * Ends an occlusion query
  116764. * @see http://doc.babylonjs.com/features/occlusionquery
  116765. * @param algorithmType defines the algorithm to use
  116766. * @returns the current engine
  116767. */
  116768. endOcclusionQuery(algorithmType: number): Engine;
  116769. /**
  116770. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  116771. * Please note that only one query can be issued at a time
  116772. * @returns a time token used to track the time span
  116773. */
  116774. startTimeQuery(): Nullable<_TimeToken>;
  116775. /**
  116776. * Ends a time query
  116777. * @param token defines the token used to measure the time span
  116778. * @returns the time spent (in ns)
  116779. */
  116780. endTimeQuery(token: _TimeToken): int;
  116781. /** @hidden */
  116782. _currentNonTimestampToken: Nullable<_TimeToken>;
  116783. /** @hidden */
  116784. _createTimeQuery(): WebGLQuery;
  116785. /** @hidden */
  116786. _deleteTimeQuery(query: WebGLQuery): void;
  116787. /** @hidden */
  116788. _getGlAlgorithmType(algorithmType: number): number;
  116789. /** @hidden */
  116790. _getTimeQueryResult(query: WebGLQuery): any;
  116791. /** @hidden */
  116792. _getTimeQueryAvailability(query: WebGLQuery): any;
  116793. }
  116794. interface AbstractMesh {
  116795. /**
  116796. * Backing filed
  116797. * @hidden
  116798. */
  116799. __occlusionDataStorage: _OcclusionDataStorage;
  116800. /**
  116801. * Access property
  116802. * @hidden
  116803. */
  116804. _occlusionDataStorage: _OcclusionDataStorage;
  116805. /**
  116806. * 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.
  116807. * The default value is -1 which means don't break the query and wait till the result
  116808. * @see http://doc.babylonjs.com/features/occlusionquery
  116809. */
  116810. occlusionRetryCount: number;
  116811. /**
  116812. * 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:
  116813. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  116814. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  116815. * * 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.
  116816. * @see http://doc.babylonjs.com/features/occlusionquery
  116817. */
  116818. occlusionType: number;
  116819. /**
  116820. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  116821. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  116822. * * 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.
  116823. * @see http://doc.babylonjs.com/features/occlusionquery
  116824. */
  116825. occlusionQueryAlgorithmType: number;
  116826. /**
  116827. * 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
  116828. * @see http://doc.babylonjs.com/features/occlusionquery
  116829. */
  116830. isOccluded: boolean;
  116831. /**
  116832. * Flag to check the progress status of the query
  116833. * @see http://doc.babylonjs.com/features/occlusionquery
  116834. */
  116835. isOcclusionQueryInProgress: boolean;
  116836. }
  116837. }
  116838. declare module BABYLON {
  116839. /** @hidden */
  116840. export var _forceTransformFeedbackToBundle: boolean;
  116841. interface Engine {
  116842. /**
  116843. * Creates a webGL transform feedback object
  116844. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  116845. * @returns the webGL transform feedback object
  116846. */
  116847. createTransformFeedback(): WebGLTransformFeedback;
  116848. /**
  116849. * Delete a webGL transform feedback object
  116850. * @param value defines the webGL transform feedback object to delete
  116851. */
  116852. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  116853. /**
  116854. * Bind a webGL transform feedback object to the webgl context
  116855. * @param value defines the webGL transform feedback object to bind
  116856. */
  116857. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  116858. /**
  116859. * Begins a transform feedback operation
  116860. * @param usePoints defines if points or triangles must be used
  116861. */
  116862. beginTransformFeedback(usePoints: boolean): void;
  116863. /**
  116864. * Ends a transform feedback operation
  116865. */
  116866. endTransformFeedback(): void;
  116867. /**
  116868. * Specify the varyings to use with transform feedback
  116869. * @param program defines the associated webGL program
  116870. * @param value defines the list of strings representing the varying names
  116871. */
  116872. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  116873. /**
  116874. * Bind a webGL buffer for a transform feedback operation
  116875. * @param value defines the webGL buffer to bind
  116876. */
  116877. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  116878. }
  116879. }
  116880. declare module BABYLON {
  116881. /**
  116882. * Creation options of the multi render target texture.
  116883. */
  116884. export interface IMultiRenderTargetOptions {
  116885. /**
  116886. * Define if the texture needs to create mip maps after render.
  116887. */
  116888. generateMipMaps?: boolean;
  116889. /**
  116890. * Define the types of all the draw buffers we want to create
  116891. */
  116892. types?: number[];
  116893. /**
  116894. * Define the sampling modes of all the draw buffers we want to create
  116895. */
  116896. samplingModes?: number[];
  116897. /**
  116898. * Define if a depth buffer is required
  116899. */
  116900. generateDepthBuffer?: boolean;
  116901. /**
  116902. * Define if a stencil buffer is required
  116903. */
  116904. generateStencilBuffer?: boolean;
  116905. /**
  116906. * Define if a depth texture is required instead of a depth buffer
  116907. */
  116908. generateDepthTexture?: boolean;
  116909. /**
  116910. * Define the number of desired draw buffers
  116911. */
  116912. textureCount?: number;
  116913. /**
  116914. * Define if aspect ratio should be adapted to the texture or stay the scene one
  116915. */
  116916. doNotChangeAspectRatio?: boolean;
  116917. /**
  116918. * Define the default type of the buffers we are creating
  116919. */
  116920. defaultType?: number;
  116921. }
  116922. /**
  116923. * A multi render target, like a render target provides the ability to render to a texture.
  116924. * Unlike the render target, it can render to several draw buffers in one draw.
  116925. * This is specially interesting in deferred rendering or for any effects requiring more than
  116926. * just one color from a single pass.
  116927. */
  116928. export class MultiRenderTarget extends RenderTargetTexture {
  116929. private _internalTextures;
  116930. private _textures;
  116931. private _multiRenderTargetOptions;
  116932. /**
  116933. * Get if draw buffers are currently supported by the used hardware and browser.
  116934. */
  116935. get isSupported(): boolean;
  116936. /**
  116937. * Get the list of textures generated by the multi render target.
  116938. */
  116939. get textures(): Texture[];
  116940. /**
  116941. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  116942. */
  116943. get depthTexture(): Texture;
  116944. /**
  116945. * Set the wrapping mode on U of all the textures we are rendering to.
  116946. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  116947. */
  116948. set wrapU(wrap: number);
  116949. /**
  116950. * Set the wrapping mode on V of all the textures we are rendering to.
  116951. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  116952. */
  116953. set wrapV(wrap: number);
  116954. /**
  116955. * Instantiate a new multi render target texture.
  116956. * A multi render target, like a render target provides the ability to render to a texture.
  116957. * Unlike the render target, it can render to several draw buffers in one draw.
  116958. * This is specially interesting in deferred rendering or for any effects requiring more than
  116959. * just one color from a single pass.
  116960. * @param name Define the name of the texture
  116961. * @param size Define the size of the buffers to render to
  116962. * @param count Define the number of target we are rendering into
  116963. * @param scene Define the scene the texture belongs to
  116964. * @param options Define the options used to create the multi render target
  116965. */
  116966. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  116967. /** @hidden */
  116968. _rebuild(): void;
  116969. private _createInternalTextures;
  116970. private _createTextures;
  116971. /**
  116972. * Define the number of samples used if MSAA is enabled.
  116973. */
  116974. get samples(): number;
  116975. set samples(value: number);
  116976. /**
  116977. * Resize all the textures in the multi render target.
  116978. * Be carrefull as it will recreate all the data in the new texture.
  116979. * @param size Define the new size
  116980. */
  116981. resize(size: any): void;
  116982. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  116983. /**
  116984. * Dispose the render targets and their associated resources
  116985. */
  116986. dispose(): void;
  116987. /**
  116988. * Release all the underlying texture used as draw buffers.
  116989. */
  116990. releaseInternalTextures(): void;
  116991. }
  116992. }
  116993. declare module BABYLON {
  116994. interface ThinEngine {
  116995. /**
  116996. * Unbind a list of render target textures from the webGL context
  116997. * This is used only when drawBuffer extension or webGL2 are active
  116998. * @param textures defines the render target textures to unbind
  116999. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  117000. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  117001. */
  117002. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  117003. /**
  117004. * Create a multi render target texture
  117005. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  117006. * @param size defines the size of the texture
  117007. * @param options defines the creation options
  117008. * @returns the cube texture as an InternalTexture
  117009. */
  117010. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  117011. /**
  117012. * Update the sample count for a given multiple render target texture
  117013. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117014. * @param textures defines the textures to update
  117015. * @param samples defines the sample count to set
  117016. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117017. */
  117018. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  117019. }
  117020. }
  117021. declare module BABYLON {
  117022. /**
  117023. * Class used to define an additional view for the engine
  117024. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117025. */
  117026. export class EngineView {
  117027. /** Defines the canvas where to render the view */
  117028. target: HTMLCanvasElement;
  117029. /** Defines an optional camera used to render the view (will use active camera else) */
  117030. camera?: Camera;
  117031. }
  117032. interface Engine {
  117033. /**
  117034. * Gets or sets the HTML element to use for attaching events
  117035. */
  117036. inputElement: Nullable<HTMLElement>;
  117037. /**
  117038. * Gets the current engine view
  117039. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117040. */
  117041. activeView: Nullable<EngineView>;
  117042. /** Gets or sets the list of views */
  117043. views: EngineView[];
  117044. /**
  117045. * Register a new child canvas
  117046. * @param canvas defines the canvas to register
  117047. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  117048. * @returns the associated view
  117049. */
  117050. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  117051. /**
  117052. * Remove a registered child canvas
  117053. * @param canvas defines the canvas to remove
  117054. * @returns the current engine
  117055. */
  117056. unRegisterView(canvas: HTMLCanvasElement): Engine;
  117057. }
  117058. }
  117059. declare module BABYLON {
  117060. /**
  117061. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  117062. */
  117063. export interface CubeMapInfo {
  117064. /**
  117065. * The pixel array for the front face.
  117066. * This is stored in format, left to right, up to down format.
  117067. */
  117068. front: Nullable<ArrayBufferView>;
  117069. /**
  117070. * The pixel array for the back face.
  117071. * This is stored in format, left to right, up to down format.
  117072. */
  117073. back: Nullable<ArrayBufferView>;
  117074. /**
  117075. * The pixel array for the left face.
  117076. * This is stored in format, left to right, up to down format.
  117077. */
  117078. left: Nullable<ArrayBufferView>;
  117079. /**
  117080. * The pixel array for the right face.
  117081. * This is stored in format, left to right, up to down format.
  117082. */
  117083. right: Nullable<ArrayBufferView>;
  117084. /**
  117085. * The pixel array for the up face.
  117086. * This is stored in format, left to right, up to down format.
  117087. */
  117088. up: Nullable<ArrayBufferView>;
  117089. /**
  117090. * The pixel array for the down face.
  117091. * This is stored in format, left to right, up to down format.
  117092. */
  117093. down: Nullable<ArrayBufferView>;
  117094. /**
  117095. * The size of the cubemap stored.
  117096. *
  117097. * Each faces will be size * size pixels.
  117098. */
  117099. size: number;
  117100. /**
  117101. * The format of the texture.
  117102. *
  117103. * RGBA, RGB.
  117104. */
  117105. format: number;
  117106. /**
  117107. * The type of the texture data.
  117108. *
  117109. * UNSIGNED_INT, FLOAT.
  117110. */
  117111. type: number;
  117112. /**
  117113. * Specifies whether the texture is in gamma space.
  117114. */
  117115. gammaSpace: boolean;
  117116. }
  117117. /**
  117118. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  117119. */
  117120. export class PanoramaToCubeMapTools {
  117121. private static FACE_FRONT;
  117122. private static FACE_BACK;
  117123. private static FACE_RIGHT;
  117124. private static FACE_LEFT;
  117125. private static FACE_DOWN;
  117126. private static FACE_UP;
  117127. /**
  117128. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  117129. *
  117130. * @param float32Array The source data.
  117131. * @param inputWidth The width of the input panorama.
  117132. * @param inputHeight The height of the input panorama.
  117133. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  117134. * @return The cubemap data
  117135. */
  117136. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  117137. private static CreateCubemapTexture;
  117138. private static CalcProjectionSpherical;
  117139. }
  117140. }
  117141. declare module BABYLON {
  117142. /**
  117143. * Helper class dealing with the extraction of spherical polynomial dataArray
  117144. * from a cube map.
  117145. */
  117146. export class CubeMapToSphericalPolynomialTools {
  117147. private static FileFaces;
  117148. /**
  117149. * Converts a texture to the according Spherical Polynomial data.
  117150. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117151. *
  117152. * @param texture The texture to extract the information from.
  117153. * @return The Spherical Polynomial data.
  117154. */
  117155. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  117156. /**
  117157. * Converts a cubemap to the according Spherical Polynomial data.
  117158. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117159. *
  117160. * @param cubeInfo The Cube map to extract the information from.
  117161. * @return The Spherical Polynomial data.
  117162. */
  117163. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  117164. }
  117165. }
  117166. declare module BABYLON {
  117167. interface BaseTexture {
  117168. /**
  117169. * Get the polynomial representation of the texture data.
  117170. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  117171. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  117172. */
  117173. sphericalPolynomial: Nullable<SphericalPolynomial>;
  117174. }
  117175. }
  117176. declare module BABYLON {
  117177. /** @hidden */
  117178. export var rgbdEncodePixelShader: {
  117179. name: string;
  117180. shader: string;
  117181. };
  117182. }
  117183. declare module BABYLON {
  117184. /** @hidden */
  117185. export var rgbdDecodePixelShader: {
  117186. name: string;
  117187. shader: string;
  117188. };
  117189. }
  117190. declare module BABYLON {
  117191. /**
  117192. * Raw texture data and descriptor sufficient for WebGL texture upload
  117193. */
  117194. export interface EnvironmentTextureInfo {
  117195. /**
  117196. * Version of the environment map
  117197. */
  117198. version: number;
  117199. /**
  117200. * Width of image
  117201. */
  117202. width: number;
  117203. /**
  117204. * Irradiance information stored in the file.
  117205. */
  117206. irradiance: any;
  117207. /**
  117208. * Specular information stored in the file.
  117209. */
  117210. specular: any;
  117211. }
  117212. /**
  117213. * Defines One Image in the file. It requires only the position in the file
  117214. * as well as the length.
  117215. */
  117216. interface BufferImageData {
  117217. /**
  117218. * Length of the image data.
  117219. */
  117220. length: number;
  117221. /**
  117222. * Position of the data from the null terminator delimiting the end of the JSON.
  117223. */
  117224. position: number;
  117225. }
  117226. /**
  117227. * Defines the specular data enclosed in the file.
  117228. * This corresponds to the version 1 of the data.
  117229. */
  117230. export interface EnvironmentTextureSpecularInfoV1 {
  117231. /**
  117232. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  117233. */
  117234. specularDataPosition?: number;
  117235. /**
  117236. * This contains all the images data needed to reconstruct the cubemap.
  117237. */
  117238. mipmaps: Array<BufferImageData>;
  117239. /**
  117240. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  117241. */
  117242. lodGenerationScale: number;
  117243. }
  117244. /**
  117245. * Sets of helpers addressing the serialization and deserialization of environment texture
  117246. * stored in a BabylonJS env file.
  117247. * Those files are usually stored as .env files.
  117248. */
  117249. export class EnvironmentTextureTools {
  117250. /**
  117251. * Magic number identifying the env file.
  117252. */
  117253. private static _MagicBytes;
  117254. /**
  117255. * Gets the environment info from an env file.
  117256. * @param data The array buffer containing the .env bytes.
  117257. * @returns the environment file info (the json header) if successfully parsed.
  117258. */
  117259. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  117260. /**
  117261. * Creates an environment texture from a loaded cube texture.
  117262. * @param texture defines the cube texture to convert in env file
  117263. * @return a promise containing the environment data if succesfull.
  117264. */
  117265. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  117266. /**
  117267. * Creates a JSON representation of the spherical data.
  117268. * @param texture defines the texture containing the polynomials
  117269. * @return the JSON representation of the spherical info
  117270. */
  117271. private static _CreateEnvTextureIrradiance;
  117272. /**
  117273. * Creates the ArrayBufferViews used for initializing environment texture image data.
  117274. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  117275. * @param info parameters that determine what views will be created for accessing the underlying buffer
  117276. * @return the views described by info providing access to the underlying buffer
  117277. */
  117278. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  117279. /**
  117280. * Uploads the texture info contained in the env file to the GPU.
  117281. * @param texture defines the internal texture to upload to
  117282. * @param arrayBuffer defines the buffer cotaining the data to load
  117283. * @param info defines the texture info retrieved through the GetEnvInfo method
  117284. * @returns a promise
  117285. */
  117286. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  117287. private static _OnImageReadyAsync;
  117288. /**
  117289. * Uploads the levels of image data to the GPU.
  117290. * @param texture defines the internal texture to upload to
  117291. * @param imageData defines the array buffer views of image data [mipmap][face]
  117292. * @returns a promise
  117293. */
  117294. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  117295. /**
  117296. * Uploads spherical polynomials information to the texture.
  117297. * @param texture defines the texture we are trying to upload the information to
  117298. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  117299. */
  117300. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  117301. /** @hidden */
  117302. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117303. }
  117304. }
  117305. declare module BABYLON {
  117306. /**
  117307. * Contains position and normal vectors for a vertex
  117308. */
  117309. export class PositionNormalVertex {
  117310. /** the position of the vertex (defaut: 0,0,0) */
  117311. position: Vector3;
  117312. /** the normal of the vertex (defaut: 0,1,0) */
  117313. normal: Vector3;
  117314. /**
  117315. * Creates a PositionNormalVertex
  117316. * @param position the position of the vertex (defaut: 0,0,0)
  117317. * @param normal the normal of the vertex (defaut: 0,1,0)
  117318. */
  117319. constructor(
  117320. /** the position of the vertex (defaut: 0,0,0) */
  117321. position?: Vector3,
  117322. /** the normal of the vertex (defaut: 0,1,0) */
  117323. normal?: Vector3);
  117324. /**
  117325. * Clones the PositionNormalVertex
  117326. * @returns the cloned PositionNormalVertex
  117327. */
  117328. clone(): PositionNormalVertex;
  117329. }
  117330. /**
  117331. * Contains position, normal and uv vectors for a vertex
  117332. */
  117333. export class PositionNormalTextureVertex {
  117334. /** the position of the vertex (defaut: 0,0,0) */
  117335. position: Vector3;
  117336. /** the normal of the vertex (defaut: 0,1,0) */
  117337. normal: Vector3;
  117338. /** the uv of the vertex (default: 0,0) */
  117339. uv: Vector2;
  117340. /**
  117341. * Creates a PositionNormalTextureVertex
  117342. * @param position the position of the vertex (defaut: 0,0,0)
  117343. * @param normal the normal of the vertex (defaut: 0,1,0)
  117344. * @param uv the uv of the vertex (default: 0,0)
  117345. */
  117346. constructor(
  117347. /** the position of the vertex (defaut: 0,0,0) */
  117348. position?: Vector3,
  117349. /** the normal of the vertex (defaut: 0,1,0) */
  117350. normal?: Vector3,
  117351. /** the uv of the vertex (default: 0,0) */
  117352. uv?: Vector2);
  117353. /**
  117354. * Clones the PositionNormalTextureVertex
  117355. * @returns the cloned PositionNormalTextureVertex
  117356. */
  117357. clone(): PositionNormalTextureVertex;
  117358. }
  117359. }
  117360. declare module BABYLON {
  117361. /** @hidden */
  117362. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  117363. private _genericAttributeLocation;
  117364. private _varyingLocationCount;
  117365. private _varyingLocationMap;
  117366. private _replacements;
  117367. private _textureCount;
  117368. private _uniforms;
  117369. lineProcessor(line: string): string;
  117370. attributeProcessor(attribute: string): string;
  117371. varyingProcessor(varying: string, isFragment: boolean): string;
  117372. uniformProcessor(uniform: string): string;
  117373. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  117374. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  117375. }
  117376. }
  117377. declare module BABYLON {
  117378. /**
  117379. * Container for accessors for natively-stored mesh data buffers.
  117380. */
  117381. class NativeDataBuffer extends DataBuffer {
  117382. /**
  117383. * Accessor value used to identify/retrieve a natively-stored index buffer.
  117384. */
  117385. nativeIndexBuffer?: any;
  117386. /**
  117387. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  117388. */
  117389. nativeVertexBuffer?: any;
  117390. }
  117391. /** @hidden */
  117392. class NativeTexture extends InternalTexture {
  117393. getInternalTexture(): InternalTexture;
  117394. getViewCount(): number;
  117395. }
  117396. /** @hidden */
  117397. export class NativeEngine extends Engine {
  117398. private readonly _native;
  117399. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  117400. private readonly INVALID_HANDLE;
  117401. getHardwareScalingLevel(): number;
  117402. constructor();
  117403. /**
  117404. * Can be used to override the current requestAnimationFrame requester.
  117405. * @hidden
  117406. */
  117407. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  117408. /**
  117409. * Override default engine behavior.
  117410. * @param color
  117411. * @param backBuffer
  117412. * @param depth
  117413. * @param stencil
  117414. */
  117415. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  117416. /**
  117417. * Gets host document
  117418. * @returns the host document object
  117419. */
  117420. getHostDocument(): Nullable<Document>;
  117421. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117422. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  117423. createVertexBuffer(data: DataArray): NativeDataBuffer;
  117424. recordVertexArrayObject(vertexBuffers: {
  117425. [key: string]: VertexBuffer;
  117426. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  117427. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117428. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117429. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117430. /**
  117431. * Draw a list of indexed primitives
  117432. * @param fillMode defines the primitive to use
  117433. * @param indexStart defines the starting index
  117434. * @param indexCount defines the number of index to draw
  117435. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117436. */
  117437. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117438. /**
  117439. * Draw a list of unindexed primitives
  117440. * @param fillMode defines the primitive to use
  117441. * @param verticesStart defines the index of first vertex to draw
  117442. * @param verticesCount defines the count of vertices to draw
  117443. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117444. */
  117445. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117446. createPipelineContext(): IPipelineContext;
  117447. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  117448. /** @hidden */
  117449. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  117450. /** @hidden */
  117451. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  117452. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117453. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117454. protected _setProgram(program: WebGLProgram): void;
  117455. _releaseEffect(effect: Effect): void;
  117456. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117457. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  117458. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  117459. bindSamplers(effect: Effect): void;
  117460. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  117461. getRenderWidth(useScreen?: boolean): number;
  117462. getRenderHeight(useScreen?: boolean): number;
  117463. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  117464. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117465. /**
  117466. * Set the z offset to apply to current rendering
  117467. * @param value defines the offset to apply
  117468. */
  117469. setZOffset(value: number): void;
  117470. /**
  117471. * Gets the current value of the zOffset
  117472. * @returns the current zOffset state
  117473. */
  117474. getZOffset(): number;
  117475. /**
  117476. * Enable or disable depth buffering
  117477. * @param enable defines the state to set
  117478. */
  117479. setDepthBuffer(enable: boolean): void;
  117480. /**
  117481. * Gets a boolean indicating if depth writing is enabled
  117482. * @returns the current depth writing state
  117483. */
  117484. getDepthWrite(): boolean;
  117485. /**
  117486. * Enable or disable depth writing
  117487. * @param enable defines the state to set
  117488. */
  117489. setDepthWrite(enable: boolean): void;
  117490. /**
  117491. * Enable or disable color writing
  117492. * @param enable defines the state to set
  117493. */
  117494. setColorWrite(enable: boolean): void;
  117495. /**
  117496. * Gets a boolean indicating if color writing is enabled
  117497. * @returns the current color writing state
  117498. */
  117499. getColorWrite(): boolean;
  117500. /**
  117501. * Sets alpha constants used by some alpha blending modes
  117502. * @param r defines the red component
  117503. * @param g defines the green component
  117504. * @param b defines the blue component
  117505. * @param a defines the alpha component
  117506. */
  117507. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  117508. /**
  117509. * Sets the current alpha mode
  117510. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  117511. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117512. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117513. */
  117514. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117515. /**
  117516. * Gets the current alpha mode
  117517. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117518. * @returns the current alpha mode
  117519. */
  117520. getAlphaMode(): number;
  117521. setInt(uniform: WebGLUniformLocation, int: number): void;
  117522. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117523. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117524. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117525. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117526. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117527. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117528. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117529. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117530. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117531. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117532. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117533. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117534. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117535. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117536. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117537. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117538. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117539. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117540. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117541. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  117542. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  117543. wipeCaches(bruteForce?: boolean): void;
  117544. _createTexture(): WebGLTexture;
  117545. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  117546. /**
  117547. * Usually called from BABYLON.Texture.ts.
  117548. * Passed information to create a WebGLTexture
  117549. * @param urlArg defines a value which contains one of the following:
  117550. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117551. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117552. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117553. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117554. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  117555. * @param scene needed for loading to the correct scene
  117556. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  117557. * @param onLoad optional callback to be called upon successful completion
  117558. * @param onError optional callback to be called upon failure
  117559. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  117560. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117561. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117562. * @param forcedExtension defines the extension to use to pick the right loader
  117563. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117564. */
  117565. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  117566. /**
  117567. * Creates a cube texture
  117568. * @param rootUrl defines the url where the files to load is located
  117569. * @param scene defines the current scene
  117570. * @param files defines the list of files to load (1 per face)
  117571. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  117572. * @param onLoad defines an optional callback raised when the texture is loaded
  117573. * @param onError defines an optional callback raised if there is an issue to load the texture
  117574. * @param format defines the format of the data
  117575. * @param forcedExtension defines the extension to use to pick the right loader
  117576. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  117577. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117578. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117579. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  117580. * @returns the cube texture as an InternalTexture
  117581. */
  117582. 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, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  117583. private _getSamplingFilter;
  117584. private static _GetNativeTextureFormat;
  117585. createRenderTargetTexture(size: number | {
  117586. width: number;
  117587. height: number;
  117588. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  117589. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117590. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117591. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117592. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  117593. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  117594. /**
  117595. * Updates a dynamic vertex buffer.
  117596. * @param vertexBuffer the vertex buffer to update
  117597. * @param data the data used to update the vertex buffer
  117598. * @param byteOffset the byte offset of the data (optional)
  117599. * @param byteLength the byte length of the data (optional)
  117600. */
  117601. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  117602. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  117603. private _updateAnisotropicLevel;
  117604. private _getAddressMode;
  117605. /** @hidden */
  117606. _bindTexture(channel: number, texture: InternalTexture): void;
  117607. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  117608. releaseEffects(): void;
  117609. /** @hidden */
  117610. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117611. /** @hidden */
  117612. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117613. /** @hidden */
  117614. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117615. /** @hidden */
  117616. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117617. }
  117618. }
  117619. declare module BABYLON {
  117620. /**
  117621. * Gather the list of clipboard event types as constants.
  117622. */
  117623. export class ClipboardEventTypes {
  117624. /**
  117625. * The clipboard event is fired when a copy command is active (pressed).
  117626. */
  117627. static readonly COPY: number;
  117628. /**
  117629. * The clipboard event is fired when a cut command is active (pressed).
  117630. */
  117631. static readonly CUT: number;
  117632. /**
  117633. * The clipboard event is fired when a paste command is active (pressed).
  117634. */
  117635. static readonly PASTE: number;
  117636. }
  117637. /**
  117638. * This class is used to store clipboard related info for the onClipboardObservable event.
  117639. */
  117640. export class ClipboardInfo {
  117641. /**
  117642. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117643. */
  117644. type: number;
  117645. /**
  117646. * Defines the related dom event
  117647. */
  117648. event: ClipboardEvent;
  117649. /**
  117650. *Creates an instance of ClipboardInfo.
  117651. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  117652. * @param event Defines the related dom event
  117653. */
  117654. constructor(
  117655. /**
  117656. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117657. */
  117658. type: number,
  117659. /**
  117660. * Defines the related dom event
  117661. */
  117662. event: ClipboardEvent);
  117663. /**
  117664. * Get the clipboard event's type from the keycode.
  117665. * @param keyCode Defines the keyCode for the current keyboard event.
  117666. * @return {number}
  117667. */
  117668. static GetTypeFromCharacter(keyCode: number): number;
  117669. }
  117670. }
  117671. declare module BABYLON {
  117672. /**
  117673. * Google Daydream controller
  117674. */
  117675. export class DaydreamController extends WebVRController {
  117676. /**
  117677. * Base Url for the controller model.
  117678. */
  117679. static MODEL_BASE_URL: string;
  117680. /**
  117681. * File name for the controller model.
  117682. */
  117683. static MODEL_FILENAME: string;
  117684. /**
  117685. * Gamepad Id prefix used to identify Daydream Controller.
  117686. */
  117687. static readonly GAMEPAD_ID_PREFIX: string;
  117688. /**
  117689. * Creates a new DaydreamController from a gamepad
  117690. * @param vrGamepad the gamepad that the controller should be created from
  117691. */
  117692. constructor(vrGamepad: any);
  117693. /**
  117694. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117695. * @param scene scene in which to add meshes
  117696. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117697. */
  117698. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117699. /**
  117700. * Called once for each button that changed state since the last frame
  117701. * @param buttonIdx Which button index changed
  117702. * @param state New state of the button
  117703. * @param changes Which properties on the state changed since last frame
  117704. */
  117705. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117706. }
  117707. }
  117708. declare module BABYLON {
  117709. /**
  117710. * Gear VR Controller
  117711. */
  117712. export class GearVRController extends WebVRController {
  117713. /**
  117714. * Base Url for the controller model.
  117715. */
  117716. static MODEL_BASE_URL: string;
  117717. /**
  117718. * File name for the controller model.
  117719. */
  117720. static MODEL_FILENAME: string;
  117721. /**
  117722. * Gamepad Id prefix used to identify this controller.
  117723. */
  117724. static readonly GAMEPAD_ID_PREFIX: string;
  117725. private readonly _buttonIndexToObservableNameMap;
  117726. /**
  117727. * Creates a new GearVRController from a gamepad
  117728. * @param vrGamepad the gamepad that the controller should be created from
  117729. */
  117730. constructor(vrGamepad: any);
  117731. /**
  117732. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117733. * @param scene scene in which to add meshes
  117734. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117735. */
  117736. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117737. /**
  117738. * Called once for each button that changed state since the last frame
  117739. * @param buttonIdx Which button index changed
  117740. * @param state New state of the button
  117741. * @param changes Which properties on the state changed since last frame
  117742. */
  117743. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117744. }
  117745. }
  117746. declare module BABYLON {
  117747. /**
  117748. * Class containing static functions to help procedurally build meshes
  117749. */
  117750. export class PolyhedronBuilder {
  117751. /**
  117752. * Creates a polyhedron mesh
  117753. * * 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
  117754. * * The parameter `size` (positive float, default 1) sets the polygon size
  117755. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  117756. * * 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`
  117757. * * 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
  117758. * * 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)`)
  117759. * * 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
  117760. * * 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
  117761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117762. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117764. * @param name defines the name of the mesh
  117765. * @param options defines the options used to create the mesh
  117766. * @param scene defines the hosting scene
  117767. * @returns the polyhedron mesh
  117768. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  117769. */
  117770. static CreatePolyhedron(name: string, options: {
  117771. type?: number;
  117772. size?: number;
  117773. sizeX?: number;
  117774. sizeY?: number;
  117775. sizeZ?: number;
  117776. custom?: any;
  117777. faceUV?: Vector4[];
  117778. faceColors?: Color4[];
  117779. flat?: boolean;
  117780. updatable?: boolean;
  117781. sideOrientation?: number;
  117782. frontUVs?: Vector4;
  117783. backUVs?: Vector4;
  117784. }, scene?: Nullable<Scene>): Mesh;
  117785. }
  117786. }
  117787. declare module BABYLON {
  117788. /**
  117789. * Gizmo that enables scaling a mesh along 3 axis
  117790. */
  117791. export class ScaleGizmo extends Gizmo {
  117792. /**
  117793. * Internal gizmo used for interactions on the x axis
  117794. */
  117795. xGizmo: AxisScaleGizmo;
  117796. /**
  117797. * Internal gizmo used for interactions on the y axis
  117798. */
  117799. yGizmo: AxisScaleGizmo;
  117800. /**
  117801. * Internal gizmo used for interactions on the z axis
  117802. */
  117803. zGizmo: AxisScaleGizmo;
  117804. /**
  117805. * Internal gizmo used to scale all axis equally
  117806. */
  117807. uniformScaleGizmo: AxisScaleGizmo;
  117808. private _meshAttached;
  117809. private _updateGizmoRotationToMatchAttachedMesh;
  117810. private _snapDistance;
  117811. private _scaleRatio;
  117812. private _uniformScalingMesh;
  117813. private _octahedron;
  117814. private _sensitivity;
  117815. /** Fires an event when any of it's sub gizmos are dragged */
  117816. onDragStartObservable: Observable<unknown>;
  117817. /** Fires an event when any of it's sub gizmos are released from dragging */
  117818. onDragEndObservable: Observable<unknown>;
  117819. get attachedMesh(): Nullable<AbstractMesh>;
  117820. set attachedMesh(mesh: Nullable<AbstractMesh>);
  117821. /**
  117822. * Creates a ScaleGizmo
  117823. * @param gizmoLayer The utility layer the gizmo will be added to
  117824. */
  117825. constructor(gizmoLayer?: UtilityLayerRenderer);
  117826. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  117827. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  117828. /**
  117829. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117830. */
  117831. set snapDistance(value: number);
  117832. get snapDistance(): number;
  117833. /**
  117834. * Ratio for the scale of the gizmo (Default: 1)
  117835. */
  117836. set scaleRatio(value: number);
  117837. get scaleRatio(): number;
  117838. /**
  117839. * Sensitivity factor for dragging (Default: 1)
  117840. */
  117841. set sensitivity(value: number);
  117842. get sensitivity(): number;
  117843. /**
  117844. * Disposes of the gizmo
  117845. */
  117846. dispose(): void;
  117847. }
  117848. }
  117849. declare module BABYLON {
  117850. /**
  117851. * Single axis scale gizmo
  117852. */
  117853. export class AxisScaleGizmo extends Gizmo {
  117854. /**
  117855. * Drag behavior responsible for the gizmos dragging interactions
  117856. */
  117857. dragBehavior: PointerDragBehavior;
  117858. private _pointerObserver;
  117859. /**
  117860. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117861. */
  117862. snapDistance: number;
  117863. /**
  117864. * Event that fires each time the gizmo snaps to a new location.
  117865. * * snapDistance is the the change in distance
  117866. */
  117867. onSnapObservable: Observable<{
  117868. snapDistance: number;
  117869. }>;
  117870. /**
  117871. * If the scaling operation should be done on all axis (default: false)
  117872. */
  117873. uniformScaling: boolean;
  117874. /**
  117875. * Custom sensitivity value for the drag strength
  117876. */
  117877. sensitivity: number;
  117878. private _isEnabled;
  117879. private _parent;
  117880. private _arrow;
  117881. private _coloredMaterial;
  117882. private _hoverMaterial;
  117883. /**
  117884. * Creates an AxisScaleGizmo
  117885. * @param gizmoLayer The utility layer the gizmo will be added to
  117886. * @param dragAxis The axis which the gizmo will be able to scale on
  117887. * @param color The color of the gizmo
  117888. */
  117889. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  117890. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  117891. /**
  117892. * If the gizmo is enabled
  117893. */
  117894. set isEnabled(value: boolean);
  117895. get isEnabled(): boolean;
  117896. /**
  117897. * Disposes of the gizmo
  117898. */
  117899. dispose(): void;
  117900. /**
  117901. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  117902. * @param mesh The mesh to replace the default mesh of the gizmo
  117903. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  117904. */
  117905. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  117906. }
  117907. }
  117908. declare module BABYLON {
  117909. /**
  117910. * Bounding box gizmo
  117911. */
  117912. export class BoundingBoxGizmo extends Gizmo {
  117913. private _lineBoundingBox;
  117914. private _rotateSpheresParent;
  117915. private _scaleBoxesParent;
  117916. private _boundingDimensions;
  117917. private _renderObserver;
  117918. private _pointerObserver;
  117919. private _scaleDragSpeed;
  117920. private _tmpQuaternion;
  117921. private _tmpVector;
  117922. private _tmpRotationMatrix;
  117923. /**
  117924. * 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)
  117925. */
  117926. ignoreChildren: boolean;
  117927. /**
  117928. * 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)
  117929. */
  117930. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  117931. /**
  117932. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  117933. */
  117934. rotationSphereSize: number;
  117935. /**
  117936. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  117937. */
  117938. scaleBoxSize: number;
  117939. /**
  117940. * 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)
  117941. */
  117942. fixedDragMeshScreenSize: boolean;
  117943. /**
  117944. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  117945. */
  117946. fixedDragMeshScreenSizeDistanceFactor: number;
  117947. /**
  117948. * Fired when a rotation sphere or scale box is dragged
  117949. */
  117950. onDragStartObservable: Observable<{}>;
  117951. /**
  117952. * Fired when a scale box is dragged
  117953. */
  117954. onScaleBoxDragObservable: Observable<{}>;
  117955. /**
  117956. * Fired when a scale box drag is ended
  117957. */
  117958. onScaleBoxDragEndObservable: Observable<{}>;
  117959. /**
  117960. * Fired when a rotation sphere is dragged
  117961. */
  117962. onRotationSphereDragObservable: Observable<{}>;
  117963. /**
  117964. * Fired when a rotation sphere drag is ended
  117965. */
  117966. onRotationSphereDragEndObservable: Observable<{}>;
  117967. /**
  117968. * 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)
  117969. */
  117970. scalePivot: Nullable<Vector3>;
  117971. /**
  117972. * Mesh used as a pivot to rotate the attached mesh
  117973. */
  117974. private _anchorMesh;
  117975. private _existingMeshScale;
  117976. private _dragMesh;
  117977. private pointerDragBehavior;
  117978. private coloredMaterial;
  117979. private hoverColoredMaterial;
  117980. /**
  117981. * Sets the color of the bounding box gizmo
  117982. * @param color the color to set
  117983. */
  117984. setColor(color: Color3): void;
  117985. /**
  117986. * Creates an BoundingBoxGizmo
  117987. * @param gizmoLayer The utility layer the gizmo will be added to
  117988. * @param color The color of the gizmo
  117989. */
  117990. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  117991. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  117992. private _selectNode;
  117993. /**
  117994. * Updates the bounding box information for the Gizmo
  117995. */
  117996. updateBoundingBox(): void;
  117997. private _updateRotationSpheres;
  117998. private _updateScaleBoxes;
  117999. /**
  118000. * Enables rotation on the specified axis and disables rotation on the others
  118001. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  118002. */
  118003. setEnabledRotationAxis(axis: string): void;
  118004. /**
  118005. * Enables/disables scaling
  118006. * @param enable if scaling should be enabled
  118007. */
  118008. setEnabledScaling(enable: boolean): void;
  118009. private _updateDummy;
  118010. /**
  118011. * Enables a pointer drag behavior on the bounding box of the gizmo
  118012. */
  118013. enableDragBehavior(): void;
  118014. /**
  118015. * Disposes of the gizmo
  118016. */
  118017. dispose(): void;
  118018. /**
  118019. * 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)
  118020. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  118021. * @returns the bounding box mesh with the passed in mesh as a child
  118022. */
  118023. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  118024. /**
  118025. * CustomMeshes are not supported by this gizmo
  118026. * @param mesh The mesh to replace the default mesh of the gizmo
  118027. */
  118028. setCustomMesh(mesh: Mesh): void;
  118029. }
  118030. }
  118031. declare module BABYLON {
  118032. /**
  118033. * Single plane rotation gizmo
  118034. */
  118035. export class PlaneRotationGizmo extends Gizmo {
  118036. /**
  118037. * Drag behavior responsible for the gizmos dragging interactions
  118038. */
  118039. dragBehavior: PointerDragBehavior;
  118040. private _pointerObserver;
  118041. /**
  118042. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  118043. */
  118044. snapDistance: number;
  118045. /**
  118046. * Event that fires each time the gizmo snaps to a new location.
  118047. * * snapDistance is the the change in distance
  118048. */
  118049. onSnapObservable: Observable<{
  118050. snapDistance: number;
  118051. }>;
  118052. private _isEnabled;
  118053. private _parent;
  118054. /**
  118055. * Creates a PlaneRotationGizmo
  118056. * @param gizmoLayer The utility layer the gizmo will be added to
  118057. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  118058. * @param color The color of the gizmo
  118059. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118060. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118061. */
  118062. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  118063. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118064. /**
  118065. * If the gizmo is enabled
  118066. */
  118067. set isEnabled(value: boolean);
  118068. get isEnabled(): boolean;
  118069. /**
  118070. * Disposes of the gizmo
  118071. */
  118072. dispose(): void;
  118073. }
  118074. }
  118075. declare module BABYLON {
  118076. /**
  118077. * Gizmo that enables rotating a mesh along 3 axis
  118078. */
  118079. export class RotationGizmo extends Gizmo {
  118080. /**
  118081. * Internal gizmo used for interactions on the x axis
  118082. */
  118083. xGizmo: PlaneRotationGizmo;
  118084. /**
  118085. * Internal gizmo used for interactions on the y axis
  118086. */
  118087. yGizmo: PlaneRotationGizmo;
  118088. /**
  118089. * Internal gizmo used for interactions on the z axis
  118090. */
  118091. zGizmo: PlaneRotationGizmo;
  118092. /** Fires an event when any of it's sub gizmos are dragged */
  118093. onDragStartObservable: Observable<unknown>;
  118094. /** Fires an event when any of it's sub gizmos are released from dragging */
  118095. onDragEndObservable: Observable<unknown>;
  118096. private _meshAttached;
  118097. get attachedMesh(): Nullable<AbstractMesh>;
  118098. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118099. /**
  118100. * Creates a RotationGizmo
  118101. * @param gizmoLayer The utility layer the gizmo will be added to
  118102. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118103. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118104. */
  118105. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  118106. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118107. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118108. /**
  118109. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118110. */
  118111. set snapDistance(value: number);
  118112. get snapDistance(): number;
  118113. /**
  118114. * Ratio for the scale of the gizmo (Default: 1)
  118115. */
  118116. set scaleRatio(value: number);
  118117. get scaleRatio(): number;
  118118. /**
  118119. * Disposes of the gizmo
  118120. */
  118121. dispose(): void;
  118122. /**
  118123. * CustomMeshes are not supported by this gizmo
  118124. * @param mesh The mesh to replace the default mesh of the gizmo
  118125. */
  118126. setCustomMesh(mesh: Mesh): void;
  118127. }
  118128. }
  118129. declare module BABYLON {
  118130. /**
  118131. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  118132. */
  118133. export class GizmoManager implements IDisposable {
  118134. private scene;
  118135. /**
  118136. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  118137. */
  118138. gizmos: {
  118139. positionGizmo: Nullable<PositionGizmo>;
  118140. rotationGizmo: Nullable<RotationGizmo>;
  118141. scaleGizmo: Nullable<ScaleGizmo>;
  118142. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  118143. };
  118144. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  118145. clearGizmoOnEmptyPointerEvent: boolean;
  118146. /** Fires an event when the manager is attached to a mesh */
  118147. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  118148. private _gizmosEnabled;
  118149. private _pointerObserver;
  118150. private _attachedMesh;
  118151. private _boundingBoxColor;
  118152. private _defaultUtilityLayer;
  118153. private _defaultKeepDepthUtilityLayer;
  118154. /**
  118155. * When bounding box gizmo is enabled, this can be used to track drag/end events
  118156. */
  118157. boundingBoxDragBehavior: SixDofDragBehavior;
  118158. /**
  118159. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  118160. */
  118161. attachableMeshes: Nullable<Array<AbstractMesh>>;
  118162. /**
  118163. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  118164. */
  118165. usePointerToAttachGizmos: boolean;
  118166. /**
  118167. * Utility layer that the bounding box gizmo belongs to
  118168. */
  118169. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  118170. /**
  118171. * Utility layer that all gizmos besides bounding box belong to
  118172. */
  118173. get utilityLayer(): UtilityLayerRenderer;
  118174. /**
  118175. * Instatiates a gizmo manager
  118176. * @param scene the scene to overlay the gizmos on top of
  118177. */
  118178. constructor(scene: Scene);
  118179. /**
  118180. * Attaches a set of gizmos to the specified mesh
  118181. * @param mesh The mesh the gizmo's should be attached to
  118182. */
  118183. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118184. /**
  118185. * If the position gizmo is enabled
  118186. */
  118187. set positionGizmoEnabled(value: boolean);
  118188. get positionGizmoEnabled(): boolean;
  118189. /**
  118190. * If the rotation gizmo is enabled
  118191. */
  118192. set rotationGizmoEnabled(value: boolean);
  118193. get rotationGizmoEnabled(): boolean;
  118194. /**
  118195. * If the scale gizmo is enabled
  118196. */
  118197. set scaleGizmoEnabled(value: boolean);
  118198. get scaleGizmoEnabled(): boolean;
  118199. /**
  118200. * If the boundingBox gizmo is enabled
  118201. */
  118202. set boundingBoxGizmoEnabled(value: boolean);
  118203. get boundingBoxGizmoEnabled(): boolean;
  118204. /**
  118205. * Disposes of the gizmo manager
  118206. */
  118207. dispose(): void;
  118208. }
  118209. }
  118210. declare module BABYLON {
  118211. /**
  118212. * A directional light is defined by a direction (what a surprise!).
  118213. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  118214. * 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.
  118215. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118216. */
  118217. export class DirectionalLight extends ShadowLight {
  118218. private _shadowFrustumSize;
  118219. /**
  118220. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  118221. */
  118222. get shadowFrustumSize(): number;
  118223. /**
  118224. * Specifies a fix frustum size for the shadow generation.
  118225. */
  118226. set shadowFrustumSize(value: number);
  118227. private _shadowOrthoScale;
  118228. /**
  118229. * Gets the shadow projection scale against the optimal computed one.
  118230. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118231. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118232. */
  118233. get shadowOrthoScale(): number;
  118234. /**
  118235. * Sets the shadow projection scale against the optimal computed one.
  118236. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118237. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118238. */
  118239. set shadowOrthoScale(value: number);
  118240. /**
  118241. * Automatically compute the projection matrix to best fit (including all the casters)
  118242. * on each frame.
  118243. */
  118244. autoUpdateExtends: boolean;
  118245. private _orthoLeft;
  118246. private _orthoRight;
  118247. private _orthoTop;
  118248. private _orthoBottom;
  118249. /**
  118250. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  118251. * The directional light is emitted from everywhere in the given direction.
  118252. * It can cast shadows.
  118253. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118254. * @param name The friendly name of the light
  118255. * @param direction The direction of the light
  118256. * @param scene The scene the light belongs to
  118257. */
  118258. constructor(name: string, direction: Vector3, scene: Scene);
  118259. /**
  118260. * Returns the string "DirectionalLight".
  118261. * @return The class name
  118262. */
  118263. getClassName(): string;
  118264. /**
  118265. * Returns the integer 1.
  118266. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118267. */
  118268. getTypeID(): number;
  118269. /**
  118270. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  118271. * Returns the DirectionalLight Shadow projection matrix.
  118272. */
  118273. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118274. /**
  118275. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  118276. * Returns the DirectionalLight Shadow projection matrix.
  118277. */
  118278. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  118279. /**
  118280. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  118281. * Returns the DirectionalLight Shadow projection matrix.
  118282. */
  118283. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118284. protected _buildUniformLayout(): void;
  118285. /**
  118286. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  118287. * @param effect The effect to update
  118288. * @param lightIndex The index of the light in the effect to update
  118289. * @returns The directional light
  118290. */
  118291. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  118292. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  118293. /**
  118294. * Gets the minZ used for shadow according to both the scene and the light.
  118295. *
  118296. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118297. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118298. * @param activeCamera The camera we are returning the min for
  118299. * @returns the depth min z
  118300. */
  118301. getDepthMinZ(activeCamera: Camera): number;
  118302. /**
  118303. * Gets the maxZ used for shadow according to both the scene and the light.
  118304. *
  118305. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118306. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118307. * @param activeCamera The camera we are returning the max for
  118308. * @returns the depth max z
  118309. */
  118310. getDepthMaxZ(activeCamera: Camera): number;
  118311. /**
  118312. * Prepares the list of defines specific to the light type.
  118313. * @param defines the list of defines
  118314. * @param lightIndex defines the index of the light for the effect
  118315. */
  118316. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118317. }
  118318. }
  118319. declare module BABYLON {
  118320. /**
  118321. * Class containing static functions to help procedurally build meshes
  118322. */
  118323. export class HemisphereBuilder {
  118324. /**
  118325. * Creates a hemisphere mesh
  118326. * @param name defines the name of the mesh
  118327. * @param options defines the options used to create the mesh
  118328. * @param scene defines the hosting scene
  118329. * @returns the hemisphere mesh
  118330. */
  118331. static CreateHemisphere(name: string, options: {
  118332. segments?: number;
  118333. diameter?: number;
  118334. sideOrientation?: number;
  118335. }, scene: any): Mesh;
  118336. }
  118337. }
  118338. declare module BABYLON {
  118339. /**
  118340. * A spot light is defined by a position, a direction, an angle, and an exponent.
  118341. * These values define a cone of light starting from the position, emitting toward the direction.
  118342. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  118343. * and the exponent defines the speed of the decay of the light with distance (reach).
  118344. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118345. */
  118346. export class SpotLight extends ShadowLight {
  118347. private _angle;
  118348. private _innerAngle;
  118349. private _cosHalfAngle;
  118350. private _lightAngleScale;
  118351. private _lightAngleOffset;
  118352. /**
  118353. * Gets the cone angle of the spot light in Radians.
  118354. */
  118355. get angle(): number;
  118356. /**
  118357. * Sets the cone angle of the spot light in Radians.
  118358. */
  118359. set angle(value: number);
  118360. /**
  118361. * Only used in gltf falloff mode, this defines the angle where
  118362. * the directional falloff will start before cutting at angle which could be seen
  118363. * as outer angle.
  118364. */
  118365. get innerAngle(): number;
  118366. /**
  118367. * Only used in gltf falloff mode, this defines the angle where
  118368. * the directional falloff will start before cutting at angle which could be seen
  118369. * as outer angle.
  118370. */
  118371. set innerAngle(value: number);
  118372. private _shadowAngleScale;
  118373. /**
  118374. * Allows scaling the angle of the light for shadow generation only.
  118375. */
  118376. get shadowAngleScale(): number;
  118377. /**
  118378. * Allows scaling the angle of the light for shadow generation only.
  118379. */
  118380. set shadowAngleScale(value: number);
  118381. /**
  118382. * The light decay speed with the distance from the emission spot.
  118383. */
  118384. exponent: number;
  118385. private _projectionTextureMatrix;
  118386. /**
  118387. * Allows reading the projecton texture
  118388. */
  118389. get projectionTextureMatrix(): Matrix;
  118390. protected _projectionTextureLightNear: number;
  118391. /**
  118392. * Gets the near clip of the Spotlight for texture projection.
  118393. */
  118394. get projectionTextureLightNear(): number;
  118395. /**
  118396. * Sets the near clip of the Spotlight for texture projection.
  118397. */
  118398. set projectionTextureLightNear(value: number);
  118399. protected _projectionTextureLightFar: number;
  118400. /**
  118401. * Gets the far clip of the Spotlight for texture projection.
  118402. */
  118403. get projectionTextureLightFar(): number;
  118404. /**
  118405. * Sets the far clip of the Spotlight for texture projection.
  118406. */
  118407. set projectionTextureLightFar(value: number);
  118408. protected _projectionTextureUpDirection: Vector3;
  118409. /**
  118410. * Gets the Up vector of the Spotlight for texture projection.
  118411. */
  118412. get projectionTextureUpDirection(): Vector3;
  118413. /**
  118414. * Sets the Up vector of the Spotlight for texture projection.
  118415. */
  118416. set projectionTextureUpDirection(value: Vector3);
  118417. private _projectionTexture;
  118418. /**
  118419. * Gets the projection texture of the light.
  118420. */
  118421. get projectionTexture(): Nullable<BaseTexture>;
  118422. /**
  118423. * Sets the projection texture of the light.
  118424. */
  118425. set projectionTexture(value: Nullable<BaseTexture>);
  118426. private _projectionTextureViewLightDirty;
  118427. private _projectionTextureProjectionLightDirty;
  118428. private _projectionTextureDirty;
  118429. private _projectionTextureViewTargetVector;
  118430. private _projectionTextureViewLightMatrix;
  118431. private _projectionTextureProjectionLightMatrix;
  118432. private _projectionTextureScalingMatrix;
  118433. /**
  118434. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  118435. * It can cast shadows.
  118436. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118437. * @param name The light friendly name
  118438. * @param position The position of the spot light in the scene
  118439. * @param direction The direction of the light in the scene
  118440. * @param angle The cone angle of the light in Radians
  118441. * @param exponent The light decay speed with the distance from the emission spot
  118442. * @param scene The scene the lights belongs to
  118443. */
  118444. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  118445. /**
  118446. * Returns the string "SpotLight".
  118447. * @returns the class name
  118448. */
  118449. getClassName(): string;
  118450. /**
  118451. * Returns the integer 2.
  118452. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118453. */
  118454. getTypeID(): number;
  118455. /**
  118456. * Overrides the direction setter to recompute the projection texture view light Matrix.
  118457. */
  118458. protected _setDirection(value: Vector3): void;
  118459. /**
  118460. * Overrides the position setter to recompute the projection texture view light Matrix.
  118461. */
  118462. protected _setPosition(value: Vector3): void;
  118463. /**
  118464. * 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.
  118465. * Returns the SpotLight.
  118466. */
  118467. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118468. protected _computeProjectionTextureViewLightMatrix(): void;
  118469. protected _computeProjectionTextureProjectionLightMatrix(): void;
  118470. /**
  118471. * Main function for light texture projection matrix computing.
  118472. */
  118473. protected _computeProjectionTextureMatrix(): void;
  118474. protected _buildUniformLayout(): void;
  118475. private _computeAngleValues;
  118476. /**
  118477. * Sets the passed Effect "effect" with the Light textures.
  118478. * @param effect The effect to update
  118479. * @param lightIndex The index of the light in the effect to update
  118480. * @returns The light
  118481. */
  118482. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  118483. /**
  118484. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  118485. * @param effect The effect to update
  118486. * @param lightIndex The index of the light in the effect to update
  118487. * @returns The spot light
  118488. */
  118489. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  118490. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118491. /**
  118492. * Disposes the light and the associated resources.
  118493. */
  118494. dispose(): void;
  118495. /**
  118496. * Prepares the list of defines specific to the light type.
  118497. * @param defines the list of defines
  118498. * @param lightIndex defines the index of the light for the effect
  118499. */
  118500. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118501. }
  118502. }
  118503. declare module BABYLON {
  118504. /**
  118505. * Gizmo that enables viewing a light
  118506. */
  118507. export class LightGizmo extends Gizmo {
  118508. private _lightMesh;
  118509. private _material;
  118510. private _cachedPosition;
  118511. private _cachedForward;
  118512. private _attachedMeshParent;
  118513. /**
  118514. * Creates a LightGizmo
  118515. * @param gizmoLayer The utility layer the gizmo will be added to
  118516. */
  118517. constructor(gizmoLayer?: UtilityLayerRenderer);
  118518. private _light;
  118519. /**
  118520. * The light that the gizmo is attached to
  118521. */
  118522. set light(light: Nullable<Light>);
  118523. get light(): Nullable<Light>;
  118524. /**
  118525. * Gets the material used to render the light gizmo
  118526. */
  118527. get material(): StandardMaterial;
  118528. /**
  118529. * @hidden
  118530. * Updates the gizmo to match the attached mesh's position/rotation
  118531. */
  118532. protected _update(): void;
  118533. private static _Scale;
  118534. /**
  118535. * Creates the lines for a light mesh
  118536. */
  118537. private static _CreateLightLines;
  118538. /**
  118539. * Disposes of the light gizmo
  118540. */
  118541. dispose(): void;
  118542. private static _CreateHemisphericLightMesh;
  118543. private static _CreatePointLightMesh;
  118544. private static _CreateSpotLightMesh;
  118545. private static _CreateDirectionalLightMesh;
  118546. }
  118547. }
  118548. declare module BABYLON {
  118549. /** @hidden */
  118550. export var backgroundFragmentDeclaration: {
  118551. name: string;
  118552. shader: string;
  118553. };
  118554. }
  118555. declare module BABYLON {
  118556. /** @hidden */
  118557. export var backgroundUboDeclaration: {
  118558. name: string;
  118559. shader: string;
  118560. };
  118561. }
  118562. declare module BABYLON {
  118563. /** @hidden */
  118564. export var backgroundPixelShader: {
  118565. name: string;
  118566. shader: string;
  118567. };
  118568. }
  118569. declare module BABYLON {
  118570. /** @hidden */
  118571. export var backgroundVertexDeclaration: {
  118572. name: string;
  118573. shader: string;
  118574. };
  118575. }
  118576. declare module BABYLON {
  118577. /** @hidden */
  118578. export var backgroundVertexShader: {
  118579. name: string;
  118580. shader: string;
  118581. };
  118582. }
  118583. declare module BABYLON {
  118584. /**
  118585. * Background material used to create an efficient environement around your scene.
  118586. */
  118587. export class BackgroundMaterial extends PushMaterial {
  118588. /**
  118589. * Standard reflectance value at parallel view angle.
  118590. */
  118591. static StandardReflectance0: number;
  118592. /**
  118593. * Standard reflectance value at grazing angle.
  118594. */
  118595. static StandardReflectance90: number;
  118596. protected _primaryColor: Color3;
  118597. /**
  118598. * Key light Color (multiply against the environement texture)
  118599. */
  118600. primaryColor: Color3;
  118601. protected __perceptualColor: Nullable<Color3>;
  118602. /**
  118603. * Experimental Internal Use Only.
  118604. *
  118605. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  118606. * This acts as a helper to set the primary color to a more "human friendly" value.
  118607. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  118608. * output color as close as possible from the chosen value.
  118609. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  118610. * part of lighting setup.)
  118611. */
  118612. get _perceptualColor(): Nullable<Color3>;
  118613. set _perceptualColor(value: Nullable<Color3>);
  118614. protected _primaryColorShadowLevel: float;
  118615. /**
  118616. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  118617. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  118618. */
  118619. get primaryColorShadowLevel(): float;
  118620. set primaryColorShadowLevel(value: float);
  118621. protected _primaryColorHighlightLevel: float;
  118622. /**
  118623. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  118624. * The primary color is used at the level chosen to define what the white area would look.
  118625. */
  118626. get primaryColorHighlightLevel(): float;
  118627. set primaryColorHighlightLevel(value: float);
  118628. protected _reflectionTexture: Nullable<BaseTexture>;
  118629. /**
  118630. * Reflection Texture used in the material.
  118631. * Should be author in a specific way for the best result (refer to the documentation).
  118632. */
  118633. reflectionTexture: Nullable<BaseTexture>;
  118634. protected _reflectionBlur: float;
  118635. /**
  118636. * Reflection Texture level of blur.
  118637. *
  118638. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  118639. * texture twice.
  118640. */
  118641. reflectionBlur: float;
  118642. protected _diffuseTexture: Nullable<BaseTexture>;
  118643. /**
  118644. * Diffuse Texture used in the material.
  118645. * Should be author in a specific way for the best result (refer to the documentation).
  118646. */
  118647. diffuseTexture: Nullable<BaseTexture>;
  118648. protected _shadowLights: Nullable<IShadowLight[]>;
  118649. /**
  118650. * Specify the list of lights casting shadow on the material.
  118651. * All scene shadow lights will be included if null.
  118652. */
  118653. shadowLights: Nullable<IShadowLight[]>;
  118654. protected _shadowLevel: float;
  118655. /**
  118656. * Helps adjusting the shadow to a softer level if required.
  118657. * 0 means black shadows and 1 means no shadows.
  118658. */
  118659. shadowLevel: float;
  118660. protected _sceneCenter: Vector3;
  118661. /**
  118662. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  118663. * It is usually zero but might be interesting to modify according to your setup.
  118664. */
  118665. sceneCenter: Vector3;
  118666. protected _opacityFresnel: boolean;
  118667. /**
  118668. * This helps specifying that the material is falling off to the sky box at grazing angle.
  118669. * This helps ensuring a nice transition when the camera goes under the ground.
  118670. */
  118671. opacityFresnel: boolean;
  118672. protected _reflectionFresnel: boolean;
  118673. /**
  118674. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  118675. * This helps adding a mirror texture on the ground.
  118676. */
  118677. reflectionFresnel: boolean;
  118678. protected _reflectionFalloffDistance: number;
  118679. /**
  118680. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  118681. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  118682. */
  118683. reflectionFalloffDistance: number;
  118684. protected _reflectionAmount: number;
  118685. /**
  118686. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  118687. */
  118688. reflectionAmount: number;
  118689. protected _reflectionReflectance0: number;
  118690. /**
  118691. * This specifies the weight of the reflection at grazing angle.
  118692. */
  118693. reflectionReflectance0: number;
  118694. protected _reflectionReflectance90: number;
  118695. /**
  118696. * This specifies the weight of the reflection at a perpendicular point of view.
  118697. */
  118698. reflectionReflectance90: number;
  118699. /**
  118700. * Sets the reflection reflectance fresnel values according to the default standard
  118701. * empirically know to work well :-)
  118702. */
  118703. set reflectionStandardFresnelWeight(value: number);
  118704. protected _useRGBColor: boolean;
  118705. /**
  118706. * Helps to directly use the maps channels instead of their level.
  118707. */
  118708. useRGBColor: boolean;
  118709. protected _enableNoise: boolean;
  118710. /**
  118711. * This helps reducing the banding effect that could occur on the background.
  118712. */
  118713. enableNoise: boolean;
  118714. /**
  118715. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118716. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  118717. * Recommended to be keep at 1.0 except for special cases.
  118718. */
  118719. get fovMultiplier(): number;
  118720. set fovMultiplier(value: number);
  118721. private _fovMultiplier;
  118722. /**
  118723. * Enable the FOV adjustment feature controlled by fovMultiplier.
  118724. */
  118725. useEquirectangularFOV: boolean;
  118726. private _maxSimultaneousLights;
  118727. /**
  118728. * Number of Simultaneous lights allowed on the material.
  118729. */
  118730. maxSimultaneousLights: int;
  118731. /**
  118732. * Default configuration related to image processing available in the Background Material.
  118733. */
  118734. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118735. /**
  118736. * Keep track of the image processing observer to allow dispose and replace.
  118737. */
  118738. private _imageProcessingObserver;
  118739. /**
  118740. * Attaches a new image processing configuration to the PBR Material.
  118741. * @param configuration (if null the scene configuration will be use)
  118742. */
  118743. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118744. /**
  118745. * Gets the image processing configuration used either in this material.
  118746. */
  118747. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  118748. /**
  118749. * Sets the Default image processing configuration used either in the this material.
  118750. *
  118751. * If sets to null, the scene one is in use.
  118752. */
  118753. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  118754. /**
  118755. * Gets wether the color curves effect is enabled.
  118756. */
  118757. get cameraColorCurvesEnabled(): boolean;
  118758. /**
  118759. * Sets wether the color curves effect is enabled.
  118760. */
  118761. set cameraColorCurvesEnabled(value: boolean);
  118762. /**
  118763. * Gets wether the color grading effect is enabled.
  118764. */
  118765. get cameraColorGradingEnabled(): boolean;
  118766. /**
  118767. * Gets wether the color grading effect is enabled.
  118768. */
  118769. set cameraColorGradingEnabled(value: boolean);
  118770. /**
  118771. * Gets wether tonemapping is enabled or not.
  118772. */
  118773. get cameraToneMappingEnabled(): boolean;
  118774. /**
  118775. * Sets wether tonemapping is enabled or not
  118776. */
  118777. set cameraToneMappingEnabled(value: boolean);
  118778. /**
  118779. * The camera exposure used on this material.
  118780. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118781. * This corresponds to a photographic exposure.
  118782. */
  118783. get cameraExposure(): float;
  118784. /**
  118785. * The camera exposure used on this material.
  118786. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118787. * This corresponds to a photographic exposure.
  118788. */
  118789. set cameraExposure(value: float);
  118790. /**
  118791. * Gets The camera contrast used on this material.
  118792. */
  118793. get cameraContrast(): float;
  118794. /**
  118795. * Sets The camera contrast used on this material.
  118796. */
  118797. set cameraContrast(value: float);
  118798. /**
  118799. * Gets the Color Grading 2D Lookup Texture.
  118800. */
  118801. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  118802. /**
  118803. * Sets the Color Grading 2D Lookup Texture.
  118804. */
  118805. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  118806. /**
  118807. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118808. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118809. * 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;
  118810. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118811. */
  118812. get cameraColorCurves(): Nullable<ColorCurves>;
  118813. /**
  118814. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118815. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118816. * 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;
  118817. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118818. */
  118819. set cameraColorCurves(value: Nullable<ColorCurves>);
  118820. /**
  118821. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  118822. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  118823. */
  118824. switchToBGR: boolean;
  118825. private _renderTargets;
  118826. private _reflectionControls;
  118827. private _white;
  118828. private _primaryShadowColor;
  118829. private _primaryHighlightColor;
  118830. /**
  118831. * Instantiates a Background Material in the given scene
  118832. * @param name The friendly name of the material
  118833. * @param scene The scene to add the material to
  118834. */
  118835. constructor(name: string, scene: Scene);
  118836. /**
  118837. * Gets a boolean indicating that current material needs to register RTT
  118838. */
  118839. get hasRenderTargetTextures(): boolean;
  118840. /**
  118841. * The entire material has been created in order to prevent overdraw.
  118842. * @returns false
  118843. */
  118844. needAlphaTesting(): boolean;
  118845. /**
  118846. * The entire material has been created in order to prevent overdraw.
  118847. * @returns true if blending is enable
  118848. */
  118849. needAlphaBlending(): boolean;
  118850. /**
  118851. * Checks wether the material is ready to be rendered for a given mesh.
  118852. * @param mesh The mesh to render
  118853. * @param subMesh The submesh to check against
  118854. * @param useInstances Specify wether or not the material is used with instances
  118855. * @returns true if all the dependencies are ready (Textures, Effects...)
  118856. */
  118857. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118858. /**
  118859. * Compute the primary color according to the chosen perceptual color.
  118860. */
  118861. private _computePrimaryColorFromPerceptualColor;
  118862. /**
  118863. * Compute the highlights and shadow colors according to their chosen levels.
  118864. */
  118865. private _computePrimaryColors;
  118866. /**
  118867. * Build the uniform buffer used in the material.
  118868. */
  118869. buildUniformLayout(): void;
  118870. /**
  118871. * Unbind the material.
  118872. */
  118873. unbind(): void;
  118874. /**
  118875. * Bind only the world matrix to the material.
  118876. * @param world The world matrix to bind.
  118877. */
  118878. bindOnlyWorldMatrix(world: Matrix): void;
  118879. /**
  118880. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  118881. * @param world The world matrix to bind.
  118882. * @param subMesh The submesh to bind for.
  118883. */
  118884. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118885. /**
  118886. * Checks to see if a texture is used in the material.
  118887. * @param texture - Base texture to use.
  118888. * @returns - Boolean specifying if a texture is used in the material.
  118889. */
  118890. hasTexture(texture: BaseTexture): boolean;
  118891. /**
  118892. * Dispose the material.
  118893. * @param forceDisposeEffect Force disposal of the associated effect.
  118894. * @param forceDisposeTextures Force disposal of the associated textures.
  118895. */
  118896. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118897. /**
  118898. * Clones the material.
  118899. * @param name The cloned name.
  118900. * @returns The cloned material.
  118901. */
  118902. clone(name: string): BackgroundMaterial;
  118903. /**
  118904. * Serializes the current material to its JSON representation.
  118905. * @returns The JSON representation.
  118906. */
  118907. serialize(): any;
  118908. /**
  118909. * Gets the class name of the material
  118910. * @returns "BackgroundMaterial"
  118911. */
  118912. getClassName(): string;
  118913. /**
  118914. * Parse a JSON input to create back a background material.
  118915. * @param source The JSON data to parse
  118916. * @param scene The scene to create the parsed material in
  118917. * @param rootUrl The root url of the assets the material depends upon
  118918. * @returns the instantiated BackgroundMaterial.
  118919. */
  118920. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  118921. }
  118922. }
  118923. declare module BABYLON {
  118924. /**
  118925. * Represents the different options available during the creation of
  118926. * a Environment helper.
  118927. *
  118928. * This can control the default ground, skybox and image processing setup of your scene.
  118929. */
  118930. export interface IEnvironmentHelperOptions {
  118931. /**
  118932. * Specifies wether or not to create a ground.
  118933. * True by default.
  118934. */
  118935. createGround: boolean;
  118936. /**
  118937. * Specifies the ground size.
  118938. * 15 by default.
  118939. */
  118940. groundSize: number;
  118941. /**
  118942. * The texture used on the ground for the main color.
  118943. * Comes from the BabylonJS CDN by default.
  118944. *
  118945. * Remarks: Can be either a texture or a url.
  118946. */
  118947. groundTexture: string | BaseTexture;
  118948. /**
  118949. * The color mixed in the ground texture by default.
  118950. * BabylonJS clearColor by default.
  118951. */
  118952. groundColor: Color3;
  118953. /**
  118954. * Specifies the ground opacity.
  118955. * 1 by default.
  118956. */
  118957. groundOpacity: number;
  118958. /**
  118959. * Enables the ground to receive shadows.
  118960. * True by default.
  118961. */
  118962. enableGroundShadow: boolean;
  118963. /**
  118964. * Helps preventing the shadow to be fully black on the ground.
  118965. * 0.5 by default.
  118966. */
  118967. groundShadowLevel: number;
  118968. /**
  118969. * Creates a mirror texture attach to the ground.
  118970. * false by default.
  118971. */
  118972. enableGroundMirror: boolean;
  118973. /**
  118974. * Specifies the ground mirror size ratio.
  118975. * 0.3 by default as the default kernel is 64.
  118976. */
  118977. groundMirrorSizeRatio: number;
  118978. /**
  118979. * Specifies the ground mirror blur kernel size.
  118980. * 64 by default.
  118981. */
  118982. groundMirrorBlurKernel: number;
  118983. /**
  118984. * Specifies the ground mirror visibility amount.
  118985. * 1 by default
  118986. */
  118987. groundMirrorAmount: number;
  118988. /**
  118989. * Specifies the ground mirror reflectance weight.
  118990. * This uses the standard weight of the background material to setup the fresnel effect
  118991. * of the mirror.
  118992. * 1 by default.
  118993. */
  118994. groundMirrorFresnelWeight: number;
  118995. /**
  118996. * Specifies the ground mirror Falloff distance.
  118997. * This can helps reducing the size of the reflection.
  118998. * 0 by Default.
  118999. */
  119000. groundMirrorFallOffDistance: number;
  119001. /**
  119002. * Specifies the ground mirror texture type.
  119003. * Unsigned Int by Default.
  119004. */
  119005. groundMirrorTextureType: number;
  119006. /**
  119007. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  119008. * the shown objects.
  119009. */
  119010. groundYBias: number;
  119011. /**
  119012. * Specifies wether or not to create a skybox.
  119013. * True by default.
  119014. */
  119015. createSkybox: boolean;
  119016. /**
  119017. * Specifies the skybox size.
  119018. * 20 by default.
  119019. */
  119020. skyboxSize: number;
  119021. /**
  119022. * The texture used on the skybox for the main color.
  119023. * Comes from the BabylonJS CDN by default.
  119024. *
  119025. * Remarks: Can be either a texture or a url.
  119026. */
  119027. skyboxTexture: string | BaseTexture;
  119028. /**
  119029. * The color mixed in the skybox texture by default.
  119030. * BabylonJS clearColor by default.
  119031. */
  119032. skyboxColor: Color3;
  119033. /**
  119034. * The background rotation around the Y axis of the scene.
  119035. * This helps aligning the key lights of your scene with the background.
  119036. * 0 by default.
  119037. */
  119038. backgroundYRotation: number;
  119039. /**
  119040. * Compute automatically the size of the elements to best fit with the scene.
  119041. */
  119042. sizeAuto: boolean;
  119043. /**
  119044. * Default position of the rootMesh if autoSize is not true.
  119045. */
  119046. rootPosition: Vector3;
  119047. /**
  119048. * Sets up the image processing in the scene.
  119049. * true by default.
  119050. */
  119051. setupImageProcessing: boolean;
  119052. /**
  119053. * The texture used as your environment texture in the scene.
  119054. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  119055. *
  119056. * Remarks: Can be either a texture or a url.
  119057. */
  119058. environmentTexture: string | BaseTexture;
  119059. /**
  119060. * The value of the exposure to apply to the scene.
  119061. * 0.6 by default if setupImageProcessing is true.
  119062. */
  119063. cameraExposure: number;
  119064. /**
  119065. * The value of the contrast to apply to the scene.
  119066. * 1.6 by default if setupImageProcessing is true.
  119067. */
  119068. cameraContrast: number;
  119069. /**
  119070. * Specifies wether or not tonemapping should be enabled in the scene.
  119071. * true by default if setupImageProcessing is true.
  119072. */
  119073. toneMappingEnabled: boolean;
  119074. }
  119075. /**
  119076. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  119077. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  119078. * It also helps with the default setup of your imageProcessing configuration.
  119079. */
  119080. export class EnvironmentHelper {
  119081. /**
  119082. * Default ground texture URL.
  119083. */
  119084. private static _groundTextureCDNUrl;
  119085. /**
  119086. * Default skybox texture URL.
  119087. */
  119088. private static _skyboxTextureCDNUrl;
  119089. /**
  119090. * Default environment texture URL.
  119091. */
  119092. private static _environmentTextureCDNUrl;
  119093. /**
  119094. * Creates the default options for the helper.
  119095. */
  119096. private static _getDefaultOptions;
  119097. private _rootMesh;
  119098. /**
  119099. * Gets the root mesh created by the helper.
  119100. */
  119101. get rootMesh(): Mesh;
  119102. private _skybox;
  119103. /**
  119104. * Gets the skybox created by the helper.
  119105. */
  119106. get skybox(): Nullable<Mesh>;
  119107. private _skyboxTexture;
  119108. /**
  119109. * Gets the skybox texture created by the helper.
  119110. */
  119111. get skyboxTexture(): Nullable<BaseTexture>;
  119112. private _skyboxMaterial;
  119113. /**
  119114. * Gets the skybox material created by the helper.
  119115. */
  119116. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  119117. private _ground;
  119118. /**
  119119. * Gets the ground mesh created by the helper.
  119120. */
  119121. get ground(): Nullable<Mesh>;
  119122. private _groundTexture;
  119123. /**
  119124. * Gets the ground texture created by the helper.
  119125. */
  119126. get groundTexture(): Nullable<BaseTexture>;
  119127. private _groundMirror;
  119128. /**
  119129. * Gets the ground mirror created by the helper.
  119130. */
  119131. get groundMirror(): Nullable<MirrorTexture>;
  119132. /**
  119133. * Gets the ground mirror render list to helps pushing the meshes
  119134. * you wish in the ground reflection.
  119135. */
  119136. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  119137. private _groundMaterial;
  119138. /**
  119139. * Gets the ground material created by the helper.
  119140. */
  119141. get groundMaterial(): Nullable<BackgroundMaterial>;
  119142. /**
  119143. * Stores the creation options.
  119144. */
  119145. private readonly _scene;
  119146. private _options;
  119147. /**
  119148. * This observable will be notified with any error during the creation of the environment,
  119149. * mainly texture creation errors.
  119150. */
  119151. onErrorObservable: Observable<{
  119152. message?: string;
  119153. exception?: any;
  119154. }>;
  119155. /**
  119156. * constructor
  119157. * @param options Defines the options we want to customize the helper
  119158. * @param scene The scene to add the material to
  119159. */
  119160. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  119161. /**
  119162. * Updates the background according to the new options
  119163. * @param options
  119164. */
  119165. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  119166. /**
  119167. * Sets the primary color of all the available elements.
  119168. * @param color the main color to affect to the ground and the background
  119169. */
  119170. setMainColor(color: Color3): void;
  119171. /**
  119172. * Setup the image processing according to the specified options.
  119173. */
  119174. private _setupImageProcessing;
  119175. /**
  119176. * Setup the environment texture according to the specified options.
  119177. */
  119178. private _setupEnvironmentTexture;
  119179. /**
  119180. * Setup the background according to the specified options.
  119181. */
  119182. private _setupBackground;
  119183. /**
  119184. * Get the scene sizes according to the setup.
  119185. */
  119186. private _getSceneSize;
  119187. /**
  119188. * Setup the ground according to the specified options.
  119189. */
  119190. private _setupGround;
  119191. /**
  119192. * Setup the ground material according to the specified options.
  119193. */
  119194. private _setupGroundMaterial;
  119195. /**
  119196. * Setup the ground diffuse texture according to the specified options.
  119197. */
  119198. private _setupGroundDiffuseTexture;
  119199. /**
  119200. * Setup the ground mirror texture according to the specified options.
  119201. */
  119202. private _setupGroundMirrorTexture;
  119203. /**
  119204. * Setup the ground to receive the mirror texture.
  119205. */
  119206. private _setupMirrorInGroundMaterial;
  119207. /**
  119208. * Setup the skybox according to the specified options.
  119209. */
  119210. private _setupSkybox;
  119211. /**
  119212. * Setup the skybox material according to the specified options.
  119213. */
  119214. private _setupSkyboxMaterial;
  119215. /**
  119216. * Setup the skybox reflection texture according to the specified options.
  119217. */
  119218. private _setupSkyboxReflectionTexture;
  119219. private _errorHandler;
  119220. /**
  119221. * Dispose all the elements created by the Helper.
  119222. */
  119223. dispose(): void;
  119224. }
  119225. }
  119226. declare module BABYLON {
  119227. /**
  119228. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  119229. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  119230. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  119231. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119232. */
  119233. export class PhotoDome extends TransformNode {
  119234. /**
  119235. * Define the image as a Monoscopic panoramic 360 image.
  119236. */
  119237. static readonly MODE_MONOSCOPIC: number;
  119238. /**
  119239. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119240. */
  119241. static readonly MODE_TOPBOTTOM: number;
  119242. /**
  119243. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119244. */
  119245. static readonly MODE_SIDEBYSIDE: number;
  119246. private _useDirectMapping;
  119247. /**
  119248. * The texture being displayed on the sphere
  119249. */
  119250. protected _photoTexture: Texture;
  119251. /**
  119252. * Gets or sets the texture being displayed on the sphere
  119253. */
  119254. get photoTexture(): Texture;
  119255. set photoTexture(value: Texture);
  119256. /**
  119257. * Observable raised when an error occured while loading the 360 image
  119258. */
  119259. onLoadErrorObservable: Observable<string>;
  119260. /**
  119261. * The skybox material
  119262. */
  119263. protected _material: BackgroundMaterial;
  119264. /**
  119265. * The surface used for the skybox
  119266. */
  119267. protected _mesh: Mesh;
  119268. /**
  119269. * Gets the mesh used for the skybox.
  119270. */
  119271. get mesh(): Mesh;
  119272. /**
  119273. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119274. * Also see the options.resolution property.
  119275. */
  119276. get fovMultiplier(): number;
  119277. set fovMultiplier(value: number);
  119278. private _imageMode;
  119279. /**
  119280. * Gets or set the current video mode for the video. It can be:
  119281. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  119282. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119283. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119284. */
  119285. get imageMode(): number;
  119286. set imageMode(value: number);
  119287. /**
  119288. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  119289. * @param name Element's name, child elements will append suffixes for their own names.
  119290. * @param urlsOfPhoto defines the url of the photo to display
  119291. * @param options defines an object containing optional or exposed sub element properties
  119292. * @param onError defines a callback called when an error occured while loading the texture
  119293. */
  119294. constructor(name: string, urlOfPhoto: string, options: {
  119295. resolution?: number;
  119296. size?: number;
  119297. useDirectMapping?: boolean;
  119298. faceForward?: boolean;
  119299. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  119300. private _onBeforeCameraRenderObserver;
  119301. private _changeImageMode;
  119302. /**
  119303. * Releases resources associated with this node.
  119304. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119305. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119306. */
  119307. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119308. }
  119309. }
  119310. declare module BABYLON {
  119311. /**
  119312. * Class used to host RGBD texture specific utilities
  119313. */
  119314. export class RGBDTextureTools {
  119315. /**
  119316. * Expand the RGBD Texture from RGBD to Half Float if possible.
  119317. * @param texture the texture to expand.
  119318. */
  119319. static ExpandRGBDTexture(texture: Texture): void;
  119320. }
  119321. }
  119322. declare module BABYLON {
  119323. /**
  119324. * Class used to host texture specific utilities
  119325. */
  119326. export class BRDFTextureTools {
  119327. /**
  119328. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  119329. * @param scene defines the hosting scene
  119330. * @returns the environment BRDF texture
  119331. */
  119332. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  119333. private static _environmentBRDFBase64Texture;
  119334. }
  119335. }
  119336. declare module BABYLON {
  119337. /**
  119338. * @hidden
  119339. */
  119340. export interface IMaterialClearCoatDefines {
  119341. CLEARCOAT: boolean;
  119342. CLEARCOAT_DEFAULTIOR: boolean;
  119343. CLEARCOAT_TEXTURE: boolean;
  119344. CLEARCOAT_TEXTUREDIRECTUV: number;
  119345. CLEARCOAT_BUMP: boolean;
  119346. CLEARCOAT_BUMPDIRECTUV: number;
  119347. CLEARCOAT_TINT: boolean;
  119348. CLEARCOAT_TINT_TEXTURE: boolean;
  119349. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  119350. /** @hidden */
  119351. _areTexturesDirty: boolean;
  119352. }
  119353. /**
  119354. * Define the code related to the clear coat parameters of the pbr material.
  119355. */
  119356. export class PBRClearCoatConfiguration {
  119357. /**
  119358. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119359. * The default fits with a polyurethane material.
  119360. */
  119361. private static readonly _DefaultIndexOfRefraction;
  119362. private _isEnabled;
  119363. /**
  119364. * Defines if the clear coat is enabled in the material.
  119365. */
  119366. isEnabled: boolean;
  119367. /**
  119368. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  119369. */
  119370. intensity: number;
  119371. /**
  119372. * Defines the clear coat layer roughness.
  119373. */
  119374. roughness: number;
  119375. private _indexOfRefraction;
  119376. /**
  119377. * Defines the index of refraction of the clear coat.
  119378. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119379. * The default fits with a polyurethane material.
  119380. * Changing the default value is more performance intensive.
  119381. */
  119382. indexOfRefraction: number;
  119383. private _texture;
  119384. /**
  119385. * Stores the clear coat values in a texture.
  119386. */
  119387. texture: Nullable<BaseTexture>;
  119388. private _bumpTexture;
  119389. /**
  119390. * Define the clear coat specific bump texture.
  119391. */
  119392. bumpTexture: Nullable<BaseTexture>;
  119393. private _isTintEnabled;
  119394. /**
  119395. * Defines if the clear coat tint is enabled in the material.
  119396. */
  119397. isTintEnabled: boolean;
  119398. /**
  119399. * Defines the clear coat tint of the material.
  119400. * This is only use if tint is enabled
  119401. */
  119402. tintColor: Color3;
  119403. /**
  119404. * Defines the distance at which the tint color should be found in the
  119405. * clear coat media.
  119406. * This is only use if tint is enabled
  119407. */
  119408. tintColorAtDistance: number;
  119409. /**
  119410. * Defines the clear coat layer thickness.
  119411. * This is only use if tint is enabled
  119412. */
  119413. tintThickness: number;
  119414. private _tintTexture;
  119415. /**
  119416. * Stores the clear tint values in a texture.
  119417. * rgb is tint
  119418. * a is a thickness factor
  119419. */
  119420. tintTexture: Nullable<BaseTexture>;
  119421. /** @hidden */
  119422. private _internalMarkAllSubMeshesAsTexturesDirty;
  119423. /** @hidden */
  119424. _markAllSubMeshesAsTexturesDirty(): void;
  119425. /**
  119426. * Instantiate a new istance of clear coat configuration.
  119427. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119428. */
  119429. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119430. /**
  119431. * Gets wehter the submesh is ready to be used or not.
  119432. * @param defines the list of "defines" to update.
  119433. * @param scene defines the scene the material belongs to.
  119434. * @param engine defines the engine the material belongs to.
  119435. * @param disableBumpMap defines wether the material disables bump or not.
  119436. * @returns - boolean indicating that the submesh is ready or not.
  119437. */
  119438. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  119439. /**
  119440. * Checks to see if a texture is used in the material.
  119441. * @param defines the list of "defines" to update.
  119442. * @param scene defines the scene to the material belongs to.
  119443. */
  119444. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  119445. /**
  119446. * Binds the material data.
  119447. * @param uniformBuffer defines the Uniform buffer to fill in.
  119448. * @param scene defines the scene the material belongs to.
  119449. * @param engine defines the engine the material belongs to.
  119450. * @param disableBumpMap defines wether the material disables bump or not.
  119451. * @param isFrozen defines wether the material is frozen or not.
  119452. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  119453. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  119454. */
  119455. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  119456. /**
  119457. * Checks to see if a texture is used in the material.
  119458. * @param texture - Base texture to use.
  119459. * @returns - Boolean specifying if a texture is used in the material.
  119460. */
  119461. hasTexture(texture: BaseTexture): boolean;
  119462. /**
  119463. * Returns an array of the actively used textures.
  119464. * @param activeTextures Array of BaseTextures
  119465. */
  119466. getActiveTextures(activeTextures: BaseTexture[]): void;
  119467. /**
  119468. * Returns the animatable textures.
  119469. * @param animatables Array of animatable textures.
  119470. */
  119471. getAnimatables(animatables: IAnimatable[]): void;
  119472. /**
  119473. * Disposes the resources of the material.
  119474. * @param forceDisposeTextures - Forces the disposal of all textures.
  119475. */
  119476. dispose(forceDisposeTextures?: boolean): void;
  119477. /**
  119478. * Get the current class name of the texture useful for serialization or dynamic coding.
  119479. * @returns "PBRClearCoatConfiguration"
  119480. */
  119481. getClassName(): string;
  119482. /**
  119483. * Add fallbacks to the effect fallbacks list.
  119484. * @param defines defines the Base texture to use.
  119485. * @param fallbacks defines the current fallback list.
  119486. * @param currentRank defines the current fallback rank.
  119487. * @returns the new fallback rank.
  119488. */
  119489. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119490. /**
  119491. * Add the required uniforms to the current list.
  119492. * @param uniforms defines the current uniform list.
  119493. */
  119494. static AddUniforms(uniforms: string[]): void;
  119495. /**
  119496. * Add the required samplers to the current list.
  119497. * @param samplers defines the current sampler list.
  119498. */
  119499. static AddSamplers(samplers: string[]): void;
  119500. /**
  119501. * Add the required uniforms to the current buffer.
  119502. * @param uniformBuffer defines the current uniform buffer.
  119503. */
  119504. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119505. /**
  119506. * Makes a duplicate of the current configuration into another one.
  119507. * @param clearCoatConfiguration define the config where to copy the info
  119508. */
  119509. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  119510. /**
  119511. * Serializes this clear coat configuration.
  119512. * @returns - An object with the serialized config.
  119513. */
  119514. serialize(): any;
  119515. /**
  119516. * Parses a anisotropy Configuration from a serialized object.
  119517. * @param source - Serialized object.
  119518. * @param scene Defines the scene we are parsing for
  119519. * @param rootUrl Defines the rootUrl to load from
  119520. */
  119521. parse(source: any, scene: Scene, rootUrl: string): void;
  119522. }
  119523. }
  119524. declare module BABYLON {
  119525. /**
  119526. * @hidden
  119527. */
  119528. export interface IMaterialAnisotropicDefines {
  119529. ANISOTROPIC: boolean;
  119530. ANISOTROPIC_TEXTURE: boolean;
  119531. ANISOTROPIC_TEXTUREDIRECTUV: number;
  119532. MAINUV1: boolean;
  119533. _areTexturesDirty: boolean;
  119534. _needUVs: boolean;
  119535. }
  119536. /**
  119537. * Define the code related to the anisotropic parameters of the pbr material.
  119538. */
  119539. export class PBRAnisotropicConfiguration {
  119540. private _isEnabled;
  119541. /**
  119542. * Defines if the anisotropy is enabled in the material.
  119543. */
  119544. isEnabled: boolean;
  119545. /**
  119546. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  119547. */
  119548. intensity: number;
  119549. /**
  119550. * Defines if the effect is along the tangents, bitangents or in between.
  119551. * By default, the effect is "strectching" the highlights along the tangents.
  119552. */
  119553. direction: Vector2;
  119554. private _texture;
  119555. /**
  119556. * Stores the anisotropy values in a texture.
  119557. * rg is direction (like normal from -1 to 1)
  119558. * b is a intensity
  119559. */
  119560. texture: Nullable<BaseTexture>;
  119561. /** @hidden */
  119562. private _internalMarkAllSubMeshesAsTexturesDirty;
  119563. /** @hidden */
  119564. _markAllSubMeshesAsTexturesDirty(): void;
  119565. /**
  119566. * Instantiate a new istance of anisotropy configuration.
  119567. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119568. */
  119569. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119570. /**
  119571. * Specifies that the submesh is ready to be used.
  119572. * @param defines the list of "defines" to update.
  119573. * @param scene defines the scene the material belongs to.
  119574. * @returns - boolean indicating that the submesh is ready or not.
  119575. */
  119576. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  119577. /**
  119578. * Checks to see if a texture is used in the material.
  119579. * @param defines the list of "defines" to update.
  119580. * @param mesh the mesh we are preparing the defines for.
  119581. * @param scene defines the scene the material belongs to.
  119582. */
  119583. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  119584. /**
  119585. * Binds the material data.
  119586. * @param uniformBuffer defines the Uniform buffer to fill in.
  119587. * @param scene defines the scene the material belongs to.
  119588. * @param isFrozen defines wether the material is frozen or not.
  119589. */
  119590. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119591. /**
  119592. * Checks to see if a texture is used in the material.
  119593. * @param texture - Base texture to use.
  119594. * @returns - Boolean specifying if a texture is used in the material.
  119595. */
  119596. hasTexture(texture: BaseTexture): boolean;
  119597. /**
  119598. * Returns an array of the actively used textures.
  119599. * @param activeTextures Array of BaseTextures
  119600. */
  119601. getActiveTextures(activeTextures: BaseTexture[]): void;
  119602. /**
  119603. * Returns the animatable textures.
  119604. * @param animatables Array of animatable textures.
  119605. */
  119606. getAnimatables(animatables: IAnimatable[]): void;
  119607. /**
  119608. * Disposes the resources of the material.
  119609. * @param forceDisposeTextures - Forces the disposal of all textures.
  119610. */
  119611. dispose(forceDisposeTextures?: boolean): void;
  119612. /**
  119613. * Get the current class name of the texture useful for serialization or dynamic coding.
  119614. * @returns "PBRAnisotropicConfiguration"
  119615. */
  119616. getClassName(): string;
  119617. /**
  119618. * Add fallbacks to the effect fallbacks list.
  119619. * @param defines defines the Base texture to use.
  119620. * @param fallbacks defines the current fallback list.
  119621. * @param currentRank defines the current fallback rank.
  119622. * @returns the new fallback rank.
  119623. */
  119624. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119625. /**
  119626. * Add the required uniforms to the current list.
  119627. * @param uniforms defines the current uniform list.
  119628. */
  119629. static AddUniforms(uniforms: string[]): void;
  119630. /**
  119631. * Add the required uniforms to the current buffer.
  119632. * @param uniformBuffer defines the current uniform buffer.
  119633. */
  119634. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119635. /**
  119636. * Add the required samplers to the current list.
  119637. * @param samplers defines the current sampler list.
  119638. */
  119639. static AddSamplers(samplers: string[]): void;
  119640. /**
  119641. * Makes a duplicate of the current configuration into another one.
  119642. * @param anisotropicConfiguration define the config where to copy the info
  119643. */
  119644. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  119645. /**
  119646. * Serializes this anisotropy configuration.
  119647. * @returns - An object with the serialized config.
  119648. */
  119649. serialize(): any;
  119650. /**
  119651. * Parses a anisotropy Configuration from a serialized object.
  119652. * @param source - Serialized object.
  119653. * @param scene Defines the scene we are parsing for
  119654. * @param rootUrl Defines the rootUrl to load from
  119655. */
  119656. parse(source: any, scene: Scene, rootUrl: string): void;
  119657. }
  119658. }
  119659. declare module BABYLON {
  119660. /**
  119661. * @hidden
  119662. */
  119663. export interface IMaterialBRDFDefines {
  119664. BRDF_V_HEIGHT_CORRELATED: boolean;
  119665. MS_BRDF_ENERGY_CONSERVATION: boolean;
  119666. SPHERICAL_HARMONICS: boolean;
  119667. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  119668. /** @hidden */
  119669. _areMiscDirty: boolean;
  119670. }
  119671. /**
  119672. * Define the code related to the BRDF parameters of the pbr material.
  119673. */
  119674. export class PBRBRDFConfiguration {
  119675. /**
  119676. * Default value used for the energy conservation.
  119677. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119678. */
  119679. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  119680. /**
  119681. * Default value used for the Smith Visibility Height Correlated mode.
  119682. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119683. */
  119684. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  119685. /**
  119686. * Default value used for the IBL diffuse part.
  119687. * This can help switching back to the polynomials mode globally which is a tiny bit
  119688. * less GPU intensive at the drawback of a lower quality.
  119689. */
  119690. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  119691. /**
  119692. * Default value used for activating energy conservation for the specular workflow.
  119693. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119694. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119695. */
  119696. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  119697. private _useEnergyConservation;
  119698. /**
  119699. * Defines if the material uses energy conservation.
  119700. */
  119701. useEnergyConservation: boolean;
  119702. private _useSmithVisibilityHeightCorrelated;
  119703. /**
  119704. * LEGACY Mode set to false
  119705. * Defines if the material uses height smith correlated visibility term.
  119706. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  119707. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  119708. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  119709. * Not relying on height correlated will also disable energy conservation.
  119710. */
  119711. useSmithVisibilityHeightCorrelated: boolean;
  119712. private _useSphericalHarmonics;
  119713. /**
  119714. * LEGACY Mode set to false
  119715. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  119716. * diffuse part of the IBL.
  119717. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  119718. * to the ground truth.
  119719. */
  119720. useSphericalHarmonics: boolean;
  119721. private _useSpecularGlossinessInputEnergyConservation;
  119722. /**
  119723. * Defines if the material uses energy conservation, when the specular workflow is active.
  119724. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119725. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119726. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  119727. */
  119728. useSpecularGlossinessInputEnergyConservation: boolean;
  119729. /** @hidden */
  119730. private _internalMarkAllSubMeshesAsMiscDirty;
  119731. /** @hidden */
  119732. _markAllSubMeshesAsMiscDirty(): void;
  119733. /**
  119734. * Instantiate a new istance of clear coat configuration.
  119735. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  119736. */
  119737. constructor(markAllSubMeshesAsMiscDirty: () => void);
  119738. /**
  119739. * Checks to see if a texture is used in the material.
  119740. * @param defines the list of "defines" to update.
  119741. */
  119742. prepareDefines(defines: IMaterialBRDFDefines): void;
  119743. /**
  119744. * Get the current class name of the texture useful for serialization or dynamic coding.
  119745. * @returns "PBRClearCoatConfiguration"
  119746. */
  119747. getClassName(): string;
  119748. /**
  119749. * Makes a duplicate of the current configuration into another one.
  119750. * @param brdfConfiguration define the config where to copy the info
  119751. */
  119752. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  119753. /**
  119754. * Serializes this BRDF configuration.
  119755. * @returns - An object with the serialized config.
  119756. */
  119757. serialize(): any;
  119758. /**
  119759. * Parses a anisotropy Configuration from a serialized object.
  119760. * @param source - Serialized object.
  119761. * @param scene Defines the scene we are parsing for
  119762. * @param rootUrl Defines the rootUrl to load from
  119763. */
  119764. parse(source: any, scene: Scene, rootUrl: string): void;
  119765. }
  119766. }
  119767. declare module BABYLON {
  119768. /**
  119769. * @hidden
  119770. */
  119771. export interface IMaterialSheenDefines {
  119772. SHEEN: boolean;
  119773. SHEEN_TEXTURE: boolean;
  119774. SHEEN_TEXTUREDIRECTUV: number;
  119775. SHEEN_LINKWITHALBEDO: boolean;
  119776. /** @hidden */
  119777. _areTexturesDirty: boolean;
  119778. }
  119779. /**
  119780. * Define the code related to the Sheen parameters of the pbr material.
  119781. */
  119782. export class PBRSheenConfiguration {
  119783. private _isEnabled;
  119784. /**
  119785. * Defines if the material uses sheen.
  119786. */
  119787. isEnabled: boolean;
  119788. private _linkSheenWithAlbedo;
  119789. /**
  119790. * Defines if the sheen is linked to the sheen color.
  119791. */
  119792. linkSheenWithAlbedo: boolean;
  119793. /**
  119794. * Defines the sheen intensity.
  119795. */
  119796. intensity: number;
  119797. /**
  119798. * Defines the sheen color.
  119799. */
  119800. color: Color3;
  119801. private _texture;
  119802. /**
  119803. * Stores the sheen tint values in a texture.
  119804. * rgb is tint
  119805. * a is a intensity
  119806. */
  119807. texture: Nullable<BaseTexture>;
  119808. /** @hidden */
  119809. private _internalMarkAllSubMeshesAsTexturesDirty;
  119810. /** @hidden */
  119811. _markAllSubMeshesAsTexturesDirty(): void;
  119812. /**
  119813. * Instantiate a new istance of clear coat configuration.
  119814. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119815. */
  119816. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119817. /**
  119818. * Specifies that the submesh is ready to be used.
  119819. * @param defines the list of "defines" to update.
  119820. * @param scene defines the scene the material belongs to.
  119821. * @returns - boolean indicating that the submesh is ready or not.
  119822. */
  119823. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  119824. /**
  119825. * Checks to see if a texture is used in the material.
  119826. * @param defines the list of "defines" to update.
  119827. * @param scene defines the scene the material belongs to.
  119828. */
  119829. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  119830. /**
  119831. * Binds the material data.
  119832. * @param uniformBuffer defines the Uniform buffer to fill in.
  119833. * @param scene defines the scene the material belongs to.
  119834. * @param isFrozen defines wether the material is frozen or not.
  119835. */
  119836. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119837. /**
  119838. * Checks to see if a texture is used in the material.
  119839. * @param texture - Base texture to use.
  119840. * @returns - Boolean specifying if a texture is used in the material.
  119841. */
  119842. hasTexture(texture: BaseTexture): boolean;
  119843. /**
  119844. * Returns an array of the actively used textures.
  119845. * @param activeTextures Array of BaseTextures
  119846. */
  119847. getActiveTextures(activeTextures: BaseTexture[]): void;
  119848. /**
  119849. * Returns the animatable textures.
  119850. * @param animatables Array of animatable textures.
  119851. */
  119852. getAnimatables(animatables: IAnimatable[]): void;
  119853. /**
  119854. * Disposes the resources of the material.
  119855. * @param forceDisposeTextures - Forces the disposal of all textures.
  119856. */
  119857. dispose(forceDisposeTextures?: boolean): void;
  119858. /**
  119859. * Get the current class name of the texture useful for serialization or dynamic coding.
  119860. * @returns "PBRSheenConfiguration"
  119861. */
  119862. getClassName(): string;
  119863. /**
  119864. * Add fallbacks to the effect fallbacks list.
  119865. * @param defines defines the Base texture to use.
  119866. * @param fallbacks defines the current fallback list.
  119867. * @param currentRank defines the current fallback rank.
  119868. * @returns the new fallback rank.
  119869. */
  119870. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119871. /**
  119872. * Add the required uniforms to the current list.
  119873. * @param uniforms defines the current uniform list.
  119874. */
  119875. static AddUniforms(uniforms: string[]): void;
  119876. /**
  119877. * Add the required uniforms to the current buffer.
  119878. * @param uniformBuffer defines the current uniform buffer.
  119879. */
  119880. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119881. /**
  119882. * Add the required samplers to the current list.
  119883. * @param samplers defines the current sampler list.
  119884. */
  119885. static AddSamplers(samplers: string[]): void;
  119886. /**
  119887. * Makes a duplicate of the current configuration into another one.
  119888. * @param sheenConfiguration define the config where to copy the info
  119889. */
  119890. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  119891. /**
  119892. * Serializes this BRDF configuration.
  119893. * @returns - An object with the serialized config.
  119894. */
  119895. serialize(): any;
  119896. /**
  119897. * Parses a anisotropy Configuration from a serialized object.
  119898. * @param source - Serialized object.
  119899. * @param scene Defines the scene we are parsing for
  119900. * @param rootUrl Defines the rootUrl to load from
  119901. */
  119902. parse(source: any, scene: Scene, rootUrl: string): void;
  119903. }
  119904. }
  119905. declare module BABYLON {
  119906. /**
  119907. * @hidden
  119908. */
  119909. export interface IMaterialSubSurfaceDefines {
  119910. SUBSURFACE: boolean;
  119911. SS_REFRACTION: boolean;
  119912. SS_TRANSLUCENCY: boolean;
  119913. SS_SCATERRING: boolean;
  119914. SS_THICKNESSANDMASK_TEXTURE: boolean;
  119915. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  119916. SS_REFRACTIONMAP_3D: boolean;
  119917. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  119918. SS_LODINREFRACTIONALPHA: boolean;
  119919. SS_GAMMAREFRACTION: boolean;
  119920. SS_RGBDREFRACTION: boolean;
  119921. SS_LINEARSPECULARREFRACTION: boolean;
  119922. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  119923. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  119924. /** @hidden */
  119925. _areTexturesDirty: boolean;
  119926. }
  119927. /**
  119928. * Define the code related to the sub surface parameters of the pbr material.
  119929. */
  119930. export class PBRSubSurfaceConfiguration {
  119931. private _isRefractionEnabled;
  119932. /**
  119933. * Defines if the refraction is enabled in the material.
  119934. */
  119935. isRefractionEnabled: boolean;
  119936. private _isTranslucencyEnabled;
  119937. /**
  119938. * Defines if the translucency is enabled in the material.
  119939. */
  119940. isTranslucencyEnabled: boolean;
  119941. private _isScatteringEnabled;
  119942. /**
  119943. * Defines the refraction intensity of the material.
  119944. * The refraction when enabled replaces the Diffuse part of the material.
  119945. * The intensity helps transitionning between diffuse and refraction.
  119946. */
  119947. refractionIntensity: number;
  119948. /**
  119949. * Defines the translucency intensity of the material.
  119950. * When translucency has been enabled, this defines how much of the "translucency"
  119951. * is addded to the diffuse part of the material.
  119952. */
  119953. translucencyIntensity: number;
  119954. /**
  119955. * Defines the scattering intensity of the material.
  119956. * When scattering has been enabled, this defines how much of the "scattered light"
  119957. * is addded to the diffuse part of the material.
  119958. */
  119959. scatteringIntensity: number;
  119960. private _thicknessTexture;
  119961. /**
  119962. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  119963. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  119964. * 0 would mean minimumThickness
  119965. * 1 would mean maximumThickness
  119966. * The other channels might be use as a mask to vary the different effects intensity.
  119967. */
  119968. thicknessTexture: Nullable<BaseTexture>;
  119969. private _refractionTexture;
  119970. /**
  119971. * Defines the texture to use for refraction.
  119972. */
  119973. refractionTexture: Nullable<BaseTexture>;
  119974. private _indexOfRefraction;
  119975. /**
  119976. * Defines the index of refraction used in the material.
  119977. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  119978. */
  119979. indexOfRefraction: number;
  119980. private _invertRefractionY;
  119981. /**
  119982. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  119983. */
  119984. invertRefractionY: boolean;
  119985. private _linkRefractionWithTransparency;
  119986. /**
  119987. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  119988. * Materials half opaque for instance using refraction could benefit from this control.
  119989. */
  119990. linkRefractionWithTransparency: boolean;
  119991. /**
  119992. * Defines the minimum thickness stored in the thickness map.
  119993. * If no thickness map is defined, this value will be used to simulate thickness.
  119994. */
  119995. minimumThickness: number;
  119996. /**
  119997. * Defines the maximum thickness stored in the thickness map.
  119998. */
  119999. maximumThickness: number;
  120000. /**
  120001. * Defines the volume tint of the material.
  120002. * This is used for both translucency and scattering.
  120003. */
  120004. tintColor: Color3;
  120005. /**
  120006. * Defines the distance at which the tint color should be found in the media.
  120007. * This is used for refraction only.
  120008. */
  120009. tintColorAtDistance: number;
  120010. /**
  120011. * Defines how far each channel transmit through the media.
  120012. * It is defined as a color to simplify it selection.
  120013. */
  120014. diffusionDistance: Color3;
  120015. private _useMaskFromThicknessTexture;
  120016. /**
  120017. * Stores the intensity of the different subsurface effects in the thickness texture.
  120018. * * the green channel is the translucency intensity.
  120019. * * the blue channel is the scattering intensity.
  120020. * * the alpha channel is the refraction intensity.
  120021. */
  120022. useMaskFromThicknessTexture: boolean;
  120023. /** @hidden */
  120024. private _internalMarkAllSubMeshesAsTexturesDirty;
  120025. /** @hidden */
  120026. _markAllSubMeshesAsTexturesDirty(): void;
  120027. /**
  120028. * Instantiate a new istance of sub surface configuration.
  120029. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  120030. */
  120031. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  120032. /**
  120033. * Gets wehter the submesh is ready to be used or not.
  120034. * @param defines the list of "defines" to update.
  120035. * @param scene defines the scene the material belongs to.
  120036. * @returns - boolean indicating that the submesh is ready or not.
  120037. */
  120038. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  120039. /**
  120040. * Checks to see if a texture is used in the material.
  120041. * @param defines the list of "defines" to update.
  120042. * @param scene defines the scene to the material belongs to.
  120043. */
  120044. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  120045. /**
  120046. * Binds the material data.
  120047. * @param uniformBuffer defines the Uniform buffer to fill in.
  120048. * @param scene defines the scene the material belongs to.
  120049. * @param engine defines the engine the material belongs to.
  120050. * @param isFrozen defines wether the material is frozen or not.
  120051. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  120052. */
  120053. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  120054. /**
  120055. * Unbinds the material from the mesh.
  120056. * @param activeEffect defines the effect that should be unbound from.
  120057. * @returns true if unbound, otherwise false
  120058. */
  120059. unbind(activeEffect: Effect): boolean;
  120060. /**
  120061. * Returns the texture used for refraction or null if none is used.
  120062. * @param scene defines the scene the material belongs to.
  120063. * @returns - Refraction texture if present. If no refraction texture and refraction
  120064. * is linked with transparency, returns environment texture. Otherwise, returns null.
  120065. */
  120066. private _getRefractionTexture;
  120067. /**
  120068. * Returns true if alpha blending should be disabled.
  120069. */
  120070. get disableAlphaBlending(): boolean;
  120071. /**
  120072. * Fills the list of render target textures.
  120073. * @param renderTargets the list of render targets to update
  120074. */
  120075. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  120076. /**
  120077. * Checks to see if a texture is used in the material.
  120078. * @param texture - Base texture to use.
  120079. * @returns - Boolean specifying if a texture is used in the material.
  120080. */
  120081. hasTexture(texture: BaseTexture): boolean;
  120082. /**
  120083. * Gets a boolean indicating that current material needs to register RTT
  120084. * @returns true if this uses a render target otherwise false.
  120085. */
  120086. hasRenderTargetTextures(): boolean;
  120087. /**
  120088. * Returns an array of the actively used textures.
  120089. * @param activeTextures Array of BaseTextures
  120090. */
  120091. getActiveTextures(activeTextures: BaseTexture[]): void;
  120092. /**
  120093. * Returns the animatable textures.
  120094. * @param animatables Array of animatable textures.
  120095. */
  120096. getAnimatables(animatables: IAnimatable[]): void;
  120097. /**
  120098. * Disposes the resources of the material.
  120099. * @param forceDisposeTextures - Forces the disposal of all textures.
  120100. */
  120101. dispose(forceDisposeTextures?: boolean): void;
  120102. /**
  120103. * Get the current class name of the texture useful for serialization or dynamic coding.
  120104. * @returns "PBRSubSurfaceConfiguration"
  120105. */
  120106. getClassName(): string;
  120107. /**
  120108. * Add fallbacks to the effect fallbacks list.
  120109. * @param defines defines the Base texture to use.
  120110. * @param fallbacks defines the current fallback list.
  120111. * @param currentRank defines the current fallback rank.
  120112. * @returns the new fallback rank.
  120113. */
  120114. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120115. /**
  120116. * Add the required uniforms to the current list.
  120117. * @param uniforms defines the current uniform list.
  120118. */
  120119. static AddUniforms(uniforms: string[]): void;
  120120. /**
  120121. * Add the required samplers to the current list.
  120122. * @param samplers defines the current sampler list.
  120123. */
  120124. static AddSamplers(samplers: string[]): void;
  120125. /**
  120126. * Add the required uniforms to the current buffer.
  120127. * @param uniformBuffer defines the current uniform buffer.
  120128. */
  120129. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120130. /**
  120131. * Makes a duplicate of the current configuration into another one.
  120132. * @param configuration define the config where to copy the info
  120133. */
  120134. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  120135. /**
  120136. * Serializes this Sub Surface configuration.
  120137. * @returns - An object with the serialized config.
  120138. */
  120139. serialize(): any;
  120140. /**
  120141. * Parses a anisotropy Configuration from a serialized object.
  120142. * @param source - Serialized object.
  120143. * @param scene Defines the scene we are parsing for
  120144. * @param rootUrl Defines the rootUrl to load from
  120145. */
  120146. parse(source: any, scene: Scene, rootUrl: string): void;
  120147. }
  120148. }
  120149. declare module BABYLON {
  120150. /** @hidden */
  120151. export var pbrFragmentDeclaration: {
  120152. name: string;
  120153. shader: string;
  120154. };
  120155. }
  120156. declare module BABYLON {
  120157. /** @hidden */
  120158. export var pbrUboDeclaration: {
  120159. name: string;
  120160. shader: string;
  120161. };
  120162. }
  120163. declare module BABYLON {
  120164. /** @hidden */
  120165. export var pbrFragmentExtraDeclaration: {
  120166. name: string;
  120167. shader: string;
  120168. };
  120169. }
  120170. declare module BABYLON {
  120171. /** @hidden */
  120172. export var pbrFragmentSamplersDeclaration: {
  120173. name: string;
  120174. shader: string;
  120175. };
  120176. }
  120177. declare module BABYLON {
  120178. /** @hidden */
  120179. export var pbrHelperFunctions: {
  120180. name: string;
  120181. shader: string;
  120182. };
  120183. }
  120184. declare module BABYLON {
  120185. /** @hidden */
  120186. export var harmonicsFunctions: {
  120187. name: string;
  120188. shader: string;
  120189. };
  120190. }
  120191. declare module BABYLON {
  120192. /** @hidden */
  120193. export var pbrDirectLightingSetupFunctions: {
  120194. name: string;
  120195. shader: string;
  120196. };
  120197. }
  120198. declare module BABYLON {
  120199. /** @hidden */
  120200. export var pbrDirectLightingFalloffFunctions: {
  120201. name: string;
  120202. shader: string;
  120203. };
  120204. }
  120205. declare module BABYLON {
  120206. /** @hidden */
  120207. export var pbrBRDFFunctions: {
  120208. name: string;
  120209. shader: string;
  120210. };
  120211. }
  120212. declare module BABYLON {
  120213. /** @hidden */
  120214. export var pbrDirectLightingFunctions: {
  120215. name: string;
  120216. shader: string;
  120217. };
  120218. }
  120219. declare module BABYLON {
  120220. /** @hidden */
  120221. export var pbrIBLFunctions: {
  120222. name: string;
  120223. shader: string;
  120224. };
  120225. }
  120226. declare module BABYLON {
  120227. /** @hidden */
  120228. export var pbrDebug: {
  120229. name: string;
  120230. shader: string;
  120231. };
  120232. }
  120233. declare module BABYLON {
  120234. /** @hidden */
  120235. export var pbrPixelShader: {
  120236. name: string;
  120237. shader: string;
  120238. };
  120239. }
  120240. declare module BABYLON {
  120241. /** @hidden */
  120242. export var pbrVertexDeclaration: {
  120243. name: string;
  120244. shader: string;
  120245. };
  120246. }
  120247. declare module BABYLON {
  120248. /** @hidden */
  120249. export var pbrVertexShader: {
  120250. name: string;
  120251. shader: string;
  120252. };
  120253. }
  120254. declare module BABYLON {
  120255. /**
  120256. * Manages the defines for the PBR Material.
  120257. * @hidden
  120258. */
  120259. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  120260. PBR: boolean;
  120261. MAINUV1: boolean;
  120262. MAINUV2: boolean;
  120263. UV1: boolean;
  120264. UV2: boolean;
  120265. ALBEDO: boolean;
  120266. ALBEDODIRECTUV: number;
  120267. VERTEXCOLOR: boolean;
  120268. AMBIENT: boolean;
  120269. AMBIENTDIRECTUV: number;
  120270. AMBIENTINGRAYSCALE: boolean;
  120271. OPACITY: boolean;
  120272. VERTEXALPHA: boolean;
  120273. OPACITYDIRECTUV: number;
  120274. OPACITYRGB: boolean;
  120275. ALPHATEST: boolean;
  120276. DEPTHPREPASS: boolean;
  120277. ALPHABLEND: boolean;
  120278. ALPHAFROMALBEDO: boolean;
  120279. ALPHATESTVALUE: string;
  120280. SPECULAROVERALPHA: boolean;
  120281. RADIANCEOVERALPHA: boolean;
  120282. ALPHAFRESNEL: boolean;
  120283. LINEARALPHAFRESNEL: boolean;
  120284. PREMULTIPLYALPHA: boolean;
  120285. EMISSIVE: boolean;
  120286. EMISSIVEDIRECTUV: number;
  120287. REFLECTIVITY: boolean;
  120288. REFLECTIVITYDIRECTUV: number;
  120289. SPECULARTERM: boolean;
  120290. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  120291. MICROSURFACEAUTOMATIC: boolean;
  120292. LODBASEDMICROSFURACE: boolean;
  120293. MICROSURFACEMAP: boolean;
  120294. MICROSURFACEMAPDIRECTUV: number;
  120295. METALLICWORKFLOW: boolean;
  120296. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  120297. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  120298. METALLNESSSTOREINMETALMAPBLUE: boolean;
  120299. AOSTOREINMETALMAPRED: boolean;
  120300. METALLICF0FACTORFROMMETALLICMAP: boolean;
  120301. ENVIRONMENTBRDF: boolean;
  120302. ENVIRONMENTBRDF_RGBD: boolean;
  120303. NORMAL: boolean;
  120304. TANGENT: boolean;
  120305. BUMP: boolean;
  120306. BUMPDIRECTUV: number;
  120307. OBJECTSPACE_NORMALMAP: boolean;
  120308. PARALLAX: boolean;
  120309. PARALLAXOCCLUSION: boolean;
  120310. NORMALXYSCALE: boolean;
  120311. LIGHTMAP: boolean;
  120312. LIGHTMAPDIRECTUV: number;
  120313. USELIGHTMAPASSHADOWMAP: boolean;
  120314. GAMMALIGHTMAP: boolean;
  120315. RGBDLIGHTMAP: boolean;
  120316. REFLECTION: boolean;
  120317. REFLECTIONMAP_3D: boolean;
  120318. REFLECTIONMAP_SPHERICAL: boolean;
  120319. REFLECTIONMAP_PLANAR: boolean;
  120320. REFLECTIONMAP_CUBIC: boolean;
  120321. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  120322. REFLECTIONMAP_PROJECTION: boolean;
  120323. REFLECTIONMAP_SKYBOX: boolean;
  120324. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  120325. REFLECTIONMAP_EXPLICIT: boolean;
  120326. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  120327. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  120328. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  120329. INVERTCUBICMAP: boolean;
  120330. USESPHERICALFROMREFLECTIONMAP: boolean;
  120331. USEIRRADIANCEMAP: boolean;
  120332. SPHERICAL_HARMONICS: boolean;
  120333. USESPHERICALINVERTEX: boolean;
  120334. REFLECTIONMAP_OPPOSITEZ: boolean;
  120335. LODINREFLECTIONALPHA: boolean;
  120336. GAMMAREFLECTION: boolean;
  120337. RGBDREFLECTION: boolean;
  120338. LINEARSPECULARREFLECTION: boolean;
  120339. RADIANCEOCCLUSION: boolean;
  120340. HORIZONOCCLUSION: boolean;
  120341. INSTANCES: boolean;
  120342. NUM_BONE_INFLUENCERS: number;
  120343. BonesPerMesh: number;
  120344. BONETEXTURE: boolean;
  120345. NONUNIFORMSCALING: boolean;
  120346. MORPHTARGETS: boolean;
  120347. MORPHTARGETS_NORMAL: boolean;
  120348. MORPHTARGETS_TANGENT: boolean;
  120349. MORPHTARGETS_UV: boolean;
  120350. NUM_MORPH_INFLUENCERS: number;
  120351. IMAGEPROCESSING: boolean;
  120352. VIGNETTE: boolean;
  120353. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120354. VIGNETTEBLENDMODEOPAQUE: boolean;
  120355. TONEMAPPING: boolean;
  120356. TONEMAPPING_ACES: boolean;
  120357. CONTRAST: boolean;
  120358. COLORCURVES: boolean;
  120359. COLORGRADING: boolean;
  120360. COLORGRADING3D: boolean;
  120361. SAMPLER3DGREENDEPTH: boolean;
  120362. SAMPLER3DBGRMAP: boolean;
  120363. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120364. EXPOSURE: boolean;
  120365. MULTIVIEW: boolean;
  120366. USEPHYSICALLIGHTFALLOFF: boolean;
  120367. USEGLTFLIGHTFALLOFF: boolean;
  120368. TWOSIDEDLIGHTING: boolean;
  120369. SHADOWFLOAT: boolean;
  120370. CLIPPLANE: boolean;
  120371. CLIPPLANE2: boolean;
  120372. CLIPPLANE3: boolean;
  120373. CLIPPLANE4: boolean;
  120374. POINTSIZE: boolean;
  120375. FOG: boolean;
  120376. LOGARITHMICDEPTH: boolean;
  120377. FORCENORMALFORWARD: boolean;
  120378. SPECULARAA: boolean;
  120379. CLEARCOAT: boolean;
  120380. CLEARCOAT_DEFAULTIOR: boolean;
  120381. CLEARCOAT_TEXTURE: boolean;
  120382. CLEARCOAT_TEXTUREDIRECTUV: number;
  120383. CLEARCOAT_BUMP: boolean;
  120384. CLEARCOAT_BUMPDIRECTUV: number;
  120385. CLEARCOAT_TINT: boolean;
  120386. CLEARCOAT_TINT_TEXTURE: boolean;
  120387. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  120388. ANISOTROPIC: boolean;
  120389. ANISOTROPIC_TEXTURE: boolean;
  120390. ANISOTROPIC_TEXTUREDIRECTUV: number;
  120391. BRDF_V_HEIGHT_CORRELATED: boolean;
  120392. MS_BRDF_ENERGY_CONSERVATION: boolean;
  120393. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  120394. SHEEN: boolean;
  120395. SHEEN_TEXTURE: boolean;
  120396. SHEEN_TEXTUREDIRECTUV: number;
  120397. SHEEN_LINKWITHALBEDO: boolean;
  120398. SUBSURFACE: boolean;
  120399. SS_REFRACTION: boolean;
  120400. SS_TRANSLUCENCY: boolean;
  120401. SS_SCATERRING: boolean;
  120402. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120403. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120404. SS_REFRACTIONMAP_3D: boolean;
  120405. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120406. SS_LODINREFRACTIONALPHA: boolean;
  120407. SS_GAMMAREFRACTION: boolean;
  120408. SS_RGBDREFRACTION: boolean;
  120409. SS_LINEARSPECULARREFRACTION: boolean;
  120410. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120411. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120412. UNLIT: boolean;
  120413. DEBUGMODE: number;
  120414. /**
  120415. * Initializes the PBR Material defines.
  120416. */
  120417. constructor();
  120418. /**
  120419. * Resets the PBR Material defines.
  120420. */
  120421. reset(): void;
  120422. }
  120423. /**
  120424. * The Physically based material base class of BJS.
  120425. *
  120426. * This offers the main features of a standard PBR material.
  120427. * For more information, please refer to the documentation :
  120428. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120429. */
  120430. export abstract class PBRBaseMaterial extends PushMaterial {
  120431. /**
  120432. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120433. */
  120434. static readonly PBRMATERIAL_OPAQUE: number;
  120435. /**
  120436. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120437. */
  120438. static readonly PBRMATERIAL_ALPHATEST: number;
  120439. /**
  120440. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120441. */
  120442. static readonly PBRMATERIAL_ALPHABLEND: number;
  120443. /**
  120444. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120445. * They are also discarded below the alpha cutoff threshold to improve performances.
  120446. */
  120447. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120448. /**
  120449. * Defines the default value of how much AO map is occluding the analytical lights
  120450. * (point spot...).
  120451. */
  120452. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120453. /**
  120454. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  120455. */
  120456. static readonly LIGHTFALLOFF_PHYSICAL: number;
  120457. /**
  120458. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  120459. * to enhance interoperability with other engines.
  120460. */
  120461. static readonly LIGHTFALLOFF_GLTF: number;
  120462. /**
  120463. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  120464. * to enhance interoperability with other materials.
  120465. */
  120466. static readonly LIGHTFALLOFF_STANDARD: number;
  120467. /**
  120468. * Intensity of the direct lights e.g. the four lights available in your scene.
  120469. * This impacts both the direct diffuse and specular highlights.
  120470. */
  120471. protected _directIntensity: number;
  120472. /**
  120473. * Intensity of the emissive part of the material.
  120474. * This helps controlling the emissive effect without modifying the emissive color.
  120475. */
  120476. protected _emissiveIntensity: number;
  120477. /**
  120478. * Intensity of the environment e.g. how much the environment will light the object
  120479. * either through harmonics for rough material or through the refelction for shiny ones.
  120480. */
  120481. protected _environmentIntensity: number;
  120482. /**
  120483. * This is a special control allowing the reduction of the specular highlights coming from the
  120484. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  120485. */
  120486. protected _specularIntensity: number;
  120487. /**
  120488. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  120489. */
  120490. private _lightingInfos;
  120491. /**
  120492. * Debug Control allowing disabling the bump map on this material.
  120493. */
  120494. protected _disableBumpMap: boolean;
  120495. /**
  120496. * AKA Diffuse Texture in standard nomenclature.
  120497. */
  120498. protected _albedoTexture: Nullable<BaseTexture>;
  120499. /**
  120500. * AKA Occlusion Texture in other nomenclature.
  120501. */
  120502. protected _ambientTexture: Nullable<BaseTexture>;
  120503. /**
  120504. * AKA Occlusion Texture Intensity in other nomenclature.
  120505. */
  120506. protected _ambientTextureStrength: number;
  120507. /**
  120508. * Defines how much the AO map is occluding the analytical lights (point spot...).
  120509. * 1 means it completely occludes it
  120510. * 0 mean it has no impact
  120511. */
  120512. protected _ambientTextureImpactOnAnalyticalLights: number;
  120513. /**
  120514. * Stores the alpha values in a texture.
  120515. */
  120516. protected _opacityTexture: Nullable<BaseTexture>;
  120517. /**
  120518. * Stores the reflection values in a texture.
  120519. */
  120520. protected _reflectionTexture: Nullable<BaseTexture>;
  120521. /**
  120522. * Stores the emissive values in a texture.
  120523. */
  120524. protected _emissiveTexture: Nullable<BaseTexture>;
  120525. /**
  120526. * AKA Specular texture in other nomenclature.
  120527. */
  120528. protected _reflectivityTexture: Nullable<BaseTexture>;
  120529. /**
  120530. * Used to switch from specular/glossiness to metallic/roughness workflow.
  120531. */
  120532. protected _metallicTexture: Nullable<BaseTexture>;
  120533. /**
  120534. * Specifies the metallic scalar of the metallic/roughness workflow.
  120535. * Can also be used to scale the metalness values of the metallic texture.
  120536. */
  120537. protected _metallic: Nullable<number>;
  120538. /**
  120539. * Specifies the roughness scalar of the metallic/roughness workflow.
  120540. * Can also be used to scale the roughness values of the metallic texture.
  120541. */
  120542. protected _roughness: Nullable<number>;
  120543. /**
  120544. * Specifies the an F0 factor to help configuring the material F0.
  120545. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  120546. * to 0.5 the previously hard coded value stays the same.
  120547. * Can also be used to scale the F0 values of the metallic texture.
  120548. */
  120549. protected _metallicF0Factor: number;
  120550. /**
  120551. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  120552. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  120553. * your expectation as it multiplies with the texture data.
  120554. */
  120555. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  120556. /**
  120557. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  120558. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  120559. */
  120560. protected _microSurfaceTexture: Nullable<BaseTexture>;
  120561. /**
  120562. * Stores surface normal data used to displace a mesh in a texture.
  120563. */
  120564. protected _bumpTexture: Nullable<BaseTexture>;
  120565. /**
  120566. * Stores the pre-calculated light information of a mesh in a texture.
  120567. */
  120568. protected _lightmapTexture: Nullable<BaseTexture>;
  120569. /**
  120570. * The color of a material in ambient lighting.
  120571. */
  120572. protected _ambientColor: Color3;
  120573. /**
  120574. * AKA Diffuse Color in other nomenclature.
  120575. */
  120576. protected _albedoColor: Color3;
  120577. /**
  120578. * AKA Specular Color in other nomenclature.
  120579. */
  120580. protected _reflectivityColor: Color3;
  120581. /**
  120582. * The color applied when light is reflected from a material.
  120583. */
  120584. protected _reflectionColor: Color3;
  120585. /**
  120586. * The color applied when light is emitted from a material.
  120587. */
  120588. protected _emissiveColor: Color3;
  120589. /**
  120590. * AKA Glossiness in other nomenclature.
  120591. */
  120592. protected _microSurface: number;
  120593. /**
  120594. * Specifies that the material will use the light map as a show map.
  120595. */
  120596. protected _useLightmapAsShadowmap: boolean;
  120597. /**
  120598. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  120599. * makes the reflect vector face the model (under horizon).
  120600. */
  120601. protected _useHorizonOcclusion: boolean;
  120602. /**
  120603. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  120604. * too much the area relying on ambient texture to define their ambient occlusion.
  120605. */
  120606. protected _useRadianceOcclusion: boolean;
  120607. /**
  120608. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  120609. */
  120610. protected _useAlphaFromAlbedoTexture: boolean;
  120611. /**
  120612. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  120613. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  120614. */
  120615. protected _useSpecularOverAlpha: boolean;
  120616. /**
  120617. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  120618. */
  120619. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  120620. /**
  120621. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  120622. */
  120623. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  120624. /**
  120625. * Specifies if the metallic texture contains the roughness information in its green channel.
  120626. */
  120627. protected _useRoughnessFromMetallicTextureGreen: boolean;
  120628. /**
  120629. * Specifies if the metallic texture contains the metallness information in its blue channel.
  120630. */
  120631. protected _useMetallnessFromMetallicTextureBlue: boolean;
  120632. /**
  120633. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  120634. */
  120635. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  120636. /**
  120637. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  120638. */
  120639. protected _useAmbientInGrayScale: boolean;
  120640. /**
  120641. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  120642. * The material will try to infer what glossiness each pixel should be.
  120643. */
  120644. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  120645. /**
  120646. * Defines the falloff type used in this material.
  120647. * It by default is Physical.
  120648. */
  120649. protected _lightFalloff: number;
  120650. /**
  120651. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  120652. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  120653. */
  120654. protected _useRadianceOverAlpha: boolean;
  120655. /**
  120656. * Allows using an object space normal map (instead of tangent space).
  120657. */
  120658. protected _useObjectSpaceNormalMap: boolean;
  120659. /**
  120660. * Allows using the bump map in parallax mode.
  120661. */
  120662. protected _useParallax: boolean;
  120663. /**
  120664. * Allows using the bump map in parallax occlusion mode.
  120665. */
  120666. protected _useParallaxOcclusion: boolean;
  120667. /**
  120668. * Controls the scale bias of the parallax mode.
  120669. */
  120670. protected _parallaxScaleBias: number;
  120671. /**
  120672. * If sets to true, disables all the lights affecting the material.
  120673. */
  120674. protected _disableLighting: boolean;
  120675. /**
  120676. * Number of Simultaneous lights allowed on the material.
  120677. */
  120678. protected _maxSimultaneousLights: number;
  120679. /**
  120680. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  120681. */
  120682. protected _invertNormalMapX: boolean;
  120683. /**
  120684. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  120685. */
  120686. protected _invertNormalMapY: boolean;
  120687. /**
  120688. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120689. */
  120690. protected _twoSidedLighting: boolean;
  120691. /**
  120692. * Defines the alpha limits in alpha test mode.
  120693. */
  120694. protected _alphaCutOff: number;
  120695. /**
  120696. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  120697. */
  120698. protected _forceAlphaTest: boolean;
  120699. /**
  120700. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120701. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  120702. */
  120703. protected _useAlphaFresnel: boolean;
  120704. /**
  120705. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120706. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  120707. */
  120708. protected _useLinearAlphaFresnel: boolean;
  120709. /**
  120710. * The transparency mode of the material.
  120711. */
  120712. protected _transparencyMode: Nullable<number>;
  120713. /**
  120714. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  120715. * from cos thetav and roughness:
  120716. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  120717. */
  120718. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  120719. /**
  120720. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  120721. */
  120722. protected _forceIrradianceInFragment: boolean;
  120723. /**
  120724. * Force normal to face away from face.
  120725. */
  120726. protected _forceNormalForward: boolean;
  120727. /**
  120728. * Enables specular anti aliasing in the PBR shader.
  120729. * It will both interacts on the Geometry for analytical and IBL lighting.
  120730. * It also prefilter the roughness map based on the bump values.
  120731. */
  120732. protected _enableSpecularAntiAliasing: boolean;
  120733. /**
  120734. * Default configuration related to image processing available in the PBR Material.
  120735. */
  120736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120737. /**
  120738. * Keep track of the image processing observer to allow dispose and replace.
  120739. */
  120740. private _imageProcessingObserver;
  120741. /**
  120742. * Attaches a new image processing configuration to the PBR Material.
  120743. * @param configuration
  120744. */
  120745. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120746. /**
  120747. * Stores the available render targets.
  120748. */
  120749. private _renderTargets;
  120750. /**
  120751. * Sets the global ambient color for the material used in lighting calculations.
  120752. */
  120753. private _globalAmbientColor;
  120754. /**
  120755. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  120756. */
  120757. private _useLogarithmicDepth;
  120758. /**
  120759. * If set to true, no lighting calculations will be applied.
  120760. */
  120761. private _unlit;
  120762. private _debugMode;
  120763. /**
  120764. * @hidden
  120765. * This is reserved for the inspector.
  120766. * Defines the material debug mode.
  120767. * It helps seeing only some components of the material while troubleshooting.
  120768. */
  120769. debugMode: number;
  120770. /**
  120771. * @hidden
  120772. * This is reserved for the inspector.
  120773. * Specify from where on screen the debug mode should start.
  120774. * The value goes from -1 (full screen) to 1 (not visible)
  120775. * It helps with side by side comparison against the final render
  120776. * This defaults to -1
  120777. */
  120778. private debugLimit;
  120779. /**
  120780. * @hidden
  120781. * This is reserved for the inspector.
  120782. * As the default viewing range might not be enough (if the ambient is really small for instance)
  120783. * You can use the factor to better multiply the final value.
  120784. */
  120785. private debugFactor;
  120786. /**
  120787. * Defines the clear coat layer parameters for the material.
  120788. */
  120789. readonly clearCoat: PBRClearCoatConfiguration;
  120790. /**
  120791. * Defines the anisotropic parameters for the material.
  120792. */
  120793. readonly anisotropy: PBRAnisotropicConfiguration;
  120794. /**
  120795. * Defines the BRDF parameters for the material.
  120796. */
  120797. readonly brdf: PBRBRDFConfiguration;
  120798. /**
  120799. * Defines the Sheen parameters for the material.
  120800. */
  120801. readonly sheen: PBRSheenConfiguration;
  120802. /**
  120803. * Defines the SubSurface parameters for the material.
  120804. */
  120805. readonly subSurface: PBRSubSurfaceConfiguration;
  120806. /**
  120807. * Custom callback helping to override the default shader used in the material.
  120808. */
  120809. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  120810. protected _rebuildInParallel: boolean;
  120811. /**
  120812. * Instantiates a new PBRMaterial instance.
  120813. *
  120814. * @param name The material name
  120815. * @param scene The scene the material will be use in.
  120816. */
  120817. constructor(name: string, scene: Scene);
  120818. /**
  120819. * Gets a boolean indicating that current material needs to register RTT
  120820. */
  120821. get hasRenderTargetTextures(): boolean;
  120822. /**
  120823. * Gets the name of the material class.
  120824. */
  120825. getClassName(): string;
  120826. /**
  120827. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120828. */
  120829. get useLogarithmicDepth(): boolean;
  120830. /**
  120831. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120832. */
  120833. set useLogarithmicDepth(value: boolean);
  120834. /**
  120835. * Gets the current transparency mode.
  120836. */
  120837. get transparencyMode(): Nullable<number>;
  120838. /**
  120839. * Sets the transparency mode of the material.
  120840. *
  120841. * | Value | Type | Description |
  120842. * | ----- | ----------------------------------- | ----------- |
  120843. * | 0 | OPAQUE | |
  120844. * | 1 | ALPHATEST | |
  120845. * | 2 | ALPHABLEND | |
  120846. * | 3 | ALPHATESTANDBLEND | |
  120847. *
  120848. */
  120849. set transparencyMode(value: Nullable<number>);
  120850. /**
  120851. * Returns true if alpha blending should be disabled.
  120852. */
  120853. private get _disableAlphaBlending();
  120854. /**
  120855. * Specifies whether or not this material should be rendered in alpha blend mode.
  120856. */
  120857. needAlphaBlending(): boolean;
  120858. /**
  120859. * Specifies if the mesh will require alpha blending.
  120860. * @param mesh - BJS mesh.
  120861. */
  120862. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  120863. /**
  120864. * Specifies whether or not this material should be rendered in alpha test mode.
  120865. */
  120866. needAlphaTesting(): boolean;
  120867. /**
  120868. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  120869. */
  120870. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  120871. /**
  120872. * Gets the texture used for the alpha test.
  120873. */
  120874. getAlphaTestTexture(): Nullable<BaseTexture>;
  120875. /**
  120876. * Specifies that the submesh is ready to be used.
  120877. * @param mesh - BJS mesh.
  120878. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  120879. * @param useInstances - Specifies that instances should be used.
  120880. * @returns - boolean indicating that the submesh is ready or not.
  120881. */
  120882. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120883. /**
  120884. * Specifies if the material uses metallic roughness workflow.
  120885. * @returns boolean specifiying if the material uses metallic roughness workflow.
  120886. */
  120887. isMetallicWorkflow(): boolean;
  120888. private _prepareEffect;
  120889. private _prepareDefines;
  120890. /**
  120891. * Force shader compilation
  120892. */
  120893. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  120894. /**
  120895. * Initializes the uniform buffer layout for the shader.
  120896. */
  120897. buildUniformLayout(): void;
  120898. /**
  120899. * Unbinds the material from the mesh
  120900. */
  120901. unbind(): void;
  120902. /**
  120903. * Binds the submesh data.
  120904. * @param world - The world matrix.
  120905. * @param mesh - The BJS mesh.
  120906. * @param subMesh - A submesh of the BJS mesh.
  120907. */
  120908. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120909. /**
  120910. * Returns the animatable textures.
  120911. * @returns - Array of animatable textures.
  120912. */
  120913. getAnimatables(): IAnimatable[];
  120914. /**
  120915. * Returns the texture used for reflections.
  120916. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  120917. */
  120918. private _getReflectionTexture;
  120919. /**
  120920. * Returns an array of the actively used textures.
  120921. * @returns - Array of BaseTextures
  120922. */
  120923. getActiveTextures(): BaseTexture[];
  120924. /**
  120925. * Checks to see if a texture is used in the material.
  120926. * @param texture - Base texture to use.
  120927. * @returns - Boolean specifying if a texture is used in the material.
  120928. */
  120929. hasTexture(texture: BaseTexture): boolean;
  120930. /**
  120931. * Disposes the resources of the material.
  120932. * @param forceDisposeEffect - Forces the disposal of effects.
  120933. * @param forceDisposeTextures - Forces the disposal of all textures.
  120934. */
  120935. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  120936. }
  120937. }
  120938. declare module BABYLON {
  120939. /**
  120940. * The Physically based material of BJS.
  120941. *
  120942. * This offers the main features of a standard PBR material.
  120943. * For more information, please refer to the documentation :
  120944. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120945. */
  120946. export class PBRMaterial extends PBRBaseMaterial {
  120947. /**
  120948. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120949. */
  120950. static readonly PBRMATERIAL_OPAQUE: number;
  120951. /**
  120952. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120953. */
  120954. static readonly PBRMATERIAL_ALPHATEST: number;
  120955. /**
  120956. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120957. */
  120958. static readonly PBRMATERIAL_ALPHABLEND: number;
  120959. /**
  120960. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120961. * They are also discarded below the alpha cutoff threshold to improve performances.
  120962. */
  120963. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120964. /**
  120965. * Defines the default value of how much AO map is occluding the analytical lights
  120966. * (point spot...).
  120967. */
  120968. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120969. /**
  120970. * Intensity of the direct lights e.g. the four lights available in your scene.
  120971. * This impacts both the direct diffuse and specular highlights.
  120972. */
  120973. directIntensity: number;
  120974. /**
  120975. * Intensity of the emissive part of the material.
  120976. * This helps controlling the emissive effect without modifying the emissive color.
  120977. */
  120978. emissiveIntensity: number;
  120979. /**
  120980. * Intensity of the environment e.g. how much the environment will light the object
  120981. * either through harmonics for rough material or through the refelction for shiny ones.
  120982. */
  120983. environmentIntensity: number;
  120984. /**
  120985. * This is a special control allowing the reduction of the specular highlights coming from the
  120986. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  120987. */
  120988. specularIntensity: number;
  120989. /**
  120990. * Debug Control allowing disabling the bump map on this material.
  120991. */
  120992. disableBumpMap: boolean;
  120993. /**
  120994. * AKA Diffuse Texture in standard nomenclature.
  120995. */
  120996. albedoTexture: BaseTexture;
  120997. /**
  120998. * AKA Occlusion Texture in other nomenclature.
  120999. */
  121000. ambientTexture: BaseTexture;
  121001. /**
  121002. * AKA Occlusion Texture Intensity in other nomenclature.
  121003. */
  121004. ambientTextureStrength: number;
  121005. /**
  121006. * Defines how much the AO map is occluding the analytical lights (point spot...).
  121007. * 1 means it completely occludes it
  121008. * 0 mean it has no impact
  121009. */
  121010. ambientTextureImpactOnAnalyticalLights: number;
  121011. /**
  121012. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  121013. */
  121014. opacityTexture: BaseTexture;
  121015. /**
  121016. * Stores the reflection values in a texture.
  121017. */
  121018. reflectionTexture: Nullable<BaseTexture>;
  121019. /**
  121020. * Stores the emissive values in a texture.
  121021. */
  121022. emissiveTexture: BaseTexture;
  121023. /**
  121024. * AKA Specular texture in other nomenclature.
  121025. */
  121026. reflectivityTexture: BaseTexture;
  121027. /**
  121028. * Used to switch from specular/glossiness to metallic/roughness workflow.
  121029. */
  121030. metallicTexture: BaseTexture;
  121031. /**
  121032. * Specifies the metallic scalar of the metallic/roughness workflow.
  121033. * Can also be used to scale the metalness values of the metallic texture.
  121034. */
  121035. metallic: Nullable<number>;
  121036. /**
  121037. * Specifies the roughness scalar of the metallic/roughness workflow.
  121038. * Can also be used to scale the roughness values of the metallic texture.
  121039. */
  121040. roughness: Nullable<number>;
  121041. /**
  121042. * Specifies the an F0 factor to help configuring the material F0.
  121043. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  121044. * to 0.5 the previously hard coded value stays the same.
  121045. * Can also be used to scale the F0 values of the metallic texture.
  121046. */
  121047. metallicF0Factor: number;
  121048. /**
  121049. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  121050. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  121051. * your expectation as it multiplies with the texture data.
  121052. */
  121053. useMetallicF0FactorFromMetallicTexture: boolean;
  121054. /**
  121055. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  121056. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  121057. */
  121058. microSurfaceTexture: BaseTexture;
  121059. /**
  121060. * Stores surface normal data used to displace a mesh in a texture.
  121061. */
  121062. bumpTexture: BaseTexture;
  121063. /**
  121064. * Stores the pre-calculated light information of a mesh in a texture.
  121065. */
  121066. lightmapTexture: BaseTexture;
  121067. /**
  121068. * Stores the refracted light information in a texture.
  121069. */
  121070. get refractionTexture(): Nullable<BaseTexture>;
  121071. set refractionTexture(value: Nullable<BaseTexture>);
  121072. /**
  121073. * The color of a material in ambient lighting.
  121074. */
  121075. ambientColor: Color3;
  121076. /**
  121077. * AKA Diffuse Color in other nomenclature.
  121078. */
  121079. albedoColor: Color3;
  121080. /**
  121081. * AKA Specular Color in other nomenclature.
  121082. */
  121083. reflectivityColor: Color3;
  121084. /**
  121085. * The color reflected from the material.
  121086. */
  121087. reflectionColor: Color3;
  121088. /**
  121089. * The color emitted from the material.
  121090. */
  121091. emissiveColor: Color3;
  121092. /**
  121093. * AKA Glossiness in other nomenclature.
  121094. */
  121095. microSurface: number;
  121096. /**
  121097. * source material index of refraction (IOR)' / 'destination material IOR.
  121098. */
  121099. get indexOfRefraction(): number;
  121100. set indexOfRefraction(value: number);
  121101. /**
  121102. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121103. */
  121104. get invertRefractionY(): boolean;
  121105. set invertRefractionY(value: boolean);
  121106. /**
  121107. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121108. * Materials half opaque for instance using refraction could benefit from this control.
  121109. */
  121110. get linkRefractionWithTransparency(): boolean;
  121111. set linkRefractionWithTransparency(value: boolean);
  121112. /**
  121113. * If true, the light map contains occlusion information instead of lighting info.
  121114. */
  121115. useLightmapAsShadowmap: boolean;
  121116. /**
  121117. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  121118. */
  121119. useAlphaFromAlbedoTexture: boolean;
  121120. /**
  121121. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  121122. */
  121123. forceAlphaTest: boolean;
  121124. /**
  121125. * Defines the alpha limits in alpha test mode.
  121126. */
  121127. alphaCutOff: number;
  121128. /**
  121129. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  121130. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  121131. */
  121132. useSpecularOverAlpha: boolean;
  121133. /**
  121134. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  121135. */
  121136. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  121137. /**
  121138. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  121139. */
  121140. useRoughnessFromMetallicTextureAlpha: boolean;
  121141. /**
  121142. * Specifies if the metallic texture contains the roughness information in its green channel.
  121143. */
  121144. useRoughnessFromMetallicTextureGreen: boolean;
  121145. /**
  121146. * Specifies if the metallic texture contains the metallness information in its blue channel.
  121147. */
  121148. useMetallnessFromMetallicTextureBlue: boolean;
  121149. /**
  121150. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  121151. */
  121152. useAmbientOcclusionFromMetallicTextureRed: boolean;
  121153. /**
  121154. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  121155. */
  121156. useAmbientInGrayScale: boolean;
  121157. /**
  121158. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  121159. * The material will try to infer what glossiness each pixel should be.
  121160. */
  121161. useAutoMicroSurfaceFromReflectivityMap: boolean;
  121162. /**
  121163. * BJS is using an harcoded light falloff based on a manually sets up range.
  121164. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121165. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121166. */
  121167. get usePhysicalLightFalloff(): boolean;
  121168. /**
  121169. * BJS is using an harcoded light falloff based on a manually sets up range.
  121170. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121171. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121172. */
  121173. set usePhysicalLightFalloff(value: boolean);
  121174. /**
  121175. * In order to support the falloff compatibility with gltf, a special mode has been added
  121176. * to reproduce the gltf light falloff.
  121177. */
  121178. get useGLTFLightFalloff(): boolean;
  121179. /**
  121180. * In order to support the falloff compatibility with gltf, a special mode has been added
  121181. * to reproduce the gltf light falloff.
  121182. */
  121183. set useGLTFLightFalloff(value: boolean);
  121184. /**
  121185. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  121186. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  121187. */
  121188. useRadianceOverAlpha: boolean;
  121189. /**
  121190. * Allows using an object space normal map (instead of tangent space).
  121191. */
  121192. useObjectSpaceNormalMap: boolean;
  121193. /**
  121194. * Allows using the bump map in parallax mode.
  121195. */
  121196. useParallax: boolean;
  121197. /**
  121198. * Allows using the bump map in parallax occlusion mode.
  121199. */
  121200. useParallaxOcclusion: boolean;
  121201. /**
  121202. * Controls the scale bias of the parallax mode.
  121203. */
  121204. parallaxScaleBias: number;
  121205. /**
  121206. * If sets to true, disables all the lights affecting the material.
  121207. */
  121208. disableLighting: boolean;
  121209. /**
  121210. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  121211. */
  121212. forceIrradianceInFragment: boolean;
  121213. /**
  121214. * Number of Simultaneous lights allowed on the material.
  121215. */
  121216. maxSimultaneousLights: number;
  121217. /**
  121218. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121219. */
  121220. invertNormalMapX: boolean;
  121221. /**
  121222. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121223. */
  121224. invertNormalMapY: boolean;
  121225. /**
  121226. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121227. */
  121228. twoSidedLighting: boolean;
  121229. /**
  121230. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121231. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  121232. */
  121233. useAlphaFresnel: boolean;
  121234. /**
  121235. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121236. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  121237. */
  121238. useLinearAlphaFresnel: boolean;
  121239. /**
  121240. * Let user defines the brdf lookup texture used for IBL.
  121241. * A default 8bit version is embedded but you could point at :
  121242. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  121243. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  121244. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  121245. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  121246. */
  121247. environmentBRDFTexture: Nullable<BaseTexture>;
  121248. /**
  121249. * Force normal to face away from face.
  121250. */
  121251. forceNormalForward: boolean;
  121252. /**
  121253. * Enables specular anti aliasing in the PBR shader.
  121254. * It will both interacts on the Geometry for analytical and IBL lighting.
  121255. * It also prefilter the roughness map based on the bump values.
  121256. */
  121257. enableSpecularAntiAliasing: boolean;
  121258. /**
  121259. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  121260. * makes the reflect vector face the model (under horizon).
  121261. */
  121262. useHorizonOcclusion: boolean;
  121263. /**
  121264. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  121265. * too much the area relying on ambient texture to define their ambient occlusion.
  121266. */
  121267. useRadianceOcclusion: boolean;
  121268. /**
  121269. * If set to true, no lighting calculations will be applied.
  121270. */
  121271. unlit: boolean;
  121272. /**
  121273. * Gets the image processing configuration used either in this material.
  121274. */
  121275. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  121276. /**
  121277. * Sets the Default image processing configuration used either in the this material.
  121278. *
  121279. * If sets to null, the scene one is in use.
  121280. */
  121281. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  121282. /**
  121283. * Gets wether the color curves effect is enabled.
  121284. */
  121285. get cameraColorCurvesEnabled(): boolean;
  121286. /**
  121287. * Sets wether the color curves effect is enabled.
  121288. */
  121289. set cameraColorCurvesEnabled(value: boolean);
  121290. /**
  121291. * Gets wether the color grading effect is enabled.
  121292. */
  121293. get cameraColorGradingEnabled(): boolean;
  121294. /**
  121295. * Gets wether the color grading effect is enabled.
  121296. */
  121297. set cameraColorGradingEnabled(value: boolean);
  121298. /**
  121299. * Gets wether tonemapping is enabled or not.
  121300. */
  121301. get cameraToneMappingEnabled(): boolean;
  121302. /**
  121303. * Sets wether tonemapping is enabled or not
  121304. */
  121305. set cameraToneMappingEnabled(value: boolean);
  121306. /**
  121307. * The camera exposure used on this material.
  121308. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121309. * This corresponds to a photographic exposure.
  121310. */
  121311. get cameraExposure(): number;
  121312. /**
  121313. * The camera exposure used on this material.
  121314. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121315. * This corresponds to a photographic exposure.
  121316. */
  121317. set cameraExposure(value: number);
  121318. /**
  121319. * Gets The camera contrast used on this material.
  121320. */
  121321. get cameraContrast(): number;
  121322. /**
  121323. * Sets The camera contrast used on this material.
  121324. */
  121325. set cameraContrast(value: number);
  121326. /**
  121327. * Gets the Color Grading 2D Lookup Texture.
  121328. */
  121329. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  121330. /**
  121331. * Sets the Color Grading 2D Lookup Texture.
  121332. */
  121333. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  121334. /**
  121335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121337. * 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;
  121338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121339. */
  121340. get cameraColorCurves(): Nullable<ColorCurves>;
  121341. /**
  121342. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121343. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121344. * 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;
  121345. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121346. */
  121347. set cameraColorCurves(value: Nullable<ColorCurves>);
  121348. /**
  121349. * Instantiates a new PBRMaterial instance.
  121350. *
  121351. * @param name The material name
  121352. * @param scene The scene the material will be use in.
  121353. */
  121354. constructor(name: string, scene: Scene);
  121355. /**
  121356. * Returns the name of this material class.
  121357. */
  121358. getClassName(): string;
  121359. /**
  121360. * Makes a duplicate of the current material.
  121361. * @param name - name to use for the new material.
  121362. */
  121363. clone(name: string): PBRMaterial;
  121364. /**
  121365. * Serializes this PBR Material.
  121366. * @returns - An object with the serialized material.
  121367. */
  121368. serialize(): any;
  121369. /**
  121370. * Parses a PBR Material from a serialized object.
  121371. * @param source - Serialized object.
  121372. * @param scene - BJS scene instance.
  121373. * @param rootUrl - url for the scene object
  121374. * @returns - PBRMaterial
  121375. */
  121376. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  121377. }
  121378. }
  121379. declare module BABYLON {
  121380. /**
  121381. * Direct draw surface info
  121382. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  121383. */
  121384. export interface DDSInfo {
  121385. /**
  121386. * Width of the texture
  121387. */
  121388. width: number;
  121389. /**
  121390. * Width of the texture
  121391. */
  121392. height: number;
  121393. /**
  121394. * Number of Mipmaps for the texture
  121395. * @see https://en.wikipedia.org/wiki/Mipmap
  121396. */
  121397. mipmapCount: number;
  121398. /**
  121399. * If the textures format is a known fourCC format
  121400. * @see https://www.fourcc.org/
  121401. */
  121402. isFourCC: boolean;
  121403. /**
  121404. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  121405. */
  121406. isRGB: boolean;
  121407. /**
  121408. * If the texture is a lumincance format
  121409. */
  121410. isLuminance: boolean;
  121411. /**
  121412. * If this is a cube texture
  121413. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  121414. */
  121415. isCube: boolean;
  121416. /**
  121417. * If the texture is a compressed format eg. FOURCC_DXT1
  121418. */
  121419. isCompressed: boolean;
  121420. /**
  121421. * The dxgiFormat of the texture
  121422. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  121423. */
  121424. dxgiFormat: number;
  121425. /**
  121426. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  121427. */
  121428. textureType: number;
  121429. /**
  121430. * Sphericle polynomial created for the dds texture
  121431. */
  121432. sphericalPolynomial?: SphericalPolynomial;
  121433. }
  121434. /**
  121435. * Class used to provide DDS decompression tools
  121436. */
  121437. export class DDSTools {
  121438. /**
  121439. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  121440. */
  121441. static StoreLODInAlphaChannel: boolean;
  121442. /**
  121443. * Gets DDS information from an array buffer
  121444. * @param arrayBuffer defines the array buffer to read data from
  121445. * @returns the DDS information
  121446. */
  121447. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  121448. private static _FloatView;
  121449. private static _Int32View;
  121450. private static _ToHalfFloat;
  121451. private static _FromHalfFloat;
  121452. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  121453. private static _GetHalfFloatRGBAArrayBuffer;
  121454. private static _GetFloatRGBAArrayBuffer;
  121455. private static _GetFloatAsUIntRGBAArrayBuffer;
  121456. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  121457. private static _GetRGBAArrayBuffer;
  121458. private static _ExtractLongWordOrder;
  121459. private static _GetRGBArrayBuffer;
  121460. private static _GetLuminanceArrayBuffer;
  121461. /**
  121462. * Uploads DDS Levels to a Babylon Texture
  121463. * @hidden
  121464. */
  121465. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  121466. }
  121467. interface ThinEngine {
  121468. /**
  121469. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  121470. * @param rootUrl defines the url where the file to load is located
  121471. * @param scene defines the current scene
  121472. * @param lodScale defines scale to apply to the mip map selection
  121473. * @param lodOffset defines offset to apply to the mip map selection
  121474. * @param onLoad defines an optional callback raised when the texture is loaded
  121475. * @param onError defines an optional callback raised if there is an issue to load the texture
  121476. * @param format defines the format of the data
  121477. * @param forcedExtension defines the extension to use to pick the right loader
  121478. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  121479. * @returns the cube texture as an InternalTexture
  121480. */
  121481. 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;
  121482. }
  121483. }
  121484. declare module BABYLON {
  121485. /**
  121486. * Implementation of the DDS Texture Loader.
  121487. * @hidden
  121488. */
  121489. export class _DDSTextureLoader implements IInternalTextureLoader {
  121490. /**
  121491. * Defines wether the loader supports cascade loading the different faces.
  121492. */
  121493. readonly supportCascades: boolean;
  121494. /**
  121495. * This returns if the loader support the current file information.
  121496. * @param extension defines the file extension of the file being loaded
  121497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121498. * @param fallback defines the fallback internal texture if any
  121499. * @param isBase64 defines whether the texture is encoded as a base64
  121500. * @param isBuffer defines whether the texture data are stored as a buffer
  121501. * @returns true if the loader can load the specified file
  121502. */
  121503. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121504. /**
  121505. * Transform the url before loading if required.
  121506. * @param rootUrl the url of the texture
  121507. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121508. * @returns the transformed texture
  121509. */
  121510. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121511. /**
  121512. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121513. * @param rootUrl the url of the texture
  121514. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121515. * @returns the fallback texture
  121516. */
  121517. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121518. /**
  121519. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121520. * @param data contains the texture data
  121521. * @param texture defines the BabylonJS internal texture
  121522. * @param createPolynomials will be true if polynomials have been requested
  121523. * @param onLoad defines the callback to trigger once the texture is ready
  121524. * @param onError defines the callback to trigger in case of error
  121525. */
  121526. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121527. /**
  121528. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121529. * @param data contains the texture data
  121530. * @param texture defines the BabylonJS internal texture
  121531. * @param callback defines the method to call once ready to upload
  121532. */
  121533. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121534. }
  121535. }
  121536. declare module BABYLON {
  121537. /**
  121538. * Implementation of the ENV Texture Loader.
  121539. * @hidden
  121540. */
  121541. export class _ENVTextureLoader implements IInternalTextureLoader {
  121542. /**
  121543. * Defines wether the loader supports cascade loading the different faces.
  121544. */
  121545. readonly supportCascades: boolean;
  121546. /**
  121547. * This returns if the loader support the current file information.
  121548. * @param extension defines the file extension of the file being loaded
  121549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121550. * @param fallback defines the fallback internal texture if any
  121551. * @param isBase64 defines whether the texture is encoded as a base64
  121552. * @param isBuffer defines whether the texture data are stored as a buffer
  121553. * @returns true if the loader can load the specified file
  121554. */
  121555. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121556. /**
  121557. * Transform the url before loading if required.
  121558. * @param rootUrl the url of the texture
  121559. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121560. * @returns the transformed texture
  121561. */
  121562. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121563. /**
  121564. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121565. * @param rootUrl the url of the texture
  121566. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121567. * @returns the fallback texture
  121568. */
  121569. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121570. /**
  121571. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121572. * @param data contains the texture data
  121573. * @param texture defines the BabylonJS internal texture
  121574. * @param createPolynomials will be true if polynomials have been requested
  121575. * @param onLoad defines the callback to trigger once the texture is ready
  121576. * @param onError defines the callback to trigger in case of error
  121577. */
  121578. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121579. /**
  121580. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121581. * @param data contains the texture data
  121582. * @param texture defines the BabylonJS internal texture
  121583. * @param callback defines the method to call once ready to upload
  121584. */
  121585. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121586. }
  121587. }
  121588. declare module BABYLON {
  121589. /**
  121590. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121591. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121592. */
  121593. export class KhronosTextureContainer {
  121594. /** contents of the KTX container file */
  121595. arrayBuffer: any;
  121596. private static HEADER_LEN;
  121597. private static COMPRESSED_2D;
  121598. private static COMPRESSED_3D;
  121599. private static TEX_2D;
  121600. private static TEX_3D;
  121601. /**
  121602. * Gets the openGL type
  121603. */
  121604. glType: number;
  121605. /**
  121606. * Gets the openGL type size
  121607. */
  121608. glTypeSize: number;
  121609. /**
  121610. * Gets the openGL format
  121611. */
  121612. glFormat: number;
  121613. /**
  121614. * Gets the openGL internal format
  121615. */
  121616. glInternalFormat: number;
  121617. /**
  121618. * Gets the base internal format
  121619. */
  121620. glBaseInternalFormat: number;
  121621. /**
  121622. * Gets image width in pixel
  121623. */
  121624. pixelWidth: number;
  121625. /**
  121626. * Gets image height in pixel
  121627. */
  121628. pixelHeight: number;
  121629. /**
  121630. * Gets image depth in pixels
  121631. */
  121632. pixelDepth: number;
  121633. /**
  121634. * Gets the number of array elements
  121635. */
  121636. numberOfArrayElements: number;
  121637. /**
  121638. * Gets the number of faces
  121639. */
  121640. numberOfFaces: number;
  121641. /**
  121642. * Gets the number of mipmap levels
  121643. */
  121644. numberOfMipmapLevels: number;
  121645. /**
  121646. * Gets the bytes of key value data
  121647. */
  121648. bytesOfKeyValueData: number;
  121649. /**
  121650. * Gets the load type
  121651. */
  121652. loadType: number;
  121653. /**
  121654. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  121655. */
  121656. isInvalid: boolean;
  121657. /**
  121658. * Creates a new KhronosTextureContainer
  121659. * @param arrayBuffer contents of the KTX container file
  121660. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  121661. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  121662. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  121663. */
  121664. constructor(
  121665. /** contents of the KTX container file */
  121666. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  121667. /**
  121668. * Uploads KTX content to a Babylon Texture.
  121669. * It is assumed that the texture has already been created & is currently bound
  121670. * @hidden
  121671. */
  121672. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  121673. private _upload2DCompressedLevels;
  121674. }
  121675. }
  121676. declare module BABYLON {
  121677. /**
  121678. * Implementation of the KTX Texture Loader.
  121679. * @hidden
  121680. */
  121681. export class _KTXTextureLoader implements IInternalTextureLoader {
  121682. /**
  121683. * Defines wether the loader supports cascade loading the different faces.
  121684. */
  121685. readonly supportCascades: boolean;
  121686. /**
  121687. * This returns if the loader support the current file information.
  121688. * @param extension defines the file extension of the file being loaded
  121689. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121690. * @param fallback defines the fallback internal texture if any
  121691. * @param isBase64 defines whether the texture is encoded as a base64
  121692. * @param isBuffer defines whether the texture data are stored as a buffer
  121693. * @returns true if the loader can load the specified file
  121694. */
  121695. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121696. /**
  121697. * Transform the url before loading if required.
  121698. * @param rootUrl the url of the texture
  121699. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121700. * @returns the transformed texture
  121701. */
  121702. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121703. /**
  121704. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121705. * @param rootUrl the url of the texture
  121706. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121707. * @returns the fallback texture
  121708. */
  121709. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121710. /**
  121711. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121712. * @param data contains the texture data
  121713. * @param texture defines the BabylonJS internal texture
  121714. * @param createPolynomials will be true if polynomials have been requested
  121715. * @param onLoad defines the callback to trigger once the texture is ready
  121716. * @param onError defines the callback to trigger in case of error
  121717. */
  121718. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121719. /**
  121720. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121721. * @param data contains the texture data
  121722. * @param texture defines the BabylonJS internal texture
  121723. * @param callback defines the method to call once ready to upload
  121724. */
  121725. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  121726. }
  121727. }
  121728. declare module BABYLON {
  121729. /** @hidden */
  121730. export var _forceSceneHelpersToBundle: boolean;
  121731. interface Scene {
  121732. /**
  121733. * Creates a default light for the scene.
  121734. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  121735. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  121736. */
  121737. createDefaultLight(replace?: boolean): void;
  121738. /**
  121739. * Creates a default camera for the scene.
  121740. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  121741. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121742. * @param replace has default false, when true replaces the active camera in the scene
  121743. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  121744. */
  121745. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121746. /**
  121747. * Creates a default camera and a default light.
  121748. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  121749. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121750. * @param replace has the default false, when true replaces the active camera/light in the scene
  121751. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  121752. */
  121753. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121754. /**
  121755. * Creates a new sky box
  121756. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  121757. * @param environmentTexture defines the texture to use as environment texture
  121758. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  121759. * @param scale defines the overall scale of the skybox
  121760. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  121761. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  121762. * @returns a new mesh holding the sky box
  121763. */
  121764. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  121765. /**
  121766. * Creates a new environment
  121767. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  121768. * @param options defines the options you can use to configure the environment
  121769. * @returns the new EnvironmentHelper
  121770. */
  121771. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  121772. /**
  121773. * Creates a new VREXperienceHelper
  121774. * @see http://doc.babylonjs.com/how_to/webvr_helper
  121775. * @param webVROptions defines the options used to create the new VREXperienceHelper
  121776. * @returns a new VREXperienceHelper
  121777. */
  121778. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  121779. /**
  121780. * Creates a new WebXRDefaultExperience
  121781. * @see http://doc.babylonjs.com/how_to/webxr
  121782. * @param options experience options
  121783. * @returns a promise for a new WebXRDefaultExperience
  121784. */
  121785. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121786. }
  121787. }
  121788. declare module BABYLON {
  121789. /**
  121790. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  121791. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  121792. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  121793. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  121794. */
  121795. export class VideoDome extends TransformNode {
  121796. /**
  121797. * Define the video source as a Monoscopic panoramic 360 video.
  121798. */
  121799. static readonly MODE_MONOSCOPIC: number;
  121800. /**
  121801. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121802. */
  121803. static readonly MODE_TOPBOTTOM: number;
  121804. /**
  121805. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121806. */
  121807. static readonly MODE_SIDEBYSIDE: number;
  121808. private _halfDome;
  121809. private _useDirectMapping;
  121810. /**
  121811. * The video texture being displayed on the sphere
  121812. */
  121813. protected _videoTexture: VideoTexture;
  121814. /**
  121815. * Gets the video texture being displayed on the sphere
  121816. */
  121817. get videoTexture(): VideoTexture;
  121818. /**
  121819. * The skybox material
  121820. */
  121821. protected _material: BackgroundMaterial;
  121822. /**
  121823. * The surface used for the skybox
  121824. */
  121825. protected _mesh: Mesh;
  121826. /**
  121827. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  121828. */
  121829. private _halfDomeMask;
  121830. /**
  121831. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121832. * Also see the options.resolution property.
  121833. */
  121834. get fovMultiplier(): number;
  121835. set fovMultiplier(value: number);
  121836. private _videoMode;
  121837. /**
  121838. * Gets or set the current video mode for the video. It can be:
  121839. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  121840. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121841. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121842. */
  121843. get videoMode(): number;
  121844. set videoMode(value: number);
  121845. /**
  121846. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  121847. *
  121848. */
  121849. get halfDome(): boolean;
  121850. /**
  121851. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  121852. */
  121853. set halfDome(enabled: boolean);
  121854. /**
  121855. * Oberserver used in Stereoscopic VR Mode.
  121856. */
  121857. private _onBeforeCameraRenderObserver;
  121858. /**
  121859. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  121860. * @param name Element's name, child elements will append suffixes for their own names.
  121861. * @param urlsOrVideo defines the url(s) or the video element to use
  121862. * @param options An object containing optional or exposed sub element properties
  121863. */
  121864. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  121865. resolution?: number;
  121866. clickToPlay?: boolean;
  121867. autoPlay?: boolean;
  121868. loop?: boolean;
  121869. size?: number;
  121870. poster?: string;
  121871. faceForward?: boolean;
  121872. useDirectMapping?: boolean;
  121873. halfDomeMode?: boolean;
  121874. }, scene: Scene);
  121875. private _changeVideoMode;
  121876. /**
  121877. * Releases resources associated with this node.
  121878. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  121879. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  121880. */
  121881. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  121882. }
  121883. }
  121884. declare module BABYLON {
  121885. /**
  121886. * This class can be used to get instrumentation data from a Babylon engine
  121887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121888. */
  121889. export class EngineInstrumentation implements IDisposable {
  121890. /**
  121891. * Define the instrumented engine.
  121892. */
  121893. engine: Engine;
  121894. private _captureGPUFrameTime;
  121895. private _gpuFrameTimeToken;
  121896. private _gpuFrameTime;
  121897. private _captureShaderCompilationTime;
  121898. private _shaderCompilationTime;
  121899. private _onBeginFrameObserver;
  121900. private _onEndFrameObserver;
  121901. private _onBeforeShaderCompilationObserver;
  121902. private _onAfterShaderCompilationObserver;
  121903. /**
  121904. * Gets the perf counter used for GPU frame time
  121905. */
  121906. get gpuFrameTimeCounter(): PerfCounter;
  121907. /**
  121908. * Gets the GPU frame time capture status
  121909. */
  121910. get captureGPUFrameTime(): boolean;
  121911. /**
  121912. * Enable or disable the GPU frame time capture
  121913. */
  121914. set captureGPUFrameTime(value: boolean);
  121915. /**
  121916. * Gets the perf counter used for shader compilation time
  121917. */
  121918. get shaderCompilationTimeCounter(): PerfCounter;
  121919. /**
  121920. * Gets the shader compilation time capture status
  121921. */
  121922. get captureShaderCompilationTime(): boolean;
  121923. /**
  121924. * Enable or disable the shader compilation time capture
  121925. */
  121926. set captureShaderCompilationTime(value: boolean);
  121927. /**
  121928. * Instantiates a new engine instrumentation.
  121929. * This class can be used to get instrumentation data from a Babylon engine
  121930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121931. * @param engine Defines the engine to instrument
  121932. */
  121933. constructor(
  121934. /**
  121935. * Define the instrumented engine.
  121936. */
  121937. engine: Engine);
  121938. /**
  121939. * Dispose and release associated resources.
  121940. */
  121941. dispose(): void;
  121942. }
  121943. }
  121944. declare module BABYLON {
  121945. /**
  121946. * This class can be used to get instrumentation data from a Babylon engine
  121947. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  121948. */
  121949. export class SceneInstrumentation implements IDisposable {
  121950. /**
  121951. * Defines the scene to instrument
  121952. */
  121953. scene: Scene;
  121954. private _captureActiveMeshesEvaluationTime;
  121955. private _activeMeshesEvaluationTime;
  121956. private _captureRenderTargetsRenderTime;
  121957. private _renderTargetsRenderTime;
  121958. private _captureFrameTime;
  121959. private _frameTime;
  121960. private _captureRenderTime;
  121961. private _renderTime;
  121962. private _captureInterFrameTime;
  121963. private _interFrameTime;
  121964. private _captureParticlesRenderTime;
  121965. private _particlesRenderTime;
  121966. private _captureSpritesRenderTime;
  121967. private _spritesRenderTime;
  121968. private _capturePhysicsTime;
  121969. private _physicsTime;
  121970. private _captureAnimationsTime;
  121971. private _animationsTime;
  121972. private _captureCameraRenderTime;
  121973. private _cameraRenderTime;
  121974. private _onBeforeActiveMeshesEvaluationObserver;
  121975. private _onAfterActiveMeshesEvaluationObserver;
  121976. private _onBeforeRenderTargetsRenderObserver;
  121977. private _onAfterRenderTargetsRenderObserver;
  121978. private _onAfterRenderObserver;
  121979. private _onBeforeDrawPhaseObserver;
  121980. private _onAfterDrawPhaseObserver;
  121981. private _onBeforeAnimationsObserver;
  121982. private _onBeforeParticlesRenderingObserver;
  121983. private _onAfterParticlesRenderingObserver;
  121984. private _onBeforeSpritesRenderingObserver;
  121985. private _onAfterSpritesRenderingObserver;
  121986. private _onBeforePhysicsObserver;
  121987. private _onAfterPhysicsObserver;
  121988. private _onAfterAnimationsObserver;
  121989. private _onBeforeCameraRenderObserver;
  121990. private _onAfterCameraRenderObserver;
  121991. /**
  121992. * Gets the perf counter used for active meshes evaluation time
  121993. */
  121994. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  121995. /**
  121996. * Gets the active meshes evaluation time capture status
  121997. */
  121998. get captureActiveMeshesEvaluationTime(): boolean;
  121999. /**
  122000. * Enable or disable the active meshes evaluation time capture
  122001. */
  122002. set captureActiveMeshesEvaluationTime(value: boolean);
  122003. /**
  122004. * Gets the perf counter used for render targets render time
  122005. */
  122006. get renderTargetsRenderTimeCounter(): PerfCounter;
  122007. /**
  122008. * Gets the render targets render time capture status
  122009. */
  122010. get captureRenderTargetsRenderTime(): boolean;
  122011. /**
  122012. * Enable or disable the render targets render time capture
  122013. */
  122014. set captureRenderTargetsRenderTime(value: boolean);
  122015. /**
  122016. * Gets the perf counter used for particles render time
  122017. */
  122018. get particlesRenderTimeCounter(): PerfCounter;
  122019. /**
  122020. * Gets the particles render time capture status
  122021. */
  122022. get captureParticlesRenderTime(): boolean;
  122023. /**
  122024. * Enable or disable the particles render time capture
  122025. */
  122026. set captureParticlesRenderTime(value: boolean);
  122027. /**
  122028. * Gets the perf counter used for sprites render time
  122029. */
  122030. get spritesRenderTimeCounter(): PerfCounter;
  122031. /**
  122032. * Gets the sprites render time capture status
  122033. */
  122034. get captureSpritesRenderTime(): boolean;
  122035. /**
  122036. * Enable or disable the sprites render time capture
  122037. */
  122038. set captureSpritesRenderTime(value: boolean);
  122039. /**
  122040. * Gets the perf counter used for physics time
  122041. */
  122042. get physicsTimeCounter(): PerfCounter;
  122043. /**
  122044. * Gets the physics time capture status
  122045. */
  122046. get capturePhysicsTime(): boolean;
  122047. /**
  122048. * Enable or disable the physics time capture
  122049. */
  122050. set capturePhysicsTime(value: boolean);
  122051. /**
  122052. * Gets the perf counter used for animations time
  122053. */
  122054. get animationsTimeCounter(): PerfCounter;
  122055. /**
  122056. * Gets the animations time capture status
  122057. */
  122058. get captureAnimationsTime(): boolean;
  122059. /**
  122060. * Enable or disable the animations time capture
  122061. */
  122062. set captureAnimationsTime(value: boolean);
  122063. /**
  122064. * Gets the perf counter used for frame time capture
  122065. */
  122066. get frameTimeCounter(): PerfCounter;
  122067. /**
  122068. * Gets the frame time capture status
  122069. */
  122070. get captureFrameTime(): boolean;
  122071. /**
  122072. * Enable or disable the frame time capture
  122073. */
  122074. set captureFrameTime(value: boolean);
  122075. /**
  122076. * Gets the perf counter used for inter-frames time capture
  122077. */
  122078. get interFrameTimeCounter(): PerfCounter;
  122079. /**
  122080. * Gets the inter-frames time capture status
  122081. */
  122082. get captureInterFrameTime(): boolean;
  122083. /**
  122084. * Enable or disable the inter-frames time capture
  122085. */
  122086. set captureInterFrameTime(value: boolean);
  122087. /**
  122088. * Gets the perf counter used for render time capture
  122089. */
  122090. get renderTimeCounter(): PerfCounter;
  122091. /**
  122092. * Gets the render time capture status
  122093. */
  122094. get captureRenderTime(): boolean;
  122095. /**
  122096. * Enable or disable the render time capture
  122097. */
  122098. set captureRenderTime(value: boolean);
  122099. /**
  122100. * Gets the perf counter used for camera render time capture
  122101. */
  122102. get cameraRenderTimeCounter(): PerfCounter;
  122103. /**
  122104. * Gets the camera render time capture status
  122105. */
  122106. get captureCameraRenderTime(): boolean;
  122107. /**
  122108. * Enable or disable the camera render time capture
  122109. */
  122110. set captureCameraRenderTime(value: boolean);
  122111. /**
  122112. * Gets the perf counter used for draw calls
  122113. */
  122114. get drawCallsCounter(): PerfCounter;
  122115. /**
  122116. * Instantiates a new scene instrumentation.
  122117. * This class can be used to get instrumentation data from a Babylon engine
  122118. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122119. * @param scene Defines the scene to instrument
  122120. */
  122121. constructor(
  122122. /**
  122123. * Defines the scene to instrument
  122124. */
  122125. scene: Scene);
  122126. /**
  122127. * Dispose and release associated resources.
  122128. */
  122129. dispose(): void;
  122130. }
  122131. }
  122132. declare module BABYLON {
  122133. /** @hidden */
  122134. export var glowMapGenerationPixelShader: {
  122135. name: string;
  122136. shader: string;
  122137. };
  122138. }
  122139. declare module BABYLON {
  122140. /** @hidden */
  122141. export var glowMapGenerationVertexShader: {
  122142. name: string;
  122143. shader: string;
  122144. };
  122145. }
  122146. declare module BABYLON {
  122147. /**
  122148. * Effect layer options. This helps customizing the behaviour
  122149. * of the effect layer.
  122150. */
  122151. export interface IEffectLayerOptions {
  122152. /**
  122153. * Multiplication factor apply to the canvas size to compute the render target size
  122154. * used to generated the objects (the smaller the faster).
  122155. */
  122156. mainTextureRatio: number;
  122157. /**
  122158. * Enforces a fixed size texture to ensure effect stability across devices.
  122159. */
  122160. mainTextureFixedSize?: number;
  122161. /**
  122162. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  122163. */
  122164. alphaBlendingMode: number;
  122165. /**
  122166. * The camera attached to the layer.
  122167. */
  122168. camera: Nullable<Camera>;
  122169. /**
  122170. * The rendering group to draw the layer in.
  122171. */
  122172. renderingGroupId: number;
  122173. }
  122174. /**
  122175. * The effect layer Helps adding post process effect blended with the main pass.
  122176. *
  122177. * This can be for instance use to generate glow or higlight effects on the scene.
  122178. *
  122179. * The effect layer class can not be used directly and is intented to inherited from to be
  122180. * customized per effects.
  122181. */
  122182. export abstract class EffectLayer {
  122183. private _vertexBuffers;
  122184. private _indexBuffer;
  122185. private _cachedDefines;
  122186. private _effectLayerMapGenerationEffect;
  122187. private _effectLayerOptions;
  122188. private _mergeEffect;
  122189. protected _scene: Scene;
  122190. protected _engine: Engine;
  122191. protected _maxSize: number;
  122192. protected _mainTextureDesiredSize: ISize;
  122193. protected _mainTexture: RenderTargetTexture;
  122194. protected _shouldRender: boolean;
  122195. protected _postProcesses: PostProcess[];
  122196. protected _textures: BaseTexture[];
  122197. protected _emissiveTextureAndColor: {
  122198. texture: Nullable<BaseTexture>;
  122199. color: Color4;
  122200. };
  122201. /**
  122202. * The name of the layer
  122203. */
  122204. name: string;
  122205. /**
  122206. * The clear color of the texture used to generate the glow map.
  122207. */
  122208. neutralColor: Color4;
  122209. /**
  122210. * Specifies wether the highlight layer is enabled or not.
  122211. */
  122212. isEnabled: boolean;
  122213. /**
  122214. * Gets the camera attached to the layer.
  122215. */
  122216. get camera(): Nullable<Camera>;
  122217. /**
  122218. * Gets the rendering group id the layer should render in.
  122219. */
  122220. get renderingGroupId(): number;
  122221. set renderingGroupId(renderingGroupId: number);
  122222. /**
  122223. * An event triggered when the effect layer has been disposed.
  122224. */
  122225. onDisposeObservable: Observable<EffectLayer>;
  122226. /**
  122227. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  122228. */
  122229. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  122230. /**
  122231. * An event triggered when the generated texture is being merged in the scene.
  122232. */
  122233. onBeforeComposeObservable: Observable<EffectLayer>;
  122234. /**
  122235. * An event triggered when the mesh is rendered into the effect render target.
  122236. */
  122237. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  122238. /**
  122239. * An event triggered after the mesh has been rendered into the effect render target.
  122240. */
  122241. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  122242. /**
  122243. * An event triggered when the generated texture has been merged in the scene.
  122244. */
  122245. onAfterComposeObservable: Observable<EffectLayer>;
  122246. /**
  122247. * An event triggered when the efffect layer changes its size.
  122248. */
  122249. onSizeChangedObservable: Observable<EffectLayer>;
  122250. /** @hidden */
  122251. static _SceneComponentInitialization: (scene: Scene) => void;
  122252. /**
  122253. * Instantiates a new effect Layer and references it in the scene.
  122254. * @param name The name of the layer
  122255. * @param scene The scene to use the layer in
  122256. */
  122257. constructor(
  122258. /** The Friendly of the effect in the scene */
  122259. name: string, scene: Scene);
  122260. /**
  122261. * Get the effect name of the layer.
  122262. * @return The effect name
  122263. */
  122264. abstract getEffectName(): string;
  122265. /**
  122266. * Checks for the readiness of the element composing the layer.
  122267. * @param subMesh the mesh to check for
  122268. * @param useInstances specify wether or not to use instances to render the mesh
  122269. * @return true if ready otherwise, false
  122270. */
  122271. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122272. /**
  122273. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122274. * @returns true if the effect requires stencil during the main canvas render pass.
  122275. */
  122276. abstract needStencil(): boolean;
  122277. /**
  122278. * Create the merge effect. This is the shader use to blit the information back
  122279. * to the main canvas at the end of the scene rendering.
  122280. * @returns The effect containing the shader used to merge the effect on the main canvas
  122281. */
  122282. protected abstract _createMergeEffect(): Effect;
  122283. /**
  122284. * Creates the render target textures and post processes used in the effect layer.
  122285. */
  122286. protected abstract _createTextureAndPostProcesses(): void;
  122287. /**
  122288. * Implementation specific of rendering the generating effect on the main canvas.
  122289. * @param effect The effect used to render through
  122290. */
  122291. protected abstract _internalRender(effect: Effect): void;
  122292. /**
  122293. * Sets the required values for both the emissive texture and and the main color.
  122294. */
  122295. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122296. /**
  122297. * Free any resources and references associated to a mesh.
  122298. * Internal use
  122299. * @param mesh The mesh to free.
  122300. */
  122301. abstract _disposeMesh(mesh: Mesh): void;
  122302. /**
  122303. * Serializes this layer (Glow or Highlight for example)
  122304. * @returns a serialized layer object
  122305. */
  122306. abstract serialize?(): any;
  122307. /**
  122308. * Initializes the effect layer with the required options.
  122309. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  122310. */
  122311. protected _init(options: Partial<IEffectLayerOptions>): void;
  122312. /**
  122313. * Generates the index buffer of the full screen quad blending to the main canvas.
  122314. */
  122315. private _generateIndexBuffer;
  122316. /**
  122317. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  122318. */
  122319. private _generateVertexBuffer;
  122320. /**
  122321. * Sets the main texture desired size which is the closest power of two
  122322. * of the engine canvas size.
  122323. */
  122324. private _setMainTextureSize;
  122325. /**
  122326. * Creates the main texture for the effect layer.
  122327. */
  122328. protected _createMainTexture(): void;
  122329. /**
  122330. * Adds specific effects defines.
  122331. * @param defines The defines to add specifics to.
  122332. */
  122333. protected _addCustomEffectDefines(defines: string[]): void;
  122334. /**
  122335. * Checks for the readiness of the element composing the layer.
  122336. * @param subMesh the mesh to check for
  122337. * @param useInstances specify wether or not to use instances to render the mesh
  122338. * @param emissiveTexture the associated emissive texture used to generate the glow
  122339. * @return true if ready otherwise, false
  122340. */
  122341. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  122342. /**
  122343. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  122344. */
  122345. render(): void;
  122346. /**
  122347. * Determine if a given mesh will be used in the current effect.
  122348. * @param mesh mesh to test
  122349. * @returns true if the mesh will be used
  122350. */
  122351. hasMesh(mesh: AbstractMesh): boolean;
  122352. /**
  122353. * Returns true if the layer contains information to display, otherwise false.
  122354. * @returns true if the glow layer should be rendered
  122355. */
  122356. shouldRender(): boolean;
  122357. /**
  122358. * Returns true if the mesh should render, otherwise false.
  122359. * @param mesh The mesh to render
  122360. * @returns true if it should render otherwise false
  122361. */
  122362. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  122363. /**
  122364. * Returns true if the mesh can be rendered, otherwise false.
  122365. * @param mesh The mesh to render
  122366. * @param material The material used on the mesh
  122367. * @returns true if it can be rendered otherwise false
  122368. */
  122369. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122370. /**
  122371. * Returns true if the mesh should render, otherwise false.
  122372. * @param mesh The mesh to render
  122373. * @returns true if it should render otherwise false
  122374. */
  122375. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  122376. /**
  122377. * Renders the submesh passed in parameter to the generation map.
  122378. */
  122379. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  122380. /**
  122381. * Defines wether the current material of the mesh should be use to render the effect.
  122382. * @param mesh defines the current mesh to render
  122383. */
  122384. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122385. /**
  122386. * Rebuild the required buffers.
  122387. * @hidden Internal use only.
  122388. */
  122389. _rebuild(): void;
  122390. /**
  122391. * Dispose only the render target textures and post process.
  122392. */
  122393. private _disposeTextureAndPostProcesses;
  122394. /**
  122395. * Dispose the highlight layer and free resources.
  122396. */
  122397. dispose(): void;
  122398. /**
  122399. * Gets the class name of the effect layer
  122400. * @returns the string with the class name of the effect layer
  122401. */
  122402. getClassName(): string;
  122403. /**
  122404. * Creates an effect layer from parsed effect layer data
  122405. * @param parsedEffectLayer defines effect layer data
  122406. * @param scene defines the current scene
  122407. * @param rootUrl defines the root URL containing the effect layer information
  122408. * @returns a parsed effect Layer
  122409. */
  122410. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  122411. }
  122412. }
  122413. declare module BABYLON {
  122414. interface AbstractScene {
  122415. /**
  122416. * The list of effect layers (highlights/glow) added to the scene
  122417. * @see http://doc.babylonjs.com/how_to/highlight_layer
  122418. * @see http://doc.babylonjs.com/how_to/glow_layer
  122419. */
  122420. effectLayers: Array<EffectLayer>;
  122421. /**
  122422. * Removes the given effect layer from this scene.
  122423. * @param toRemove defines the effect layer to remove
  122424. * @returns the index of the removed effect layer
  122425. */
  122426. removeEffectLayer(toRemove: EffectLayer): number;
  122427. /**
  122428. * Adds the given effect layer to this scene
  122429. * @param newEffectLayer defines the effect layer to add
  122430. */
  122431. addEffectLayer(newEffectLayer: EffectLayer): void;
  122432. }
  122433. /**
  122434. * Defines the layer scene component responsible to manage any effect layers
  122435. * in a given scene.
  122436. */
  122437. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  122438. /**
  122439. * The component name helpfull to identify the component in the list of scene components.
  122440. */
  122441. readonly name: string;
  122442. /**
  122443. * The scene the component belongs to.
  122444. */
  122445. scene: Scene;
  122446. private _engine;
  122447. private _renderEffects;
  122448. private _needStencil;
  122449. private _previousStencilState;
  122450. /**
  122451. * Creates a new instance of the component for the given scene
  122452. * @param scene Defines the scene to register the component in
  122453. */
  122454. constructor(scene: Scene);
  122455. /**
  122456. * Registers the component in a given scene
  122457. */
  122458. register(): void;
  122459. /**
  122460. * Rebuilds the elements related to this component in case of
  122461. * context lost for instance.
  122462. */
  122463. rebuild(): void;
  122464. /**
  122465. * Serializes the component data to the specified json object
  122466. * @param serializationObject The object to serialize to
  122467. */
  122468. serialize(serializationObject: any): void;
  122469. /**
  122470. * Adds all the elements from the container to the scene
  122471. * @param container the container holding the elements
  122472. */
  122473. addFromContainer(container: AbstractScene): void;
  122474. /**
  122475. * Removes all the elements in the container from the scene
  122476. * @param container contains the elements to remove
  122477. * @param dispose if the removed element should be disposed (default: false)
  122478. */
  122479. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122480. /**
  122481. * Disposes the component and the associated ressources.
  122482. */
  122483. dispose(): void;
  122484. private _isReadyForMesh;
  122485. private _renderMainTexture;
  122486. private _setStencil;
  122487. private _setStencilBack;
  122488. private _draw;
  122489. private _drawCamera;
  122490. private _drawRenderingGroup;
  122491. }
  122492. }
  122493. declare module BABYLON {
  122494. /** @hidden */
  122495. export var glowMapMergePixelShader: {
  122496. name: string;
  122497. shader: string;
  122498. };
  122499. }
  122500. declare module BABYLON {
  122501. /** @hidden */
  122502. export var glowMapMergeVertexShader: {
  122503. name: string;
  122504. shader: string;
  122505. };
  122506. }
  122507. declare module BABYLON {
  122508. interface AbstractScene {
  122509. /**
  122510. * Return a the first highlight layer of the scene with a given name.
  122511. * @param name The name of the highlight layer to look for.
  122512. * @return The highlight layer if found otherwise null.
  122513. */
  122514. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  122515. }
  122516. /**
  122517. * Glow layer options. This helps customizing the behaviour
  122518. * of the glow layer.
  122519. */
  122520. export interface IGlowLayerOptions {
  122521. /**
  122522. * Multiplication factor apply to the canvas size to compute the render target size
  122523. * used to generated the glowing objects (the smaller the faster).
  122524. */
  122525. mainTextureRatio: number;
  122526. /**
  122527. * Enforces a fixed size texture to ensure resize independant blur.
  122528. */
  122529. mainTextureFixedSize?: number;
  122530. /**
  122531. * How big is the kernel of the blur texture.
  122532. */
  122533. blurKernelSize: number;
  122534. /**
  122535. * The camera attached to the layer.
  122536. */
  122537. camera: Nullable<Camera>;
  122538. /**
  122539. * Enable MSAA by chosing the number of samples.
  122540. */
  122541. mainTextureSamples?: number;
  122542. /**
  122543. * The rendering group to draw the layer in.
  122544. */
  122545. renderingGroupId: number;
  122546. }
  122547. /**
  122548. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  122549. *
  122550. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  122551. *
  122552. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  122553. */
  122554. export class GlowLayer extends EffectLayer {
  122555. /**
  122556. * Effect Name of the layer.
  122557. */
  122558. static readonly EffectName: string;
  122559. /**
  122560. * The default blur kernel size used for the glow.
  122561. */
  122562. static DefaultBlurKernelSize: number;
  122563. /**
  122564. * The default texture size ratio used for the glow.
  122565. */
  122566. static DefaultTextureRatio: number;
  122567. /**
  122568. * Sets the kernel size of the blur.
  122569. */
  122570. set blurKernelSize(value: number);
  122571. /**
  122572. * Gets the kernel size of the blur.
  122573. */
  122574. get blurKernelSize(): number;
  122575. /**
  122576. * Sets the glow intensity.
  122577. */
  122578. set intensity(value: number);
  122579. /**
  122580. * Gets the glow intensity.
  122581. */
  122582. get intensity(): number;
  122583. private _options;
  122584. private _intensity;
  122585. private _horizontalBlurPostprocess1;
  122586. private _verticalBlurPostprocess1;
  122587. private _horizontalBlurPostprocess2;
  122588. private _verticalBlurPostprocess2;
  122589. private _blurTexture1;
  122590. private _blurTexture2;
  122591. private _postProcesses1;
  122592. private _postProcesses2;
  122593. private _includedOnlyMeshes;
  122594. private _excludedMeshes;
  122595. private _meshesUsingTheirOwnMaterials;
  122596. /**
  122597. * Callback used to let the user override the color selection on a per mesh basis
  122598. */
  122599. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  122600. /**
  122601. * Callback used to let the user override the texture selection on a per mesh basis
  122602. */
  122603. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  122604. /**
  122605. * Instantiates a new glow Layer and references it to the scene.
  122606. * @param name The name of the layer
  122607. * @param scene The scene to use the layer in
  122608. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  122609. */
  122610. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  122611. /**
  122612. * Get the effect name of the layer.
  122613. * @return The effect name
  122614. */
  122615. getEffectName(): string;
  122616. /**
  122617. * Create the merge effect. This is the shader use to blit the information back
  122618. * to the main canvas at the end of the scene rendering.
  122619. */
  122620. protected _createMergeEffect(): Effect;
  122621. /**
  122622. * Creates the render target textures and post processes used in the glow layer.
  122623. */
  122624. protected _createTextureAndPostProcesses(): void;
  122625. /**
  122626. * Checks for the readiness of the element composing the layer.
  122627. * @param subMesh the mesh to check for
  122628. * @param useInstances specify wether or not to use instances to render the mesh
  122629. * @param emissiveTexture the associated emissive texture used to generate the glow
  122630. * @return true if ready otherwise, false
  122631. */
  122632. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122633. /**
  122634. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122635. */
  122636. needStencil(): boolean;
  122637. /**
  122638. * Returns true if the mesh can be rendered, otherwise false.
  122639. * @param mesh The mesh to render
  122640. * @param material The material used on the mesh
  122641. * @returns true if it can be rendered otherwise false
  122642. */
  122643. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122644. /**
  122645. * Implementation specific of rendering the generating effect on the main canvas.
  122646. * @param effect The effect used to render through
  122647. */
  122648. protected _internalRender(effect: Effect): void;
  122649. /**
  122650. * Sets the required values for both the emissive texture and and the main color.
  122651. */
  122652. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122653. /**
  122654. * Returns true if the mesh should render, otherwise false.
  122655. * @param mesh The mesh to render
  122656. * @returns true if it should render otherwise false
  122657. */
  122658. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122659. /**
  122660. * Adds specific effects defines.
  122661. * @param defines The defines to add specifics to.
  122662. */
  122663. protected _addCustomEffectDefines(defines: string[]): void;
  122664. /**
  122665. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  122666. * @param mesh The mesh to exclude from the glow layer
  122667. */
  122668. addExcludedMesh(mesh: Mesh): void;
  122669. /**
  122670. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  122671. * @param mesh The mesh to remove
  122672. */
  122673. removeExcludedMesh(mesh: Mesh): void;
  122674. /**
  122675. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  122676. * @param mesh The mesh to include in the glow layer
  122677. */
  122678. addIncludedOnlyMesh(mesh: Mesh): void;
  122679. /**
  122680. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  122681. * @param mesh The mesh to remove
  122682. */
  122683. removeIncludedOnlyMesh(mesh: Mesh): void;
  122684. /**
  122685. * Determine if a given mesh will be used in the glow layer
  122686. * @param mesh The mesh to test
  122687. * @returns true if the mesh will be highlighted by the current glow layer
  122688. */
  122689. hasMesh(mesh: AbstractMesh): boolean;
  122690. /**
  122691. * Defines wether the current material of the mesh should be use to render the effect.
  122692. * @param mesh defines the current mesh to render
  122693. */
  122694. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122695. /**
  122696. * Add a mesh to be rendered through its own material and not with emissive only.
  122697. * @param mesh The mesh for which we need to use its material
  122698. */
  122699. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  122700. /**
  122701. * Remove a mesh from being rendered through its own material and not with emissive only.
  122702. * @param mesh The mesh for which we need to not use its material
  122703. */
  122704. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  122705. /**
  122706. * Free any resources and references associated to a mesh.
  122707. * Internal use
  122708. * @param mesh The mesh to free.
  122709. * @hidden
  122710. */
  122711. _disposeMesh(mesh: Mesh): void;
  122712. /**
  122713. * Gets the class name of the effect layer
  122714. * @returns the string with the class name of the effect layer
  122715. */
  122716. getClassName(): string;
  122717. /**
  122718. * Serializes this glow layer
  122719. * @returns a serialized glow layer object
  122720. */
  122721. serialize(): any;
  122722. /**
  122723. * Creates a Glow Layer from parsed glow layer data
  122724. * @param parsedGlowLayer defines glow layer data
  122725. * @param scene defines the current scene
  122726. * @param rootUrl defines the root URL containing the glow layer information
  122727. * @returns a parsed Glow Layer
  122728. */
  122729. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  122730. }
  122731. }
  122732. declare module BABYLON {
  122733. /** @hidden */
  122734. export var glowBlurPostProcessPixelShader: {
  122735. name: string;
  122736. shader: string;
  122737. };
  122738. }
  122739. declare module BABYLON {
  122740. interface AbstractScene {
  122741. /**
  122742. * Return a the first highlight layer of the scene with a given name.
  122743. * @param name The name of the highlight layer to look for.
  122744. * @return The highlight layer if found otherwise null.
  122745. */
  122746. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  122747. }
  122748. /**
  122749. * Highlight layer options. This helps customizing the behaviour
  122750. * of the highlight layer.
  122751. */
  122752. export interface IHighlightLayerOptions {
  122753. /**
  122754. * Multiplication factor apply to the canvas size to compute the render target size
  122755. * used to generated the glowing objects (the smaller the faster).
  122756. */
  122757. mainTextureRatio: number;
  122758. /**
  122759. * Enforces a fixed size texture to ensure resize independant blur.
  122760. */
  122761. mainTextureFixedSize?: number;
  122762. /**
  122763. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  122764. * of the picture to blur (the smaller the faster).
  122765. */
  122766. blurTextureSizeRatio: number;
  122767. /**
  122768. * How big in texel of the blur texture is the vertical blur.
  122769. */
  122770. blurVerticalSize: number;
  122771. /**
  122772. * How big in texel of the blur texture is the horizontal blur.
  122773. */
  122774. blurHorizontalSize: number;
  122775. /**
  122776. * Alpha blending mode used to apply the blur. Default is combine.
  122777. */
  122778. alphaBlendingMode: number;
  122779. /**
  122780. * The camera attached to the layer.
  122781. */
  122782. camera: Nullable<Camera>;
  122783. /**
  122784. * Should we display highlight as a solid stroke?
  122785. */
  122786. isStroke?: boolean;
  122787. /**
  122788. * The rendering group to draw the layer in.
  122789. */
  122790. renderingGroupId: number;
  122791. }
  122792. /**
  122793. * The highlight layer Helps adding a glow effect around a mesh.
  122794. *
  122795. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  122796. * glowy meshes to your scene.
  122797. *
  122798. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  122799. */
  122800. export class HighlightLayer extends EffectLayer {
  122801. name: string;
  122802. /**
  122803. * Effect Name of the highlight layer.
  122804. */
  122805. static readonly EffectName: string;
  122806. /**
  122807. * The neutral color used during the preparation of the glow effect.
  122808. * This is black by default as the blend operation is a blend operation.
  122809. */
  122810. static NeutralColor: Color4;
  122811. /**
  122812. * Stencil value used for glowing meshes.
  122813. */
  122814. static GlowingMeshStencilReference: number;
  122815. /**
  122816. * Stencil value used for the other meshes in the scene.
  122817. */
  122818. static NormalMeshStencilReference: number;
  122819. /**
  122820. * Specifies whether or not the inner glow is ACTIVE in the layer.
  122821. */
  122822. innerGlow: boolean;
  122823. /**
  122824. * Specifies whether or not the outer glow is ACTIVE in the layer.
  122825. */
  122826. outerGlow: boolean;
  122827. /**
  122828. * Specifies the horizontal size of the blur.
  122829. */
  122830. set blurHorizontalSize(value: number);
  122831. /**
  122832. * Specifies the vertical size of the blur.
  122833. */
  122834. set blurVerticalSize(value: number);
  122835. /**
  122836. * Gets the horizontal size of the blur.
  122837. */
  122838. get blurHorizontalSize(): number;
  122839. /**
  122840. * Gets the vertical size of the blur.
  122841. */
  122842. get blurVerticalSize(): number;
  122843. /**
  122844. * An event triggered when the highlight layer is being blurred.
  122845. */
  122846. onBeforeBlurObservable: Observable<HighlightLayer>;
  122847. /**
  122848. * An event triggered when the highlight layer has been blurred.
  122849. */
  122850. onAfterBlurObservable: Observable<HighlightLayer>;
  122851. private _instanceGlowingMeshStencilReference;
  122852. private _options;
  122853. private _downSamplePostprocess;
  122854. private _horizontalBlurPostprocess;
  122855. private _verticalBlurPostprocess;
  122856. private _blurTexture;
  122857. private _meshes;
  122858. private _excludedMeshes;
  122859. /**
  122860. * Instantiates a new highlight Layer and references it to the scene..
  122861. * @param name The name of the layer
  122862. * @param scene The scene to use the layer in
  122863. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  122864. */
  122865. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  122866. /**
  122867. * Get the effect name of the layer.
  122868. * @return The effect name
  122869. */
  122870. getEffectName(): string;
  122871. /**
  122872. * Create the merge effect. This is the shader use to blit the information back
  122873. * to the main canvas at the end of the scene rendering.
  122874. */
  122875. protected _createMergeEffect(): Effect;
  122876. /**
  122877. * Creates the render target textures and post processes used in the highlight layer.
  122878. */
  122879. protected _createTextureAndPostProcesses(): void;
  122880. /**
  122881. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122882. */
  122883. needStencil(): boolean;
  122884. /**
  122885. * Checks for the readiness of the element composing the layer.
  122886. * @param subMesh the mesh to check for
  122887. * @param useInstances specify wether or not to use instances to render the mesh
  122888. * @param emissiveTexture the associated emissive texture used to generate the glow
  122889. * @return true if ready otherwise, false
  122890. */
  122891. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122892. /**
  122893. * Implementation specific of rendering the generating effect on the main canvas.
  122894. * @param effect The effect used to render through
  122895. */
  122896. protected _internalRender(effect: Effect): void;
  122897. /**
  122898. * Returns true if the layer contains information to display, otherwise false.
  122899. */
  122900. shouldRender(): boolean;
  122901. /**
  122902. * Returns true if the mesh should render, otherwise false.
  122903. * @param mesh The mesh to render
  122904. * @returns true if it should render otherwise false
  122905. */
  122906. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122907. /**
  122908. * Sets the required values for both the emissive texture and and the main color.
  122909. */
  122910. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122911. /**
  122912. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  122913. * @param mesh The mesh to exclude from the highlight layer
  122914. */
  122915. addExcludedMesh(mesh: Mesh): void;
  122916. /**
  122917. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  122918. * @param mesh The mesh to highlight
  122919. */
  122920. removeExcludedMesh(mesh: Mesh): void;
  122921. /**
  122922. * Determine if a given mesh will be highlighted by the current HighlightLayer
  122923. * @param mesh mesh to test
  122924. * @returns true if the mesh will be highlighted by the current HighlightLayer
  122925. */
  122926. hasMesh(mesh: AbstractMesh): boolean;
  122927. /**
  122928. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  122929. * @param mesh The mesh to highlight
  122930. * @param color The color of the highlight
  122931. * @param glowEmissiveOnly Extract the glow from the emissive texture
  122932. */
  122933. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  122934. /**
  122935. * Remove a mesh from the highlight layer in order to make it stop glowing.
  122936. * @param mesh The mesh to highlight
  122937. */
  122938. removeMesh(mesh: Mesh): void;
  122939. /**
  122940. * Force the stencil to the normal expected value for none glowing parts
  122941. */
  122942. private _defaultStencilReference;
  122943. /**
  122944. * Free any resources and references associated to a mesh.
  122945. * Internal use
  122946. * @param mesh The mesh to free.
  122947. * @hidden
  122948. */
  122949. _disposeMesh(mesh: Mesh): void;
  122950. /**
  122951. * Dispose the highlight layer and free resources.
  122952. */
  122953. dispose(): void;
  122954. /**
  122955. * Gets the class name of the effect layer
  122956. * @returns the string with the class name of the effect layer
  122957. */
  122958. getClassName(): string;
  122959. /**
  122960. * Serializes this Highlight layer
  122961. * @returns a serialized Highlight layer object
  122962. */
  122963. serialize(): any;
  122964. /**
  122965. * Creates a Highlight layer from parsed Highlight layer data
  122966. * @param parsedHightlightLayer defines the Highlight layer data
  122967. * @param scene defines the current scene
  122968. * @param rootUrl defines the root URL containing the Highlight layer information
  122969. * @returns a parsed Highlight layer
  122970. */
  122971. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  122972. }
  122973. }
  122974. declare module BABYLON {
  122975. interface AbstractScene {
  122976. /**
  122977. * The list of layers (background and foreground) of the scene
  122978. */
  122979. layers: Array<Layer>;
  122980. }
  122981. /**
  122982. * Defines the layer scene component responsible to manage any layers
  122983. * in a given scene.
  122984. */
  122985. export class LayerSceneComponent implements ISceneComponent {
  122986. /**
  122987. * The component name helpfull to identify the component in the list of scene components.
  122988. */
  122989. readonly name: string;
  122990. /**
  122991. * The scene the component belongs to.
  122992. */
  122993. scene: Scene;
  122994. private _engine;
  122995. /**
  122996. * Creates a new instance of the component for the given scene
  122997. * @param scene Defines the scene to register the component in
  122998. */
  122999. constructor(scene: Scene);
  123000. /**
  123001. * Registers the component in a given scene
  123002. */
  123003. register(): void;
  123004. /**
  123005. * Rebuilds the elements related to this component in case of
  123006. * context lost for instance.
  123007. */
  123008. rebuild(): void;
  123009. /**
  123010. * Disposes the component and the associated ressources.
  123011. */
  123012. dispose(): void;
  123013. private _draw;
  123014. private _drawCameraPredicate;
  123015. private _drawCameraBackground;
  123016. private _drawCameraForeground;
  123017. private _drawRenderTargetPredicate;
  123018. private _drawRenderTargetBackground;
  123019. private _drawRenderTargetForeground;
  123020. /**
  123021. * Adds all the elements from the container to the scene
  123022. * @param container the container holding the elements
  123023. */
  123024. addFromContainer(container: AbstractScene): void;
  123025. /**
  123026. * Removes all the elements in the container from the scene
  123027. * @param container contains the elements to remove
  123028. * @param dispose if the removed element should be disposed (default: false)
  123029. */
  123030. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123031. }
  123032. }
  123033. declare module BABYLON {
  123034. /** @hidden */
  123035. export var layerPixelShader: {
  123036. name: string;
  123037. shader: string;
  123038. };
  123039. }
  123040. declare module BABYLON {
  123041. /** @hidden */
  123042. export var layerVertexShader: {
  123043. name: string;
  123044. shader: string;
  123045. };
  123046. }
  123047. declare module BABYLON {
  123048. /**
  123049. * This represents a full screen 2d layer.
  123050. * This can be useful to display a picture in the background of your scene for instance.
  123051. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123052. */
  123053. export class Layer {
  123054. /**
  123055. * Define the name of the layer.
  123056. */
  123057. name: string;
  123058. /**
  123059. * Define the texture the layer should display.
  123060. */
  123061. texture: Nullable<Texture>;
  123062. /**
  123063. * Is the layer in background or foreground.
  123064. */
  123065. isBackground: boolean;
  123066. /**
  123067. * Define the color of the layer (instead of texture).
  123068. */
  123069. color: Color4;
  123070. /**
  123071. * Define the scale of the layer in order to zoom in out of the texture.
  123072. */
  123073. scale: Vector2;
  123074. /**
  123075. * Define an offset for the layer in order to shift the texture.
  123076. */
  123077. offset: Vector2;
  123078. /**
  123079. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  123080. */
  123081. alphaBlendingMode: number;
  123082. /**
  123083. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  123084. * Alpha test will not mix with the background color in case of transparency.
  123085. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  123086. */
  123087. alphaTest: boolean;
  123088. /**
  123089. * Define a mask to restrict the layer to only some of the scene cameras.
  123090. */
  123091. layerMask: number;
  123092. /**
  123093. * Define the list of render target the layer is visible into.
  123094. */
  123095. renderTargetTextures: RenderTargetTexture[];
  123096. /**
  123097. * Define if the layer is only used in renderTarget or if it also
  123098. * renders in the main frame buffer of the canvas.
  123099. */
  123100. renderOnlyInRenderTargetTextures: boolean;
  123101. private _scene;
  123102. private _vertexBuffers;
  123103. private _indexBuffer;
  123104. private _effect;
  123105. private _previousDefines;
  123106. /**
  123107. * An event triggered when the layer is disposed.
  123108. */
  123109. onDisposeObservable: Observable<Layer>;
  123110. private _onDisposeObserver;
  123111. /**
  123112. * Back compatibility with callback before the onDisposeObservable existed.
  123113. * The set callback will be triggered when the layer has been disposed.
  123114. */
  123115. set onDispose(callback: () => void);
  123116. /**
  123117. * An event triggered before rendering the scene
  123118. */
  123119. onBeforeRenderObservable: Observable<Layer>;
  123120. private _onBeforeRenderObserver;
  123121. /**
  123122. * Back compatibility with callback before the onBeforeRenderObservable existed.
  123123. * The set callback will be triggered just before rendering the layer.
  123124. */
  123125. set onBeforeRender(callback: () => void);
  123126. /**
  123127. * An event triggered after rendering the scene
  123128. */
  123129. onAfterRenderObservable: Observable<Layer>;
  123130. private _onAfterRenderObserver;
  123131. /**
  123132. * Back compatibility with callback before the onAfterRenderObservable existed.
  123133. * The set callback will be triggered just after rendering the layer.
  123134. */
  123135. set onAfterRender(callback: () => void);
  123136. /**
  123137. * Instantiates a new layer.
  123138. * This represents a full screen 2d layer.
  123139. * This can be useful to display a picture in the background of your scene for instance.
  123140. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123141. * @param name Define the name of the layer in the scene
  123142. * @param imgUrl Define the url of the texture to display in the layer
  123143. * @param scene Define the scene the layer belongs to
  123144. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  123145. * @param color Defines a color for the layer
  123146. */
  123147. constructor(
  123148. /**
  123149. * Define the name of the layer.
  123150. */
  123151. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  123152. private _createIndexBuffer;
  123153. /** @hidden */
  123154. _rebuild(): void;
  123155. /**
  123156. * Renders the layer in the scene.
  123157. */
  123158. render(): void;
  123159. /**
  123160. * Disposes and releases the associated ressources.
  123161. */
  123162. dispose(): void;
  123163. }
  123164. }
  123165. declare module BABYLON {
  123166. /** @hidden */
  123167. export var lensFlarePixelShader: {
  123168. name: string;
  123169. shader: string;
  123170. };
  123171. }
  123172. declare module BABYLON {
  123173. /** @hidden */
  123174. export var lensFlareVertexShader: {
  123175. name: string;
  123176. shader: string;
  123177. };
  123178. }
  123179. declare module BABYLON {
  123180. /**
  123181. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123182. * It is usually composed of several `lensFlare`.
  123183. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123184. */
  123185. export class LensFlareSystem {
  123186. /**
  123187. * Define the name of the lens flare system
  123188. */
  123189. name: string;
  123190. /**
  123191. * List of lens flares used in this system.
  123192. */
  123193. lensFlares: LensFlare[];
  123194. /**
  123195. * Define a limit from the border the lens flare can be visible.
  123196. */
  123197. borderLimit: number;
  123198. /**
  123199. * Define a viewport border we do not want to see the lens flare in.
  123200. */
  123201. viewportBorder: number;
  123202. /**
  123203. * Define a predicate which could limit the list of meshes able to occlude the effect.
  123204. */
  123205. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  123206. /**
  123207. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  123208. */
  123209. layerMask: number;
  123210. /**
  123211. * Define the id of the lens flare system in the scene.
  123212. * (equal to name by default)
  123213. */
  123214. id: string;
  123215. private _scene;
  123216. private _emitter;
  123217. private _vertexBuffers;
  123218. private _indexBuffer;
  123219. private _effect;
  123220. private _positionX;
  123221. private _positionY;
  123222. private _isEnabled;
  123223. /** @hidden */
  123224. static _SceneComponentInitialization: (scene: Scene) => void;
  123225. /**
  123226. * Instantiates a lens flare system.
  123227. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123228. * It is usually composed of several `lensFlare`.
  123229. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123230. * @param name Define the name of the lens flare system in the scene
  123231. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  123232. * @param scene Define the scene the lens flare system belongs to
  123233. */
  123234. constructor(
  123235. /**
  123236. * Define the name of the lens flare system
  123237. */
  123238. name: string, emitter: any, scene: Scene);
  123239. /**
  123240. * Define if the lens flare system is enabled.
  123241. */
  123242. get isEnabled(): boolean;
  123243. set isEnabled(value: boolean);
  123244. /**
  123245. * Get the scene the effects belongs to.
  123246. * @returns the scene holding the lens flare system
  123247. */
  123248. getScene(): Scene;
  123249. /**
  123250. * Get the emitter of the lens flare system.
  123251. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123252. * @returns the emitter of the lens flare system
  123253. */
  123254. getEmitter(): any;
  123255. /**
  123256. * Set the emitter of the lens flare system.
  123257. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123258. * @param newEmitter Define the new emitter of the system
  123259. */
  123260. setEmitter(newEmitter: any): void;
  123261. /**
  123262. * Get the lens flare system emitter position.
  123263. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  123264. * @returns the position
  123265. */
  123266. getEmitterPosition(): Vector3;
  123267. /**
  123268. * @hidden
  123269. */
  123270. computeEffectivePosition(globalViewport: Viewport): boolean;
  123271. /** @hidden */
  123272. _isVisible(): boolean;
  123273. /**
  123274. * @hidden
  123275. */
  123276. render(): boolean;
  123277. /**
  123278. * Dispose and release the lens flare with its associated resources.
  123279. */
  123280. dispose(): void;
  123281. /**
  123282. * Parse a lens flare system from a JSON repressentation
  123283. * @param parsedLensFlareSystem Define the JSON to parse
  123284. * @param scene Define the scene the parsed system should be instantiated in
  123285. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  123286. * @returns the parsed system
  123287. */
  123288. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  123289. /**
  123290. * Serialize the current Lens Flare System into a JSON representation.
  123291. * @returns the serialized JSON
  123292. */
  123293. serialize(): any;
  123294. }
  123295. }
  123296. declare module BABYLON {
  123297. /**
  123298. * This represents one of the lens effect in a `lensFlareSystem`.
  123299. * It controls one of the indiviual texture used in the effect.
  123300. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123301. */
  123302. export class LensFlare {
  123303. /**
  123304. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123305. */
  123306. size: number;
  123307. /**
  123308. * 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.
  123309. */
  123310. position: number;
  123311. /**
  123312. * Define the lens color.
  123313. */
  123314. color: Color3;
  123315. /**
  123316. * Define the lens texture.
  123317. */
  123318. texture: Nullable<Texture>;
  123319. /**
  123320. * Define the alpha mode to render this particular lens.
  123321. */
  123322. alphaMode: number;
  123323. private _system;
  123324. /**
  123325. * Creates a new Lens Flare.
  123326. * This represents one of the lens effect in a `lensFlareSystem`.
  123327. * It controls one of the indiviual texture used in the effect.
  123328. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123329. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  123330. * @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.
  123331. * @param color Define the lens color
  123332. * @param imgUrl Define the lens texture url
  123333. * @param system Define the `lensFlareSystem` this flare is part of
  123334. * @returns The newly created Lens Flare
  123335. */
  123336. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  123337. /**
  123338. * Instantiates a new Lens Flare.
  123339. * This represents one of the lens effect in a `lensFlareSystem`.
  123340. * It controls one of the indiviual texture used in the effect.
  123341. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123342. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  123343. * @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.
  123344. * @param color Define the lens color
  123345. * @param imgUrl Define the lens texture url
  123346. * @param system Define the `lensFlareSystem` this flare is part of
  123347. */
  123348. constructor(
  123349. /**
  123350. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123351. */
  123352. size: number,
  123353. /**
  123354. * 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.
  123355. */
  123356. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  123357. /**
  123358. * Dispose and release the lens flare with its associated resources.
  123359. */
  123360. dispose(): void;
  123361. }
  123362. }
  123363. declare module BABYLON {
  123364. interface AbstractScene {
  123365. /**
  123366. * The list of lens flare system added to the scene
  123367. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123368. */
  123369. lensFlareSystems: Array<LensFlareSystem>;
  123370. /**
  123371. * Removes the given lens flare system from this scene.
  123372. * @param toRemove The lens flare system to remove
  123373. * @returns The index of the removed lens flare system
  123374. */
  123375. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  123376. /**
  123377. * Adds the given lens flare system to this scene
  123378. * @param newLensFlareSystem The lens flare system to add
  123379. */
  123380. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  123381. /**
  123382. * Gets a lens flare system using its name
  123383. * @param name defines the name to look for
  123384. * @returns the lens flare system or null if not found
  123385. */
  123386. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  123387. /**
  123388. * Gets a lens flare system using its id
  123389. * @param id defines the id to look for
  123390. * @returns the lens flare system or null if not found
  123391. */
  123392. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  123393. }
  123394. /**
  123395. * Defines the lens flare scene component responsible to manage any lens flares
  123396. * in a given scene.
  123397. */
  123398. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  123399. /**
  123400. * The component name helpfull to identify the component in the list of scene components.
  123401. */
  123402. readonly name: string;
  123403. /**
  123404. * The scene the component belongs to.
  123405. */
  123406. scene: Scene;
  123407. /**
  123408. * Creates a new instance of the component for the given scene
  123409. * @param scene Defines the scene to register the component in
  123410. */
  123411. constructor(scene: Scene);
  123412. /**
  123413. * Registers the component in a given scene
  123414. */
  123415. register(): void;
  123416. /**
  123417. * Rebuilds the elements related to this component in case of
  123418. * context lost for instance.
  123419. */
  123420. rebuild(): void;
  123421. /**
  123422. * Adds all the elements from the container to the scene
  123423. * @param container the container holding the elements
  123424. */
  123425. addFromContainer(container: AbstractScene): void;
  123426. /**
  123427. * Removes all the elements in the container from the scene
  123428. * @param container contains the elements to remove
  123429. * @param dispose if the removed element should be disposed (default: false)
  123430. */
  123431. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123432. /**
  123433. * Serializes the component data to the specified json object
  123434. * @param serializationObject The object to serialize to
  123435. */
  123436. serialize(serializationObject: any): void;
  123437. /**
  123438. * Disposes the component and the associated ressources.
  123439. */
  123440. dispose(): void;
  123441. private _draw;
  123442. }
  123443. }
  123444. declare module BABYLON {
  123445. /**
  123446. * Defines the shadow generator component responsible to manage any shadow generators
  123447. * in a given scene.
  123448. */
  123449. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  123450. /**
  123451. * The component name helpfull to identify the component in the list of scene components.
  123452. */
  123453. readonly name: string;
  123454. /**
  123455. * The scene the component belongs to.
  123456. */
  123457. scene: Scene;
  123458. /**
  123459. * Creates a new instance of the component for the given scene
  123460. * @param scene Defines the scene to register the component in
  123461. */
  123462. constructor(scene: Scene);
  123463. /**
  123464. * Registers the component in a given scene
  123465. */
  123466. register(): void;
  123467. /**
  123468. * Rebuilds the elements related to this component in case of
  123469. * context lost for instance.
  123470. */
  123471. rebuild(): void;
  123472. /**
  123473. * Serializes the component data to the specified json object
  123474. * @param serializationObject The object to serialize to
  123475. */
  123476. serialize(serializationObject: any): void;
  123477. /**
  123478. * Adds all the elements from the container to the scene
  123479. * @param container the container holding the elements
  123480. */
  123481. addFromContainer(container: AbstractScene): void;
  123482. /**
  123483. * Removes all the elements in the container from the scene
  123484. * @param container contains the elements to remove
  123485. * @param dispose if the removed element should be disposed (default: false)
  123486. */
  123487. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123488. /**
  123489. * Rebuilds the elements related to this component in case of
  123490. * context lost for instance.
  123491. */
  123492. dispose(): void;
  123493. private _gatherRenderTargets;
  123494. }
  123495. }
  123496. declare module BABYLON {
  123497. /**
  123498. * A point light is a light defined by an unique point in world space.
  123499. * The light is emitted in every direction from this point.
  123500. * A good example of a point light is a standard light bulb.
  123501. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123502. */
  123503. export class PointLight extends ShadowLight {
  123504. private _shadowAngle;
  123505. /**
  123506. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123507. * This specifies what angle the shadow will use to be created.
  123508. *
  123509. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123510. */
  123511. get shadowAngle(): number;
  123512. /**
  123513. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123514. * This specifies what angle the shadow will use to be created.
  123515. *
  123516. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123517. */
  123518. set shadowAngle(value: number);
  123519. /**
  123520. * Gets the direction if it has been set.
  123521. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123522. */
  123523. get direction(): Vector3;
  123524. /**
  123525. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123526. */
  123527. set direction(value: Vector3);
  123528. /**
  123529. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  123530. * A PointLight emits the light in every direction.
  123531. * It can cast shadows.
  123532. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  123533. * ```javascript
  123534. * var pointLight = new PointLight("pl", camera.position, scene);
  123535. * ```
  123536. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123537. * @param name The light friendly name
  123538. * @param position The position of the point light in the scene
  123539. * @param scene The scene the lights belongs to
  123540. */
  123541. constructor(name: string, position: Vector3, scene: Scene);
  123542. /**
  123543. * Returns the string "PointLight"
  123544. * @returns the class name
  123545. */
  123546. getClassName(): string;
  123547. /**
  123548. * Returns the integer 0.
  123549. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123550. */
  123551. getTypeID(): number;
  123552. /**
  123553. * Specifies wether or not the shadowmap should be a cube texture.
  123554. * @returns true if the shadowmap needs to be a cube texture.
  123555. */
  123556. needCube(): boolean;
  123557. /**
  123558. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  123559. * @param faceIndex The index of the face we are computed the direction to generate shadow
  123560. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  123561. */
  123562. getShadowDirection(faceIndex?: number): Vector3;
  123563. /**
  123564. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  123565. * - fov = PI / 2
  123566. * - aspect ratio : 1.0
  123567. * - z-near and far equal to the active camera minZ and maxZ.
  123568. * Returns the PointLight.
  123569. */
  123570. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123571. protected _buildUniformLayout(): void;
  123572. /**
  123573. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  123574. * @param effect The effect to update
  123575. * @param lightIndex The index of the light in the effect to update
  123576. * @returns The point light
  123577. */
  123578. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  123579. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123580. /**
  123581. * Prepares the list of defines specific to the light type.
  123582. * @param defines the list of defines
  123583. * @param lightIndex defines the index of the light for the effect
  123584. */
  123585. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123586. }
  123587. }
  123588. declare module BABYLON {
  123589. /**
  123590. * Header information of HDR texture files.
  123591. */
  123592. export interface HDRInfo {
  123593. /**
  123594. * The height of the texture in pixels.
  123595. */
  123596. height: number;
  123597. /**
  123598. * The width of the texture in pixels.
  123599. */
  123600. width: number;
  123601. /**
  123602. * The index of the beginning of the data in the binary file.
  123603. */
  123604. dataPosition: number;
  123605. }
  123606. /**
  123607. * This groups tools to convert HDR texture to native colors array.
  123608. */
  123609. export class HDRTools {
  123610. private static Ldexp;
  123611. private static Rgbe2float;
  123612. private static readStringLine;
  123613. /**
  123614. * Reads header information from an RGBE texture stored in a native array.
  123615. * More information on this format are available here:
  123616. * https://en.wikipedia.org/wiki/RGBE_image_format
  123617. *
  123618. * @param uint8array The binary file stored in native array.
  123619. * @return The header information.
  123620. */
  123621. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  123622. /**
  123623. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  123624. * This RGBE texture needs to store the information as a panorama.
  123625. *
  123626. * More information on this format are available here:
  123627. * https://en.wikipedia.org/wiki/RGBE_image_format
  123628. *
  123629. * @param buffer The binary file stored in an array buffer.
  123630. * @param size The expected size of the extracted cubemap.
  123631. * @return The Cube Map information.
  123632. */
  123633. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  123634. /**
  123635. * Returns the pixels data extracted from an RGBE texture.
  123636. * This pixels will be stored left to right up to down in the R G B order in one array.
  123637. *
  123638. * More information on this format are available here:
  123639. * https://en.wikipedia.org/wiki/RGBE_image_format
  123640. *
  123641. * @param uint8array The binary file stored in an array buffer.
  123642. * @param hdrInfo The header information of the file.
  123643. * @return The pixels data in RGB right to left up to down order.
  123644. */
  123645. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  123646. private static RGBE_ReadPixels_RLE;
  123647. }
  123648. }
  123649. declare module BABYLON {
  123650. /**
  123651. * This represents a texture coming from an HDR input.
  123652. *
  123653. * The only supported format is currently panorama picture stored in RGBE format.
  123654. * Example of such files can be found on HDRLib: http://hdrlib.com/
  123655. */
  123656. export class HDRCubeTexture extends BaseTexture {
  123657. private static _facesMapping;
  123658. private _generateHarmonics;
  123659. private _noMipmap;
  123660. private _textureMatrix;
  123661. private _size;
  123662. private _onLoad;
  123663. private _onError;
  123664. /**
  123665. * The texture URL.
  123666. */
  123667. url: string;
  123668. /**
  123669. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  123670. */
  123671. coordinatesMode: number;
  123672. protected _isBlocking: boolean;
  123673. /**
  123674. * Sets wether or not the texture is blocking during loading.
  123675. */
  123676. set isBlocking(value: boolean);
  123677. /**
  123678. * Gets wether or not the texture is blocking during loading.
  123679. */
  123680. get isBlocking(): boolean;
  123681. protected _rotationY: number;
  123682. /**
  123683. * Sets texture matrix rotation angle around Y axis in radians.
  123684. */
  123685. set rotationY(value: number);
  123686. /**
  123687. * Gets texture matrix rotation angle around Y axis radians.
  123688. */
  123689. get rotationY(): number;
  123690. /**
  123691. * Gets or sets the center of the bounding box associated with the cube texture
  123692. * It must define where the camera used to render the texture was set
  123693. */
  123694. boundingBoxPosition: Vector3;
  123695. private _boundingBoxSize;
  123696. /**
  123697. * Gets or sets the size of the bounding box associated with the cube texture
  123698. * When defined, the cubemap will switch to local mode
  123699. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123700. * @example https://www.babylonjs-playground.com/#RNASML
  123701. */
  123702. set boundingBoxSize(value: Vector3);
  123703. get boundingBoxSize(): Vector3;
  123704. /**
  123705. * Instantiates an HDRTexture from the following parameters.
  123706. *
  123707. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  123708. * @param scene The scene the texture will be used in
  123709. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  123710. * @param noMipmap Forces to not generate the mipmap if true
  123711. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  123712. * @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)
  123713. * @param reserved Reserved flag for internal use.
  123714. */
  123715. 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>);
  123716. /**
  123717. * Get the current class name of the texture useful for serialization or dynamic coding.
  123718. * @returns "HDRCubeTexture"
  123719. */
  123720. getClassName(): string;
  123721. /**
  123722. * Occurs when the file is raw .hdr file.
  123723. */
  123724. private loadTexture;
  123725. clone(): HDRCubeTexture;
  123726. delayLoad(): void;
  123727. /**
  123728. * Get the texture reflection matrix used to rotate/transform the reflection.
  123729. * @returns the reflection matrix
  123730. */
  123731. getReflectionTextureMatrix(): Matrix;
  123732. /**
  123733. * Set the texture reflection matrix used to rotate/transform the reflection.
  123734. * @param value Define the reflection matrix to set
  123735. */
  123736. setReflectionTextureMatrix(value: Matrix): void;
  123737. /**
  123738. * Parses a JSON representation of an HDR Texture in order to create the texture
  123739. * @param parsedTexture Define the JSON representation
  123740. * @param scene Define the scene the texture should be created in
  123741. * @param rootUrl Define the root url in case we need to load relative dependencies
  123742. * @returns the newly created texture after parsing
  123743. */
  123744. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  123745. serialize(): any;
  123746. }
  123747. }
  123748. declare module BABYLON {
  123749. /**
  123750. * Class used to control physics engine
  123751. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123752. */
  123753. export class PhysicsEngine implements IPhysicsEngine {
  123754. private _physicsPlugin;
  123755. /**
  123756. * Global value used to control the smallest number supported by the simulation
  123757. */
  123758. static Epsilon: number;
  123759. private _impostors;
  123760. private _joints;
  123761. private _subTimeStep;
  123762. /**
  123763. * Gets the gravity vector used by the simulation
  123764. */
  123765. gravity: Vector3;
  123766. /**
  123767. * Factory used to create the default physics plugin.
  123768. * @returns The default physics plugin
  123769. */
  123770. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  123771. /**
  123772. * Creates a new Physics Engine
  123773. * @param gravity defines the gravity vector used by the simulation
  123774. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  123775. */
  123776. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  123777. /**
  123778. * Sets the gravity vector used by the simulation
  123779. * @param gravity defines the gravity vector to use
  123780. */
  123781. setGravity(gravity: Vector3): void;
  123782. /**
  123783. * Set the time step of the physics engine.
  123784. * Default is 1/60.
  123785. * To slow it down, enter 1/600 for example.
  123786. * To speed it up, 1/30
  123787. * @param newTimeStep defines the new timestep to apply to this world.
  123788. */
  123789. setTimeStep(newTimeStep?: number): void;
  123790. /**
  123791. * Get the time step of the physics engine.
  123792. * @returns the current time step
  123793. */
  123794. getTimeStep(): number;
  123795. /**
  123796. * Set the sub time step of the physics engine.
  123797. * Default is 0 meaning there is no sub steps
  123798. * To increase physics resolution precision, set a small value (like 1 ms)
  123799. * @param subTimeStep defines the new sub timestep used for physics resolution.
  123800. */
  123801. setSubTimeStep(subTimeStep?: number): void;
  123802. /**
  123803. * Get the sub time step of the physics engine.
  123804. * @returns the current sub time step
  123805. */
  123806. getSubTimeStep(): number;
  123807. /**
  123808. * Release all resources
  123809. */
  123810. dispose(): void;
  123811. /**
  123812. * Gets the name of the current physics plugin
  123813. * @returns the name of the plugin
  123814. */
  123815. getPhysicsPluginName(): string;
  123816. /**
  123817. * Adding a new impostor for the impostor tracking.
  123818. * This will be done by the impostor itself.
  123819. * @param impostor the impostor to add
  123820. */
  123821. addImpostor(impostor: PhysicsImpostor): void;
  123822. /**
  123823. * Remove an impostor from the engine.
  123824. * This impostor and its mesh will not longer be updated by the physics engine.
  123825. * @param impostor the impostor to remove
  123826. */
  123827. removeImpostor(impostor: PhysicsImpostor): void;
  123828. /**
  123829. * Add a joint to the physics engine
  123830. * @param mainImpostor defines the main impostor to which the joint is added.
  123831. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  123832. * @param joint defines the joint that will connect both impostors.
  123833. */
  123834. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123835. /**
  123836. * Removes a joint from the simulation
  123837. * @param mainImpostor defines the impostor used with the joint
  123838. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  123839. * @param joint defines the joint to remove
  123840. */
  123841. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123842. /**
  123843. * Called by the scene. No need to call it.
  123844. * @param delta defines the timespam between frames
  123845. */
  123846. _step(delta: number): void;
  123847. /**
  123848. * Gets the current plugin used to run the simulation
  123849. * @returns current plugin
  123850. */
  123851. getPhysicsPlugin(): IPhysicsEnginePlugin;
  123852. /**
  123853. * Gets the list of physic impostors
  123854. * @returns an array of PhysicsImpostor
  123855. */
  123856. getImpostors(): Array<PhysicsImpostor>;
  123857. /**
  123858. * Gets the impostor for a physics enabled object
  123859. * @param object defines the object impersonated by the impostor
  123860. * @returns the PhysicsImpostor or null if not found
  123861. */
  123862. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  123863. /**
  123864. * Gets the impostor for a physics body object
  123865. * @param body defines physics body used by the impostor
  123866. * @returns the PhysicsImpostor or null if not found
  123867. */
  123868. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  123869. /**
  123870. * Does a raycast in the physics world
  123871. * @param from when should the ray start?
  123872. * @param to when should the ray end?
  123873. * @returns PhysicsRaycastResult
  123874. */
  123875. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123876. }
  123877. }
  123878. declare module BABYLON {
  123879. /** @hidden */
  123880. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  123881. private _useDeltaForWorldStep;
  123882. world: any;
  123883. name: string;
  123884. private _physicsMaterials;
  123885. private _fixedTimeStep;
  123886. private _cannonRaycastResult;
  123887. private _raycastResult;
  123888. private _physicsBodysToRemoveAfterStep;
  123889. BJSCANNON: any;
  123890. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  123891. setGravity(gravity: Vector3): void;
  123892. setTimeStep(timeStep: number): void;
  123893. getTimeStep(): number;
  123894. executeStep(delta: number): void;
  123895. private _removeMarkedPhysicsBodiesFromWorld;
  123896. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123897. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123898. generatePhysicsBody(impostor: PhysicsImpostor): void;
  123899. private _processChildMeshes;
  123900. removePhysicsBody(impostor: PhysicsImpostor): void;
  123901. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  123902. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  123903. private _addMaterial;
  123904. private _checkWithEpsilon;
  123905. private _createShape;
  123906. private _createHeightmap;
  123907. private _minus90X;
  123908. private _plus90X;
  123909. private _tmpPosition;
  123910. private _tmpDeltaPosition;
  123911. private _tmpUnityRotation;
  123912. private _updatePhysicsBodyTransformation;
  123913. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  123914. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  123915. isSupported(): boolean;
  123916. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123917. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123918. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123919. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123920. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  123921. getBodyMass(impostor: PhysicsImpostor): number;
  123922. getBodyFriction(impostor: PhysicsImpostor): number;
  123923. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  123924. getBodyRestitution(impostor: PhysicsImpostor): number;
  123925. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  123926. sleepBody(impostor: PhysicsImpostor): void;
  123927. wakeUpBody(impostor: PhysicsImpostor): void;
  123928. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  123929. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  123930. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  123931. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  123932. getRadius(impostor: PhysicsImpostor): number;
  123933. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  123934. dispose(): void;
  123935. private _extendNamespace;
  123936. /**
  123937. * Does a raycast in the physics world
  123938. * @param from when should the ray start?
  123939. * @param to when should the ray end?
  123940. * @returns PhysicsRaycastResult
  123941. */
  123942. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123943. }
  123944. }
  123945. declare module BABYLON {
  123946. /** @hidden */
  123947. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  123948. world: any;
  123949. name: string;
  123950. BJSOIMO: any;
  123951. private _raycastResult;
  123952. constructor(iterations?: number, oimoInjection?: any);
  123953. setGravity(gravity: Vector3): void;
  123954. setTimeStep(timeStep: number): void;
  123955. getTimeStep(): number;
  123956. private _tmpImpostorsArray;
  123957. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  123958. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123959. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123960. generatePhysicsBody(impostor: PhysicsImpostor): void;
  123961. private _tmpPositionVector;
  123962. removePhysicsBody(impostor: PhysicsImpostor): void;
  123963. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  123964. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  123965. isSupported(): boolean;
  123966. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  123967. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  123968. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123969. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123970. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123971. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123972. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  123973. getBodyMass(impostor: PhysicsImpostor): number;
  123974. getBodyFriction(impostor: PhysicsImpostor): number;
  123975. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  123976. getBodyRestitution(impostor: PhysicsImpostor): number;
  123977. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  123978. sleepBody(impostor: PhysicsImpostor): void;
  123979. wakeUpBody(impostor: PhysicsImpostor): void;
  123980. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  123981. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  123982. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  123983. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  123984. getRadius(impostor: PhysicsImpostor): number;
  123985. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  123986. dispose(): void;
  123987. /**
  123988. * Does a raycast in the physics world
  123989. * @param from when should the ray start?
  123990. * @param to when should the ray end?
  123991. * @returns PhysicsRaycastResult
  123992. */
  123993. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123994. }
  123995. }
  123996. declare module BABYLON {
  123997. /**
  123998. * Class containing static functions to help procedurally build meshes
  123999. */
  124000. export class RibbonBuilder {
  124001. /**
  124002. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124003. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124004. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124005. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124006. * * 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
  124007. * * 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
  124008. * * 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
  124009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124012. * * 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
  124013. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124014. * * 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
  124015. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124017. * @param name defines the name of the mesh
  124018. * @param options defines the options used to create the mesh
  124019. * @param scene defines the hosting scene
  124020. * @returns the ribbon mesh
  124021. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124022. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124023. */
  124024. static CreateRibbon(name: string, options: {
  124025. pathArray: Vector3[][];
  124026. closeArray?: boolean;
  124027. closePath?: boolean;
  124028. offset?: number;
  124029. updatable?: boolean;
  124030. sideOrientation?: number;
  124031. frontUVs?: Vector4;
  124032. backUVs?: Vector4;
  124033. instance?: Mesh;
  124034. invertUV?: boolean;
  124035. uvs?: Vector2[];
  124036. colors?: Color4[];
  124037. }, scene?: Nullable<Scene>): Mesh;
  124038. }
  124039. }
  124040. declare module BABYLON {
  124041. /**
  124042. * Class containing static functions to help procedurally build meshes
  124043. */
  124044. export class ShapeBuilder {
  124045. /**
  124046. * 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.
  124047. * * 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.
  124048. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124049. * * 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.
  124050. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124051. * * 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
  124052. * * 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
  124053. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124056. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124058. * @param name defines the name of the mesh
  124059. * @param options defines the options used to create the mesh
  124060. * @param scene defines the hosting scene
  124061. * @returns the extruded shape mesh
  124062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124063. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124064. */
  124065. static ExtrudeShape(name: string, options: {
  124066. shape: Vector3[];
  124067. path: Vector3[];
  124068. scale?: number;
  124069. rotation?: number;
  124070. cap?: number;
  124071. updatable?: boolean;
  124072. sideOrientation?: number;
  124073. frontUVs?: Vector4;
  124074. backUVs?: Vector4;
  124075. instance?: Mesh;
  124076. invertUV?: boolean;
  124077. }, scene?: Nullable<Scene>): Mesh;
  124078. /**
  124079. * Creates an custom extruded shape mesh.
  124080. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124081. * * 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.
  124082. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124083. * * 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
  124084. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124085. * * 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
  124086. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124087. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124088. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124089. * * 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
  124090. * * 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
  124091. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124093. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124094. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124096. * @param name defines the name of the mesh
  124097. * @param options defines the options used to create the mesh
  124098. * @param scene defines the hosting scene
  124099. * @returns the custom extruded shape mesh
  124100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124101. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124103. */
  124104. static ExtrudeShapeCustom(name: string, options: {
  124105. shape: Vector3[];
  124106. path: Vector3[];
  124107. scaleFunction?: any;
  124108. rotationFunction?: any;
  124109. ribbonCloseArray?: boolean;
  124110. ribbonClosePath?: boolean;
  124111. cap?: number;
  124112. updatable?: boolean;
  124113. sideOrientation?: number;
  124114. frontUVs?: Vector4;
  124115. backUVs?: Vector4;
  124116. instance?: Mesh;
  124117. invertUV?: boolean;
  124118. }, scene?: Nullable<Scene>): Mesh;
  124119. private static _ExtrudeShapeGeneric;
  124120. }
  124121. }
  124122. declare module BABYLON {
  124123. /**
  124124. * AmmoJS Physics plugin
  124125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  124126. * @see https://github.com/kripken/ammo.js/
  124127. */
  124128. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  124129. private _useDeltaForWorldStep;
  124130. /**
  124131. * Reference to the Ammo library
  124132. */
  124133. bjsAMMO: any;
  124134. /**
  124135. * Created ammoJS world which physics bodies are added to
  124136. */
  124137. world: any;
  124138. /**
  124139. * Name of the plugin
  124140. */
  124141. name: string;
  124142. private _timeStep;
  124143. private _fixedTimeStep;
  124144. private _maxSteps;
  124145. private _tmpQuaternion;
  124146. private _tmpAmmoTransform;
  124147. private _tmpAmmoQuaternion;
  124148. private _tmpAmmoConcreteContactResultCallback;
  124149. private _collisionConfiguration;
  124150. private _dispatcher;
  124151. private _overlappingPairCache;
  124152. private _solver;
  124153. private _softBodySolver;
  124154. private _tmpAmmoVectorA;
  124155. private _tmpAmmoVectorB;
  124156. private _tmpAmmoVectorC;
  124157. private _tmpAmmoVectorD;
  124158. private _tmpContactCallbackResult;
  124159. private _tmpAmmoVectorRCA;
  124160. private _tmpAmmoVectorRCB;
  124161. private _raycastResult;
  124162. private static readonly DISABLE_COLLISION_FLAG;
  124163. private static readonly KINEMATIC_FLAG;
  124164. private static readonly DISABLE_DEACTIVATION_FLAG;
  124165. /**
  124166. * Initializes the ammoJS plugin
  124167. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  124168. * @param ammoInjection can be used to inject your own ammo reference
  124169. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  124170. */
  124171. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  124172. /**
  124173. * Sets the gravity of the physics world (m/(s^2))
  124174. * @param gravity Gravity to set
  124175. */
  124176. setGravity(gravity: Vector3): void;
  124177. /**
  124178. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  124179. * @param timeStep timestep to use in seconds
  124180. */
  124181. setTimeStep(timeStep: number): void;
  124182. /**
  124183. * 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)
  124184. * @param fixedTimeStep fixedTimeStep to use in seconds
  124185. */
  124186. setFixedTimeStep(fixedTimeStep: number): void;
  124187. /**
  124188. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  124189. * @param maxSteps the maximum number of steps by the physics engine per frame
  124190. */
  124191. setMaxSteps(maxSteps: number): void;
  124192. /**
  124193. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  124194. * @returns the current timestep in seconds
  124195. */
  124196. getTimeStep(): number;
  124197. /**
  124198. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  124199. */
  124200. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  124201. private _isImpostorInContact;
  124202. private _isImpostorPairInContact;
  124203. private _stepSimulation;
  124204. /**
  124205. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  124206. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  124207. * After the step the babylon meshes are set to the position of the physics imposters
  124208. * @param delta amount of time to step forward
  124209. * @param impostors array of imposters to update before/after the step
  124210. */
  124211. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124212. /**
  124213. * Update babylon mesh to match physics world object
  124214. * @param impostor imposter to match
  124215. */
  124216. private _afterSoftStep;
  124217. /**
  124218. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124219. * @param impostor imposter to match
  124220. */
  124221. private _ropeStep;
  124222. /**
  124223. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124224. * @param impostor imposter to match
  124225. */
  124226. private _softbodyOrClothStep;
  124227. private _tmpVector;
  124228. private _tmpMatrix;
  124229. /**
  124230. * Applies an impulse on the imposter
  124231. * @param impostor imposter to apply impulse to
  124232. * @param force amount of force to be applied to the imposter
  124233. * @param contactPoint the location to apply the impulse on the imposter
  124234. */
  124235. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124236. /**
  124237. * Applies a force on the imposter
  124238. * @param impostor imposter to apply force
  124239. * @param force amount of force to be applied to the imposter
  124240. * @param contactPoint the location to apply the force on the imposter
  124241. */
  124242. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124243. /**
  124244. * Creates a physics body using the plugin
  124245. * @param impostor the imposter to create the physics body on
  124246. */
  124247. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124248. /**
  124249. * Removes the physics body from the imposter and disposes of the body's memory
  124250. * @param impostor imposter to remove the physics body from
  124251. */
  124252. removePhysicsBody(impostor: PhysicsImpostor): void;
  124253. /**
  124254. * Generates a joint
  124255. * @param impostorJoint the imposter joint to create the joint with
  124256. */
  124257. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124258. /**
  124259. * Removes a joint
  124260. * @param impostorJoint the imposter joint to remove the joint from
  124261. */
  124262. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124263. private _addMeshVerts;
  124264. /**
  124265. * Initialise the soft body vertices to match its object's (mesh) vertices
  124266. * Softbody vertices (nodes) are in world space and to match this
  124267. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  124268. * @param impostor to create the softbody for
  124269. */
  124270. private _softVertexData;
  124271. /**
  124272. * Create an impostor's soft body
  124273. * @param impostor to create the softbody for
  124274. */
  124275. private _createSoftbody;
  124276. /**
  124277. * Create cloth for an impostor
  124278. * @param impostor to create the softbody for
  124279. */
  124280. private _createCloth;
  124281. /**
  124282. * Create rope for an impostor
  124283. * @param impostor to create the softbody for
  124284. */
  124285. private _createRope;
  124286. /**
  124287. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  124288. * @param impostor to create the custom physics shape for
  124289. */
  124290. private _createCustom;
  124291. private _addHullVerts;
  124292. private _createShape;
  124293. /**
  124294. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  124295. * @param impostor imposter containing the physics body and babylon object
  124296. */
  124297. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124298. /**
  124299. * Sets the babylon object's position/rotation from the physics body's position/rotation
  124300. * @param impostor imposter containing the physics body and babylon object
  124301. * @param newPosition new position
  124302. * @param newRotation new rotation
  124303. */
  124304. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124305. /**
  124306. * If this plugin is supported
  124307. * @returns true if its supported
  124308. */
  124309. isSupported(): boolean;
  124310. /**
  124311. * Sets the linear velocity of the physics body
  124312. * @param impostor imposter to set the velocity on
  124313. * @param velocity velocity to set
  124314. */
  124315. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124316. /**
  124317. * Sets the angular velocity of the physics body
  124318. * @param impostor imposter to set the velocity on
  124319. * @param velocity velocity to set
  124320. */
  124321. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124322. /**
  124323. * gets the linear velocity
  124324. * @param impostor imposter to get linear velocity from
  124325. * @returns linear velocity
  124326. */
  124327. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124328. /**
  124329. * gets the angular velocity
  124330. * @param impostor imposter to get angular velocity from
  124331. * @returns angular velocity
  124332. */
  124333. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124334. /**
  124335. * Sets the mass of physics body
  124336. * @param impostor imposter to set the mass on
  124337. * @param mass mass to set
  124338. */
  124339. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124340. /**
  124341. * Gets the mass of the physics body
  124342. * @param impostor imposter to get the mass from
  124343. * @returns mass
  124344. */
  124345. getBodyMass(impostor: PhysicsImpostor): number;
  124346. /**
  124347. * Gets friction of the impostor
  124348. * @param impostor impostor to get friction from
  124349. * @returns friction value
  124350. */
  124351. getBodyFriction(impostor: PhysicsImpostor): number;
  124352. /**
  124353. * Sets friction of the impostor
  124354. * @param impostor impostor to set friction on
  124355. * @param friction friction value
  124356. */
  124357. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124358. /**
  124359. * Gets restitution of the impostor
  124360. * @param impostor impostor to get restitution from
  124361. * @returns restitution value
  124362. */
  124363. getBodyRestitution(impostor: PhysicsImpostor): number;
  124364. /**
  124365. * Sets resitution of the impostor
  124366. * @param impostor impostor to set resitution on
  124367. * @param restitution resitution value
  124368. */
  124369. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124370. /**
  124371. * Gets pressure inside the impostor
  124372. * @param impostor impostor to get pressure from
  124373. * @returns pressure value
  124374. */
  124375. getBodyPressure(impostor: PhysicsImpostor): number;
  124376. /**
  124377. * Sets pressure inside a soft body impostor
  124378. * Cloth and rope must remain 0 pressure
  124379. * @param impostor impostor to set pressure on
  124380. * @param pressure pressure value
  124381. */
  124382. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  124383. /**
  124384. * Gets stiffness of the impostor
  124385. * @param impostor impostor to get stiffness from
  124386. * @returns pressure value
  124387. */
  124388. getBodyStiffness(impostor: PhysicsImpostor): number;
  124389. /**
  124390. * Sets stiffness of the impostor
  124391. * @param impostor impostor to set stiffness on
  124392. * @param stiffness stiffness value from 0 to 1
  124393. */
  124394. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  124395. /**
  124396. * Gets velocityIterations of the impostor
  124397. * @param impostor impostor to get velocity iterations from
  124398. * @returns velocityIterations value
  124399. */
  124400. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  124401. /**
  124402. * Sets velocityIterations of the impostor
  124403. * @param impostor impostor to set velocity iterations on
  124404. * @param velocityIterations velocityIterations value
  124405. */
  124406. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  124407. /**
  124408. * Gets positionIterations of the impostor
  124409. * @param impostor impostor to get position iterations from
  124410. * @returns positionIterations value
  124411. */
  124412. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  124413. /**
  124414. * Sets positionIterations of the impostor
  124415. * @param impostor impostor to set position on
  124416. * @param positionIterations positionIterations value
  124417. */
  124418. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  124419. /**
  124420. * Append an anchor to a cloth object
  124421. * @param impostor is the cloth impostor to add anchor to
  124422. * @param otherImpostor is the rigid impostor to anchor to
  124423. * @param width ratio across width from 0 to 1
  124424. * @param height ratio up height from 0 to 1
  124425. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  124426. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124427. */
  124428. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124429. /**
  124430. * Append an hook to a rope object
  124431. * @param impostor is the rope impostor to add hook to
  124432. * @param otherImpostor is the rigid impostor to hook to
  124433. * @param length ratio along the rope from 0 to 1
  124434. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  124435. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124436. */
  124437. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124438. /**
  124439. * Sleeps the physics body and stops it from being active
  124440. * @param impostor impostor to sleep
  124441. */
  124442. sleepBody(impostor: PhysicsImpostor): void;
  124443. /**
  124444. * Activates the physics body
  124445. * @param impostor impostor to activate
  124446. */
  124447. wakeUpBody(impostor: PhysicsImpostor): void;
  124448. /**
  124449. * Updates the distance parameters of the joint
  124450. * @param joint joint to update
  124451. * @param maxDistance maximum distance of the joint
  124452. * @param minDistance minimum distance of the joint
  124453. */
  124454. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124455. /**
  124456. * Sets a motor on the joint
  124457. * @param joint joint to set motor on
  124458. * @param speed speed of the motor
  124459. * @param maxForce maximum force of the motor
  124460. * @param motorIndex index of the motor
  124461. */
  124462. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124463. /**
  124464. * Sets the motors limit
  124465. * @param joint joint to set limit on
  124466. * @param upperLimit upper limit
  124467. * @param lowerLimit lower limit
  124468. */
  124469. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124470. /**
  124471. * Syncs the position and rotation of a mesh with the impostor
  124472. * @param mesh mesh to sync
  124473. * @param impostor impostor to update the mesh with
  124474. */
  124475. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124476. /**
  124477. * Gets the radius of the impostor
  124478. * @param impostor impostor to get radius from
  124479. * @returns the radius
  124480. */
  124481. getRadius(impostor: PhysicsImpostor): number;
  124482. /**
  124483. * Gets the box size of the impostor
  124484. * @param impostor impostor to get box size from
  124485. * @param result the resulting box size
  124486. */
  124487. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124488. /**
  124489. * Disposes of the impostor
  124490. */
  124491. dispose(): void;
  124492. /**
  124493. * Does a raycast in the physics world
  124494. * @param from when should the ray start?
  124495. * @param to when should the ray end?
  124496. * @returns PhysicsRaycastResult
  124497. */
  124498. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124499. }
  124500. }
  124501. declare module BABYLON {
  124502. interface AbstractScene {
  124503. /**
  124504. * The list of reflection probes added to the scene
  124505. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124506. */
  124507. reflectionProbes: Array<ReflectionProbe>;
  124508. /**
  124509. * Removes the given reflection probe from this scene.
  124510. * @param toRemove The reflection probe to remove
  124511. * @returns The index of the removed reflection probe
  124512. */
  124513. removeReflectionProbe(toRemove: ReflectionProbe): number;
  124514. /**
  124515. * Adds the given reflection probe to this scene.
  124516. * @param newReflectionProbe The reflection probe to add
  124517. */
  124518. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  124519. }
  124520. /**
  124521. * Class used to generate realtime reflection / refraction cube textures
  124522. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124523. */
  124524. export class ReflectionProbe {
  124525. /** defines the name of the probe */
  124526. name: string;
  124527. private _scene;
  124528. private _renderTargetTexture;
  124529. private _projectionMatrix;
  124530. private _viewMatrix;
  124531. private _target;
  124532. private _add;
  124533. private _attachedMesh;
  124534. private _invertYAxis;
  124535. /** Gets or sets probe position (center of the cube map) */
  124536. position: Vector3;
  124537. /**
  124538. * Creates a new reflection probe
  124539. * @param name defines the name of the probe
  124540. * @param size defines the texture resolution (for each face)
  124541. * @param scene defines the hosting scene
  124542. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  124543. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  124544. */
  124545. constructor(
  124546. /** defines the name of the probe */
  124547. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  124548. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  124549. get samples(): number;
  124550. set samples(value: number);
  124551. /** Gets or sets the refresh rate to use (on every frame by default) */
  124552. get refreshRate(): number;
  124553. set refreshRate(value: number);
  124554. /**
  124555. * Gets the hosting scene
  124556. * @returns a Scene
  124557. */
  124558. getScene(): Scene;
  124559. /** Gets the internal CubeTexture used to render to */
  124560. get cubeTexture(): RenderTargetTexture;
  124561. /** Gets the list of meshes to render */
  124562. get renderList(): Nullable<AbstractMesh[]>;
  124563. /**
  124564. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  124565. * @param mesh defines the mesh to attach to
  124566. */
  124567. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  124568. /**
  124569. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  124570. * @param renderingGroupId The rendering group id corresponding to its index
  124571. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124572. */
  124573. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  124574. /**
  124575. * Clean all associated resources
  124576. */
  124577. dispose(): void;
  124578. /**
  124579. * Converts the reflection probe information to a readable string for debug purpose.
  124580. * @param fullDetails Supports for multiple levels of logging within scene loading
  124581. * @returns the human readable reflection probe info
  124582. */
  124583. toString(fullDetails?: boolean): string;
  124584. /**
  124585. * Get the class name of the relfection probe.
  124586. * @returns "ReflectionProbe"
  124587. */
  124588. getClassName(): string;
  124589. /**
  124590. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  124591. * @returns The JSON representation of the texture
  124592. */
  124593. serialize(): any;
  124594. /**
  124595. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  124596. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  124597. * @param scene Define the scene the parsed reflection probe should be instantiated in
  124598. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  124599. * @returns The parsed reflection probe if successful
  124600. */
  124601. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  124602. }
  124603. }
  124604. declare module BABYLON {
  124605. /** @hidden */
  124606. export var _BabylonLoaderRegistered: boolean;
  124607. /**
  124608. * Helps setting up some configuration for the babylon file loader.
  124609. */
  124610. export class BabylonFileLoaderConfiguration {
  124611. /**
  124612. * The loader does not allow injecting custom physix engine into the plugins.
  124613. * Unfortunately in ES6, we need to manually inject them into the plugin.
  124614. * So you could set this variable to your engine import to make it work.
  124615. */
  124616. static LoaderInjectedPhysicsEngine: any;
  124617. }
  124618. }
  124619. declare module BABYLON {
  124620. /**
  124621. * The Physically based simple base material of BJS.
  124622. *
  124623. * This enables better naming and convention enforcements on top of the pbrMaterial.
  124624. * It is used as the base class for both the specGloss and metalRough conventions.
  124625. */
  124626. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  124627. /**
  124628. * Number of Simultaneous lights allowed on the material.
  124629. */
  124630. maxSimultaneousLights: number;
  124631. /**
  124632. * If sets to true, disables all the lights affecting the material.
  124633. */
  124634. disableLighting: boolean;
  124635. /**
  124636. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  124637. */
  124638. environmentTexture: BaseTexture;
  124639. /**
  124640. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124641. */
  124642. invertNormalMapX: boolean;
  124643. /**
  124644. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124645. */
  124646. invertNormalMapY: boolean;
  124647. /**
  124648. * Normal map used in the model.
  124649. */
  124650. normalTexture: BaseTexture;
  124651. /**
  124652. * Emissivie color used to self-illuminate the model.
  124653. */
  124654. emissiveColor: Color3;
  124655. /**
  124656. * Emissivie texture used to self-illuminate the model.
  124657. */
  124658. emissiveTexture: BaseTexture;
  124659. /**
  124660. * Occlusion Channel Strenght.
  124661. */
  124662. occlusionStrength: number;
  124663. /**
  124664. * Occlusion Texture of the material (adding extra occlusion effects).
  124665. */
  124666. occlusionTexture: BaseTexture;
  124667. /**
  124668. * Defines the alpha limits in alpha test mode.
  124669. */
  124670. alphaCutOff: number;
  124671. /**
  124672. * Gets the current double sided mode.
  124673. */
  124674. get doubleSided(): boolean;
  124675. /**
  124676. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124677. */
  124678. set doubleSided(value: boolean);
  124679. /**
  124680. * Stores the pre-calculated light information of a mesh in a texture.
  124681. */
  124682. lightmapTexture: BaseTexture;
  124683. /**
  124684. * If true, the light map contains occlusion information instead of lighting info.
  124685. */
  124686. useLightmapAsShadowmap: boolean;
  124687. /**
  124688. * Instantiates a new PBRMaterial instance.
  124689. *
  124690. * @param name The material name
  124691. * @param scene The scene the material will be use in.
  124692. */
  124693. constructor(name: string, scene: Scene);
  124694. getClassName(): string;
  124695. }
  124696. }
  124697. declare module BABYLON {
  124698. /**
  124699. * The PBR material of BJS following the metal roughness convention.
  124700. *
  124701. * This fits to the PBR convention in the GLTF definition:
  124702. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  124703. */
  124704. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  124705. /**
  124706. * The base color has two different interpretations depending on the value of metalness.
  124707. * When the material is a metal, the base color is the specific measured reflectance value
  124708. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  124709. * of the material.
  124710. */
  124711. baseColor: Color3;
  124712. /**
  124713. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  124714. * well as opacity information in the alpha channel.
  124715. */
  124716. baseTexture: BaseTexture;
  124717. /**
  124718. * Specifies the metallic scalar value of the material.
  124719. * Can also be used to scale the metalness values of the metallic texture.
  124720. */
  124721. metallic: number;
  124722. /**
  124723. * Specifies the roughness scalar value of the material.
  124724. * Can also be used to scale the roughness values of the metallic texture.
  124725. */
  124726. roughness: number;
  124727. /**
  124728. * Texture containing both the metallic value in the B channel and the
  124729. * roughness value in the G channel to keep better precision.
  124730. */
  124731. metallicRoughnessTexture: BaseTexture;
  124732. /**
  124733. * Instantiates a new PBRMetalRoughnessMaterial instance.
  124734. *
  124735. * @param name The material name
  124736. * @param scene The scene the material will be use in.
  124737. */
  124738. constructor(name: string, scene: Scene);
  124739. /**
  124740. * Return the currrent class name of the material.
  124741. */
  124742. getClassName(): string;
  124743. /**
  124744. * Makes a duplicate of the current material.
  124745. * @param name - name to use for the new material.
  124746. */
  124747. clone(name: string): PBRMetallicRoughnessMaterial;
  124748. /**
  124749. * Serialize the material to a parsable JSON object.
  124750. */
  124751. serialize(): any;
  124752. /**
  124753. * Parses a JSON object correponding to the serialize function.
  124754. */
  124755. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  124756. }
  124757. }
  124758. declare module BABYLON {
  124759. /**
  124760. * The PBR material of BJS following the specular glossiness convention.
  124761. *
  124762. * This fits to the PBR convention in the GLTF definition:
  124763. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  124764. */
  124765. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  124766. /**
  124767. * Specifies the diffuse color of the material.
  124768. */
  124769. diffuseColor: Color3;
  124770. /**
  124771. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  124772. * channel.
  124773. */
  124774. diffuseTexture: BaseTexture;
  124775. /**
  124776. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  124777. */
  124778. specularColor: Color3;
  124779. /**
  124780. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  124781. */
  124782. glossiness: number;
  124783. /**
  124784. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  124785. */
  124786. specularGlossinessTexture: BaseTexture;
  124787. /**
  124788. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  124789. *
  124790. * @param name The material name
  124791. * @param scene The scene the material will be use in.
  124792. */
  124793. constructor(name: string, scene: Scene);
  124794. /**
  124795. * Return the currrent class name of the material.
  124796. */
  124797. getClassName(): string;
  124798. /**
  124799. * Makes a duplicate of the current material.
  124800. * @param name - name to use for the new material.
  124801. */
  124802. clone(name: string): PBRSpecularGlossinessMaterial;
  124803. /**
  124804. * Serialize the material to a parsable JSON object.
  124805. */
  124806. serialize(): any;
  124807. /**
  124808. * Parses a JSON object correponding to the serialize function.
  124809. */
  124810. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  124811. }
  124812. }
  124813. declare module BABYLON {
  124814. /**
  124815. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  124816. * It can help converting any input color in a desired output one. This can then be used to create effects
  124817. * from sepia, black and white to sixties or futuristic rendering...
  124818. *
  124819. * The only supported format is currently 3dl.
  124820. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  124821. */
  124822. export class ColorGradingTexture extends BaseTexture {
  124823. /**
  124824. * The current texture matrix. (will always be identity in color grading texture)
  124825. */
  124826. private _textureMatrix;
  124827. /**
  124828. * The texture URL.
  124829. */
  124830. url: string;
  124831. /**
  124832. * Empty line regex stored for GC.
  124833. */
  124834. private static _noneEmptyLineRegex;
  124835. private _engine;
  124836. /**
  124837. * Instantiates a ColorGradingTexture from the following parameters.
  124838. *
  124839. * @param url The location of the color gradind data (currently only supporting 3dl)
  124840. * @param scene The scene the texture will be used in
  124841. */
  124842. constructor(url: string, scene: Scene);
  124843. /**
  124844. * Returns the texture matrix used in most of the material.
  124845. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  124846. */
  124847. getTextureMatrix(): Matrix;
  124848. /**
  124849. * Occurs when the file being loaded is a .3dl LUT file.
  124850. */
  124851. private load3dlTexture;
  124852. /**
  124853. * Starts the loading process of the texture.
  124854. */
  124855. private loadTexture;
  124856. /**
  124857. * Clones the color gradind texture.
  124858. */
  124859. clone(): ColorGradingTexture;
  124860. /**
  124861. * Called during delayed load for textures.
  124862. */
  124863. delayLoad(): void;
  124864. /**
  124865. * Parses a color grading texture serialized by Babylon.
  124866. * @param parsedTexture The texture information being parsedTexture
  124867. * @param scene The scene to load the texture in
  124868. * @param rootUrl The root url of the data assets to load
  124869. * @return A color gradind texture
  124870. */
  124871. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  124872. /**
  124873. * Serializes the LUT texture to json format.
  124874. */
  124875. serialize(): any;
  124876. }
  124877. }
  124878. declare module BABYLON {
  124879. /**
  124880. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  124881. */
  124882. export class EquiRectangularCubeTexture extends BaseTexture {
  124883. /** The six faces of the cube. */
  124884. private static _FacesMapping;
  124885. private _noMipmap;
  124886. private _onLoad;
  124887. private _onError;
  124888. /** The size of the cubemap. */
  124889. private _size;
  124890. /** The buffer of the image. */
  124891. private _buffer;
  124892. /** The width of the input image. */
  124893. private _width;
  124894. /** The height of the input image. */
  124895. private _height;
  124896. /** The URL to the image. */
  124897. url: string;
  124898. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  124899. coordinatesMode: number;
  124900. /**
  124901. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  124902. * @param url The location of the image
  124903. * @param scene The scene the texture will be used in
  124904. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  124905. * @param noMipmap Forces to not generate the mipmap if true
  124906. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  124907. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  124908. * @param onLoad — defines a callback called when texture is loaded
  124909. * @param onError — defines a callback called if there is an error
  124910. */
  124911. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  124912. /**
  124913. * Load the image data, by putting the image on a canvas and extracting its buffer.
  124914. */
  124915. private loadImage;
  124916. /**
  124917. * Convert the image buffer into a cubemap and create a CubeTexture.
  124918. */
  124919. private loadTexture;
  124920. /**
  124921. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  124922. * @param buffer The ArrayBuffer that should be converted.
  124923. * @returns The buffer as Float32Array.
  124924. */
  124925. private getFloat32ArrayFromArrayBuffer;
  124926. /**
  124927. * Get the current class name of the texture useful for serialization or dynamic coding.
  124928. * @returns "EquiRectangularCubeTexture"
  124929. */
  124930. getClassName(): string;
  124931. /**
  124932. * Create a clone of the current EquiRectangularCubeTexture and return it.
  124933. * @returns A clone of the current EquiRectangularCubeTexture.
  124934. */
  124935. clone(): EquiRectangularCubeTexture;
  124936. }
  124937. }
  124938. declare module BABYLON {
  124939. /**
  124940. * Based on jsTGALoader - Javascript loader for TGA file
  124941. * By Vincent Thibault
  124942. * @see http://blog.robrowser.com/javascript-tga-loader.html
  124943. */
  124944. export class TGATools {
  124945. private static _TYPE_INDEXED;
  124946. private static _TYPE_RGB;
  124947. private static _TYPE_GREY;
  124948. private static _TYPE_RLE_INDEXED;
  124949. private static _TYPE_RLE_RGB;
  124950. private static _TYPE_RLE_GREY;
  124951. private static _ORIGIN_MASK;
  124952. private static _ORIGIN_SHIFT;
  124953. private static _ORIGIN_BL;
  124954. private static _ORIGIN_BR;
  124955. private static _ORIGIN_UL;
  124956. private static _ORIGIN_UR;
  124957. /**
  124958. * Gets the header of a TGA file
  124959. * @param data defines the TGA data
  124960. * @returns the header
  124961. */
  124962. static GetTGAHeader(data: Uint8Array): any;
  124963. /**
  124964. * Uploads TGA content to a Babylon Texture
  124965. * @hidden
  124966. */
  124967. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  124968. /** @hidden */
  124969. 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;
  124970. /** @hidden */
  124971. 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;
  124972. /** @hidden */
  124973. 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;
  124974. /** @hidden */
  124975. 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;
  124976. /** @hidden */
  124977. 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;
  124978. /** @hidden */
  124979. 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;
  124980. }
  124981. }
  124982. declare module BABYLON {
  124983. /**
  124984. * Implementation of the TGA Texture Loader.
  124985. * @hidden
  124986. */
  124987. export class _TGATextureLoader implements IInternalTextureLoader {
  124988. /**
  124989. * Defines wether the loader supports cascade loading the different faces.
  124990. */
  124991. readonly supportCascades: boolean;
  124992. /**
  124993. * This returns if the loader support the current file information.
  124994. * @param extension defines the file extension of the file being loaded
  124995. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124996. * @param fallback defines the fallback internal texture if any
  124997. * @param isBase64 defines whether the texture is encoded as a base64
  124998. * @param isBuffer defines whether the texture data are stored as a buffer
  124999. * @returns true if the loader can load the specified file
  125000. */
  125001. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125002. /**
  125003. * Transform the url before loading if required.
  125004. * @param rootUrl the url of the texture
  125005. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125006. * @returns the transformed texture
  125007. */
  125008. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125009. /**
  125010. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125011. * @param rootUrl the url of the texture
  125012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125013. * @returns the fallback texture
  125014. */
  125015. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125016. /**
  125017. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125018. * @param data contains the texture data
  125019. * @param texture defines the BabylonJS internal texture
  125020. * @param createPolynomials will be true if polynomials have been requested
  125021. * @param onLoad defines the callback to trigger once the texture is ready
  125022. * @param onError defines the callback to trigger in case of error
  125023. */
  125024. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125025. /**
  125026. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125027. * @param data contains the texture data
  125028. * @param texture defines the BabylonJS internal texture
  125029. * @param callback defines the method to call once ready to upload
  125030. */
  125031. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125032. }
  125033. }
  125034. declare module BABYLON {
  125035. /**
  125036. * Info about the .basis files
  125037. */
  125038. class BasisFileInfo {
  125039. /**
  125040. * If the file has alpha
  125041. */
  125042. hasAlpha: boolean;
  125043. /**
  125044. * Info about each image of the basis file
  125045. */
  125046. images: Array<{
  125047. levels: Array<{
  125048. width: number;
  125049. height: number;
  125050. transcodedPixels: ArrayBufferView;
  125051. }>;
  125052. }>;
  125053. }
  125054. /**
  125055. * Result of transcoding a basis file
  125056. */
  125057. class TranscodeResult {
  125058. /**
  125059. * Info about the .basis file
  125060. */
  125061. fileInfo: BasisFileInfo;
  125062. /**
  125063. * Format to use when loading the file
  125064. */
  125065. format: number;
  125066. }
  125067. /**
  125068. * Configuration options for the Basis transcoder
  125069. */
  125070. export class BasisTranscodeConfiguration {
  125071. /**
  125072. * Supported compression formats used to determine the supported output format of the transcoder
  125073. */
  125074. supportedCompressionFormats?: {
  125075. /**
  125076. * etc1 compression format
  125077. */
  125078. etc1?: boolean;
  125079. /**
  125080. * s3tc compression format
  125081. */
  125082. s3tc?: boolean;
  125083. /**
  125084. * pvrtc compression format
  125085. */
  125086. pvrtc?: boolean;
  125087. /**
  125088. * etc2 compression format
  125089. */
  125090. etc2?: boolean;
  125091. };
  125092. /**
  125093. * If mipmap levels should be loaded for transcoded images (Default: true)
  125094. */
  125095. loadMipmapLevels?: boolean;
  125096. /**
  125097. * Index of a single image to load (Default: all images)
  125098. */
  125099. loadSingleImage?: number;
  125100. }
  125101. /**
  125102. * Used to load .Basis files
  125103. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  125104. */
  125105. export class BasisTools {
  125106. private static _IgnoreSupportedFormats;
  125107. /**
  125108. * URL to use when loading the basis transcoder
  125109. */
  125110. static JSModuleURL: string;
  125111. /**
  125112. * URL to use when loading the wasm module for the transcoder
  125113. */
  125114. static WasmModuleURL: string;
  125115. /**
  125116. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  125117. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  125118. * @returns internal format corresponding to the Basis format
  125119. */
  125120. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  125121. private static _WorkerPromise;
  125122. private static _Worker;
  125123. private static _actionId;
  125124. private static _CreateWorkerAsync;
  125125. /**
  125126. * Transcodes a loaded image file to compressed pixel data
  125127. * @param imageData image data to transcode
  125128. * @param config configuration options for the transcoding
  125129. * @returns a promise resulting in the transcoded image
  125130. */
  125131. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  125132. /**
  125133. * Loads a texture from the transcode result
  125134. * @param texture texture load to
  125135. * @param transcodeResult the result of transcoding the basis file to load from
  125136. */
  125137. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  125138. }
  125139. }
  125140. declare module BABYLON {
  125141. /**
  125142. * Loader for .basis file format
  125143. */
  125144. export class _BasisTextureLoader implements IInternalTextureLoader {
  125145. /**
  125146. * Defines whether the loader supports cascade loading the different faces.
  125147. */
  125148. readonly supportCascades: boolean;
  125149. /**
  125150. * This returns if the loader support the current file information.
  125151. * @param extension defines the file extension of the file being loaded
  125152. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125153. * @param fallback defines the fallback internal texture if any
  125154. * @param isBase64 defines whether the texture is encoded as a base64
  125155. * @param isBuffer defines whether the texture data are stored as a buffer
  125156. * @returns true if the loader can load the specified file
  125157. */
  125158. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125159. /**
  125160. * Transform the url before loading if required.
  125161. * @param rootUrl the url of the texture
  125162. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125163. * @returns the transformed texture
  125164. */
  125165. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125166. /**
  125167. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125168. * @param rootUrl the url of the texture
  125169. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125170. * @returns the fallback texture
  125171. */
  125172. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125173. /**
  125174. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  125175. * @param data contains the texture data
  125176. * @param texture defines the BabylonJS internal texture
  125177. * @param createPolynomials will be true if polynomials have been requested
  125178. * @param onLoad defines the callback to trigger once the texture is ready
  125179. * @param onError defines the callback to trigger in case of error
  125180. */
  125181. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125182. /**
  125183. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125184. * @param data contains the texture data
  125185. * @param texture defines the BabylonJS internal texture
  125186. * @param callback defines the method to call once ready to upload
  125187. */
  125188. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125189. }
  125190. }
  125191. declare module BABYLON {
  125192. /**
  125193. * 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.
  125194. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125195. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125196. */
  125197. export class CustomProceduralTexture extends ProceduralTexture {
  125198. private _animate;
  125199. private _time;
  125200. private _config;
  125201. private _texturePath;
  125202. /**
  125203. * Instantiates a new Custom Procedural Texture.
  125204. * 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.
  125205. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125206. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125207. * @param name Define the name of the texture
  125208. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  125209. * @param size Define the size of the texture to create
  125210. * @param scene Define the scene the texture belongs to
  125211. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  125212. * @param generateMipMaps Define if the texture should creates mip maps or not
  125213. */
  125214. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125215. private _loadJson;
  125216. /**
  125217. * Is the texture ready to be used ? (rendered at least once)
  125218. * @returns true if ready, otherwise, false.
  125219. */
  125220. isReady(): boolean;
  125221. /**
  125222. * Render the texture to its associated render target.
  125223. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  125224. */
  125225. render(useCameraPostProcess?: boolean): void;
  125226. /**
  125227. * Update the list of dependant textures samplers in the shader.
  125228. */
  125229. updateTextures(): void;
  125230. /**
  125231. * Update the uniform values of the procedural texture in the shader.
  125232. */
  125233. updateShaderUniforms(): void;
  125234. /**
  125235. * Define if the texture animates or not.
  125236. */
  125237. get animate(): boolean;
  125238. set animate(value: boolean);
  125239. }
  125240. }
  125241. declare module BABYLON {
  125242. /** @hidden */
  125243. export var noisePixelShader: {
  125244. name: string;
  125245. shader: string;
  125246. };
  125247. }
  125248. declare module BABYLON {
  125249. /**
  125250. * Class used to generate noise procedural textures
  125251. */
  125252. export class NoiseProceduralTexture extends ProceduralTexture {
  125253. private _time;
  125254. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  125255. brightness: number;
  125256. /** Defines the number of octaves to process */
  125257. octaves: number;
  125258. /** Defines the level of persistence (0.8 by default) */
  125259. persistence: number;
  125260. /** Gets or sets animation speed factor (default is 1) */
  125261. animationSpeedFactor: number;
  125262. /**
  125263. * Creates a new NoiseProceduralTexture
  125264. * @param name defines the name fo the texture
  125265. * @param size defines the size of the texture (default is 256)
  125266. * @param scene defines the hosting scene
  125267. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  125268. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  125269. */
  125270. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125271. private _updateShaderUniforms;
  125272. protected _getDefines(): string;
  125273. /** Generate the current state of the procedural texture */
  125274. render(useCameraPostProcess?: boolean): void;
  125275. /**
  125276. * Serializes this noise procedural texture
  125277. * @returns a serialized noise procedural texture object
  125278. */
  125279. serialize(): any;
  125280. /**
  125281. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  125282. * @param parsedTexture defines parsed texture data
  125283. * @param scene defines the current scene
  125284. * @param rootUrl defines the root URL containing noise procedural texture information
  125285. * @returns a parsed NoiseProceduralTexture
  125286. */
  125287. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  125288. }
  125289. }
  125290. declare module BABYLON {
  125291. /**
  125292. * Raw cube texture where the raw buffers are passed in
  125293. */
  125294. export class RawCubeTexture extends CubeTexture {
  125295. /**
  125296. * Creates a cube texture where the raw buffers are passed in.
  125297. * @param scene defines the scene the texture is attached to
  125298. * @param data defines the array of data to use to create each face
  125299. * @param size defines the size of the textures
  125300. * @param format defines the format of the data
  125301. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  125302. * @param generateMipMaps defines if the engine should generate the mip levels
  125303. * @param invertY defines if data must be stored with Y axis inverted
  125304. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  125305. * @param compression defines the compression used (null by default)
  125306. */
  125307. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  125308. /**
  125309. * Updates the raw cube texture.
  125310. * @param data defines the data to store
  125311. * @param format defines the data format
  125312. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125313. * @param invertY defines if data must be stored with Y axis inverted
  125314. * @param compression defines the compression used (null by default)
  125315. * @param level defines which level of the texture to update
  125316. */
  125317. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  125318. /**
  125319. * Updates a raw cube texture with RGBD encoded data.
  125320. * @param data defines the array of data [mipmap][face] to use to create each face
  125321. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  125322. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  125323. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  125324. * @returns a promsie that resolves when the operation is complete
  125325. */
  125326. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  125327. /**
  125328. * Clones the raw cube texture.
  125329. * @return a new cube texture
  125330. */
  125331. clone(): CubeTexture;
  125332. /** @hidden */
  125333. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  125334. }
  125335. }
  125336. declare module BABYLON {
  125337. /**
  125338. * Class used to store 3D textures containing user data
  125339. */
  125340. export class RawTexture3D extends Texture {
  125341. /** Gets or sets the texture format to use */
  125342. format: number;
  125343. private _engine;
  125344. /**
  125345. * Create a new RawTexture3D
  125346. * @param data defines the data of the texture
  125347. * @param width defines the width of the texture
  125348. * @param height defines the height of the texture
  125349. * @param depth defines the depth of the texture
  125350. * @param format defines the texture format to use
  125351. * @param scene defines the hosting scene
  125352. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125353. * @param invertY defines if texture must be stored with Y axis inverted
  125354. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125355. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125356. */
  125357. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125358. /** Gets or sets the texture format to use */
  125359. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125360. /**
  125361. * Update the texture with new data
  125362. * @param data defines the data to store in the texture
  125363. */
  125364. update(data: ArrayBufferView): void;
  125365. }
  125366. }
  125367. declare module BABYLON {
  125368. /**
  125369. * Class used to store 2D array textures containing user data
  125370. */
  125371. export class RawTexture2DArray extends Texture {
  125372. /** Gets or sets the texture format to use */
  125373. format: number;
  125374. private _engine;
  125375. /**
  125376. * Create a new RawTexture2DArray
  125377. * @param data defines the data of the texture
  125378. * @param width defines the width of the texture
  125379. * @param height defines the height of the texture
  125380. * @param depth defines the number of layers of the texture
  125381. * @param format defines the texture format to use
  125382. * @param scene defines the hosting scene
  125383. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125384. * @param invertY defines if texture must be stored with Y axis inverted
  125385. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125386. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125387. */
  125388. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125389. /** Gets or sets the texture format to use */
  125390. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125391. /**
  125392. * Update the texture with new data
  125393. * @param data defines the data to store in the texture
  125394. */
  125395. update(data: ArrayBufferView): void;
  125396. }
  125397. }
  125398. declare module BABYLON {
  125399. /**
  125400. * Creates a refraction texture used by refraction channel of the standard material.
  125401. * It is like a mirror but to see through a material.
  125402. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125403. */
  125404. export class RefractionTexture extends RenderTargetTexture {
  125405. /**
  125406. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  125407. * 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.
  125408. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125409. */
  125410. refractionPlane: Plane;
  125411. /**
  125412. * Define how deep under the surface we should see.
  125413. */
  125414. depth: number;
  125415. /**
  125416. * Creates a refraction texture used by refraction channel of the standard material.
  125417. * It is like a mirror but to see through a material.
  125418. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125419. * @param name Define the texture name
  125420. * @param size Define the size of the underlying texture
  125421. * @param scene Define the scene the refraction belongs to
  125422. * @param generateMipMaps Define if we need to generate mips level for the refraction
  125423. */
  125424. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  125425. /**
  125426. * Clone the refraction texture.
  125427. * @returns the cloned texture
  125428. */
  125429. clone(): RefractionTexture;
  125430. /**
  125431. * Serialize the texture to a JSON representation you could use in Parse later on
  125432. * @returns the serialized JSON representation
  125433. */
  125434. serialize(): any;
  125435. }
  125436. }
  125437. declare module BABYLON {
  125438. /**
  125439. * Defines the options related to the creation of an HtmlElementTexture
  125440. */
  125441. export interface IHtmlElementTextureOptions {
  125442. /**
  125443. * Defines wether mip maps should be created or not.
  125444. */
  125445. generateMipMaps?: boolean;
  125446. /**
  125447. * Defines the sampling mode of the texture.
  125448. */
  125449. samplingMode?: number;
  125450. /**
  125451. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  125452. */
  125453. engine: Nullable<ThinEngine>;
  125454. /**
  125455. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  125456. */
  125457. scene: Nullable<Scene>;
  125458. }
  125459. /**
  125460. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  125461. * To be as efficient as possible depending on your constraints nothing aside the first upload
  125462. * is automatically managed.
  125463. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  125464. * in your application.
  125465. *
  125466. * As the update is not automatic, you need to call them manually.
  125467. */
  125468. export class HtmlElementTexture extends BaseTexture {
  125469. /**
  125470. * The texture URL.
  125471. */
  125472. element: HTMLVideoElement | HTMLCanvasElement;
  125473. private static readonly DefaultOptions;
  125474. private _textureMatrix;
  125475. private _engine;
  125476. private _isVideo;
  125477. private _generateMipMaps;
  125478. private _samplingMode;
  125479. /**
  125480. * Instantiates a HtmlElementTexture from the following parameters.
  125481. *
  125482. * @param name Defines the name of the texture
  125483. * @param element Defines the video or canvas the texture is filled with
  125484. * @param options Defines the other none mandatory texture creation options
  125485. */
  125486. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  125487. private _createInternalTexture;
  125488. /**
  125489. * Returns the texture matrix used in most of the material.
  125490. */
  125491. getTextureMatrix(): Matrix;
  125492. /**
  125493. * Updates the content of the texture.
  125494. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  125495. */
  125496. update(invertY?: Nullable<boolean>): void;
  125497. }
  125498. }
  125499. declare module BABYLON {
  125500. /**
  125501. * Enum used to define the target of a block
  125502. */
  125503. export enum NodeMaterialBlockTargets {
  125504. /** Vertex shader */
  125505. Vertex = 1,
  125506. /** Fragment shader */
  125507. Fragment = 2,
  125508. /** Neutral */
  125509. Neutral = 4,
  125510. /** Vertex and Fragment */
  125511. VertexAndFragment = 3
  125512. }
  125513. }
  125514. declare module BABYLON {
  125515. /**
  125516. * Defines the kind of connection point for node based material
  125517. */
  125518. export enum NodeMaterialBlockConnectionPointTypes {
  125519. /** Float */
  125520. Float = 1,
  125521. /** Int */
  125522. Int = 2,
  125523. /** Vector2 */
  125524. Vector2 = 4,
  125525. /** Vector3 */
  125526. Vector3 = 8,
  125527. /** Vector4 */
  125528. Vector4 = 16,
  125529. /** Color3 */
  125530. Color3 = 32,
  125531. /** Color4 */
  125532. Color4 = 64,
  125533. /** Matrix */
  125534. Matrix = 128,
  125535. /** Detect type based on connection */
  125536. AutoDetect = 1024,
  125537. /** Output type that will be defined by input type */
  125538. BasedOnInput = 2048
  125539. }
  125540. }
  125541. declare module BABYLON {
  125542. /**
  125543. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  125544. */
  125545. export enum NodeMaterialBlockConnectionPointMode {
  125546. /** Value is an uniform */
  125547. Uniform = 0,
  125548. /** Value is a mesh attribute */
  125549. Attribute = 1,
  125550. /** Value is a varying between vertex and fragment shaders */
  125551. Varying = 2,
  125552. /** Mode is undefined */
  125553. Undefined = 3
  125554. }
  125555. }
  125556. declare module BABYLON {
  125557. /**
  125558. * Enum used to define system values e.g. values automatically provided by the system
  125559. */
  125560. export enum NodeMaterialSystemValues {
  125561. /** World */
  125562. World = 1,
  125563. /** View */
  125564. View = 2,
  125565. /** Projection */
  125566. Projection = 3,
  125567. /** ViewProjection */
  125568. ViewProjection = 4,
  125569. /** WorldView */
  125570. WorldView = 5,
  125571. /** WorldViewProjection */
  125572. WorldViewProjection = 6,
  125573. /** CameraPosition */
  125574. CameraPosition = 7,
  125575. /** Fog Color */
  125576. FogColor = 8,
  125577. /** Delta time */
  125578. DeltaTime = 9
  125579. }
  125580. }
  125581. declare module BABYLON {
  125582. /**
  125583. * Root class for all node material optimizers
  125584. */
  125585. export class NodeMaterialOptimizer {
  125586. /**
  125587. * Function used to optimize a NodeMaterial graph
  125588. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  125589. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  125590. */
  125591. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  125592. }
  125593. }
  125594. declare module BABYLON {
  125595. /**
  125596. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  125597. */
  125598. export class TransformBlock extends NodeMaterialBlock {
  125599. /**
  125600. * Defines the value to use to complement W value to transform it to a Vector4
  125601. */
  125602. complementW: number;
  125603. /**
  125604. * Defines the value to use to complement z value to transform it to a Vector4
  125605. */
  125606. complementZ: number;
  125607. /**
  125608. * Creates a new TransformBlock
  125609. * @param name defines the block name
  125610. */
  125611. constructor(name: string);
  125612. /**
  125613. * Gets the current class name
  125614. * @returns the class name
  125615. */
  125616. getClassName(): string;
  125617. /**
  125618. * Gets the vector input
  125619. */
  125620. get vector(): NodeMaterialConnectionPoint;
  125621. /**
  125622. * Gets the output component
  125623. */
  125624. get output(): NodeMaterialConnectionPoint;
  125625. /**
  125626. * Gets the matrix transform input
  125627. */
  125628. get transform(): NodeMaterialConnectionPoint;
  125629. protected _buildBlock(state: NodeMaterialBuildState): this;
  125630. serialize(): any;
  125631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125632. protected _dumpPropertiesCode(): string;
  125633. }
  125634. }
  125635. declare module BABYLON {
  125636. /**
  125637. * Block used to output the vertex position
  125638. */
  125639. export class VertexOutputBlock extends NodeMaterialBlock {
  125640. /**
  125641. * Creates a new VertexOutputBlock
  125642. * @param name defines the block name
  125643. */
  125644. constructor(name: string);
  125645. /**
  125646. * Gets the current class name
  125647. * @returns the class name
  125648. */
  125649. getClassName(): string;
  125650. /**
  125651. * Gets the vector input component
  125652. */
  125653. get vector(): NodeMaterialConnectionPoint;
  125654. protected _buildBlock(state: NodeMaterialBuildState): this;
  125655. }
  125656. }
  125657. declare module BABYLON {
  125658. /**
  125659. * Block used to output the final color
  125660. */
  125661. export class FragmentOutputBlock extends NodeMaterialBlock {
  125662. /**
  125663. * Create a new FragmentOutputBlock
  125664. * @param name defines the block name
  125665. */
  125666. constructor(name: string);
  125667. /**
  125668. * Gets the current class name
  125669. * @returns the class name
  125670. */
  125671. getClassName(): string;
  125672. /**
  125673. * Gets the rgba input component
  125674. */
  125675. get rgba(): NodeMaterialConnectionPoint;
  125676. /**
  125677. * Gets the rgb input component
  125678. */
  125679. get rgb(): NodeMaterialConnectionPoint;
  125680. /**
  125681. * Gets the a input component
  125682. */
  125683. get a(): NodeMaterialConnectionPoint;
  125684. protected _buildBlock(state: NodeMaterialBuildState): this;
  125685. }
  125686. }
  125687. declare module BABYLON {
  125688. /**
  125689. * Block used to read a reflection texture from a sampler
  125690. */
  125691. export class ReflectionTextureBlock extends NodeMaterialBlock {
  125692. private _define3DName;
  125693. private _defineCubicName;
  125694. private _defineExplicitName;
  125695. private _defineProjectionName;
  125696. private _defineLocalCubicName;
  125697. private _defineSphericalName;
  125698. private _definePlanarName;
  125699. private _defineEquirectangularName;
  125700. private _defineMirroredEquirectangularFixedName;
  125701. private _defineEquirectangularFixedName;
  125702. private _defineSkyboxName;
  125703. private _cubeSamplerName;
  125704. private _2DSamplerName;
  125705. private _positionUVWName;
  125706. private _directionWName;
  125707. private _reflectionCoordsName;
  125708. private _reflection2DCoordsName;
  125709. private _reflectionColorName;
  125710. private _reflectionMatrixName;
  125711. /**
  125712. * Gets or sets the texture associated with the node
  125713. */
  125714. texture: Nullable<BaseTexture>;
  125715. /**
  125716. * Create a new TextureBlock
  125717. * @param name defines the block name
  125718. */
  125719. constructor(name: string);
  125720. /**
  125721. * Gets the current class name
  125722. * @returns the class name
  125723. */
  125724. getClassName(): string;
  125725. /**
  125726. * Gets the world position input component
  125727. */
  125728. get position(): NodeMaterialConnectionPoint;
  125729. /**
  125730. * Gets the world position input component
  125731. */
  125732. get worldPosition(): NodeMaterialConnectionPoint;
  125733. /**
  125734. * Gets the world normal input component
  125735. */
  125736. get worldNormal(): NodeMaterialConnectionPoint;
  125737. /**
  125738. * Gets the world input component
  125739. */
  125740. get world(): NodeMaterialConnectionPoint;
  125741. /**
  125742. * Gets the camera (or eye) position component
  125743. */
  125744. get cameraPosition(): NodeMaterialConnectionPoint;
  125745. /**
  125746. * Gets the view input component
  125747. */
  125748. get view(): NodeMaterialConnectionPoint;
  125749. /**
  125750. * Gets the rgb output component
  125751. */
  125752. get rgb(): NodeMaterialConnectionPoint;
  125753. /**
  125754. * Gets the r output component
  125755. */
  125756. get r(): NodeMaterialConnectionPoint;
  125757. /**
  125758. * Gets the g output component
  125759. */
  125760. get g(): NodeMaterialConnectionPoint;
  125761. /**
  125762. * Gets the b output component
  125763. */
  125764. get b(): NodeMaterialConnectionPoint;
  125765. autoConfigure(material: NodeMaterial): void;
  125766. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125767. isReady(): boolean;
  125768. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125769. private _injectVertexCode;
  125770. private _writeOutput;
  125771. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125772. protected _dumpPropertiesCode(): string;
  125773. serialize(): any;
  125774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125775. }
  125776. }
  125777. declare module BABYLON {
  125778. /**
  125779. * Interface used to configure the node material editor
  125780. */
  125781. export interface INodeMaterialEditorOptions {
  125782. /** Define the URl to load node editor script */
  125783. editorURL?: string;
  125784. }
  125785. /** @hidden */
  125786. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  125787. /** BONES */
  125788. NUM_BONE_INFLUENCERS: number;
  125789. BonesPerMesh: number;
  125790. BONETEXTURE: boolean;
  125791. /** MORPH TARGETS */
  125792. MORPHTARGETS: boolean;
  125793. MORPHTARGETS_NORMAL: boolean;
  125794. MORPHTARGETS_TANGENT: boolean;
  125795. MORPHTARGETS_UV: boolean;
  125796. NUM_MORPH_INFLUENCERS: number;
  125797. /** IMAGE PROCESSING */
  125798. IMAGEPROCESSING: boolean;
  125799. VIGNETTE: boolean;
  125800. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125801. VIGNETTEBLENDMODEOPAQUE: boolean;
  125802. TONEMAPPING: boolean;
  125803. TONEMAPPING_ACES: boolean;
  125804. CONTRAST: boolean;
  125805. EXPOSURE: boolean;
  125806. COLORCURVES: boolean;
  125807. COLORGRADING: boolean;
  125808. COLORGRADING3D: boolean;
  125809. SAMPLER3DGREENDEPTH: boolean;
  125810. SAMPLER3DBGRMAP: boolean;
  125811. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125812. /** MISC. */
  125813. BUMPDIRECTUV: number;
  125814. constructor();
  125815. setValue(name: string, value: boolean): void;
  125816. }
  125817. /**
  125818. * Class used to configure NodeMaterial
  125819. */
  125820. export interface INodeMaterialOptions {
  125821. /**
  125822. * Defines if blocks should emit comments
  125823. */
  125824. emitComments: boolean;
  125825. }
  125826. /**
  125827. * Class used to create a node based material built by assembling shader blocks
  125828. */
  125829. export class NodeMaterial extends PushMaterial {
  125830. private static _BuildIdGenerator;
  125831. private _options;
  125832. private _vertexCompilationState;
  125833. private _fragmentCompilationState;
  125834. private _sharedData;
  125835. private _buildId;
  125836. private _buildWasSuccessful;
  125837. private _cachedWorldViewMatrix;
  125838. private _cachedWorldViewProjectionMatrix;
  125839. private _optimizers;
  125840. private _animationFrame;
  125841. /** Define the URl to load node editor script */
  125842. static EditorURL: string;
  125843. private BJSNODEMATERIALEDITOR;
  125844. /** Get the inspector from bundle or global */
  125845. private _getGlobalNodeMaterialEditor;
  125846. /**
  125847. * Gets or sets data used by visual editor
  125848. * @see https://nme.babylonjs.com
  125849. */
  125850. editorData: any;
  125851. /**
  125852. * 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)
  125853. */
  125854. ignoreAlpha: boolean;
  125855. /**
  125856. * Defines the maximum number of lights that can be used in the material
  125857. */
  125858. maxSimultaneousLights: number;
  125859. /**
  125860. * Observable raised when the material is built
  125861. */
  125862. onBuildObservable: Observable<NodeMaterial>;
  125863. /**
  125864. * Gets or sets the root nodes of the material vertex shader
  125865. */
  125866. _vertexOutputNodes: NodeMaterialBlock[];
  125867. /**
  125868. * Gets or sets the root nodes of the material fragment (pixel) shader
  125869. */
  125870. _fragmentOutputNodes: NodeMaterialBlock[];
  125871. /** Gets or sets options to control the node material overall behavior */
  125872. get options(): INodeMaterialOptions;
  125873. set options(options: INodeMaterialOptions);
  125874. /**
  125875. * Default configuration related to image processing available in the standard Material.
  125876. */
  125877. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125878. /**
  125879. * Gets the image processing configuration used either in this material.
  125880. */
  125881. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125882. /**
  125883. * Sets the Default image processing configuration used either in the this material.
  125884. *
  125885. * If sets to null, the scene one is in use.
  125886. */
  125887. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125888. /**
  125889. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  125890. */
  125891. attachedBlocks: NodeMaterialBlock[];
  125892. /**
  125893. * Create a new node based material
  125894. * @param name defines the material name
  125895. * @param scene defines the hosting scene
  125896. * @param options defines creation option
  125897. */
  125898. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  125899. /**
  125900. * Gets the current class name of the material e.g. "NodeMaterial"
  125901. * @returns the class name
  125902. */
  125903. getClassName(): string;
  125904. /**
  125905. * Keep track of the image processing observer to allow dispose and replace.
  125906. */
  125907. private _imageProcessingObserver;
  125908. /**
  125909. * Attaches a new image processing configuration to the Standard Material.
  125910. * @param configuration
  125911. */
  125912. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125913. /**
  125914. * Get a block by its name
  125915. * @param name defines the name of the block to retrieve
  125916. * @returns the required block or null if not found
  125917. */
  125918. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  125919. /**
  125920. * Get a block by its name
  125921. * @param predicate defines the predicate used to find the good candidate
  125922. * @returns the required block or null if not found
  125923. */
  125924. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  125925. /**
  125926. * Get an input block by its name
  125927. * @param predicate defines the predicate used to find the good candidate
  125928. * @returns the required input block or null if not found
  125929. */
  125930. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  125931. /**
  125932. * Gets the list of input blocks attached to this material
  125933. * @returns an array of InputBlocks
  125934. */
  125935. getInputBlocks(): InputBlock[];
  125936. /**
  125937. * Adds a new optimizer to the list of optimizers
  125938. * @param optimizer defines the optimizers to add
  125939. * @returns the current material
  125940. */
  125941. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  125942. /**
  125943. * Remove an optimizer from the list of optimizers
  125944. * @param optimizer defines the optimizers to remove
  125945. * @returns the current material
  125946. */
  125947. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  125948. /**
  125949. * Add a new block to the list of output nodes
  125950. * @param node defines the node to add
  125951. * @returns the current material
  125952. */
  125953. addOutputNode(node: NodeMaterialBlock): this;
  125954. /**
  125955. * Remove a block from the list of root nodes
  125956. * @param node defines the node to remove
  125957. * @returns the current material
  125958. */
  125959. removeOutputNode(node: NodeMaterialBlock): this;
  125960. private _addVertexOutputNode;
  125961. private _removeVertexOutputNode;
  125962. private _addFragmentOutputNode;
  125963. private _removeFragmentOutputNode;
  125964. /**
  125965. * Specifies if the material will require alpha blending
  125966. * @returns a boolean specifying if alpha blending is needed
  125967. */
  125968. needAlphaBlending(): boolean;
  125969. /**
  125970. * Specifies if this material should be rendered in alpha test mode
  125971. * @returns a boolean specifying if an alpha test is needed.
  125972. */
  125973. needAlphaTesting(): boolean;
  125974. private _initializeBlock;
  125975. private _resetDualBlocks;
  125976. /**
  125977. * Remove a block from the current node material
  125978. * @param block defines the block to remove
  125979. */
  125980. removeBlock(block: NodeMaterialBlock): void;
  125981. /**
  125982. * Build the material and generates the inner effect
  125983. * @param verbose defines if the build should log activity
  125984. */
  125985. build(verbose?: boolean): void;
  125986. /**
  125987. * Runs an otpimization phase to try to improve the shader code
  125988. */
  125989. optimize(): void;
  125990. private _prepareDefinesForAttributes;
  125991. /**
  125992. * Get if the submesh is ready to be used and all its information available.
  125993. * Child classes can use it to update shaders
  125994. * @param mesh defines the mesh to check
  125995. * @param subMesh defines which submesh to check
  125996. * @param useInstances specifies that instances should be used
  125997. * @returns a boolean indicating that the submesh is ready or not
  125998. */
  125999. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126000. /**
  126001. * Get a string representing the shaders built by the current node graph
  126002. */
  126003. get compiledShaders(): string;
  126004. /**
  126005. * Binds the world matrix to the material
  126006. * @param world defines the world transformation matrix
  126007. */
  126008. bindOnlyWorldMatrix(world: Matrix): void;
  126009. /**
  126010. * Binds the submesh to this material by preparing the effect and shader to draw
  126011. * @param world defines the world transformation matrix
  126012. * @param mesh defines the mesh containing the submesh
  126013. * @param subMesh defines the submesh to bind the material to
  126014. */
  126015. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126016. /**
  126017. * Gets the active textures from the material
  126018. * @returns an array of textures
  126019. */
  126020. getActiveTextures(): BaseTexture[];
  126021. /**
  126022. * Gets the list of texture blocks
  126023. * @returns an array of texture blocks
  126024. */
  126025. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  126026. /**
  126027. * Specifies if the material uses a texture
  126028. * @param texture defines the texture to check against the material
  126029. * @returns a boolean specifying if the material uses the texture
  126030. */
  126031. hasTexture(texture: BaseTexture): boolean;
  126032. /**
  126033. * Disposes the material
  126034. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  126035. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  126036. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  126037. */
  126038. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  126039. /** Creates the node editor window. */
  126040. private _createNodeEditor;
  126041. /**
  126042. * Launch the node material editor
  126043. * @param config Define the configuration of the editor
  126044. * @return a promise fulfilled when the node editor is visible
  126045. */
  126046. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  126047. /**
  126048. * Clear the current material
  126049. */
  126050. clear(): void;
  126051. /**
  126052. * Clear the current material and set it to a default state
  126053. */
  126054. setToDefault(): void;
  126055. /**
  126056. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  126057. * @param url defines the url to load from
  126058. * @returns a promise that will fullfil when the material is fully loaded
  126059. */
  126060. loadAsync(url: string): Promise<void>;
  126061. private _gatherBlocks;
  126062. /**
  126063. * Generate a string containing the code declaration required to create an equivalent of this material
  126064. * @returns a string
  126065. */
  126066. generateCode(): string;
  126067. /**
  126068. * Serializes this material in a JSON representation
  126069. * @returns the serialized material object
  126070. */
  126071. serialize(): any;
  126072. private _restoreConnections;
  126073. /**
  126074. * Clear the current graph and load a new one from a serialization object
  126075. * @param source defines the JSON representation of the material
  126076. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126077. */
  126078. loadFromSerialization(source: any, rootUrl?: string): void;
  126079. /**
  126080. * Creates a node material from parsed material data
  126081. * @param source defines the JSON representation of the material
  126082. * @param scene defines the hosting scene
  126083. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126084. * @returns a new node material
  126085. */
  126086. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  126087. /**
  126088. * Creates a new node material set to default basic configuration
  126089. * @param name defines the name of the material
  126090. * @param scene defines the hosting scene
  126091. * @returns a new NodeMaterial
  126092. */
  126093. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  126094. }
  126095. }
  126096. declare module BABYLON {
  126097. /**
  126098. * Block used to read a texture from a sampler
  126099. */
  126100. export class TextureBlock extends NodeMaterialBlock {
  126101. private _defineName;
  126102. private _linearDefineName;
  126103. private _tempTextureRead;
  126104. private _samplerName;
  126105. private _transformedUVName;
  126106. private _textureTransformName;
  126107. private _textureInfoName;
  126108. private _mainUVName;
  126109. private _mainUVDefineName;
  126110. /**
  126111. * Gets or sets the texture associated with the node
  126112. */
  126113. texture: Nullable<Texture>;
  126114. /**
  126115. * Create a new TextureBlock
  126116. * @param name defines the block name
  126117. */
  126118. constructor(name: string);
  126119. /**
  126120. * Gets the current class name
  126121. * @returns the class name
  126122. */
  126123. getClassName(): string;
  126124. /**
  126125. * Gets the uv input component
  126126. */
  126127. get uv(): NodeMaterialConnectionPoint;
  126128. /**
  126129. * Gets the rgba output component
  126130. */
  126131. get rgba(): NodeMaterialConnectionPoint;
  126132. /**
  126133. * Gets the rgb output component
  126134. */
  126135. get rgb(): NodeMaterialConnectionPoint;
  126136. /**
  126137. * Gets the r output component
  126138. */
  126139. get r(): NodeMaterialConnectionPoint;
  126140. /**
  126141. * Gets the g output component
  126142. */
  126143. get g(): NodeMaterialConnectionPoint;
  126144. /**
  126145. * Gets the b output component
  126146. */
  126147. get b(): NodeMaterialConnectionPoint;
  126148. /**
  126149. * Gets the a output component
  126150. */
  126151. get a(): NodeMaterialConnectionPoint;
  126152. get target(): NodeMaterialBlockTargets;
  126153. autoConfigure(material: NodeMaterial): void;
  126154. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126156. private _getTextureBase;
  126157. isReady(): boolean;
  126158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126159. private get _isMixed();
  126160. private _injectVertexCode;
  126161. private _writeTextureRead;
  126162. private _writeOutput;
  126163. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126164. protected _dumpPropertiesCode(): string;
  126165. serialize(): any;
  126166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126167. }
  126168. }
  126169. declare module BABYLON {
  126170. /**
  126171. * Class used to store shared data between 2 NodeMaterialBuildState
  126172. */
  126173. export class NodeMaterialBuildStateSharedData {
  126174. /**
  126175. * Gets the list of emitted varyings
  126176. */
  126177. temps: string[];
  126178. /**
  126179. * Gets the list of emitted varyings
  126180. */
  126181. varyings: string[];
  126182. /**
  126183. * Gets the varying declaration string
  126184. */
  126185. varyingDeclaration: string;
  126186. /**
  126187. * Input blocks
  126188. */
  126189. inputBlocks: InputBlock[];
  126190. /**
  126191. * Input blocks
  126192. */
  126193. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  126194. /**
  126195. * Bindable blocks (Blocks that need to set data to the effect)
  126196. */
  126197. bindableBlocks: NodeMaterialBlock[];
  126198. /**
  126199. * List of blocks that can provide a compilation fallback
  126200. */
  126201. blocksWithFallbacks: NodeMaterialBlock[];
  126202. /**
  126203. * List of blocks that can provide a define update
  126204. */
  126205. blocksWithDefines: NodeMaterialBlock[];
  126206. /**
  126207. * List of blocks that can provide a repeatable content
  126208. */
  126209. repeatableContentBlocks: NodeMaterialBlock[];
  126210. /**
  126211. * List of blocks that can provide a dynamic list of uniforms
  126212. */
  126213. dynamicUniformBlocks: NodeMaterialBlock[];
  126214. /**
  126215. * List of blocks that can block the isReady function for the material
  126216. */
  126217. blockingBlocks: NodeMaterialBlock[];
  126218. /**
  126219. * Gets the list of animated inputs
  126220. */
  126221. animatedInputs: InputBlock[];
  126222. /**
  126223. * Build Id used to avoid multiple recompilations
  126224. */
  126225. buildId: number;
  126226. /** List of emitted variables */
  126227. variableNames: {
  126228. [key: string]: number;
  126229. };
  126230. /** List of emitted defines */
  126231. defineNames: {
  126232. [key: string]: number;
  126233. };
  126234. /** Should emit comments? */
  126235. emitComments: boolean;
  126236. /** Emit build activity */
  126237. verbose: boolean;
  126238. /** Gets or sets the hosting scene */
  126239. scene: Scene;
  126240. /**
  126241. * Gets the compilation hints emitted at compilation time
  126242. */
  126243. hints: {
  126244. needWorldViewMatrix: boolean;
  126245. needWorldViewProjectionMatrix: boolean;
  126246. needAlphaBlending: boolean;
  126247. needAlphaTesting: boolean;
  126248. };
  126249. /**
  126250. * List of compilation checks
  126251. */
  126252. checks: {
  126253. emitVertex: boolean;
  126254. emitFragment: boolean;
  126255. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  126256. };
  126257. /** Creates a new shared data */
  126258. constructor();
  126259. /**
  126260. * Emits console errors and exceptions if there is a failing check
  126261. */
  126262. emitErrors(): void;
  126263. }
  126264. }
  126265. declare module BABYLON {
  126266. /**
  126267. * Class used to store node based material build state
  126268. */
  126269. export class NodeMaterialBuildState {
  126270. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  126271. supportUniformBuffers: boolean;
  126272. /**
  126273. * Gets the list of emitted attributes
  126274. */
  126275. attributes: string[];
  126276. /**
  126277. * Gets the list of emitted uniforms
  126278. */
  126279. uniforms: string[];
  126280. /**
  126281. * Gets the list of emitted constants
  126282. */
  126283. constants: string[];
  126284. /**
  126285. * Gets the list of emitted samplers
  126286. */
  126287. samplers: string[];
  126288. /**
  126289. * Gets the list of emitted functions
  126290. */
  126291. functions: {
  126292. [key: string]: string;
  126293. };
  126294. /**
  126295. * Gets the list of emitted extensions
  126296. */
  126297. extensions: {
  126298. [key: string]: string;
  126299. };
  126300. /**
  126301. * Gets the target of the compilation state
  126302. */
  126303. target: NodeMaterialBlockTargets;
  126304. /**
  126305. * Gets the list of emitted counters
  126306. */
  126307. counters: {
  126308. [key: string]: number;
  126309. };
  126310. /**
  126311. * Shared data between multiple NodeMaterialBuildState instances
  126312. */
  126313. sharedData: NodeMaterialBuildStateSharedData;
  126314. /** @hidden */
  126315. _vertexState: NodeMaterialBuildState;
  126316. /** @hidden */
  126317. _attributeDeclaration: string;
  126318. /** @hidden */
  126319. _uniformDeclaration: string;
  126320. /** @hidden */
  126321. _constantDeclaration: string;
  126322. /** @hidden */
  126323. _samplerDeclaration: string;
  126324. /** @hidden */
  126325. _varyingTransfer: string;
  126326. private _repeatableContentAnchorIndex;
  126327. /** @hidden */
  126328. _builtCompilationString: string;
  126329. /**
  126330. * Gets the emitted compilation strings
  126331. */
  126332. compilationString: string;
  126333. /**
  126334. * Finalize the compilation strings
  126335. * @param state defines the current compilation state
  126336. */
  126337. finalize(state: NodeMaterialBuildState): void;
  126338. /** @hidden */
  126339. get _repeatableContentAnchor(): string;
  126340. /** @hidden */
  126341. _getFreeVariableName(prefix: string): string;
  126342. /** @hidden */
  126343. _getFreeDefineName(prefix: string): string;
  126344. /** @hidden */
  126345. _excludeVariableName(name: string): void;
  126346. /** @hidden */
  126347. _emit2DSampler(name: string): void;
  126348. /** @hidden */
  126349. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  126350. /** @hidden */
  126351. _emitExtension(name: string, extension: string): void;
  126352. /** @hidden */
  126353. _emitFunction(name: string, code: string, comments: string): void;
  126354. /** @hidden */
  126355. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  126356. replaceStrings?: {
  126357. search: RegExp;
  126358. replace: string;
  126359. }[];
  126360. repeatKey?: string;
  126361. }): string;
  126362. /** @hidden */
  126363. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  126364. repeatKey?: string;
  126365. removeAttributes?: boolean;
  126366. removeUniforms?: boolean;
  126367. removeVaryings?: boolean;
  126368. removeIfDef?: boolean;
  126369. replaceStrings?: {
  126370. search: RegExp;
  126371. replace: string;
  126372. }[];
  126373. }, storeKey?: string): void;
  126374. /** @hidden */
  126375. _registerTempVariable(name: string): boolean;
  126376. /** @hidden */
  126377. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  126378. /** @hidden */
  126379. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  126380. /** @hidden */
  126381. _emitFloat(value: number): string;
  126382. }
  126383. }
  126384. declare module BABYLON {
  126385. /**
  126386. * Defines a block that can be used inside a node based material
  126387. */
  126388. export class NodeMaterialBlock {
  126389. private _buildId;
  126390. private _buildTarget;
  126391. private _target;
  126392. private _isFinalMerger;
  126393. private _isInput;
  126394. protected _isUnique: boolean;
  126395. /** @hidden */
  126396. _codeVariableName: string;
  126397. /** @hidden */
  126398. _inputs: NodeMaterialConnectionPoint[];
  126399. /** @hidden */
  126400. _outputs: NodeMaterialConnectionPoint[];
  126401. /** @hidden */
  126402. _preparationId: number;
  126403. /**
  126404. * Gets or sets the name of the block
  126405. */
  126406. name: string;
  126407. /**
  126408. * Gets or sets the unique id of the node
  126409. */
  126410. uniqueId: number;
  126411. /**
  126412. * Gets or sets the comments associated with this block
  126413. */
  126414. comments: string;
  126415. /**
  126416. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  126417. */
  126418. get isUnique(): boolean;
  126419. /**
  126420. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  126421. */
  126422. get isFinalMerger(): boolean;
  126423. /**
  126424. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  126425. */
  126426. get isInput(): boolean;
  126427. /**
  126428. * Gets or sets the build Id
  126429. */
  126430. get buildId(): number;
  126431. set buildId(value: number);
  126432. /**
  126433. * Gets or sets the target of the block
  126434. */
  126435. get target(): NodeMaterialBlockTargets;
  126436. set target(value: NodeMaterialBlockTargets);
  126437. /**
  126438. * Gets the list of input points
  126439. */
  126440. get inputs(): NodeMaterialConnectionPoint[];
  126441. /** Gets the list of output points */
  126442. get outputs(): NodeMaterialConnectionPoint[];
  126443. /**
  126444. * Find an input by its name
  126445. * @param name defines the name of the input to look for
  126446. * @returns the input or null if not found
  126447. */
  126448. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126449. /**
  126450. * Find an output by its name
  126451. * @param name defines the name of the outputto look for
  126452. * @returns the output or null if not found
  126453. */
  126454. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126455. /**
  126456. * Creates a new NodeMaterialBlock
  126457. * @param name defines the block name
  126458. * @param target defines the target of that block (Vertex by default)
  126459. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  126460. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  126461. */
  126462. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  126463. /**
  126464. * Initialize the block and prepare the context for build
  126465. * @param state defines the state that will be used for the build
  126466. */
  126467. initialize(state: NodeMaterialBuildState): void;
  126468. /**
  126469. * Bind data to effect. Will only be called for blocks with isBindable === true
  126470. * @param effect defines the effect to bind data to
  126471. * @param nodeMaterial defines the hosting NodeMaterial
  126472. * @param mesh defines the mesh that will be rendered
  126473. */
  126474. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126475. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  126476. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  126477. protected _writeFloat(value: number): string;
  126478. /**
  126479. * Gets the current class name e.g. "NodeMaterialBlock"
  126480. * @returns the class name
  126481. */
  126482. getClassName(): string;
  126483. /**
  126484. * Register a new input. Must be called inside a block constructor
  126485. * @param name defines the connection point name
  126486. * @param type defines the connection point type
  126487. * @param isOptional defines a boolean indicating that this input can be omitted
  126488. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126489. * @returns the current block
  126490. */
  126491. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  126492. /**
  126493. * Register a new output. Must be called inside a block constructor
  126494. * @param name defines the connection point name
  126495. * @param type defines the connection point type
  126496. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126497. * @returns the current block
  126498. */
  126499. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  126500. /**
  126501. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  126502. * @param forOutput defines an optional connection point to check compatibility with
  126503. * @returns the first available input or null
  126504. */
  126505. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  126506. /**
  126507. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  126508. * @param forBlock defines an optional block to check compatibility with
  126509. * @returns the first available input or null
  126510. */
  126511. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  126512. /**
  126513. * Gets the sibling of the given output
  126514. * @param current defines the current output
  126515. * @returns the next output in the list or null
  126516. */
  126517. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  126518. /**
  126519. * Connect current block with another block
  126520. * @param other defines the block to connect with
  126521. * @param options define the various options to help pick the right connections
  126522. * @returns the current block
  126523. */
  126524. connectTo(other: NodeMaterialBlock, options?: {
  126525. input?: string;
  126526. output?: string;
  126527. outputSwizzle?: string;
  126528. }): this | undefined;
  126529. protected _buildBlock(state: NodeMaterialBuildState): void;
  126530. /**
  126531. * Add uniforms, samplers and uniform buffers at compilation time
  126532. * @param state defines the state to update
  126533. * @param nodeMaterial defines the node material requesting the update
  126534. * @param defines defines the material defines to update
  126535. * @param uniformBuffers defines the list of uniform buffer names
  126536. */
  126537. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  126538. /**
  126539. * Add potential fallbacks if shader compilation fails
  126540. * @param mesh defines the mesh to be rendered
  126541. * @param fallbacks defines the current prioritized list of fallbacks
  126542. */
  126543. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126544. /**
  126545. * Initialize defines for shader compilation
  126546. * @param mesh defines the mesh to be rendered
  126547. * @param nodeMaterial defines the node material requesting the update
  126548. * @param defines defines the material defines to update
  126549. * @param useInstances specifies that instances should be used
  126550. */
  126551. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126552. /**
  126553. * Update defines for shader compilation
  126554. * @param mesh defines the mesh to be rendered
  126555. * @param nodeMaterial defines the node material requesting the update
  126556. * @param defines defines the material defines to update
  126557. * @param useInstances specifies that instances should be used
  126558. */
  126559. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126560. /**
  126561. * Lets the block try to connect some inputs automatically
  126562. * @param material defines the hosting NodeMaterial
  126563. */
  126564. autoConfigure(material: NodeMaterial): void;
  126565. /**
  126566. * Function called when a block is declared as repeatable content generator
  126567. * @param vertexShaderState defines the current compilation state for the vertex shader
  126568. * @param fragmentShaderState defines the current compilation state for the fragment shader
  126569. * @param mesh defines the mesh to be rendered
  126570. * @param defines defines the material defines to update
  126571. */
  126572. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  126573. /**
  126574. * Checks if the block is ready
  126575. * @param mesh defines the mesh to be rendered
  126576. * @param nodeMaterial defines the node material requesting the update
  126577. * @param defines defines the material defines to update
  126578. * @param useInstances specifies that instances should be used
  126579. * @returns true if the block is ready
  126580. */
  126581. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  126582. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  126583. private _processBuild;
  126584. /**
  126585. * Compile the current node and generate the shader code
  126586. * @param state defines the current compilation state (uniforms, samplers, current string)
  126587. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  126588. * @returns true if already built
  126589. */
  126590. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  126591. protected _inputRename(name: string): string;
  126592. protected _outputRename(name: string): string;
  126593. protected _dumpPropertiesCode(): string;
  126594. /** @hidden */
  126595. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  126596. /** @hidden */
  126597. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  126598. /**
  126599. * Clone the current block to a new identical block
  126600. * @param scene defines the hosting scene
  126601. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126602. * @returns a copy of the current block
  126603. */
  126604. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  126605. /**
  126606. * Serializes this block in a JSON representation
  126607. * @returns the serialized block object
  126608. */
  126609. serialize(): any;
  126610. /** @hidden */
  126611. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126612. /**
  126613. * Release resources
  126614. */
  126615. dispose(): void;
  126616. }
  126617. }
  126618. declare module BABYLON {
  126619. /**
  126620. * Enum defining the type of animations supported by InputBlock
  126621. */
  126622. export enum AnimatedInputBlockTypes {
  126623. /** No animation */
  126624. None = 0,
  126625. /** Time based animation. Will only work for floats */
  126626. Time = 1
  126627. }
  126628. }
  126629. declare module BABYLON {
  126630. /**
  126631. * Block used to expose an input value
  126632. */
  126633. export class InputBlock extends NodeMaterialBlock {
  126634. private _mode;
  126635. private _associatedVariableName;
  126636. private _storedValue;
  126637. private _valueCallback;
  126638. private _type;
  126639. private _animationType;
  126640. /** Gets or set a value used to limit the range of float values */
  126641. min: number;
  126642. /** Gets or set a value used to limit the range of float values */
  126643. max: number;
  126644. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  126645. matrixMode: number;
  126646. /** @hidden */
  126647. _systemValue: Nullable<NodeMaterialSystemValues>;
  126648. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  126649. visibleInInspector: boolean;
  126650. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  126651. isConstant: boolean;
  126652. /** Gets or sets the group to use to display this block in the Inspector */
  126653. groupInInspector: string;
  126654. /**
  126655. * Gets or sets the connection point type (default is float)
  126656. */
  126657. get type(): NodeMaterialBlockConnectionPointTypes;
  126658. /**
  126659. * Creates a new InputBlock
  126660. * @param name defines the block name
  126661. * @param target defines the target of that block (Vertex by default)
  126662. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  126663. */
  126664. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  126665. /**
  126666. * Gets the output component
  126667. */
  126668. get output(): NodeMaterialConnectionPoint;
  126669. /**
  126670. * Set the source of this connection point to a vertex attribute
  126671. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  126672. * @returns the current connection point
  126673. */
  126674. setAsAttribute(attributeName?: string): InputBlock;
  126675. /**
  126676. * Set the source of this connection point to a system value
  126677. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  126678. * @returns the current connection point
  126679. */
  126680. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  126681. /**
  126682. * Gets or sets the value of that point.
  126683. * Please note that this value will be ignored if valueCallback is defined
  126684. */
  126685. get value(): any;
  126686. set value(value: any);
  126687. /**
  126688. * Gets or sets a callback used to get the value of that point.
  126689. * Please note that setting this value will force the connection point to ignore the value property
  126690. */
  126691. get valueCallback(): () => any;
  126692. set valueCallback(value: () => any);
  126693. /**
  126694. * Gets or sets the associated variable name in the shader
  126695. */
  126696. get associatedVariableName(): string;
  126697. set associatedVariableName(value: string);
  126698. /** Gets or sets the type of animation applied to the input */
  126699. get animationType(): AnimatedInputBlockTypes;
  126700. set animationType(value: AnimatedInputBlockTypes);
  126701. /**
  126702. * Gets a boolean indicating that this connection point not defined yet
  126703. */
  126704. get isUndefined(): boolean;
  126705. /**
  126706. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  126707. * In this case the connection point name must be the name of the uniform to use.
  126708. * Can only be set on inputs
  126709. */
  126710. get isUniform(): boolean;
  126711. set isUniform(value: boolean);
  126712. /**
  126713. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  126714. * In this case the connection point name must be the name of the attribute to use
  126715. * Can only be set on inputs
  126716. */
  126717. get isAttribute(): boolean;
  126718. set isAttribute(value: boolean);
  126719. /**
  126720. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  126721. * Can only be set on exit points
  126722. */
  126723. get isVarying(): boolean;
  126724. set isVarying(value: boolean);
  126725. /**
  126726. * Gets a boolean indicating that the current connection point is a system value
  126727. */
  126728. get isSystemValue(): boolean;
  126729. /**
  126730. * Gets or sets the current well known value or null if not defined as a system value
  126731. */
  126732. get systemValue(): Nullable<NodeMaterialSystemValues>;
  126733. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  126734. /**
  126735. * Gets the current class name
  126736. * @returns the class name
  126737. */
  126738. getClassName(): string;
  126739. /**
  126740. * Animate the input if animationType !== None
  126741. * @param scene defines the rendering scene
  126742. */
  126743. animate(scene: Scene): void;
  126744. private _emitDefine;
  126745. initialize(state: NodeMaterialBuildState): void;
  126746. /**
  126747. * Set the input block to its default value (based on its type)
  126748. */
  126749. setDefaultValue(): void;
  126750. private _emitConstant;
  126751. private _emit;
  126752. /** @hidden */
  126753. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  126754. /** @hidden */
  126755. _transmit(effect: Effect, scene: Scene): void;
  126756. protected _buildBlock(state: NodeMaterialBuildState): void;
  126757. protected _dumpPropertiesCode(): string;
  126758. serialize(): any;
  126759. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126760. }
  126761. }
  126762. declare module BABYLON {
  126763. /**
  126764. * Enum used to define the compatibility state between two connection points
  126765. */
  126766. export enum NodeMaterialConnectionPointCompatibilityStates {
  126767. /** Points are compatibles */
  126768. Compatible = 0,
  126769. /** Points are incompatible because of their types */
  126770. TypeIncompatible = 1,
  126771. /** Points are incompatible because of their targets (vertex vs fragment) */
  126772. TargetIncompatible = 2
  126773. }
  126774. /**
  126775. * Defines the direction of a connection point
  126776. */
  126777. export enum NodeMaterialConnectionPointDirection {
  126778. /** Input */
  126779. Input = 0,
  126780. /** Output */
  126781. Output = 1
  126782. }
  126783. /**
  126784. * Defines a connection point for a block
  126785. */
  126786. export class NodeMaterialConnectionPoint {
  126787. /** @hidden */
  126788. _ownerBlock: NodeMaterialBlock;
  126789. /** @hidden */
  126790. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  126791. private _endpoints;
  126792. private _associatedVariableName;
  126793. private _direction;
  126794. /** @hidden */
  126795. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126796. /** @hidden */
  126797. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126798. private _type;
  126799. /** @hidden */
  126800. _enforceAssociatedVariableName: boolean;
  126801. /** Gets the direction of the point */
  126802. get direction(): NodeMaterialConnectionPointDirection;
  126803. /**
  126804. * Gets or sets the additional types supported by this connection point
  126805. */
  126806. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126807. /**
  126808. * Gets or sets the additional types excluded by this connection point
  126809. */
  126810. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126811. /**
  126812. * Observable triggered when this point is connected
  126813. */
  126814. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  126815. /**
  126816. * Gets or sets the associated variable name in the shader
  126817. */
  126818. get associatedVariableName(): string;
  126819. set associatedVariableName(value: string);
  126820. /**
  126821. * Gets or sets the connection point type (default is float)
  126822. */
  126823. get type(): NodeMaterialBlockConnectionPointTypes;
  126824. set type(value: NodeMaterialBlockConnectionPointTypes);
  126825. /**
  126826. * Gets or sets the connection point name
  126827. */
  126828. name: string;
  126829. /**
  126830. * Gets or sets a boolean indicating that this connection point can be omitted
  126831. */
  126832. isOptional: boolean;
  126833. /**
  126834. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  126835. */
  126836. define: string;
  126837. /** @hidden */
  126838. _prioritizeVertex: boolean;
  126839. private _target;
  126840. /** Gets or sets the target of that connection point */
  126841. get target(): NodeMaterialBlockTargets;
  126842. set target(value: NodeMaterialBlockTargets);
  126843. /**
  126844. * Gets a boolean indicating that the current point is connected
  126845. */
  126846. get isConnected(): boolean;
  126847. /**
  126848. * Gets a boolean indicating that the current point is connected to an input block
  126849. */
  126850. get isConnectedToInputBlock(): boolean;
  126851. /**
  126852. * Gets a the connected input block (if any)
  126853. */
  126854. get connectInputBlock(): Nullable<InputBlock>;
  126855. /** Get the other side of the connection (if any) */
  126856. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  126857. /** Get the block that owns this connection point */
  126858. get ownerBlock(): NodeMaterialBlock;
  126859. /** Get the block connected on the other side of this connection (if any) */
  126860. get sourceBlock(): Nullable<NodeMaterialBlock>;
  126861. /** Get the block connected on the endpoints of this connection (if any) */
  126862. get connectedBlocks(): Array<NodeMaterialBlock>;
  126863. /** Gets the list of connected endpoints */
  126864. get endpoints(): NodeMaterialConnectionPoint[];
  126865. /** Gets a boolean indicating if that output point is connected to at least one input */
  126866. get hasEndpoints(): boolean;
  126867. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  126868. get isConnectedInVertexShader(): boolean;
  126869. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  126870. get isConnectedInFragmentShader(): boolean;
  126871. /**
  126872. * Creates a new connection point
  126873. * @param name defines the connection point name
  126874. * @param ownerBlock defines the block hosting this connection point
  126875. * @param direction defines the direction of the connection point
  126876. */
  126877. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  126878. /**
  126879. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  126880. * @returns the class name
  126881. */
  126882. getClassName(): string;
  126883. /**
  126884. * Gets a boolean indicating if the current point can be connected to another point
  126885. * @param connectionPoint defines the other connection point
  126886. * @returns a boolean
  126887. */
  126888. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  126889. /**
  126890. * Gets a number indicating if the current point can be connected to another point
  126891. * @param connectionPoint defines the other connection point
  126892. * @returns a number defining the compatibility state
  126893. */
  126894. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  126895. /**
  126896. * Connect this point to another connection point
  126897. * @param connectionPoint defines the other connection point
  126898. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  126899. * @returns the current connection point
  126900. */
  126901. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  126902. /**
  126903. * Disconnect this point from one of his endpoint
  126904. * @param endpoint defines the other connection point
  126905. * @returns the current connection point
  126906. */
  126907. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  126908. /**
  126909. * Serializes this point in a JSON representation
  126910. * @returns the serialized point object
  126911. */
  126912. serialize(): any;
  126913. /**
  126914. * Release resources
  126915. */
  126916. dispose(): void;
  126917. }
  126918. }
  126919. declare module BABYLON {
  126920. /**
  126921. * Block used to add support for vertex skinning (bones)
  126922. */
  126923. export class BonesBlock extends NodeMaterialBlock {
  126924. /**
  126925. * Creates a new BonesBlock
  126926. * @param name defines the block name
  126927. */
  126928. constructor(name: string);
  126929. /**
  126930. * Initialize the block and prepare the context for build
  126931. * @param state defines the state that will be used for the build
  126932. */
  126933. initialize(state: NodeMaterialBuildState): void;
  126934. /**
  126935. * Gets the current class name
  126936. * @returns the class name
  126937. */
  126938. getClassName(): string;
  126939. /**
  126940. * Gets the matrix indices input component
  126941. */
  126942. get matricesIndices(): NodeMaterialConnectionPoint;
  126943. /**
  126944. * Gets the matrix weights input component
  126945. */
  126946. get matricesWeights(): NodeMaterialConnectionPoint;
  126947. /**
  126948. * Gets the extra matrix indices input component
  126949. */
  126950. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  126951. /**
  126952. * Gets the extra matrix weights input component
  126953. */
  126954. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  126955. /**
  126956. * Gets the world input component
  126957. */
  126958. get world(): NodeMaterialConnectionPoint;
  126959. /**
  126960. * Gets the output component
  126961. */
  126962. get output(): NodeMaterialConnectionPoint;
  126963. autoConfigure(material: NodeMaterial): void;
  126964. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126967. protected _buildBlock(state: NodeMaterialBuildState): this;
  126968. }
  126969. }
  126970. declare module BABYLON {
  126971. /**
  126972. * Block used to add support for instances
  126973. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  126974. */
  126975. export class InstancesBlock extends NodeMaterialBlock {
  126976. /**
  126977. * Creates a new InstancesBlock
  126978. * @param name defines the block name
  126979. */
  126980. constructor(name: string);
  126981. /**
  126982. * Gets the current class name
  126983. * @returns the class name
  126984. */
  126985. getClassName(): string;
  126986. /**
  126987. * Gets the first world row input component
  126988. */
  126989. get world0(): NodeMaterialConnectionPoint;
  126990. /**
  126991. * Gets the second world row input component
  126992. */
  126993. get world1(): NodeMaterialConnectionPoint;
  126994. /**
  126995. * Gets the third world row input component
  126996. */
  126997. get world2(): NodeMaterialConnectionPoint;
  126998. /**
  126999. * Gets the forth world row input component
  127000. */
  127001. get world3(): NodeMaterialConnectionPoint;
  127002. /**
  127003. * Gets the world input component
  127004. */
  127005. get world(): NodeMaterialConnectionPoint;
  127006. /**
  127007. * Gets the output component
  127008. */
  127009. get output(): NodeMaterialConnectionPoint;
  127010. autoConfigure(material: NodeMaterial): void;
  127011. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127012. protected _buildBlock(state: NodeMaterialBuildState): this;
  127013. }
  127014. }
  127015. declare module BABYLON {
  127016. /**
  127017. * Block used to add morph targets support to vertex shader
  127018. */
  127019. export class MorphTargetsBlock extends NodeMaterialBlock {
  127020. private _repeatableContentAnchor;
  127021. private _repeatebleContentGenerated;
  127022. /**
  127023. * Create a new MorphTargetsBlock
  127024. * @param name defines the block name
  127025. */
  127026. constructor(name: string);
  127027. /**
  127028. * Gets the current class name
  127029. * @returns the class name
  127030. */
  127031. getClassName(): string;
  127032. /**
  127033. * Gets the position input component
  127034. */
  127035. get position(): NodeMaterialConnectionPoint;
  127036. /**
  127037. * Gets the normal input component
  127038. */
  127039. get normal(): NodeMaterialConnectionPoint;
  127040. /**
  127041. * Gets the tangent input component
  127042. */
  127043. get tangent(): NodeMaterialConnectionPoint;
  127044. /**
  127045. * Gets the tangent input component
  127046. */
  127047. get uv(): NodeMaterialConnectionPoint;
  127048. /**
  127049. * Gets the position output component
  127050. */
  127051. get positionOutput(): NodeMaterialConnectionPoint;
  127052. /**
  127053. * Gets the normal output component
  127054. */
  127055. get normalOutput(): NodeMaterialConnectionPoint;
  127056. /**
  127057. * Gets the tangent output component
  127058. */
  127059. get tangentOutput(): NodeMaterialConnectionPoint;
  127060. /**
  127061. * Gets the tangent output component
  127062. */
  127063. get uvOutput(): NodeMaterialConnectionPoint;
  127064. initialize(state: NodeMaterialBuildState): void;
  127065. autoConfigure(material: NodeMaterial): void;
  127066. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127068. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  127069. protected _buildBlock(state: NodeMaterialBuildState): this;
  127070. }
  127071. }
  127072. declare module BABYLON {
  127073. /**
  127074. * Block used to get data information from a light
  127075. */
  127076. export class LightInformationBlock extends NodeMaterialBlock {
  127077. private _lightDataUniformName;
  127078. private _lightColorUniformName;
  127079. private _lightTypeDefineName;
  127080. /**
  127081. * Gets or sets the light associated with this block
  127082. */
  127083. light: Nullable<Light>;
  127084. /**
  127085. * Creates a new LightInformationBlock
  127086. * @param name defines the block name
  127087. */
  127088. constructor(name: string);
  127089. /**
  127090. * Gets the current class name
  127091. * @returns the class name
  127092. */
  127093. getClassName(): string;
  127094. /**
  127095. * Gets the world position input component
  127096. */
  127097. get worldPosition(): NodeMaterialConnectionPoint;
  127098. /**
  127099. * Gets the direction output component
  127100. */
  127101. get direction(): NodeMaterialConnectionPoint;
  127102. /**
  127103. * Gets the direction output component
  127104. */
  127105. get color(): NodeMaterialConnectionPoint;
  127106. /**
  127107. * Gets the direction output component
  127108. */
  127109. get intensity(): NodeMaterialConnectionPoint;
  127110. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127111. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127112. protected _buildBlock(state: NodeMaterialBuildState): this;
  127113. serialize(): any;
  127114. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127115. }
  127116. }
  127117. declare module BABYLON {
  127118. /**
  127119. * Block used to add image processing support to fragment shader
  127120. */
  127121. export class ImageProcessingBlock extends NodeMaterialBlock {
  127122. /**
  127123. * Create a new ImageProcessingBlock
  127124. * @param name defines the block name
  127125. */
  127126. constructor(name: string);
  127127. /**
  127128. * Gets the current class name
  127129. * @returns the class name
  127130. */
  127131. getClassName(): string;
  127132. /**
  127133. * Gets the color input component
  127134. */
  127135. get color(): NodeMaterialConnectionPoint;
  127136. /**
  127137. * Gets the output component
  127138. */
  127139. get output(): NodeMaterialConnectionPoint;
  127140. /**
  127141. * Initialize the block and prepare the context for build
  127142. * @param state defines the state that will be used for the build
  127143. */
  127144. initialize(state: NodeMaterialBuildState): void;
  127145. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  127146. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127147. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127148. protected _buildBlock(state: NodeMaterialBuildState): this;
  127149. }
  127150. }
  127151. declare module BABYLON {
  127152. /**
  127153. * Block used to pertub normals based on a normal map
  127154. */
  127155. export class PerturbNormalBlock extends NodeMaterialBlock {
  127156. private _tangentSpaceParameterName;
  127157. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  127158. invertX: boolean;
  127159. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  127160. invertY: boolean;
  127161. /**
  127162. * Create a new PerturbNormalBlock
  127163. * @param name defines the block name
  127164. */
  127165. constructor(name: string);
  127166. /**
  127167. * Gets the current class name
  127168. * @returns the class name
  127169. */
  127170. getClassName(): string;
  127171. /**
  127172. * Gets the world position input component
  127173. */
  127174. get worldPosition(): NodeMaterialConnectionPoint;
  127175. /**
  127176. * Gets the world normal input component
  127177. */
  127178. get worldNormal(): NodeMaterialConnectionPoint;
  127179. /**
  127180. * Gets the uv input component
  127181. */
  127182. get uv(): NodeMaterialConnectionPoint;
  127183. /**
  127184. * Gets the normal map color input component
  127185. */
  127186. get normalMapColor(): NodeMaterialConnectionPoint;
  127187. /**
  127188. * Gets the strength input component
  127189. */
  127190. get strength(): NodeMaterialConnectionPoint;
  127191. /**
  127192. * Gets the output component
  127193. */
  127194. get output(): NodeMaterialConnectionPoint;
  127195. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127196. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127197. autoConfigure(material: NodeMaterial): void;
  127198. protected _buildBlock(state: NodeMaterialBuildState): this;
  127199. protected _dumpPropertiesCode(): string;
  127200. serialize(): any;
  127201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127202. }
  127203. }
  127204. declare module BABYLON {
  127205. /**
  127206. * Block used to discard a pixel if a value is smaller than a cutoff
  127207. */
  127208. export class DiscardBlock extends NodeMaterialBlock {
  127209. /**
  127210. * Create a new DiscardBlock
  127211. * @param name defines the block name
  127212. */
  127213. constructor(name: string);
  127214. /**
  127215. * Gets the current class name
  127216. * @returns the class name
  127217. */
  127218. getClassName(): string;
  127219. /**
  127220. * Gets the color input component
  127221. */
  127222. get value(): NodeMaterialConnectionPoint;
  127223. /**
  127224. * Gets the cutoff input component
  127225. */
  127226. get cutoff(): NodeMaterialConnectionPoint;
  127227. protected _buildBlock(state: NodeMaterialBuildState): this;
  127228. }
  127229. }
  127230. declare module BABYLON {
  127231. /**
  127232. * Block used to test if the fragment shader is front facing
  127233. */
  127234. export class FrontFacingBlock extends NodeMaterialBlock {
  127235. /**
  127236. * Creates a new FrontFacingBlock
  127237. * @param name defines the block name
  127238. */
  127239. constructor(name: string);
  127240. /**
  127241. * Gets the current class name
  127242. * @returns the class name
  127243. */
  127244. getClassName(): string;
  127245. /**
  127246. * Gets the output component
  127247. */
  127248. get output(): NodeMaterialConnectionPoint;
  127249. protected _buildBlock(state: NodeMaterialBuildState): this;
  127250. }
  127251. }
  127252. declare module BABYLON {
  127253. /**
  127254. * Block used to get the derivative value on x and y of a given input
  127255. */
  127256. export class DerivativeBlock extends NodeMaterialBlock {
  127257. /**
  127258. * Create a new DerivativeBlock
  127259. * @param name defines the block name
  127260. */
  127261. constructor(name: string);
  127262. /**
  127263. * Gets the current class name
  127264. * @returns the class name
  127265. */
  127266. getClassName(): string;
  127267. /**
  127268. * Gets the input component
  127269. */
  127270. get input(): NodeMaterialConnectionPoint;
  127271. /**
  127272. * Gets the derivative output on x
  127273. */
  127274. get dx(): NodeMaterialConnectionPoint;
  127275. /**
  127276. * Gets the derivative output on y
  127277. */
  127278. get dy(): NodeMaterialConnectionPoint;
  127279. protected _buildBlock(state: NodeMaterialBuildState): this;
  127280. }
  127281. }
  127282. declare module BABYLON {
  127283. /**
  127284. * Block used to add support for scene fog
  127285. */
  127286. export class FogBlock extends NodeMaterialBlock {
  127287. private _fogDistanceName;
  127288. private _fogParameters;
  127289. /**
  127290. * Create a new FogBlock
  127291. * @param name defines the block name
  127292. */
  127293. constructor(name: string);
  127294. /**
  127295. * Gets the current class name
  127296. * @returns the class name
  127297. */
  127298. getClassName(): string;
  127299. /**
  127300. * Gets the world position input component
  127301. */
  127302. get worldPosition(): NodeMaterialConnectionPoint;
  127303. /**
  127304. * Gets the view input component
  127305. */
  127306. get view(): NodeMaterialConnectionPoint;
  127307. /**
  127308. * Gets the color input component
  127309. */
  127310. get input(): NodeMaterialConnectionPoint;
  127311. /**
  127312. * Gets the fog color input component
  127313. */
  127314. get fogColor(): NodeMaterialConnectionPoint;
  127315. /**
  127316. * Gets the output component
  127317. */
  127318. get output(): NodeMaterialConnectionPoint;
  127319. autoConfigure(material: NodeMaterial): void;
  127320. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127321. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127322. protected _buildBlock(state: NodeMaterialBuildState): this;
  127323. }
  127324. }
  127325. declare module BABYLON {
  127326. /**
  127327. * Block used to add light in the fragment shader
  127328. */
  127329. export class LightBlock extends NodeMaterialBlock {
  127330. private _lightId;
  127331. /**
  127332. * Gets or sets the light associated with this block
  127333. */
  127334. light: Nullable<Light>;
  127335. /**
  127336. * Create a new LightBlock
  127337. * @param name defines the block name
  127338. */
  127339. constructor(name: string);
  127340. /**
  127341. * Gets the current class name
  127342. * @returns the class name
  127343. */
  127344. getClassName(): string;
  127345. /**
  127346. * Gets the world position input component
  127347. */
  127348. get worldPosition(): NodeMaterialConnectionPoint;
  127349. /**
  127350. * Gets the world normal input component
  127351. */
  127352. get worldNormal(): NodeMaterialConnectionPoint;
  127353. /**
  127354. * Gets the camera (or eye) position component
  127355. */
  127356. get cameraPosition(): NodeMaterialConnectionPoint;
  127357. /**
  127358. * Gets the glossiness component
  127359. */
  127360. get glossiness(): NodeMaterialConnectionPoint;
  127361. /**
  127362. * Gets the glossinness power component
  127363. */
  127364. get glossPower(): NodeMaterialConnectionPoint;
  127365. /**
  127366. * Gets the diffuse color component
  127367. */
  127368. get diffuseColor(): NodeMaterialConnectionPoint;
  127369. /**
  127370. * Gets the specular color component
  127371. */
  127372. get specularColor(): NodeMaterialConnectionPoint;
  127373. /**
  127374. * Gets the diffuse output component
  127375. */
  127376. get diffuseOutput(): NodeMaterialConnectionPoint;
  127377. /**
  127378. * Gets the specular output component
  127379. */
  127380. get specularOutput(): NodeMaterialConnectionPoint;
  127381. autoConfigure(material: NodeMaterial): void;
  127382. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127383. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  127384. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127385. private _injectVertexCode;
  127386. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127387. serialize(): any;
  127388. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127389. }
  127390. }
  127391. declare module BABYLON {
  127392. /**
  127393. * Block used to multiply 2 values
  127394. */
  127395. export class MultiplyBlock extends NodeMaterialBlock {
  127396. /**
  127397. * Creates a new MultiplyBlock
  127398. * @param name defines the block name
  127399. */
  127400. constructor(name: string);
  127401. /**
  127402. * Gets the current class name
  127403. * @returns the class name
  127404. */
  127405. getClassName(): string;
  127406. /**
  127407. * Gets the left operand input component
  127408. */
  127409. get left(): NodeMaterialConnectionPoint;
  127410. /**
  127411. * Gets the right operand input component
  127412. */
  127413. get right(): NodeMaterialConnectionPoint;
  127414. /**
  127415. * Gets the output component
  127416. */
  127417. get output(): NodeMaterialConnectionPoint;
  127418. protected _buildBlock(state: NodeMaterialBuildState): this;
  127419. }
  127420. }
  127421. declare module BABYLON {
  127422. /**
  127423. * Block used to add 2 vectors
  127424. */
  127425. export class AddBlock extends NodeMaterialBlock {
  127426. /**
  127427. * Creates a new AddBlock
  127428. * @param name defines the block name
  127429. */
  127430. constructor(name: string);
  127431. /**
  127432. * Gets the current class name
  127433. * @returns the class name
  127434. */
  127435. getClassName(): string;
  127436. /**
  127437. * Gets the left operand input component
  127438. */
  127439. get left(): NodeMaterialConnectionPoint;
  127440. /**
  127441. * Gets the right operand input component
  127442. */
  127443. get right(): NodeMaterialConnectionPoint;
  127444. /**
  127445. * Gets the output component
  127446. */
  127447. get output(): NodeMaterialConnectionPoint;
  127448. protected _buildBlock(state: NodeMaterialBuildState): this;
  127449. }
  127450. }
  127451. declare module BABYLON {
  127452. /**
  127453. * Block used to scale a vector by a float
  127454. */
  127455. export class ScaleBlock extends NodeMaterialBlock {
  127456. /**
  127457. * Creates a new ScaleBlock
  127458. * @param name defines the block name
  127459. */
  127460. constructor(name: string);
  127461. /**
  127462. * Gets the current class name
  127463. * @returns the class name
  127464. */
  127465. getClassName(): string;
  127466. /**
  127467. * Gets the input component
  127468. */
  127469. get input(): NodeMaterialConnectionPoint;
  127470. /**
  127471. * Gets the factor input component
  127472. */
  127473. get factor(): NodeMaterialConnectionPoint;
  127474. /**
  127475. * Gets the output component
  127476. */
  127477. get output(): NodeMaterialConnectionPoint;
  127478. protected _buildBlock(state: NodeMaterialBuildState): this;
  127479. }
  127480. }
  127481. declare module BABYLON {
  127482. /**
  127483. * Block used to clamp a float
  127484. */
  127485. export class ClampBlock extends NodeMaterialBlock {
  127486. /** Gets or sets the minimum range */
  127487. minimum: number;
  127488. /** Gets or sets the maximum range */
  127489. maximum: number;
  127490. /**
  127491. * Creates a new ClampBlock
  127492. * @param name defines the block name
  127493. */
  127494. constructor(name: string);
  127495. /**
  127496. * Gets the current class name
  127497. * @returns the class name
  127498. */
  127499. getClassName(): string;
  127500. /**
  127501. * Gets the value input component
  127502. */
  127503. get value(): NodeMaterialConnectionPoint;
  127504. /**
  127505. * Gets the output component
  127506. */
  127507. get output(): NodeMaterialConnectionPoint;
  127508. protected _buildBlock(state: NodeMaterialBuildState): this;
  127509. protected _dumpPropertiesCode(): string;
  127510. serialize(): any;
  127511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127512. }
  127513. }
  127514. declare module BABYLON {
  127515. /**
  127516. * Block used to apply a cross product between 2 vectors
  127517. */
  127518. export class CrossBlock extends NodeMaterialBlock {
  127519. /**
  127520. * Creates a new CrossBlock
  127521. * @param name defines the block name
  127522. */
  127523. constructor(name: string);
  127524. /**
  127525. * Gets the current class name
  127526. * @returns the class name
  127527. */
  127528. getClassName(): string;
  127529. /**
  127530. * Gets the left operand input component
  127531. */
  127532. get left(): NodeMaterialConnectionPoint;
  127533. /**
  127534. * Gets the right operand input component
  127535. */
  127536. get right(): NodeMaterialConnectionPoint;
  127537. /**
  127538. * Gets the output component
  127539. */
  127540. get output(): NodeMaterialConnectionPoint;
  127541. protected _buildBlock(state: NodeMaterialBuildState): this;
  127542. }
  127543. }
  127544. declare module BABYLON {
  127545. /**
  127546. * Block used to apply a dot product between 2 vectors
  127547. */
  127548. export class DotBlock extends NodeMaterialBlock {
  127549. /**
  127550. * Creates a new DotBlock
  127551. * @param name defines the block name
  127552. */
  127553. constructor(name: string);
  127554. /**
  127555. * Gets the current class name
  127556. * @returns the class name
  127557. */
  127558. getClassName(): string;
  127559. /**
  127560. * Gets the left operand input component
  127561. */
  127562. get left(): NodeMaterialConnectionPoint;
  127563. /**
  127564. * Gets the right operand input component
  127565. */
  127566. get right(): NodeMaterialConnectionPoint;
  127567. /**
  127568. * Gets the output component
  127569. */
  127570. get output(): NodeMaterialConnectionPoint;
  127571. protected _buildBlock(state: NodeMaterialBuildState): this;
  127572. }
  127573. }
  127574. declare module BABYLON {
  127575. /**
  127576. * Block used to remap a float from a range to a new one
  127577. */
  127578. export class RemapBlock extends NodeMaterialBlock {
  127579. /**
  127580. * Gets or sets the source range
  127581. */
  127582. sourceRange: Vector2;
  127583. /**
  127584. * Gets or sets the target range
  127585. */
  127586. targetRange: Vector2;
  127587. /**
  127588. * Creates a new RemapBlock
  127589. * @param name defines the block name
  127590. */
  127591. constructor(name: string);
  127592. /**
  127593. * Gets the current class name
  127594. * @returns the class name
  127595. */
  127596. getClassName(): string;
  127597. /**
  127598. * Gets the input component
  127599. */
  127600. get input(): NodeMaterialConnectionPoint;
  127601. /**
  127602. * Gets the source min input component
  127603. */
  127604. get sourceMin(): NodeMaterialConnectionPoint;
  127605. /**
  127606. * Gets the source max input component
  127607. */
  127608. get sourceMax(): NodeMaterialConnectionPoint;
  127609. /**
  127610. * Gets the target min input component
  127611. */
  127612. get targetMin(): NodeMaterialConnectionPoint;
  127613. /**
  127614. * Gets the target max input component
  127615. */
  127616. get targetMax(): NodeMaterialConnectionPoint;
  127617. /**
  127618. * Gets the output component
  127619. */
  127620. get output(): NodeMaterialConnectionPoint;
  127621. protected _buildBlock(state: NodeMaterialBuildState): this;
  127622. protected _dumpPropertiesCode(): string;
  127623. serialize(): any;
  127624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127625. }
  127626. }
  127627. declare module BABYLON {
  127628. /**
  127629. * Block used to normalize a vector
  127630. */
  127631. export class NormalizeBlock extends NodeMaterialBlock {
  127632. /**
  127633. * Creates a new NormalizeBlock
  127634. * @param name defines the block name
  127635. */
  127636. constructor(name: string);
  127637. /**
  127638. * Gets the current class name
  127639. * @returns the class name
  127640. */
  127641. getClassName(): string;
  127642. /**
  127643. * Gets the input component
  127644. */
  127645. get input(): NodeMaterialConnectionPoint;
  127646. /**
  127647. * Gets the output component
  127648. */
  127649. get output(): NodeMaterialConnectionPoint;
  127650. protected _buildBlock(state: NodeMaterialBuildState): this;
  127651. }
  127652. }
  127653. declare module BABYLON {
  127654. /**
  127655. * Operations supported by the Trigonometry block
  127656. */
  127657. export enum TrigonometryBlockOperations {
  127658. /** Cos */
  127659. Cos = 0,
  127660. /** Sin */
  127661. Sin = 1,
  127662. /** Abs */
  127663. Abs = 2,
  127664. /** Exp */
  127665. Exp = 3,
  127666. /** Exp2 */
  127667. Exp2 = 4,
  127668. /** Round */
  127669. Round = 5,
  127670. /** Floor */
  127671. Floor = 6,
  127672. /** Ceiling */
  127673. Ceiling = 7,
  127674. /** Square root */
  127675. Sqrt = 8,
  127676. /** Log */
  127677. Log = 9,
  127678. /** Tangent */
  127679. Tan = 10,
  127680. /** Arc tangent */
  127681. ArcTan = 11,
  127682. /** Arc cosinus */
  127683. ArcCos = 12,
  127684. /** Arc sinus */
  127685. ArcSin = 13,
  127686. /** Fraction */
  127687. Fract = 14,
  127688. /** Sign */
  127689. Sign = 15,
  127690. /** To radians (from degrees) */
  127691. Radians = 16,
  127692. /** To degrees (from radians) */
  127693. Degrees = 17
  127694. }
  127695. /**
  127696. * Block used to apply trigonometry operation to floats
  127697. */
  127698. export class TrigonometryBlock extends NodeMaterialBlock {
  127699. /**
  127700. * Gets or sets the operation applied by the block
  127701. */
  127702. operation: TrigonometryBlockOperations;
  127703. /**
  127704. * Creates a new TrigonometryBlock
  127705. * @param name defines the block name
  127706. */
  127707. constructor(name: string);
  127708. /**
  127709. * Gets the current class name
  127710. * @returns the class name
  127711. */
  127712. getClassName(): string;
  127713. /**
  127714. * Gets the input component
  127715. */
  127716. get input(): NodeMaterialConnectionPoint;
  127717. /**
  127718. * Gets the output component
  127719. */
  127720. get output(): NodeMaterialConnectionPoint;
  127721. protected _buildBlock(state: NodeMaterialBuildState): this;
  127722. serialize(): any;
  127723. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127724. protected _dumpPropertiesCode(): string;
  127725. }
  127726. }
  127727. declare module BABYLON {
  127728. /**
  127729. * Block used to create a Color3/4 out of individual inputs (one for each component)
  127730. */
  127731. export class ColorMergerBlock extends NodeMaterialBlock {
  127732. /**
  127733. * Create a new ColorMergerBlock
  127734. * @param name defines the block name
  127735. */
  127736. constructor(name: string);
  127737. /**
  127738. * Gets the current class name
  127739. * @returns the class name
  127740. */
  127741. getClassName(): string;
  127742. /**
  127743. * Gets the rgb component (input)
  127744. */
  127745. get rgbIn(): NodeMaterialConnectionPoint;
  127746. /**
  127747. * Gets the r component (input)
  127748. */
  127749. get r(): NodeMaterialConnectionPoint;
  127750. /**
  127751. * Gets the g component (input)
  127752. */
  127753. get g(): NodeMaterialConnectionPoint;
  127754. /**
  127755. * Gets the b component (input)
  127756. */
  127757. get b(): NodeMaterialConnectionPoint;
  127758. /**
  127759. * Gets the a component (input)
  127760. */
  127761. get a(): NodeMaterialConnectionPoint;
  127762. /**
  127763. * Gets the rgba component (output)
  127764. */
  127765. get rgba(): NodeMaterialConnectionPoint;
  127766. /**
  127767. * Gets the rgb component (output)
  127768. */
  127769. get rgbOut(): NodeMaterialConnectionPoint;
  127770. /**
  127771. * Gets the rgb component (output)
  127772. * @deprecated Please use rgbOut instead.
  127773. */
  127774. get rgb(): NodeMaterialConnectionPoint;
  127775. protected _buildBlock(state: NodeMaterialBuildState): this;
  127776. }
  127777. }
  127778. declare module BABYLON {
  127779. /**
  127780. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  127781. */
  127782. export class VectorMergerBlock extends NodeMaterialBlock {
  127783. /**
  127784. * Create a new VectorMergerBlock
  127785. * @param name defines the block name
  127786. */
  127787. constructor(name: string);
  127788. /**
  127789. * Gets the current class name
  127790. * @returns the class name
  127791. */
  127792. getClassName(): string;
  127793. /**
  127794. * Gets the xyz component (input)
  127795. */
  127796. get xyzIn(): NodeMaterialConnectionPoint;
  127797. /**
  127798. * Gets the xy component (input)
  127799. */
  127800. get xyIn(): NodeMaterialConnectionPoint;
  127801. /**
  127802. * Gets the x component (input)
  127803. */
  127804. get x(): NodeMaterialConnectionPoint;
  127805. /**
  127806. * Gets the y component (input)
  127807. */
  127808. get y(): NodeMaterialConnectionPoint;
  127809. /**
  127810. * Gets the z component (input)
  127811. */
  127812. get z(): NodeMaterialConnectionPoint;
  127813. /**
  127814. * Gets the w component (input)
  127815. */
  127816. get w(): NodeMaterialConnectionPoint;
  127817. /**
  127818. * Gets the xyzw component (output)
  127819. */
  127820. get xyzw(): NodeMaterialConnectionPoint;
  127821. /**
  127822. * Gets the xyz component (output)
  127823. */
  127824. get xyzOut(): NodeMaterialConnectionPoint;
  127825. /**
  127826. * Gets the xy component (output)
  127827. */
  127828. get xyOut(): NodeMaterialConnectionPoint;
  127829. /**
  127830. * Gets the xy component (output)
  127831. * @deprecated Please use xyOut instead.
  127832. */
  127833. get xy(): NodeMaterialConnectionPoint;
  127834. /**
  127835. * Gets the xyz component (output)
  127836. * @deprecated Please use xyzOut instead.
  127837. */
  127838. get xyz(): NodeMaterialConnectionPoint;
  127839. protected _buildBlock(state: NodeMaterialBuildState): this;
  127840. }
  127841. }
  127842. declare module BABYLON {
  127843. /**
  127844. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  127845. */
  127846. export class ColorSplitterBlock extends NodeMaterialBlock {
  127847. /**
  127848. * Create a new ColorSplitterBlock
  127849. * @param name defines the block name
  127850. */
  127851. constructor(name: string);
  127852. /**
  127853. * Gets the current class name
  127854. * @returns the class name
  127855. */
  127856. getClassName(): string;
  127857. /**
  127858. * Gets the rgba component (input)
  127859. */
  127860. get rgba(): NodeMaterialConnectionPoint;
  127861. /**
  127862. * Gets the rgb component (input)
  127863. */
  127864. get rgbIn(): NodeMaterialConnectionPoint;
  127865. /**
  127866. * Gets the rgb component (output)
  127867. */
  127868. get rgbOut(): NodeMaterialConnectionPoint;
  127869. /**
  127870. * Gets the r component (output)
  127871. */
  127872. get r(): NodeMaterialConnectionPoint;
  127873. /**
  127874. * Gets the g component (output)
  127875. */
  127876. get g(): NodeMaterialConnectionPoint;
  127877. /**
  127878. * Gets the b component (output)
  127879. */
  127880. get b(): NodeMaterialConnectionPoint;
  127881. /**
  127882. * Gets the a component (output)
  127883. */
  127884. get a(): NodeMaterialConnectionPoint;
  127885. protected _inputRename(name: string): string;
  127886. protected _outputRename(name: string): string;
  127887. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127888. }
  127889. }
  127890. declare module BABYLON {
  127891. /**
  127892. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  127893. */
  127894. export class VectorSplitterBlock extends NodeMaterialBlock {
  127895. /**
  127896. * Create a new VectorSplitterBlock
  127897. * @param name defines the block name
  127898. */
  127899. constructor(name: string);
  127900. /**
  127901. * Gets the current class name
  127902. * @returns the class name
  127903. */
  127904. getClassName(): string;
  127905. /**
  127906. * Gets the xyzw component (input)
  127907. */
  127908. get xyzw(): NodeMaterialConnectionPoint;
  127909. /**
  127910. * Gets the xyz component (input)
  127911. */
  127912. get xyzIn(): NodeMaterialConnectionPoint;
  127913. /**
  127914. * Gets the xy component (input)
  127915. */
  127916. get xyIn(): NodeMaterialConnectionPoint;
  127917. /**
  127918. * Gets the xyz component (output)
  127919. */
  127920. get xyzOut(): NodeMaterialConnectionPoint;
  127921. /**
  127922. * Gets the xy component (output)
  127923. */
  127924. get xyOut(): NodeMaterialConnectionPoint;
  127925. /**
  127926. * Gets the x component (output)
  127927. */
  127928. get x(): NodeMaterialConnectionPoint;
  127929. /**
  127930. * Gets the y component (output)
  127931. */
  127932. get y(): NodeMaterialConnectionPoint;
  127933. /**
  127934. * Gets the z component (output)
  127935. */
  127936. get z(): NodeMaterialConnectionPoint;
  127937. /**
  127938. * Gets the w component (output)
  127939. */
  127940. get w(): NodeMaterialConnectionPoint;
  127941. protected _inputRename(name: string): string;
  127942. protected _outputRename(name: string): string;
  127943. protected _buildBlock(state: NodeMaterialBuildState): this;
  127944. }
  127945. }
  127946. declare module BABYLON {
  127947. /**
  127948. * Block used to lerp between 2 values
  127949. */
  127950. export class LerpBlock extends NodeMaterialBlock {
  127951. /**
  127952. * Creates a new LerpBlock
  127953. * @param name defines the block name
  127954. */
  127955. constructor(name: string);
  127956. /**
  127957. * Gets the current class name
  127958. * @returns the class name
  127959. */
  127960. getClassName(): string;
  127961. /**
  127962. * Gets the left operand input component
  127963. */
  127964. get left(): NodeMaterialConnectionPoint;
  127965. /**
  127966. * Gets the right operand input component
  127967. */
  127968. get right(): NodeMaterialConnectionPoint;
  127969. /**
  127970. * Gets the gradient operand input component
  127971. */
  127972. get gradient(): NodeMaterialConnectionPoint;
  127973. /**
  127974. * Gets the output component
  127975. */
  127976. get output(): NodeMaterialConnectionPoint;
  127977. protected _buildBlock(state: NodeMaterialBuildState): this;
  127978. }
  127979. }
  127980. declare module BABYLON {
  127981. /**
  127982. * Block used to divide 2 vectors
  127983. */
  127984. export class DivideBlock extends NodeMaterialBlock {
  127985. /**
  127986. * Creates a new DivideBlock
  127987. * @param name defines the block name
  127988. */
  127989. constructor(name: string);
  127990. /**
  127991. * Gets the current class name
  127992. * @returns the class name
  127993. */
  127994. getClassName(): string;
  127995. /**
  127996. * Gets the left operand input component
  127997. */
  127998. get left(): NodeMaterialConnectionPoint;
  127999. /**
  128000. * Gets the right operand input component
  128001. */
  128002. get right(): NodeMaterialConnectionPoint;
  128003. /**
  128004. * Gets the output component
  128005. */
  128006. get output(): NodeMaterialConnectionPoint;
  128007. protected _buildBlock(state: NodeMaterialBuildState): this;
  128008. }
  128009. }
  128010. declare module BABYLON {
  128011. /**
  128012. * Block used to subtract 2 vectors
  128013. */
  128014. export class SubtractBlock extends NodeMaterialBlock {
  128015. /**
  128016. * Creates a new SubtractBlock
  128017. * @param name defines the block name
  128018. */
  128019. constructor(name: string);
  128020. /**
  128021. * Gets the current class name
  128022. * @returns the class name
  128023. */
  128024. getClassName(): string;
  128025. /**
  128026. * Gets the left operand input component
  128027. */
  128028. get left(): NodeMaterialConnectionPoint;
  128029. /**
  128030. * Gets the right operand input component
  128031. */
  128032. get right(): NodeMaterialConnectionPoint;
  128033. /**
  128034. * Gets the output component
  128035. */
  128036. get output(): NodeMaterialConnectionPoint;
  128037. protected _buildBlock(state: NodeMaterialBuildState): this;
  128038. }
  128039. }
  128040. declare module BABYLON {
  128041. /**
  128042. * Block used to step a value
  128043. */
  128044. export class StepBlock extends NodeMaterialBlock {
  128045. /**
  128046. * Creates a new StepBlock
  128047. * @param name defines the block name
  128048. */
  128049. constructor(name: string);
  128050. /**
  128051. * Gets the current class name
  128052. * @returns the class name
  128053. */
  128054. getClassName(): string;
  128055. /**
  128056. * Gets the value operand input component
  128057. */
  128058. get value(): NodeMaterialConnectionPoint;
  128059. /**
  128060. * Gets the edge operand input component
  128061. */
  128062. get edge(): NodeMaterialConnectionPoint;
  128063. /**
  128064. * Gets the output component
  128065. */
  128066. get output(): NodeMaterialConnectionPoint;
  128067. protected _buildBlock(state: NodeMaterialBuildState): this;
  128068. }
  128069. }
  128070. declare module BABYLON {
  128071. /**
  128072. * Block used to get the opposite (1 - x) of a value
  128073. */
  128074. export class OneMinusBlock extends NodeMaterialBlock {
  128075. /**
  128076. * Creates a new OneMinusBlock
  128077. * @param name defines the block name
  128078. */
  128079. constructor(name: string);
  128080. /**
  128081. * Gets the current class name
  128082. * @returns the class name
  128083. */
  128084. getClassName(): string;
  128085. /**
  128086. * Gets the input component
  128087. */
  128088. get input(): NodeMaterialConnectionPoint;
  128089. /**
  128090. * Gets the output component
  128091. */
  128092. get output(): NodeMaterialConnectionPoint;
  128093. protected _buildBlock(state: NodeMaterialBuildState): this;
  128094. }
  128095. }
  128096. declare module BABYLON {
  128097. /**
  128098. * Block used to get the view direction
  128099. */
  128100. export class ViewDirectionBlock extends NodeMaterialBlock {
  128101. /**
  128102. * Creates a new ViewDirectionBlock
  128103. * @param name defines the block name
  128104. */
  128105. constructor(name: string);
  128106. /**
  128107. * Gets the current class name
  128108. * @returns the class name
  128109. */
  128110. getClassName(): string;
  128111. /**
  128112. * Gets the world position component
  128113. */
  128114. get worldPosition(): NodeMaterialConnectionPoint;
  128115. /**
  128116. * Gets the camera position component
  128117. */
  128118. get cameraPosition(): NodeMaterialConnectionPoint;
  128119. /**
  128120. * Gets the output component
  128121. */
  128122. get output(): NodeMaterialConnectionPoint;
  128123. autoConfigure(material: NodeMaterial): void;
  128124. protected _buildBlock(state: NodeMaterialBuildState): this;
  128125. }
  128126. }
  128127. declare module BABYLON {
  128128. /**
  128129. * Block used to compute fresnel value
  128130. */
  128131. export class FresnelBlock extends NodeMaterialBlock {
  128132. /**
  128133. * Create a new FresnelBlock
  128134. * @param name defines the block name
  128135. */
  128136. constructor(name: string);
  128137. /**
  128138. * Gets the current class name
  128139. * @returns the class name
  128140. */
  128141. getClassName(): string;
  128142. /**
  128143. * Gets the world normal input component
  128144. */
  128145. get worldNormal(): NodeMaterialConnectionPoint;
  128146. /**
  128147. * Gets the view direction input component
  128148. */
  128149. get viewDirection(): NodeMaterialConnectionPoint;
  128150. /**
  128151. * Gets the bias input component
  128152. */
  128153. get bias(): NodeMaterialConnectionPoint;
  128154. /**
  128155. * Gets the camera (or eye) position component
  128156. */
  128157. get power(): NodeMaterialConnectionPoint;
  128158. /**
  128159. * Gets the fresnel output component
  128160. */
  128161. get fresnel(): NodeMaterialConnectionPoint;
  128162. autoConfigure(material: NodeMaterial): void;
  128163. protected _buildBlock(state: NodeMaterialBuildState): this;
  128164. }
  128165. }
  128166. declare module BABYLON {
  128167. /**
  128168. * Block used to get the max of 2 values
  128169. */
  128170. export class MaxBlock extends NodeMaterialBlock {
  128171. /**
  128172. * Creates a new MaxBlock
  128173. * @param name defines the block name
  128174. */
  128175. constructor(name: string);
  128176. /**
  128177. * Gets the current class name
  128178. * @returns the class name
  128179. */
  128180. getClassName(): string;
  128181. /**
  128182. * Gets the left operand input component
  128183. */
  128184. get left(): NodeMaterialConnectionPoint;
  128185. /**
  128186. * Gets the right operand input component
  128187. */
  128188. get right(): NodeMaterialConnectionPoint;
  128189. /**
  128190. * Gets the output component
  128191. */
  128192. get output(): NodeMaterialConnectionPoint;
  128193. protected _buildBlock(state: NodeMaterialBuildState): this;
  128194. }
  128195. }
  128196. declare module BABYLON {
  128197. /**
  128198. * Block used to get the min of 2 values
  128199. */
  128200. export class MinBlock extends NodeMaterialBlock {
  128201. /**
  128202. * Creates a new MinBlock
  128203. * @param name defines the block name
  128204. */
  128205. constructor(name: string);
  128206. /**
  128207. * Gets the current class name
  128208. * @returns the class name
  128209. */
  128210. getClassName(): string;
  128211. /**
  128212. * Gets the left operand input component
  128213. */
  128214. get left(): NodeMaterialConnectionPoint;
  128215. /**
  128216. * Gets the right operand input component
  128217. */
  128218. get right(): NodeMaterialConnectionPoint;
  128219. /**
  128220. * Gets the output component
  128221. */
  128222. get output(): NodeMaterialConnectionPoint;
  128223. protected _buildBlock(state: NodeMaterialBuildState): this;
  128224. }
  128225. }
  128226. declare module BABYLON {
  128227. /**
  128228. * Block used to get the distance between 2 values
  128229. */
  128230. export class DistanceBlock extends NodeMaterialBlock {
  128231. /**
  128232. * Creates a new DistanceBlock
  128233. * @param name defines the block name
  128234. */
  128235. constructor(name: string);
  128236. /**
  128237. * Gets the current class name
  128238. * @returns the class name
  128239. */
  128240. getClassName(): string;
  128241. /**
  128242. * Gets the left operand input component
  128243. */
  128244. get left(): NodeMaterialConnectionPoint;
  128245. /**
  128246. * Gets the right operand input component
  128247. */
  128248. get right(): NodeMaterialConnectionPoint;
  128249. /**
  128250. * Gets the output component
  128251. */
  128252. get output(): NodeMaterialConnectionPoint;
  128253. protected _buildBlock(state: NodeMaterialBuildState): this;
  128254. }
  128255. }
  128256. declare module BABYLON {
  128257. /**
  128258. * Block used to get the length of a vector
  128259. */
  128260. export class LengthBlock extends NodeMaterialBlock {
  128261. /**
  128262. * Creates a new LengthBlock
  128263. * @param name defines the block name
  128264. */
  128265. constructor(name: string);
  128266. /**
  128267. * Gets the current class name
  128268. * @returns the class name
  128269. */
  128270. getClassName(): string;
  128271. /**
  128272. * Gets the value input component
  128273. */
  128274. get value(): NodeMaterialConnectionPoint;
  128275. /**
  128276. * Gets the output component
  128277. */
  128278. get output(): NodeMaterialConnectionPoint;
  128279. protected _buildBlock(state: NodeMaterialBuildState): this;
  128280. }
  128281. }
  128282. declare module BABYLON {
  128283. /**
  128284. * Block used to get negative version of a value (i.e. x * -1)
  128285. */
  128286. export class NegateBlock extends NodeMaterialBlock {
  128287. /**
  128288. * Creates a new NegateBlock
  128289. * @param name defines the block name
  128290. */
  128291. constructor(name: string);
  128292. /**
  128293. * Gets the current class name
  128294. * @returns the class name
  128295. */
  128296. getClassName(): string;
  128297. /**
  128298. * Gets the value input component
  128299. */
  128300. get value(): NodeMaterialConnectionPoint;
  128301. /**
  128302. * Gets the output component
  128303. */
  128304. get output(): NodeMaterialConnectionPoint;
  128305. protected _buildBlock(state: NodeMaterialBuildState): this;
  128306. }
  128307. }
  128308. declare module BABYLON {
  128309. /**
  128310. * Block used to get the value of the first parameter raised to the power of the second
  128311. */
  128312. export class PowBlock extends NodeMaterialBlock {
  128313. /**
  128314. * Creates a new PowBlock
  128315. * @param name defines the block name
  128316. */
  128317. constructor(name: string);
  128318. /**
  128319. * Gets the current class name
  128320. * @returns the class name
  128321. */
  128322. getClassName(): string;
  128323. /**
  128324. * Gets the value operand input component
  128325. */
  128326. get value(): NodeMaterialConnectionPoint;
  128327. /**
  128328. * Gets the power operand input component
  128329. */
  128330. get power(): NodeMaterialConnectionPoint;
  128331. /**
  128332. * Gets the output component
  128333. */
  128334. get output(): NodeMaterialConnectionPoint;
  128335. protected _buildBlock(state: NodeMaterialBuildState): this;
  128336. }
  128337. }
  128338. declare module BABYLON {
  128339. /**
  128340. * Block used to get a random number
  128341. */
  128342. export class RandomNumberBlock extends NodeMaterialBlock {
  128343. /**
  128344. * Creates a new RandomNumberBlock
  128345. * @param name defines the block name
  128346. */
  128347. constructor(name: string);
  128348. /**
  128349. * Gets the current class name
  128350. * @returns the class name
  128351. */
  128352. getClassName(): string;
  128353. /**
  128354. * Gets the seed input component
  128355. */
  128356. get seed(): NodeMaterialConnectionPoint;
  128357. /**
  128358. * Gets the output component
  128359. */
  128360. get output(): NodeMaterialConnectionPoint;
  128361. protected _buildBlock(state: NodeMaterialBuildState): this;
  128362. }
  128363. }
  128364. declare module BABYLON {
  128365. /**
  128366. * Block used to compute arc tangent of 2 values
  128367. */
  128368. export class ArcTan2Block extends NodeMaterialBlock {
  128369. /**
  128370. * Creates a new ArcTan2Block
  128371. * @param name defines the block name
  128372. */
  128373. constructor(name: string);
  128374. /**
  128375. * Gets the current class name
  128376. * @returns the class name
  128377. */
  128378. getClassName(): string;
  128379. /**
  128380. * Gets the x operand input component
  128381. */
  128382. get x(): NodeMaterialConnectionPoint;
  128383. /**
  128384. * Gets the y operand input component
  128385. */
  128386. get y(): NodeMaterialConnectionPoint;
  128387. /**
  128388. * Gets the output component
  128389. */
  128390. get output(): NodeMaterialConnectionPoint;
  128391. protected _buildBlock(state: NodeMaterialBuildState): this;
  128392. }
  128393. }
  128394. declare module BABYLON {
  128395. /**
  128396. * Block used to smooth step a value
  128397. */
  128398. export class SmoothStepBlock extends NodeMaterialBlock {
  128399. /**
  128400. * Creates a new SmoothStepBlock
  128401. * @param name defines the block name
  128402. */
  128403. constructor(name: string);
  128404. /**
  128405. * Gets the current class name
  128406. * @returns the class name
  128407. */
  128408. getClassName(): string;
  128409. /**
  128410. * Gets the value operand input component
  128411. */
  128412. get value(): NodeMaterialConnectionPoint;
  128413. /**
  128414. * Gets the first edge operand input component
  128415. */
  128416. get edge0(): NodeMaterialConnectionPoint;
  128417. /**
  128418. * Gets the second edge operand input component
  128419. */
  128420. get edge1(): NodeMaterialConnectionPoint;
  128421. /**
  128422. * Gets the output component
  128423. */
  128424. get output(): NodeMaterialConnectionPoint;
  128425. protected _buildBlock(state: NodeMaterialBuildState): this;
  128426. }
  128427. }
  128428. declare module BABYLON {
  128429. /**
  128430. * Block used to get the reciprocal (1 / x) of a value
  128431. */
  128432. export class ReciprocalBlock extends NodeMaterialBlock {
  128433. /**
  128434. * Creates a new ReciprocalBlock
  128435. * @param name defines the block name
  128436. */
  128437. constructor(name: string);
  128438. /**
  128439. * Gets the current class name
  128440. * @returns the class name
  128441. */
  128442. getClassName(): string;
  128443. /**
  128444. * Gets the input component
  128445. */
  128446. get input(): NodeMaterialConnectionPoint;
  128447. /**
  128448. * Gets the output component
  128449. */
  128450. get output(): NodeMaterialConnectionPoint;
  128451. protected _buildBlock(state: NodeMaterialBuildState): this;
  128452. }
  128453. }
  128454. declare module BABYLON {
  128455. /**
  128456. * Block used to replace a color by another one
  128457. */
  128458. export class ReplaceColorBlock extends NodeMaterialBlock {
  128459. /**
  128460. * Creates a new ReplaceColorBlock
  128461. * @param name defines the block name
  128462. */
  128463. constructor(name: string);
  128464. /**
  128465. * Gets the current class name
  128466. * @returns the class name
  128467. */
  128468. getClassName(): string;
  128469. /**
  128470. * Gets the value input component
  128471. */
  128472. get value(): NodeMaterialConnectionPoint;
  128473. /**
  128474. * Gets the reference input component
  128475. */
  128476. get reference(): NodeMaterialConnectionPoint;
  128477. /**
  128478. * Gets the distance input component
  128479. */
  128480. get distance(): NodeMaterialConnectionPoint;
  128481. /**
  128482. * Gets the replacement input component
  128483. */
  128484. get replacement(): NodeMaterialConnectionPoint;
  128485. /**
  128486. * Gets the output component
  128487. */
  128488. get output(): NodeMaterialConnectionPoint;
  128489. protected _buildBlock(state: NodeMaterialBuildState): this;
  128490. }
  128491. }
  128492. declare module BABYLON {
  128493. /**
  128494. * Block used to posterize a value
  128495. * @see https://en.wikipedia.org/wiki/Posterization
  128496. */
  128497. export class PosterizeBlock extends NodeMaterialBlock {
  128498. /**
  128499. * Creates a new PosterizeBlock
  128500. * @param name defines the block name
  128501. */
  128502. constructor(name: string);
  128503. /**
  128504. * Gets the current class name
  128505. * @returns the class name
  128506. */
  128507. getClassName(): string;
  128508. /**
  128509. * Gets the value input component
  128510. */
  128511. get value(): NodeMaterialConnectionPoint;
  128512. /**
  128513. * Gets the steps input component
  128514. */
  128515. get steps(): NodeMaterialConnectionPoint;
  128516. /**
  128517. * Gets the output component
  128518. */
  128519. get output(): NodeMaterialConnectionPoint;
  128520. protected _buildBlock(state: NodeMaterialBuildState): this;
  128521. }
  128522. }
  128523. declare module BABYLON {
  128524. /**
  128525. * Operations supported by the Wave block
  128526. */
  128527. export enum WaveBlockKind {
  128528. /** SawTooth */
  128529. SawTooth = 0,
  128530. /** Square */
  128531. Square = 1,
  128532. /** Triangle */
  128533. Triangle = 2
  128534. }
  128535. /**
  128536. * Block used to apply wave operation to floats
  128537. */
  128538. export class WaveBlock extends NodeMaterialBlock {
  128539. /**
  128540. * Gets or sets the kibnd of wave to be applied by the block
  128541. */
  128542. kind: WaveBlockKind;
  128543. /**
  128544. * Creates a new WaveBlock
  128545. * @param name defines the block name
  128546. */
  128547. constructor(name: string);
  128548. /**
  128549. * Gets the current class name
  128550. * @returns the class name
  128551. */
  128552. getClassName(): string;
  128553. /**
  128554. * Gets the input component
  128555. */
  128556. get input(): NodeMaterialConnectionPoint;
  128557. /**
  128558. * Gets the output component
  128559. */
  128560. get output(): NodeMaterialConnectionPoint;
  128561. protected _buildBlock(state: NodeMaterialBuildState): this;
  128562. serialize(): any;
  128563. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128564. }
  128565. }
  128566. declare module BABYLON {
  128567. /**
  128568. * Class used to store a color step for the GradientBlock
  128569. */
  128570. export class GradientBlockColorStep {
  128571. /**
  128572. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128573. */
  128574. step: number;
  128575. /**
  128576. * Gets or sets the color associated with this step
  128577. */
  128578. color: Color3;
  128579. /**
  128580. * Creates a new GradientBlockColorStep
  128581. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  128582. * @param color defines the color associated with this step
  128583. */
  128584. constructor(
  128585. /**
  128586. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128587. */
  128588. step: number,
  128589. /**
  128590. * Gets or sets the color associated with this step
  128591. */
  128592. color: Color3);
  128593. }
  128594. /**
  128595. * Block used to return a color from a gradient based on an input value between 0 and 1
  128596. */
  128597. export class GradientBlock extends NodeMaterialBlock {
  128598. /**
  128599. * Gets or sets the list of color steps
  128600. */
  128601. colorSteps: GradientBlockColorStep[];
  128602. /**
  128603. * Creates a new GradientBlock
  128604. * @param name defines the block name
  128605. */
  128606. constructor(name: string);
  128607. /**
  128608. * Gets the current class name
  128609. * @returns the class name
  128610. */
  128611. getClassName(): string;
  128612. /**
  128613. * Gets the gradient input component
  128614. */
  128615. get gradient(): NodeMaterialConnectionPoint;
  128616. /**
  128617. * Gets the output component
  128618. */
  128619. get output(): NodeMaterialConnectionPoint;
  128620. private _writeColorConstant;
  128621. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128622. serialize(): any;
  128623. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128624. protected _dumpPropertiesCode(): string;
  128625. }
  128626. }
  128627. declare module BABYLON {
  128628. /**
  128629. * Block used to normalize lerp between 2 values
  128630. */
  128631. export class NLerpBlock extends NodeMaterialBlock {
  128632. /**
  128633. * Creates a new NLerpBlock
  128634. * @param name defines the block name
  128635. */
  128636. constructor(name: string);
  128637. /**
  128638. * Gets the current class name
  128639. * @returns the class name
  128640. */
  128641. getClassName(): string;
  128642. /**
  128643. * Gets the left operand input component
  128644. */
  128645. get left(): NodeMaterialConnectionPoint;
  128646. /**
  128647. * Gets the right operand input component
  128648. */
  128649. get right(): NodeMaterialConnectionPoint;
  128650. /**
  128651. * Gets the gradient operand input component
  128652. */
  128653. get gradient(): NodeMaterialConnectionPoint;
  128654. /**
  128655. * Gets the output component
  128656. */
  128657. get output(): NodeMaterialConnectionPoint;
  128658. protected _buildBlock(state: NodeMaterialBuildState): this;
  128659. }
  128660. }
  128661. declare module BABYLON {
  128662. /**
  128663. * block used to Generate a Worley Noise 3D Noise Pattern
  128664. */
  128665. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  128666. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128667. manhattanDistance: boolean;
  128668. /**
  128669. * Creates a new WorleyNoise3DBlock
  128670. * @param name defines the block name
  128671. */
  128672. constructor(name: string);
  128673. /**
  128674. * Gets the current class name
  128675. * @returns the class name
  128676. */
  128677. getClassName(): string;
  128678. /**
  128679. * Gets the seed input component
  128680. */
  128681. get seed(): NodeMaterialConnectionPoint;
  128682. /**
  128683. * Gets the jitter input component
  128684. */
  128685. get jitter(): NodeMaterialConnectionPoint;
  128686. /**
  128687. * Gets the output component
  128688. */
  128689. get output(): NodeMaterialConnectionPoint;
  128690. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128691. /**
  128692. * Exposes the properties to the UI?
  128693. */
  128694. protected _dumpPropertiesCode(): string;
  128695. /**
  128696. * Exposes the properties to the Seralize?
  128697. */
  128698. serialize(): any;
  128699. /**
  128700. * Exposes the properties to the deseralize?
  128701. */
  128702. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128703. }
  128704. }
  128705. declare module BABYLON {
  128706. /**
  128707. * block used to Generate a Simplex Perlin 3d Noise Pattern
  128708. */
  128709. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  128710. /**
  128711. * Creates a new SimplexPerlin3DBlock
  128712. * @param name defines the block name
  128713. */
  128714. constructor(name: string);
  128715. /**
  128716. * Gets the current class name
  128717. * @returns the class name
  128718. */
  128719. getClassName(): string;
  128720. /**
  128721. * Gets the seed operand input component
  128722. */
  128723. get seed(): NodeMaterialConnectionPoint;
  128724. /**
  128725. * Gets the output component
  128726. */
  128727. get output(): NodeMaterialConnectionPoint;
  128728. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128729. }
  128730. }
  128731. declare module BABYLON {
  128732. /**
  128733. * Block used to blend normals
  128734. */
  128735. export class NormalBlendBlock extends NodeMaterialBlock {
  128736. /**
  128737. * Creates a new NormalBlendBlock
  128738. * @param name defines the block name
  128739. */
  128740. constructor(name: string);
  128741. /**
  128742. * Gets the current class name
  128743. * @returns the class name
  128744. */
  128745. getClassName(): string;
  128746. /**
  128747. * Gets the first input component
  128748. */
  128749. get normalMap0(): NodeMaterialConnectionPoint;
  128750. /**
  128751. * Gets the second input component
  128752. */
  128753. get normalMap1(): NodeMaterialConnectionPoint;
  128754. /**
  128755. * Gets the output component
  128756. */
  128757. get output(): NodeMaterialConnectionPoint;
  128758. protected _buildBlock(state: NodeMaterialBuildState): this;
  128759. }
  128760. }
  128761. declare module BABYLON {
  128762. /**
  128763. * Block used to rotate a 2d vector by a given angle
  128764. */
  128765. export class Rotate2dBlock extends NodeMaterialBlock {
  128766. /**
  128767. * Creates a new Rotate2dBlock
  128768. * @param name defines the block name
  128769. */
  128770. constructor(name: string);
  128771. /**
  128772. * Gets the current class name
  128773. * @returns the class name
  128774. */
  128775. getClassName(): string;
  128776. /**
  128777. * Gets the input vector
  128778. */
  128779. get input(): NodeMaterialConnectionPoint;
  128780. /**
  128781. * Gets the input angle
  128782. */
  128783. get angle(): NodeMaterialConnectionPoint;
  128784. /**
  128785. * Gets the output component
  128786. */
  128787. get output(): NodeMaterialConnectionPoint;
  128788. autoConfigure(material: NodeMaterial): void;
  128789. protected _buildBlock(state: NodeMaterialBuildState): this;
  128790. }
  128791. }
  128792. declare module BABYLON {
  128793. /**
  128794. * Block used to get the reflected vector from a direction and a normal
  128795. */
  128796. export class ReflectBlock extends NodeMaterialBlock {
  128797. /**
  128798. * Creates a new ReflectBlock
  128799. * @param name defines the block name
  128800. */
  128801. constructor(name: string);
  128802. /**
  128803. * Gets the current class name
  128804. * @returns the class name
  128805. */
  128806. getClassName(): string;
  128807. /**
  128808. * Gets the incident component
  128809. */
  128810. get incident(): NodeMaterialConnectionPoint;
  128811. /**
  128812. * Gets the normal component
  128813. */
  128814. get normal(): NodeMaterialConnectionPoint;
  128815. /**
  128816. * Gets the output component
  128817. */
  128818. get output(): NodeMaterialConnectionPoint;
  128819. protected _buildBlock(state: NodeMaterialBuildState): this;
  128820. }
  128821. }
  128822. declare module BABYLON {
  128823. /**
  128824. * Block used to get the refracted vector from a direction and a normal
  128825. */
  128826. export class RefractBlock extends NodeMaterialBlock {
  128827. /**
  128828. * Creates a new RefractBlock
  128829. * @param name defines the block name
  128830. */
  128831. constructor(name: string);
  128832. /**
  128833. * Gets the current class name
  128834. * @returns the class name
  128835. */
  128836. getClassName(): string;
  128837. /**
  128838. * Gets the incident component
  128839. */
  128840. get incident(): NodeMaterialConnectionPoint;
  128841. /**
  128842. * Gets the normal component
  128843. */
  128844. get normal(): NodeMaterialConnectionPoint;
  128845. /**
  128846. * Gets the index of refraction component
  128847. */
  128848. get ior(): NodeMaterialConnectionPoint;
  128849. /**
  128850. * Gets the output component
  128851. */
  128852. get output(): NodeMaterialConnectionPoint;
  128853. protected _buildBlock(state: NodeMaterialBuildState): this;
  128854. }
  128855. }
  128856. declare module BABYLON {
  128857. /**
  128858. * Block used to desaturate a color
  128859. */
  128860. export class DesaturateBlock extends NodeMaterialBlock {
  128861. /**
  128862. * Creates a new DesaturateBlock
  128863. * @param name defines the block name
  128864. */
  128865. constructor(name: string);
  128866. /**
  128867. * Gets the current class name
  128868. * @returns the class name
  128869. */
  128870. getClassName(): string;
  128871. /**
  128872. * Gets the color operand input component
  128873. */
  128874. get color(): NodeMaterialConnectionPoint;
  128875. /**
  128876. * Gets the level operand input component
  128877. */
  128878. get level(): NodeMaterialConnectionPoint;
  128879. /**
  128880. * Gets the output component
  128881. */
  128882. get output(): NodeMaterialConnectionPoint;
  128883. protected _buildBlock(state: NodeMaterialBuildState): this;
  128884. }
  128885. }
  128886. declare module BABYLON {
  128887. /**
  128888. * Effect Render Options
  128889. */
  128890. export interface IEffectRendererOptions {
  128891. /**
  128892. * Defines the vertices positions.
  128893. */
  128894. positions?: number[];
  128895. /**
  128896. * Defines the indices.
  128897. */
  128898. indices?: number[];
  128899. }
  128900. /**
  128901. * Helper class to render one or more effects
  128902. */
  128903. export class EffectRenderer {
  128904. private engine;
  128905. private static _DefaultOptions;
  128906. private _vertexBuffers;
  128907. private _indexBuffer;
  128908. private _ringBufferIndex;
  128909. private _ringScreenBuffer;
  128910. private _fullscreenViewport;
  128911. private _getNextFrameBuffer;
  128912. /**
  128913. * Creates an effect renderer
  128914. * @param engine the engine to use for rendering
  128915. * @param options defines the options of the effect renderer
  128916. */
  128917. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  128918. /**
  128919. * Sets the current viewport in normalized coordinates 0-1
  128920. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  128921. */
  128922. setViewport(viewport?: Viewport): void;
  128923. /**
  128924. * Binds the embedded attributes buffer to the effect.
  128925. * @param effect Defines the effect to bind the attributes for
  128926. */
  128927. bindBuffers(effect: Effect): void;
  128928. /**
  128929. * Sets the current effect wrapper to use during draw.
  128930. * The effect needs to be ready before calling this api.
  128931. * This also sets the default full screen position attribute.
  128932. * @param effectWrapper Defines the effect to draw with
  128933. */
  128934. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  128935. /**
  128936. * Draws a full screen quad.
  128937. */
  128938. draw(): void;
  128939. /**
  128940. * renders one or more effects to a specified texture
  128941. * @param effectWrappers list of effects to renderer
  128942. * @param outputTexture texture to draw to, if null it will render to the screen
  128943. */
  128944. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  128945. /**
  128946. * Disposes of the effect renderer
  128947. */
  128948. dispose(): void;
  128949. }
  128950. /**
  128951. * Options to create an EffectWrapper
  128952. */
  128953. interface EffectWrapperCreationOptions {
  128954. /**
  128955. * Engine to use to create the effect
  128956. */
  128957. engine: ThinEngine;
  128958. /**
  128959. * Fragment shader for the effect
  128960. */
  128961. fragmentShader: string;
  128962. /**
  128963. * Vertex shader for the effect
  128964. */
  128965. vertexShader?: string;
  128966. /**
  128967. * Attributes to use in the shader
  128968. */
  128969. attributeNames?: Array<string>;
  128970. /**
  128971. * Uniforms to use in the shader
  128972. */
  128973. uniformNames?: Array<string>;
  128974. /**
  128975. * Texture sampler names to use in the shader
  128976. */
  128977. samplerNames?: Array<string>;
  128978. /**
  128979. * The friendly name of the effect displayed in Spector.
  128980. */
  128981. name?: string;
  128982. }
  128983. /**
  128984. * Wraps an effect to be used for rendering
  128985. */
  128986. export class EffectWrapper {
  128987. /**
  128988. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  128989. */
  128990. onApplyObservable: Observable<{}>;
  128991. /**
  128992. * The underlying effect
  128993. */
  128994. effect: Effect;
  128995. /**
  128996. * Creates an effect to be renderer
  128997. * @param creationOptions options to create the effect
  128998. */
  128999. constructor(creationOptions: EffectWrapperCreationOptions);
  129000. /**
  129001. * Disposes of the effect wrapper
  129002. */
  129003. dispose(): void;
  129004. }
  129005. }
  129006. declare module BABYLON {
  129007. /**
  129008. * Helper class to push actions to a pool of workers.
  129009. */
  129010. export class WorkerPool implements IDisposable {
  129011. private _workerInfos;
  129012. private _pendingActions;
  129013. /**
  129014. * Constructor
  129015. * @param workers Array of workers to use for actions
  129016. */
  129017. constructor(workers: Array<Worker>);
  129018. /**
  129019. * Terminates all workers and clears any pending actions.
  129020. */
  129021. dispose(): void;
  129022. /**
  129023. * Pushes an action to the worker pool. If all the workers are active, the action will be
  129024. * pended until a worker has completed its action.
  129025. * @param action The action to perform. Call onComplete when the action is complete.
  129026. */
  129027. push(action: (worker: Worker, onComplete: () => void) => void): void;
  129028. private _execute;
  129029. }
  129030. }
  129031. declare module BABYLON {
  129032. /**
  129033. * Configuration for Draco compression
  129034. */
  129035. export interface IDracoCompressionConfiguration {
  129036. /**
  129037. * Configuration for the decoder.
  129038. */
  129039. decoder: {
  129040. /**
  129041. * The url to the WebAssembly module.
  129042. */
  129043. wasmUrl?: string;
  129044. /**
  129045. * The url to the WebAssembly binary.
  129046. */
  129047. wasmBinaryUrl?: string;
  129048. /**
  129049. * The url to the fallback JavaScript module.
  129050. */
  129051. fallbackUrl?: string;
  129052. };
  129053. }
  129054. /**
  129055. * Draco compression (https://google.github.io/draco/)
  129056. *
  129057. * This class wraps the Draco module.
  129058. *
  129059. * **Encoder**
  129060. *
  129061. * The encoder is not currently implemented.
  129062. *
  129063. * **Decoder**
  129064. *
  129065. * 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.
  129066. *
  129067. * To update the configuration, use the following code:
  129068. * ```javascript
  129069. * DracoCompression.Configuration = {
  129070. * decoder: {
  129071. * wasmUrl: "<url to the WebAssembly library>",
  129072. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  129073. * fallbackUrl: "<url to the fallback JavaScript library>",
  129074. * }
  129075. * };
  129076. * ```
  129077. *
  129078. * 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.
  129079. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  129080. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  129081. *
  129082. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  129083. * ```javascript
  129084. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  129085. * ```
  129086. *
  129087. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  129088. */
  129089. export class DracoCompression implements IDisposable {
  129090. private _workerPoolPromise?;
  129091. private _decoderModulePromise?;
  129092. /**
  129093. * The configuration. Defaults to the following urls:
  129094. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  129095. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  129096. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  129097. */
  129098. static Configuration: IDracoCompressionConfiguration;
  129099. /**
  129100. * Returns true if the decoder configuration is available.
  129101. */
  129102. static get DecoderAvailable(): boolean;
  129103. /**
  129104. * Default number of workers to create when creating the draco compression object.
  129105. */
  129106. static DefaultNumWorkers: number;
  129107. private static GetDefaultNumWorkers;
  129108. private static _Default;
  129109. /**
  129110. * Default instance for the draco compression object.
  129111. */
  129112. static get Default(): DracoCompression;
  129113. /**
  129114. * Constructor
  129115. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  129116. */
  129117. constructor(numWorkers?: number);
  129118. /**
  129119. * Stop all async operations and release resources.
  129120. */
  129121. dispose(): void;
  129122. /**
  129123. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  129124. * @returns a promise that resolves when ready
  129125. */
  129126. whenReadyAsync(): Promise<void>;
  129127. /**
  129128. * Decode Draco compressed mesh data to vertex data.
  129129. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  129130. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  129131. * @returns A promise that resolves with the decoded vertex data
  129132. */
  129133. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  129134. [kind: string]: number;
  129135. }): Promise<VertexData>;
  129136. }
  129137. }
  129138. declare module BABYLON {
  129139. /**
  129140. * Class for building Constructive Solid Geometry
  129141. */
  129142. export class CSG {
  129143. private polygons;
  129144. /**
  129145. * The world matrix
  129146. */
  129147. matrix: Matrix;
  129148. /**
  129149. * Stores the position
  129150. */
  129151. position: Vector3;
  129152. /**
  129153. * Stores the rotation
  129154. */
  129155. rotation: Vector3;
  129156. /**
  129157. * Stores the rotation quaternion
  129158. */
  129159. rotationQuaternion: Nullable<Quaternion>;
  129160. /**
  129161. * Stores the scaling vector
  129162. */
  129163. scaling: Vector3;
  129164. /**
  129165. * Convert the Mesh to CSG
  129166. * @param mesh The Mesh to convert to CSG
  129167. * @returns A new CSG from the Mesh
  129168. */
  129169. static FromMesh(mesh: Mesh): CSG;
  129170. /**
  129171. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  129172. * @param polygons Polygons used to construct a CSG solid
  129173. */
  129174. private static FromPolygons;
  129175. /**
  129176. * Clones, or makes a deep copy, of the CSG
  129177. * @returns A new CSG
  129178. */
  129179. clone(): CSG;
  129180. /**
  129181. * Unions this CSG with another CSG
  129182. * @param csg The CSG to union against this CSG
  129183. * @returns The unioned CSG
  129184. */
  129185. union(csg: CSG): CSG;
  129186. /**
  129187. * Unions this CSG with another CSG in place
  129188. * @param csg The CSG to union against this CSG
  129189. */
  129190. unionInPlace(csg: CSG): void;
  129191. /**
  129192. * Subtracts this CSG with another CSG
  129193. * @param csg The CSG to subtract against this CSG
  129194. * @returns A new CSG
  129195. */
  129196. subtract(csg: CSG): CSG;
  129197. /**
  129198. * Subtracts this CSG with another CSG in place
  129199. * @param csg The CSG to subtact against this CSG
  129200. */
  129201. subtractInPlace(csg: CSG): void;
  129202. /**
  129203. * Intersect this CSG with another CSG
  129204. * @param csg The CSG to intersect against this CSG
  129205. * @returns A new CSG
  129206. */
  129207. intersect(csg: CSG): CSG;
  129208. /**
  129209. * Intersects this CSG with another CSG in place
  129210. * @param csg The CSG to intersect against this CSG
  129211. */
  129212. intersectInPlace(csg: CSG): void;
  129213. /**
  129214. * Return a new CSG solid with solid and empty space switched. This solid is
  129215. * not modified.
  129216. * @returns A new CSG solid with solid and empty space switched
  129217. */
  129218. inverse(): CSG;
  129219. /**
  129220. * Inverses the CSG in place
  129221. */
  129222. inverseInPlace(): void;
  129223. /**
  129224. * This is used to keep meshes transformations so they can be restored
  129225. * when we build back a Babylon Mesh
  129226. * NB : All CSG operations are performed in world coordinates
  129227. * @param csg The CSG to copy the transform attributes from
  129228. * @returns This CSG
  129229. */
  129230. copyTransformAttributes(csg: CSG): CSG;
  129231. /**
  129232. * Build Raw mesh from CSG
  129233. * Coordinates here are in world space
  129234. * @param name The name of the mesh geometry
  129235. * @param scene The Scene
  129236. * @param keepSubMeshes Specifies if the submeshes should be kept
  129237. * @returns A new Mesh
  129238. */
  129239. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129240. /**
  129241. * Build Mesh from CSG taking material and transforms into account
  129242. * @param name The name of the Mesh
  129243. * @param material The material of the Mesh
  129244. * @param scene The Scene
  129245. * @param keepSubMeshes Specifies if submeshes should be kept
  129246. * @returns The new Mesh
  129247. */
  129248. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129249. }
  129250. }
  129251. declare module BABYLON {
  129252. /**
  129253. * Class used to create a trail following a mesh
  129254. */
  129255. export class TrailMesh extends Mesh {
  129256. private _generator;
  129257. private _autoStart;
  129258. private _running;
  129259. private _diameter;
  129260. private _length;
  129261. private _sectionPolygonPointsCount;
  129262. private _sectionVectors;
  129263. private _sectionNormalVectors;
  129264. private _beforeRenderObserver;
  129265. /**
  129266. * @constructor
  129267. * @param name The value used by scene.getMeshByName() to do a lookup.
  129268. * @param generator The mesh to generate a trail.
  129269. * @param scene The scene to add this mesh to.
  129270. * @param diameter Diameter of trailing mesh. Default is 1.
  129271. * @param length Length of trailing mesh. Default is 60.
  129272. * @param autoStart Automatically start trailing mesh. Default true.
  129273. */
  129274. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  129275. /**
  129276. * "TrailMesh"
  129277. * @returns "TrailMesh"
  129278. */
  129279. getClassName(): string;
  129280. private _createMesh;
  129281. /**
  129282. * Start trailing mesh.
  129283. */
  129284. start(): void;
  129285. /**
  129286. * Stop trailing mesh.
  129287. */
  129288. stop(): void;
  129289. /**
  129290. * Update trailing mesh geometry.
  129291. */
  129292. update(): void;
  129293. /**
  129294. * Returns a new TrailMesh object.
  129295. * @param name is a string, the name given to the new mesh
  129296. * @param newGenerator use new generator object for cloned trail mesh
  129297. * @returns a new mesh
  129298. */
  129299. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  129300. /**
  129301. * Serializes this trail mesh
  129302. * @param serializationObject object to write serialization to
  129303. */
  129304. serialize(serializationObject: any): void;
  129305. /**
  129306. * Parses a serialized trail mesh
  129307. * @param parsedMesh the serialized mesh
  129308. * @param scene the scene to create the trail mesh in
  129309. * @returns the created trail mesh
  129310. */
  129311. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  129312. }
  129313. }
  129314. declare module BABYLON {
  129315. /**
  129316. * Class containing static functions to help procedurally build meshes
  129317. */
  129318. export class TiledBoxBuilder {
  129319. /**
  129320. * Creates a box mesh
  129321. * 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)
  129322. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129326. * @param name defines the name of the mesh
  129327. * @param options defines the options used to create the mesh
  129328. * @param scene defines the hosting scene
  129329. * @returns the box mesh
  129330. */
  129331. static CreateTiledBox(name: string, options: {
  129332. pattern?: number;
  129333. width?: number;
  129334. height?: number;
  129335. depth?: number;
  129336. tileSize?: number;
  129337. tileWidth?: number;
  129338. tileHeight?: number;
  129339. alignHorizontal?: number;
  129340. alignVertical?: number;
  129341. faceUV?: Vector4[];
  129342. faceColors?: Color4[];
  129343. sideOrientation?: number;
  129344. updatable?: boolean;
  129345. }, scene?: Nullable<Scene>): Mesh;
  129346. }
  129347. }
  129348. declare module BABYLON {
  129349. /**
  129350. * Class containing static functions to help procedurally build meshes
  129351. */
  129352. export class TorusKnotBuilder {
  129353. /**
  129354. * Creates a torus knot mesh
  129355. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129356. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129357. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129358. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129362. * @param name defines the name of the mesh
  129363. * @param options defines the options used to create the mesh
  129364. * @param scene defines the hosting scene
  129365. * @returns the torus knot mesh
  129366. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  129367. */
  129368. static CreateTorusKnot(name: string, options: {
  129369. radius?: number;
  129370. tube?: number;
  129371. radialSegments?: number;
  129372. tubularSegments?: number;
  129373. p?: number;
  129374. q?: number;
  129375. updatable?: boolean;
  129376. sideOrientation?: number;
  129377. frontUVs?: Vector4;
  129378. backUVs?: Vector4;
  129379. }, scene: any): Mesh;
  129380. }
  129381. }
  129382. declare module BABYLON {
  129383. /**
  129384. * Polygon
  129385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  129386. */
  129387. export class Polygon {
  129388. /**
  129389. * Creates a rectangle
  129390. * @param xmin bottom X coord
  129391. * @param ymin bottom Y coord
  129392. * @param xmax top X coord
  129393. * @param ymax top Y coord
  129394. * @returns points that make the resulting rectation
  129395. */
  129396. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  129397. /**
  129398. * Creates a circle
  129399. * @param radius radius of circle
  129400. * @param cx scale in x
  129401. * @param cy scale in y
  129402. * @param numberOfSides number of sides that make up the circle
  129403. * @returns points that make the resulting circle
  129404. */
  129405. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  129406. /**
  129407. * Creates a polygon from input string
  129408. * @param input Input polygon data
  129409. * @returns the parsed points
  129410. */
  129411. static Parse(input: string): Vector2[];
  129412. /**
  129413. * Starts building a polygon from x and y coordinates
  129414. * @param x x coordinate
  129415. * @param y y coordinate
  129416. * @returns the started path2
  129417. */
  129418. static StartingAt(x: number, y: number): Path2;
  129419. }
  129420. /**
  129421. * Builds a polygon
  129422. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  129423. */
  129424. export class PolygonMeshBuilder {
  129425. private _points;
  129426. private _outlinepoints;
  129427. private _holes;
  129428. private _name;
  129429. private _scene;
  129430. private _epoints;
  129431. private _eholes;
  129432. private _addToepoint;
  129433. /**
  129434. * Babylon reference to the earcut plugin.
  129435. */
  129436. bjsEarcut: any;
  129437. /**
  129438. * Creates a PolygonMeshBuilder
  129439. * @param name name of the builder
  129440. * @param contours Path of the polygon
  129441. * @param scene scene to add to when creating the mesh
  129442. * @param earcutInjection can be used to inject your own earcut reference
  129443. */
  129444. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  129445. /**
  129446. * Adds a whole within the polygon
  129447. * @param hole Array of points defining the hole
  129448. * @returns this
  129449. */
  129450. addHole(hole: Vector2[]): PolygonMeshBuilder;
  129451. /**
  129452. * Creates the polygon
  129453. * @param updatable If the mesh should be updatable
  129454. * @param depth The depth of the mesh created
  129455. * @returns the created mesh
  129456. */
  129457. build(updatable?: boolean, depth?: number): Mesh;
  129458. /**
  129459. * Creates the polygon
  129460. * @param depth The depth of the mesh created
  129461. * @returns the created VertexData
  129462. */
  129463. buildVertexData(depth?: number): VertexData;
  129464. /**
  129465. * Adds a side to the polygon
  129466. * @param positions points that make the polygon
  129467. * @param normals normals of the polygon
  129468. * @param uvs uvs of the polygon
  129469. * @param indices indices of the polygon
  129470. * @param bounds bounds of the polygon
  129471. * @param points points of the polygon
  129472. * @param depth depth of the polygon
  129473. * @param flip flip of the polygon
  129474. */
  129475. private addSide;
  129476. }
  129477. }
  129478. declare module BABYLON {
  129479. /**
  129480. * Class containing static functions to help procedurally build meshes
  129481. */
  129482. export class PolygonBuilder {
  129483. /**
  129484. * Creates a polygon mesh
  129485. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  129486. * * 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
  129487. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  129490. * * Remember you can only change the shape positions, not their number when updating a polygon
  129491. * @param name defines the name of the mesh
  129492. * @param options defines the options used to create the mesh
  129493. * @param scene defines the hosting scene
  129494. * @param earcutInjection can be used to inject your own earcut reference
  129495. * @returns the polygon mesh
  129496. */
  129497. static CreatePolygon(name: string, options: {
  129498. shape: Vector3[];
  129499. holes?: Vector3[][];
  129500. depth?: number;
  129501. faceUV?: Vector4[];
  129502. faceColors?: Color4[];
  129503. updatable?: boolean;
  129504. sideOrientation?: number;
  129505. frontUVs?: Vector4;
  129506. backUVs?: Vector4;
  129507. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129508. /**
  129509. * Creates an extruded polygon mesh, with depth in the Y direction.
  129510. * * 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)
  129511. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129512. * @param name defines the name of the mesh
  129513. * @param options defines the options used to create the mesh
  129514. * @param scene defines the hosting scene
  129515. * @param earcutInjection can be used to inject your own earcut reference
  129516. * @returns the polygon mesh
  129517. */
  129518. static ExtrudePolygon(name: string, options: {
  129519. shape: Vector3[];
  129520. holes?: Vector3[][];
  129521. depth?: number;
  129522. faceUV?: Vector4[];
  129523. faceColors?: Color4[];
  129524. updatable?: boolean;
  129525. sideOrientation?: number;
  129526. frontUVs?: Vector4;
  129527. backUVs?: Vector4;
  129528. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129529. }
  129530. }
  129531. declare module BABYLON {
  129532. /**
  129533. * Class containing static functions to help procedurally build meshes
  129534. */
  129535. export class LatheBuilder {
  129536. /**
  129537. * Creates lathe mesh.
  129538. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  129539. * * 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
  129540. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  129541. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  129542. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  129543. * * 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
  129544. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  129545. * * 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
  129546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129550. * @param name defines the name of the mesh
  129551. * @param options defines the options used to create the mesh
  129552. * @param scene defines the hosting scene
  129553. * @returns the lathe mesh
  129554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  129555. */
  129556. static CreateLathe(name: string, options: {
  129557. shape: Vector3[];
  129558. radius?: number;
  129559. tessellation?: number;
  129560. clip?: number;
  129561. arc?: number;
  129562. closed?: boolean;
  129563. updatable?: boolean;
  129564. sideOrientation?: number;
  129565. frontUVs?: Vector4;
  129566. backUVs?: Vector4;
  129567. cap?: number;
  129568. invertUV?: boolean;
  129569. }, scene?: Nullable<Scene>): Mesh;
  129570. }
  129571. }
  129572. declare module BABYLON {
  129573. /**
  129574. * Class containing static functions to help procedurally build meshes
  129575. */
  129576. export class TiledPlaneBuilder {
  129577. /**
  129578. * Creates a tiled plane mesh
  129579. * * The parameter `pattern` will, depending on value, do nothing or
  129580. * * * flip (reflect about central vertical) alternate tiles across and up
  129581. * * * flip every tile on alternate rows
  129582. * * * rotate (180 degs) alternate tiles across and up
  129583. * * * rotate every tile on alternate rows
  129584. * * * flip and rotate alternate tiles across and up
  129585. * * * flip and rotate every tile on alternate rows
  129586. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  129587. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  129588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129590. * * 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)
  129591. * * 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)
  129592. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129593. * @param name defines the name of the mesh
  129594. * @param options defines the options used to create the mesh
  129595. * @param scene defines the hosting scene
  129596. * @returns the box mesh
  129597. */
  129598. static CreateTiledPlane(name: string, options: {
  129599. pattern?: number;
  129600. tileSize?: number;
  129601. tileWidth?: number;
  129602. tileHeight?: number;
  129603. size?: number;
  129604. width?: number;
  129605. height?: number;
  129606. alignHorizontal?: number;
  129607. alignVertical?: number;
  129608. sideOrientation?: number;
  129609. frontUVs?: Vector4;
  129610. backUVs?: Vector4;
  129611. updatable?: boolean;
  129612. }, scene?: Nullable<Scene>): Mesh;
  129613. }
  129614. }
  129615. declare module BABYLON {
  129616. /**
  129617. * Class containing static functions to help procedurally build meshes
  129618. */
  129619. export class TubeBuilder {
  129620. /**
  129621. * Creates a tube mesh.
  129622. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129623. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  129624. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  129625. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  129626. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  129627. * * 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)
  129628. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  129629. * * 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
  129630. * * 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
  129631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129635. * @param name defines the name of the mesh
  129636. * @param options defines the options used to create the mesh
  129637. * @param scene defines the hosting scene
  129638. * @returns the tube mesh
  129639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129640. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  129641. */
  129642. static CreateTube(name: string, options: {
  129643. path: Vector3[];
  129644. radius?: number;
  129645. tessellation?: number;
  129646. radiusFunction?: {
  129647. (i: number, distance: number): number;
  129648. };
  129649. cap?: number;
  129650. arc?: number;
  129651. updatable?: boolean;
  129652. sideOrientation?: number;
  129653. frontUVs?: Vector4;
  129654. backUVs?: Vector4;
  129655. instance?: Mesh;
  129656. invertUV?: boolean;
  129657. }, scene?: Nullable<Scene>): Mesh;
  129658. }
  129659. }
  129660. declare module BABYLON {
  129661. /**
  129662. * Class containing static functions to help procedurally build meshes
  129663. */
  129664. export class IcoSphereBuilder {
  129665. /**
  129666. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129667. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129668. * * 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`)
  129669. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129670. * * 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
  129671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129674. * @param name defines the name of the mesh
  129675. * @param options defines the options used to create the mesh
  129676. * @param scene defines the hosting scene
  129677. * @returns the icosahedron mesh
  129678. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129679. */
  129680. static CreateIcoSphere(name: string, options: {
  129681. radius?: number;
  129682. radiusX?: number;
  129683. radiusY?: number;
  129684. radiusZ?: number;
  129685. flat?: boolean;
  129686. subdivisions?: number;
  129687. sideOrientation?: number;
  129688. frontUVs?: Vector4;
  129689. backUVs?: Vector4;
  129690. updatable?: boolean;
  129691. }, scene?: Nullable<Scene>): Mesh;
  129692. }
  129693. }
  129694. declare module BABYLON {
  129695. /**
  129696. * Class containing static functions to help procedurally build meshes
  129697. */
  129698. export class DecalBuilder {
  129699. /**
  129700. * Creates a decal mesh.
  129701. * 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
  129702. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  129703. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  129704. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  129705. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  129706. * @param name defines the name of the mesh
  129707. * @param sourceMesh defines the mesh where the decal must be applied
  129708. * @param options defines the options used to create the mesh
  129709. * @param scene defines the hosting scene
  129710. * @returns the decal mesh
  129711. * @see https://doc.babylonjs.com/how_to/decals
  129712. */
  129713. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  129714. position?: Vector3;
  129715. normal?: Vector3;
  129716. size?: Vector3;
  129717. angle?: number;
  129718. }): Mesh;
  129719. }
  129720. }
  129721. declare module BABYLON {
  129722. /**
  129723. * Class containing static functions to help procedurally build meshes
  129724. */
  129725. export class MeshBuilder {
  129726. /**
  129727. * Creates a box mesh
  129728. * * The parameter `size` sets the size (float) of each box side (default 1)
  129729. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129730. * * 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)
  129731. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129735. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129736. * @param name defines the name of the mesh
  129737. * @param options defines the options used to create the mesh
  129738. * @param scene defines the hosting scene
  129739. * @returns the box mesh
  129740. */
  129741. static CreateBox(name: string, options: {
  129742. size?: number;
  129743. width?: number;
  129744. height?: number;
  129745. depth?: number;
  129746. faceUV?: Vector4[];
  129747. faceColors?: Color4[];
  129748. sideOrientation?: number;
  129749. frontUVs?: Vector4;
  129750. backUVs?: Vector4;
  129751. updatable?: boolean;
  129752. }, scene?: Nullable<Scene>): Mesh;
  129753. /**
  129754. * Creates a tiled box mesh
  129755. * * faceTiles sets the pattern, tile size and number of tiles for a face
  129756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129757. * @param name defines the name of the mesh
  129758. * @param options defines the options used to create the mesh
  129759. * @param scene defines the hosting scene
  129760. * @returns the tiled box mesh
  129761. */
  129762. static CreateTiledBox(name: string, options: {
  129763. pattern?: number;
  129764. size?: number;
  129765. width?: number;
  129766. height?: number;
  129767. depth: number;
  129768. tileSize?: number;
  129769. tileWidth?: number;
  129770. tileHeight?: number;
  129771. faceUV?: Vector4[];
  129772. faceColors?: Color4[];
  129773. alignHorizontal?: number;
  129774. alignVertical?: number;
  129775. sideOrientation?: number;
  129776. updatable?: boolean;
  129777. }, scene?: Nullable<Scene>): Mesh;
  129778. /**
  129779. * Creates a sphere mesh
  129780. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  129781. * * 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`)
  129782. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  129783. * * 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
  129784. * * 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)
  129785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129788. * @param name defines the name of the mesh
  129789. * @param options defines the options used to create the mesh
  129790. * @param scene defines the hosting scene
  129791. * @returns the sphere mesh
  129792. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  129793. */
  129794. static CreateSphere(name: string, options: {
  129795. segments?: number;
  129796. diameter?: number;
  129797. diameterX?: number;
  129798. diameterY?: number;
  129799. diameterZ?: number;
  129800. arc?: number;
  129801. slice?: number;
  129802. sideOrientation?: number;
  129803. frontUVs?: Vector4;
  129804. backUVs?: Vector4;
  129805. updatable?: boolean;
  129806. }, scene?: Nullable<Scene>): Mesh;
  129807. /**
  129808. * Creates a plane polygonal mesh. By default, this is a disc
  129809. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  129810. * * 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
  129811. * * 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
  129812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129815. * @param name defines the name of the mesh
  129816. * @param options defines the options used to create the mesh
  129817. * @param scene defines the hosting scene
  129818. * @returns the plane polygonal mesh
  129819. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  129820. */
  129821. static CreateDisc(name: string, options: {
  129822. radius?: number;
  129823. tessellation?: number;
  129824. arc?: number;
  129825. updatable?: boolean;
  129826. sideOrientation?: number;
  129827. frontUVs?: Vector4;
  129828. backUVs?: Vector4;
  129829. }, scene?: Nullable<Scene>): Mesh;
  129830. /**
  129831. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129832. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129833. * * 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`)
  129834. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129835. * * 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
  129836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129839. * @param name defines the name of the mesh
  129840. * @param options defines the options used to create the mesh
  129841. * @param scene defines the hosting scene
  129842. * @returns the icosahedron mesh
  129843. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129844. */
  129845. static CreateIcoSphere(name: string, options: {
  129846. radius?: number;
  129847. radiusX?: number;
  129848. radiusY?: number;
  129849. radiusZ?: number;
  129850. flat?: boolean;
  129851. subdivisions?: number;
  129852. sideOrientation?: number;
  129853. frontUVs?: Vector4;
  129854. backUVs?: Vector4;
  129855. updatable?: boolean;
  129856. }, scene?: Nullable<Scene>): Mesh;
  129857. /**
  129858. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129859. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129860. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129861. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129862. * * 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
  129863. * * 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
  129864. * * 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
  129865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129867. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129868. * * 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
  129869. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129870. * * 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
  129871. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129873. * @param name defines the name of the mesh
  129874. * @param options defines the options used to create the mesh
  129875. * @param scene defines the hosting scene
  129876. * @returns the ribbon mesh
  129877. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129879. */
  129880. static CreateRibbon(name: string, options: {
  129881. pathArray: Vector3[][];
  129882. closeArray?: boolean;
  129883. closePath?: boolean;
  129884. offset?: number;
  129885. updatable?: boolean;
  129886. sideOrientation?: number;
  129887. frontUVs?: Vector4;
  129888. backUVs?: Vector4;
  129889. instance?: Mesh;
  129890. invertUV?: boolean;
  129891. uvs?: Vector2[];
  129892. colors?: Color4[];
  129893. }, scene?: Nullable<Scene>): Mesh;
  129894. /**
  129895. * Creates a cylinder or a cone mesh
  129896. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  129897. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  129898. * * 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.
  129899. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  129900. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  129901. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  129902. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  129903. * * 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).
  129904. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  129905. * * 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).
  129906. * * 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
  129907. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  129908. * * 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
  129909. * * 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.
  129910. * * If `enclose` is false, a ring surface is one element.
  129911. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  129912. * * 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
  129913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129916. * @param name defines the name of the mesh
  129917. * @param options defines the options used to create the mesh
  129918. * @param scene defines the hosting scene
  129919. * @returns the cylinder mesh
  129920. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  129921. */
  129922. static CreateCylinder(name: string, options: {
  129923. height?: number;
  129924. diameterTop?: number;
  129925. diameterBottom?: number;
  129926. diameter?: number;
  129927. tessellation?: number;
  129928. subdivisions?: number;
  129929. arc?: number;
  129930. faceColors?: Color4[];
  129931. faceUV?: Vector4[];
  129932. updatable?: boolean;
  129933. hasRings?: boolean;
  129934. enclose?: boolean;
  129935. cap?: number;
  129936. sideOrientation?: number;
  129937. frontUVs?: Vector4;
  129938. backUVs?: Vector4;
  129939. }, scene?: Nullable<Scene>): Mesh;
  129940. /**
  129941. * Creates a torus mesh
  129942. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  129943. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  129944. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  129945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129948. * @param name defines the name of the mesh
  129949. * @param options defines the options used to create the mesh
  129950. * @param scene defines the hosting scene
  129951. * @returns the torus mesh
  129952. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  129953. */
  129954. static CreateTorus(name: string, options: {
  129955. diameter?: number;
  129956. thickness?: number;
  129957. tessellation?: number;
  129958. updatable?: boolean;
  129959. sideOrientation?: number;
  129960. frontUVs?: Vector4;
  129961. backUVs?: Vector4;
  129962. }, scene?: Nullable<Scene>): Mesh;
  129963. /**
  129964. * Creates a torus knot mesh
  129965. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129966. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129967. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129968. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129972. * @param name defines the name of the mesh
  129973. * @param options defines the options used to create the mesh
  129974. * @param scene defines the hosting scene
  129975. * @returns the torus knot mesh
  129976. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  129977. */
  129978. static CreateTorusKnot(name: string, options: {
  129979. radius?: number;
  129980. tube?: number;
  129981. radialSegments?: number;
  129982. tubularSegments?: number;
  129983. p?: number;
  129984. q?: number;
  129985. updatable?: boolean;
  129986. sideOrientation?: number;
  129987. frontUVs?: Vector4;
  129988. backUVs?: Vector4;
  129989. }, scene?: Nullable<Scene>): Mesh;
  129990. /**
  129991. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129992. * * 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
  129993. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129994. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129995. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129996. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129997. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129998. * * 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
  129999. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  130000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  130002. * @param name defines the name of the new line system
  130003. * @param options defines the options used to create the line system
  130004. * @param scene defines the hosting scene
  130005. * @returns a new line system mesh
  130006. */
  130007. static CreateLineSystem(name: string, options: {
  130008. lines: Vector3[][];
  130009. updatable?: boolean;
  130010. instance?: Nullable<LinesMesh>;
  130011. colors?: Nullable<Color4[][]>;
  130012. useVertexAlpha?: boolean;
  130013. }, scene: Nullable<Scene>): LinesMesh;
  130014. /**
  130015. * Creates a line mesh
  130016. * 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
  130017. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130018. * * The parameter `points` is an array successive Vector3
  130019. * * 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
  130020. * * The optional parameter `colors` is an array of successive Color4, one per line point
  130021. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  130022. * * When updating an instance, remember that only point positions can change, not the number of points
  130023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130024. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  130025. * @param name defines the name of the new line system
  130026. * @param options defines the options used to create the line system
  130027. * @param scene defines the hosting scene
  130028. * @returns a new line mesh
  130029. */
  130030. static CreateLines(name: string, options: {
  130031. points: Vector3[];
  130032. updatable?: boolean;
  130033. instance?: Nullable<LinesMesh>;
  130034. colors?: Color4[];
  130035. useVertexAlpha?: boolean;
  130036. }, scene?: Nullable<Scene>): LinesMesh;
  130037. /**
  130038. * Creates a dashed line mesh
  130039. * * 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
  130040. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130041. * * The parameter `points` is an array successive Vector3
  130042. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  130043. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  130044. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  130045. * * 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
  130046. * * When updating an instance, remember that only point positions can change, not the number of points
  130047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130048. * @param name defines the name of the mesh
  130049. * @param options defines the options used to create the mesh
  130050. * @param scene defines the hosting scene
  130051. * @returns the dashed line mesh
  130052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  130053. */
  130054. static CreateDashedLines(name: string, options: {
  130055. points: Vector3[];
  130056. dashSize?: number;
  130057. gapSize?: number;
  130058. dashNb?: number;
  130059. updatable?: boolean;
  130060. instance?: LinesMesh;
  130061. }, scene?: Nullable<Scene>): LinesMesh;
  130062. /**
  130063. * 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.
  130064. * * 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.
  130065. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130066. * * 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.
  130067. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130068. * * 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
  130069. * * 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
  130070. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130073. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130075. * @param name defines the name of the mesh
  130076. * @param options defines the options used to create the mesh
  130077. * @param scene defines the hosting scene
  130078. * @returns the extruded shape mesh
  130079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130081. */
  130082. static ExtrudeShape(name: string, options: {
  130083. shape: Vector3[];
  130084. path: Vector3[];
  130085. scale?: number;
  130086. rotation?: number;
  130087. cap?: number;
  130088. updatable?: boolean;
  130089. sideOrientation?: number;
  130090. frontUVs?: Vector4;
  130091. backUVs?: Vector4;
  130092. instance?: Mesh;
  130093. invertUV?: boolean;
  130094. }, scene?: Nullable<Scene>): Mesh;
  130095. /**
  130096. * Creates an custom extruded shape mesh.
  130097. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130098. * * 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.
  130099. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130100. * * 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
  130101. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130102. * * 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
  130103. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130104. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130105. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130106. * * 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
  130107. * * 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
  130108. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130111. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130113. * @param name defines the name of the mesh
  130114. * @param options defines the options used to create the mesh
  130115. * @param scene defines the hosting scene
  130116. * @returns the custom extruded shape mesh
  130117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130118. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130120. */
  130121. static ExtrudeShapeCustom(name: string, options: {
  130122. shape: Vector3[];
  130123. path: Vector3[];
  130124. scaleFunction?: any;
  130125. rotationFunction?: any;
  130126. ribbonCloseArray?: boolean;
  130127. ribbonClosePath?: boolean;
  130128. cap?: number;
  130129. updatable?: boolean;
  130130. sideOrientation?: number;
  130131. frontUVs?: Vector4;
  130132. backUVs?: Vector4;
  130133. instance?: Mesh;
  130134. invertUV?: boolean;
  130135. }, scene?: Nullable<Scene>): Mesh;
  130136. /**
  130137. * Creates lathe mesh.
  130138. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  130139. * * 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
  130140. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  130141. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  130142. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  130143. * * 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
  130144. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  130145. * * 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
  130146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130150. * @param name defines the name of the mesh
  130151. * @param options defines the options used to create the mesh
  130152. * @param scene defines the hosting scene
  130153. * @returns the lathe mesh
  130154. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  130155. */
  130156. static CreateLathe(name: string, options: {
  130157. shape: Vector3[];
  130158. radius?: number;
  130159. tessellation?: number;
  130160. clip?: number;
  130161. arc?: number;
  130162. closed?: boolean;
  130163. updatable?: boolean;
  130164. sideOrientation?: number;
  130165. frontUVs?: Vector4;
  130166. backUVs?: Vector4;
  130167. cap?: number;
  130168. invertUV?: boolean;
  130169. }, scene?: Nullable<Scene>): Mesh;
  130170. /**
  130171. * Creates a tiled plane mesh
  130172. * * You can set a limited pattern arrangement with the tiles
  130173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130176. * @param name defines the name of the mesh
  130177. * @param options defines the options used to create the mesh
  130178. * @param scene defines the hosting scene
  130179. * @returns the plane mesh
  130180. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130181. */
  130182. static CreateTiledPlane(name: string, options: {
  130183. pattern?: number;
  130184. tileSize?: number;
  130185. tileWidth?: number;
  130186. tileHeight?: number;
  130187. size?: number;
  130188. width?: number;
  130189. height?: number;
  130190. alignHorizontal?: number;
  130191. alignVertical?: number;
  130192. sideOrientation?: number;
  130193. frontUVs?: Vector4;
  130194. backUVs?: Vector4;
  130195. updatable?: boolean;
  130196. }, scene?: Nullable<Scene>): Mesh;
  130197. /**
  130198. * Creates a plane mesh
  130199. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  130200. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  130201. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  130202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130205. * @param name defines the name of the mesh
  130206. * @param options defines the options used to create the mesh
  130207. * @param scene defines the hosting scene
  130208. * @returns the plane mesh
  130209. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130210. */
  130211. static CreatePlane(name: string, options: {
  130212. size?: number;
  130213. width?: number;
  130214. height?: number;
  130215. sideOrientation?: number;
  130216. frontUVs?: Vector4;
  130217. backUVs?: Vector4;
  130218. updatable?: boolean;
  130219. sourcePlane?: Plane;
  130220. }, scene?: Nullable<Scene>): Mesh;
  130221. /**
  130222. * Creates a ground mesh
  130223. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130224. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130226. * @param name defines the name of the mesh
  130227. * @param options defines the options used to create the mesh
  130228. * @param scene defines the hosting scene
  130229. * @returns the ground mesh
  130230. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130231. */
  130232. static CreateGround(name: string, options: {
  130233. width?: number;
  130234. height?: number;
  130235. subdivisions?: number;
  130236. subdivisionsX?: number;
  130237. subdivisionsY?: number;
  130238. updatable?: boolean;
  130239. }, scene?: Nullable<Scene>): Mesh;
  130240. /**
  130241. * Creates a tiled ground mesh
  130242. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130243. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130244. * * 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
  130245. * * 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
  130246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130247. * @param name defines the name of the mesh
  130248. * @param options defines the options used to create the mesh
  130249. * @param scene defines the hosting scene
  130250. * @returns the tiled ground mesh
  130251. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130252. */
  130253. static CreateTiledGround(name: string, options: {
  130254. xmin: number;
  130255. zmin: number;
  130256. xmax: number;
  130257. zmax: number;
  130258. subdivisions?: {
  130259. w: number;
  130260. h: number;
  130261. };
  130262. precision?: {
  130263. w: number;
  130264. h: number;
  130265. };
  130266. updatable?: boolean;
  130267. }, scene?: Nullable<Scene>): Mesh;
  130268. /**
  130269. * Creates a ground mesh from a height map
  130270. * * The parameter `url` sets the URL of the height map image resource.
  130271. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130272. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130273. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130274. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130275. * * 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.
  130276. * * 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).
  130277. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130279. * @param name defines the name of the mesh
  130280. * @param url defines the url to the height map
  130281. * @param options defines the options used to create the mesh
  130282. * @param scene defines the hosting scene
  130283. * @returns the ground mesh
  130284. * @see https://doc.babylonjs.com/babylon101/height_map
  130285. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130286. */
  130287. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130288. width?: number;
  130289. height?: number;
  130290. subdivisions?: number;
  130291. minHeight?: number;
  130292. maxHeight?: number;
  130293. colorFilter?: Color3;
  130294. alphaFilter?: number;
  130295. updatable?: boolean;
  130296. onReady?: (mesh: GroundMesh) => void;
  130297. }, scene?: Nullable<Scene>): GroundMesh;
  130298. /**
  130299. * Creates a polygon mesh
  130300. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  130301. * * 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
  130302. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  130303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  130305. * * Remember you can only change the shape positions, not their number when updating a polygon
  130306. * @param name defines the name of the mesh
  130307. * @param options defines the options used to create the mesh
  130308. * @param scene defines the hosting scene
  130309. * @param earcutInjection can be used to inject your own earcut reference
  130310. * @returns the polygon mesh
  130311. */
  130312. static CreatePolygon(name: string, options: {
  130313. shape: Vector3[];
  130314. holes?: Vector3[][];
  130315. depth?: number;
  130316. faceUV?: Vector4[];
  130317. faceColors?: Color4[];
  130318. updatable?: boolean;
  130319. sideOrientation?: number;
  130320. frontUVs?: Vector4;
  130321. backUVs?: Vector4;
  130322. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130323. /**
  130324. * Creates an extruded polygon mesh, with depth in the Y direction.
  130325. * * 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)
  130326. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130327. * @param name defines the name of the mesh
  130328. * @param options defines the options used to create the mesh
  130329. * @param scene defines the hosting scene
  130330. * @param earcutInjection can be used to inject your own earcut reference
  130331. * @returns the polygon mesh
  130332. */
  130333. static ExtrudePolygon(name: string, options: {
  130334. shape: Vector3[];
  130335. holes?: Vector3[][];
  130336. depth?: number;
  130337. faceUV?: Vector4[];
  130338. faceColors?: Color4[];
  130339. updatable?: boolean;
  130340. sideOrientation?: number;
  130341. frontUVs?: Vector4;
  130342. backUVs?: Vector4;
  130343. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130344. /**
  130345. * Creates a tube mesh.
  130346. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130347. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  130348. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  130349. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  130350. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  130351. * * 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)
  130352. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  130353. * * 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
  130354. * * 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
  130355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130357. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130359. * @param name defines the name of the mesh
  130360. * @param options defines the options used to create the mesh
  130361. * @param scene defines the hosting scene
  130362. * @returns the tube mesh
  130363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130364. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  130365. */
  130366. static CreateTube(name: string, options: {
  130367. path: Vector3[];
  130368. radius?: number;
  130369. tessellation?: number;
  130370. radiusFunction?: {
  130371. (i: number, distance: number): number;
  130372. };
  130373. cap?: number;
  130374. arc?: number;
  130375. updatable?: boolean;
  130376. sideOrientation?: number;
  130377. frontUVs?: Vector4;
  130378. backUVs?: Vector4;
  130379. instance?: Mesh;
  130380. invertUV?: boolean;
  130381. }, scene?: Nullable<Scene>): Mesh;
  130382. /**
  130383. * Creates a polyhedron mesh
  130384. * * 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
  130385. * * The parameter `size` (positive float, default 1) sets the polygon size
  130386. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130387. * * 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`
  130388. * * 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
  130389. * * 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)`)
  130390. * * 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
  130391. * * 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
  130392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130395. * @param name defines the name of the mesh
  130396. * @param options defines the options used to create the mesh
  130397. * @param scene defines the hosting scene
  130398. * @returns the polyhedron mesh
  130399. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130400. */
  130401. static CreatePolyhedron(name: string, options: {
  130402. type?: number;
  130403. size?: number;
  130404. sizeX?: number;
  130405. sizeY?: number;
  130406. sizeZ?: number;
  130407. custom?: any;
  130408. faceUV?: Vector4[];
  130409. faceColors?: Color4[];
  130410. flat?: boolean;
  130411. updatable?: boolean;
  130412. sideOrientation?: number;
  130413. frontUVs?: Vector4;
  130414. backUVs?: Vector4;
  130415. }, scene?: Nullable<Scene>): Mesh;
  130416. /**
  130417. * Creates a decal mesh.
  130418. * 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
  130419. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  130420. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  130421. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  130422. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  130423. * @param name defines the name of the mesh
  130424. * @param sourceMesh defines the mesh where the decal must be applied
  130425. * @param options defines the options used to create the mesh
  130426. * @param scene defines the hosting scene
  130427. * @returns the decal mesh
  130428. * @see https://doc.babylonjs.com/how_to/decals
  130429. */
  130430. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  130431. position?: Vector3;
  130432. normal?: Vector3;
  130433. size?: Vector3;
  130434. angle?: number;
  130435. }): Mesh;
  130436. }
  130437. }
  130438. declare module BABYLON {
  130439. /**
  130440. * A simplifier interface for future simplification implementations
  130441. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130442. */
  130443. export interface ISimplifier {
  130444. /**
  130445. * Simplification of a given mesh according to the given settings.
  130446. * Since this requires computation, it is assumed that the function runs async.
  130447. * @param settings The settings of the simplification, including quality and distance
  130448. * @param successCallback A callback that will be called after the mesh was simplified.
  130449. * @param errorCallback in case of an error, this callback will be called. optional.
  130450. */
  130451. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  130452. }
  130453. /**
  130454. * Expected simplification settings.
  130455. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  130456. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130457. */
  130458. export interface ISimplificationSettings {
  130459. /**
  130460. * Gets or sets the expected quality
  130461. */
  130462. quality: number;
  130463. /**
  130464. * Gets or sets the distance when this optimized version should be used
  130465. */
  130466. distance: number;
  130467. /**
  130468. * Gets an already optimized mesh
  130469. */
  130470. optimizeMesh?: boolean;
  130471. }
  130472. /**
  130473. * Class used to specify simplification options
  130474. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130475. */
  130476. export class SimplificationSettings implements ISimplificationSettings {
  130477. /** expected quality */
  130478. quality: number;
  130479. /** distance when this optimized version should be used */
  130480. distance: number;
  130481. /** already optimized mesh */
  130482. optimizeMesh?: boolean | undefined;
  130483. /**
  130484. * Creates a SimplificationSettings
  130485. * @param quality expected quality
  130486. * @param distance distance when this optimized version should be used
  130487. * @param optimizeMesh already optimized mesh
  130488. */
  130489. constructor(
  130490. /** expected quality */
  130491. quality: number,
  130492. /** distance when this optimized version should be used */
  130493. distance: number,
  130494. /** already optimized mesh */
  130495. optimizeMesh?: boolean | undefined);
  130496. }
  130497. /**
  130498. * Interface used to define a simplification task
  130499. */
  130500. export interface ISimplificationTask {
  130501. /**
  130502. * Array of settings
  130503. */
  130504. settings: Array<ISimplificationSettings>;
  130505. /**
  130506. * Simplification type
  130507. */
  130508. simplificationType: SimplificationType;
  130509. /**
  130510. * Mesh to simplify
  130511. */
  130512. mesh: Mesh;
  130513. /**
  130514. * Callback called on success
  130515. */
  130516. successCallback?: () => void;
  130517. /**
  130518. * Defines if parallel processing can be used
  130519. */
  130520. parallelProcessing: boolean;
  130521. }
  130522. /**
  130523. * Queue used to order the simplification tasks
  130524. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130525. */
  130526. export class SimplificationQueue {
  130527. private _simplificationArray;
  130528. /**
  130529. * Gets a boolean indicating that the process is still running
  130530. */
  130531. running: boolean;
  130532. /**
  130533. * Creates a new queue
  130534. */
  130535. constructor();
  130536. /**
  130537. * Adds a new simplification task
  130538. * @param task defines a task to add
  130539. */
  130540. addTask(task: ISimplificationTask): void;
  130541. /**
  130542. * Execute next task
  130543. */
  130544. executeNext(): void;
  130545. /**
  130546. * Execute a simplification task
  130547. * @param task defines the task to run
  130548. */
  130549. runSimplification(task: ISimplificationTask): void;
  130550. private getSimplifier;
  130551. }
  130552. /**
  130553. * The implemented types of simplification
  130554. * At the moment only Quadratic Error Decimation is implemented
  130555. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130556. */
  130557. export enum SimplificationType {
  130558. /** Quadratic error decimation */
  130559. QUADRATIC = 0
  130560. }
  130561. }
  130562. declare module BABYLON {
  130563. interface Scene {
  130564. /** @hidden (Backing field) */
  130565. _simplificationQueue: SimplificationQueue;
  130566. /**
  130567. * Gets or sets the simplification queue attached to the scene
  130568. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130569. */
  130570. simplificationQueue: SimplificationQueue;
  130571. }
  130572. interface Mesh {
  130573. /**
  130574. * Simplify the mesh according to the given array of settings.
  130575. * Function will return immediately and will simplify async
  130576. * @param settings a collection of simplification settings
  130577. * @param parallelProcessing should all levels calculate parallel or one after the other
  130578. * @param simplificationType the type of simplification to run
  130579. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  130580. * @returns the current mesh
  130581. */
  130582. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  130583. }
  130584. /**
  130585. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  130586. * created in a scene
  130587. */
  130588. export class SimplicationQueueSceneComponent implements ISceneComponent {
  130589. /**
  130590. * The component name helpfull to identify the component in the list of scene components.
  130591. */
  130592. readonly name: string;
  130593. /**
  130594. * The scene the component belongs to.
  130595. */
  130596. scene: Scene;
  130597. /**
  130598. * Creates a new instance of the component for the given scene
  130599. * @param scene Defines the scene to register the component in
  130600. */
  130601. constructor(scene: Scene);
  130602. /**
  130603. * Registers the component in a given scene
  130604. */
  130605. register(): void;
  130606. /**
  130607. * Rebuilds the elements related to this component in case of
  130608. * context lost for instance.
  130609. */
  130610. rebuild(): void;
  130611. /**
  130612. * Disposes the component and the associated ressources
  130613. */
  130614. dispose(): void;
  130615. private _beforeCameraUpdate;
  130616. }
  130617. }
  130618. declare module BABYLON {
  130619. /**
  130620. * Navigation plugin interface to add navigation constrained by a navigation mesh
  130621. */
  130622. export interface INavigationEnginePlugin {
  130623. /**
  130624. * plugin name
  130625. */
  130626. name: string;
  130627. /**
  130628. * Creates a navigation mesh
  130629. * @param meshes array of all the geometry used to compute the navigatio mesh
  130630. * @param parameters bunch of parameters used to filter geometry
  130631. */
  130632. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130633. /**
  130634. * Create a navigation mesh debug mesh
  130635. * @param scene is where the mesh will be added
  130636. * @returns debug display mesh
  130637. */
  130638. createDebugNavMesh(scene: Scene): Mesh;
  130639. /**
  130640. * Get a navigation mesh constrained position, closest to the parameter position
  130641. * @param position world position
  130642. * @returns the closest point to position constrained by the navigation mesh
  130643. */
  130644. getClosestPoint(position: Vector3): Vector3;
  130645. /**
  130646. * Get a navigation mesh constrained position, within a particular radius
  130647. * @param position world position
  130648. * @param maxRadius the maximum distance to the constrained world position
  130649. * @returns the closest point to position constrained by the navigation mesh
  130650. */
  130651. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130652. /**
  130653. * Compute the final position from a segment made of destination-position
  130654. * @param position world position
  130655. * @param destination world position
  130656. * @returns the resulting point along the navmesh
  130657. */
  130658. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130659. /**
  130660. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130661. * @param start world position
  130662. * @param end world position
  130663. * @returns array containing world position composing the path
  130664. */
  130665. computePath(start: Vector3, end: Vector3): Vector3[];
  130666. /**
  130667. * If this plugin is supported
  130668. * @returns true if plugin is supported
  130669. */
  130670. isSupported(): boolean;
  130671. /**
  130672. * Create a new Crowd so you can add agents
  130673. * @param maxAgents the maximum agent count in the crowd
  130674. * @param maxAgentRadius the maximum radius an agent can have
  130675. * @param scene to attach the crowd to
  130676. * @returns the crowd you can add agents to
  130677. */
  130678. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130679. /**
  130680. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130681. * The queries will try to find a solution within those bounds
  130682. * default is (1,1,1)
  130683. * @param extent x,y,z value that define the extent around the queries point of reference
  130684. */
  130685. setDefaultQueryExtent(extent: Vector3): void;
  130686. /**
  130687. * Get the Bounding box extent specified by setDefaultQueryExtent
  130688. * @returns the box extent values
  130689. */
  130690. getDefaultQueryExtent(): Vector3;
  130691. /**
  130692. * Release all resources
  130693. */
  130694. dispose(): void;
  130695. }
  130696. /**
  130697. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  130698. */
  130699. export interface ICrowd {
  130700. /**
  130701. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  130702. * You can attach anything to that node. The node position is updated in the scene update tick.
  130703. * @param pos world position that will be constrained by the navigation mesh
  130704. * @param parameters agent parameters
  130705. * @param transform hooked to the agent that will be update by the scene
  130706. * @returns agent index
  130707. */
  130708. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  130709. /**
  130710. * Returns the agent position in world space
  130711. * @param index agent index returned by addAgent
  130712. * @returns world space position
  130713. */
  130714. getAgentPosition(index: number): Vector3;
  130715. /**
  130716. * Gets the agent velocity in world space
  130717. * @param index agent index returned by addAgent
  130718. * @returns world space velocity
  130719. */
  130720. getAgentVelocity(index: number): Vector3;
  130721. /**
  130722. * remove a particular agent previously created
  130723. * @param index agent index returned by addAgent
  130724. */
  130725. removeAgent(index: number): void;
  130726. /**
  130727. * get the list of all agents attached to this crowd
  130728. * @returns list of agent indices
  130729. */
  130730. getAgents(): number[];
  130731. /**
  130732. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  130733. * @param deltaTime in seconds
  130734. */
  130735. update(deltaTime: number): void;
  130736. /**
  130737. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  130738. * @param index agent index returned by addAgent
  130739. * @param destination targeted world position
  130740. */
  130741. agentGoto(index: number, destination: Vector3): void;
  130742. /**
  130743. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130744. * The queries will try to find a solution within those bounds
  130745. * default is (1,1,1)
  130746. * @param extent x,y,z value that define the extent around the queries point of reference
  130747. */
  130748. setDefaultQueryExtent(extent: Vector3): void;
  130749. /**
  130750. * Get the Bounding box extent specified by setDefaultQueryExtent
  130751. * @returns the box extent values
  130752. */
  130753. getDefaultQueryExtent(): Vector3;
  130754. /**
  130755. * Release all resources
  130756. */
  130757. dispose(): void;
  130758. }
  130759. /**
  130760. * Configures an agent
  130761. */
  130762. export interface IAgentParameters {
  130763. /**
  130764. * Agent radius. [Limit: >= 0]
  130765. */
  130766. radius: number;
  130767. /**
  130768. * Agent height. [Limit: > 0]
  130769. */
  130770. height: number;
  130771. /**
  130772. * Maximum allowed acceleration. [Limit: >= 0]
  130773. */
  130774. maxAcceleration: number;
  130775. /**
  130776. * Maximum allowed speed. [Limit: >= 0]
  130777. */
  130778. maxSpeed: number;
  130779. /**
  130780. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  130781. */
  130782. collisionQueryRange: number;
  130783. /**
  130784. * The path visibility optimization range. [Limit: > 0]
  130785. */
  130786. pathOptimizationRange: number;
  130787. /**
  130788. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  130789. */
  130790. separationWeight: number;
  130791. }
  130792. /**
  130793. * Configures the navigation mesh creation
  130794. */
  130795. export interface INavMeshParameters {
  130796. /**
  130797. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  130798. */
  130799. cs: number;
  130800. /**
  130801. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  130802. */
  130803. ch: number;
  130804. /**
  130805. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  130806. */
  130807. walkableSlopeAngle: number;
  130808. /**
  130809. * Minimum floor to 'ceiling' height that will still allow the floor area to
  130810. * be considered walkable. [Limit: >= 3] [Units: vx]
  130811. */
  130812. walkableHeight: number;
  130813. /**
  130814. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  130815. */
  130816. walkableClimb: number;
  130817. /**
  130818. * The distance to erode/shrink the walkable area of the heightfield away from
  130819. * obstructions. [Limit: >=0] [Units: vx]
  130820. */
  130821. walkableRadius: number;
  130822. /**
  130823. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  130824. */
  130825. maxEdgeLen: number;
  130826. /**
  130827. * The maximum distance a simplfied contour's border edges should deviate
  130828. * the original raw contour. [Limit: >=0] [Units: vx]
  130829. */
  130830. maxSimplificationError: number;
  130831. /**
  130832. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  130833. */
  130834. minRegionArea: number;
  130835. /**
  130836. * Any regions with a span count smaller than this value will, if possible,
  130837. * be merged with larger regions. [Limit: >=0] [Units: vx]
  130838. */
  130839. mergeRegionArea: number;
  130840. /**
  130841. * The maximum number of vertices allowed for polygons generated during the
  130842. * contour to polygon conversion process. [Limit: >= 3]
  130843. */
  130844. maxVertsPerPoly: number;
  130845. /**
  130846. * Sets the sampling distance to use when generating the detail mesh.
  130847. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  130848. */
  130849. detailSampleDist: number;
  130850. /**
  130851. * The maximum distance the detail mesh surface should deviate from heightfield
  130852. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  130853. */
  130854. detailSampleMaxError: number;
  130855. }
  130856. }
  130857. declare module BABYLON {
  130858. /**
  130859. * RecastJS navigation plugin
  130860. */
  130861. export class RecastJSPlugin implements INavigationEnginePlugin {
  130862. /**
  130863. * Reference to the Recast library
  130864. */
  130865. bjsRECAST: any;
  130866. /**
  130867. * plugin name
  130868. */
  130869. name: string;
  130870. /**
  130871. * the first navmesh created. We might extend this to support multiple navmeshes
  130872. */
  130873. navMesh: any;
  130874. /**
  130875. * Initializes the recastJS plugin
  130876. * @param recastInjection can be used to inject your own recast reference
  130877. */
  130878. constructor(recastInjection?: any);
  130879. /**
  130880. * Creates a navigation mesh
  130881. * @param meshes array of all the geometry used to compute the navigatio mesh
  130882. * @param parameters bunch of parameters used to filter geometry
  130883. */
  130884. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130885. /**
  130886. * Create a navigation mesh debug mesh
  130887. * @param scene is where the mesh will be added
  130888. * @returns debug display mesh
  130889. */
  130890. createDebugNavMesh(scene: Scene): Mesh;
  130891. /**
  130892. * Get a navigation mesh constrained position, closest to the parameter position
  130893. * @param position world position
  130894. * @returns the closest point to position constrained by the navigation mesh
  130895. */
  130896. getClosestPoint(position: Vector3): Vector3;
  130897. /**
  130898. * Get a navigation mesh constrained position, within a particular radius
  130899. * @param position world position
  130900. * @param maxRadius the maximum distance to the constrained world position
  130901. * @returns the closest point to position constrained by the navigation mesh
  130902. */
  130903. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130904. /**
  130905. * Compute the final position from a segment made of destination-position
  130906. * @param position world position
  130907. * @param destination world position
  130908. * @returns the resulting point along the navmesh
  130909. */
  130910. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130911. /**
  130912. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130913. * @param start world position
  130914. * @param end world position
  130915. * @returns array containing world position composing the path
  130916. */
  130917. computePath(start: Vector3, end: Vector3): Vector3[];
  130918. /**
  130919. * Create a new Crowd so you can add agents
  130920. * @param maxAgents the maximum agent count in the crowd
  130921. * @param maxAgentRadius the maximum radius an agent can have
  130922. * @param scene to attach the crowd to
  130923. * @returns the crowd you can add agents to
  130924. */
  130925. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130926. /**
  130927. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130928. * The queries will try to find a solution within those bounds
  130929. * default is (1,1,1)
  130930. * @param extent x,y,z value that define the extent around the queries point of reference
  130931. */
  130932. setDefaultQueryExtent(extent: Vector3): void;
  130933. /**
  130934. * Get the Bounding box extent specified by setDefaultQueryExtent
  130935. * @returns the box extent values
  130936. */
  130937. getDefaultQueryExtent(): Vector3;
  130938. /**
  130939. * Disposes
  130940. */
  130941. dispose(): void;
  130942. /**
  130943. * If this plugin is supported
  130944. * @returns true if plugin is supported
  130945. */
  130946. isSupported(): boolean;
  130947. }
  130948. /**
  130949. * Recast detour crowd implementation
  130950. */
  130951. export class RecastJSCrowd implements ICrowd {
  130952. /**
  130953. * Recast/detour plugin
  130954. */
  130955. bjsRECASTPlugin: RecastJSPlugin;
  130956. /**
  130957. * Link to the detour crowd
  130958. */
  130959. recastCrowd: any;
  130960. /**
  130961. * One transform per agent
  130962. */
  130963. transforms: TransformNode[];
  130964. /**
  130965. * All agents created
  130966. */
  130967. agents: number[];
  130968. /**
  130969. * Link to the scene is kept to unregister the crowd from the scene
  130970. */
  130971. private _scene;
  130972. /**
  130973. * Observer for crowd updates
  130974. */
  130975. private _onBeforeAnimationsObserver;
  130976. /**
  130977. * Constructor
  130978. * @param plugin recastJS plugin
  130979. * @param maxAgents the maximum agent count in the crowd
  130980. * @param maxAgentRadius the maximum radius an agent can have
  130981. * @param scene to attach the crowd to
  130982. * @returns the crowd you can add agents to
  130983. */
  130984. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  130985. /**
  130986. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  130987. * You can attach anything to that node. The node position is updated in the scene update tick.
  130988. * @param pos world position that will be constrained by the navigation mesh
  130989. * @param parameters agent parameters
  130990. * @param transform hooked to the agent that will be update by the scene
  130991. * @returns agent index
  130992. */
  130993. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  130994. /**
  130995. * Returns the agent position in world space
  130996. * @param index agent index returned by addAgent
  130997. * @returns world space position
  130998. */
  130999. getAgentPosition(index: number): Vector3;
  131000. /**
  131001. * Returns the agent velocity in world space
  131002. * @param index agent index returned by addAgent
  131003. * @returns world space velocity
  131004. */
  131005. getAgentVelocity(index: number): Vector3;
  131006. /**
  131007. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  131008. * @param index agent index returned by addAgent
  131009. * @param destination targeted world position
  131010. */
  131011. agentGoto(index: number, destination: Vector3): void;
  131012. /**
  131013. * remove a particular agent previously created
  131014. * @param index agent index returned by addAgent
  131015. */
  131016. removeAgent(index: number): void;
  131017. /**
  131018. * get the list of all agents attached to this crowd
  131019. * @returns list of agent indices
  131020. */
  131021. getAgents(): number[];
  131022. /**
  131023. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  131024. * @param deltaTime in seconds
  131025. */
  131026. update(deltaTime: number): void;
  131027. /**
  131028. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131029. * The queries will try to find a solution within those bounds
  131030. * default is (1,1,1)
  131031. * @param extent x,y,z value that define the extent around the queries point of reference
  131032. */
  131033. setDefaultQueryExtent(extent: Vector3): void;
  131034. /**
  131035. * Get the Bounding box extent specified by setDefaultQueryExtent
  131036. * @returns the box extent values
  131037. */
  131038. getDefaultQueryExtent(): Vector3;
  131039. /**
  131040. * Release all resources
  131041. */
  131042. dispose(): void;
  131043. }
  131044. }
  131045. declare module BABYLON {
  131046. /**
  131047. * Class used to enable access to IndexedDB
  131048. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  131049. */
  131050. export class Database implements IOfflineProvider {
  131051. private _callbackManifestChecked;
  131052. private _currentSceneUrl;
  131053. private _db;
  131054. private _enableSceneOffline;
  131055. private _enableTexturesOffline;
  131056. private _manifestVersionFound;
  131057. private _mustUpdateRessources;
  131058. private _hasReachedQuota;
  131059. private _isSupported;
  131060. private _idbFactory;
  131061. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  131062. private static IsUASupportingBlobStorage;
  131063. /**
  131064. * Gets a boolean indicating if Database storate is enabled (off by default)
  131065. */
  131066. static IDBStorageEnabled: boolean;
  131067. /**
  131068. * Gets a boolean indicating if scene must be saved in the database
  131069. */
  131070. get enableSceneOffline(): boolean;
  131071. /**
  131072. * Gets a boolean indicating if textures must be saved in the database
  131073. */
  131074. get enableTexturesOffline(): boolean;
  131075. /**
  131076. * Creates a new Database
  131077. * @param urlToScene defines the url to load the scene
  131078. * @param callbackManifestChecked defines the callback to use when manifest is checked
  131079. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  131080. */
  131081. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  131082. private static _ParseURL;
  131083. private static _ReturnFullUrlLocation;
  131084. private _checkManifestFile;
  131085. /**
  131086. * Open the database and make it available
  131087. * @param successCallback defines the callback to call on success
  131088. * @param errorCallback defines the callback to call on error
  131089. */
  131090. open(successCallback: () => void, errorCallback: () => void): void;
  131091. /**
  131092. * Loads an image from the database
  131093. * @param url defines the url to load from
  131094. * @param image defines the target DOM image
  131095. */
  131096. loadImage(url: string, image: HTMLImageElement): void;
  131097. private _loadImageFromDBAsync;
  131098. private _saveImageIntoDBAsync;
  131099. private _checkVersionFromDB;
  131100. private _loadVersionFromDBAsync;
  131101. private _saveVersionIntoDBAsync;
  131102. /**
  131103. * Loads a file from database
  131104. * @param url defines the URL to load from
  131105. * @param sceneLoaded defines a callback to call on success
  131106. * @param progressCallBack defines a callback to call when progress changed
  131107. * @param errorCallback defines a callback to call on error
  131108. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  131109. */
  131110. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  131111. private _loadFileAsync;
  131112. private _saveFileAsync;
  131113. /**
  131114. * Validates if xhr data is correct
  131115. * @param xhr defines the request to validate
  131116. * @param dataType defines the expected data type
  131117. * @returns true if data is correct
  131118. */
  131119. private static _ValidateXHRData;
  131120. }
  131121. }
  131122. declare module BABYLON {
  131123. /** @hidden */
  131124. export var gpuUpdateParticlesPixelShader: {
  131125. name: string;
  131126. shader: string;
  131127. };
  131128. }
  131129. declare module BABYLON {
  131130. /** @hidden */
  131131. export var gpuUpdateParticlesVertexShader: {
  131132. name: string;
  131133. shader: string;
  131134. };
  131135. }
  131136. declare module BABYLON {
  131137. /** @hidden */
  131138. export var clipPlaneFragmentDeclaration2: {
  131139. name: string;
  131140. shader: string;
  131141. };
  131142. }
  131143. declare module BABYLON {
  131144. /** @hidden */
  131145. export var gpuRenderParticlesPixelShader: {
  131146. name: string;
  131147. shader: string;
  131148. };
  131149. }
  131150. declare module BABYLON {
  131151. /** @hidden */
  131152. export var clipPlaneVertexDeclaration2: {
  131153. name: string;
  131154. shader: string;
  131155. };
  131156. }
  131157. declare module BABYLON {
  131158. /** @hidden */
  131159. export var gpuRenderParticlesVertexShader: {
  131160. name: string;
  131161. shader: string;
  131162. };
  131163. }
  131164. declare module BABYLON {
  131165. /**
  131166. * This represents a GPU particle system in Babylon
  131167. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  131168. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  131169. */
  131170. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  131171. /**
  131172. * The layer mask we are rendering the particles through.
  131173. */
  131174. layerMask: number;
  131175. private _capacity;
  131176. private _activeCount;
  131177. private _currentActiveCount;
  131178. private _accumulatedCount;
  131179. private _renderEffect;
  131180. private _updateEffect;
  131181. private _buffer0;
  131182. private _buffer1;
  131183. private _spriteBuffer;
  131184. private _updateVAO;
  131185. private _renderVAO;
  131186. private _targetIndex;
  131187. private _sourceBuffer;
  131188. private _targetBuffer;
  131189. private _engine;
  131190. private _currentRenderId;
  131191. private _started;
  131192. private _stopped;
  131193. private _timeDelta;
  131194. private _randomTexture;
  131195. private _randomTexture2;
  131196. private _attributesStrideSize;
  131197. private _updateEffectOptions;
  131198. private _randomTextureSize;
  131199. private _actualFrame;
  131200. private readonly _rawTextureWidth;
  131201. /**
  131202. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  131203. */
  131204. static get IsSupported(): boolean;
  131205. /**
  131206. * An event triggered when the system is disposed.
  131207. */
  131208. onDisposeObservable: Observable<GPUParticleSystem>;
  131209. /**
  131210. * Gets the maximum number of particles active at the same time.
  131211. * @returns The max number of active particles.
  131212. */
  131213. getCapacity(): number;
  131214. /**
  131215. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  131216. * to override the particles.
  131217. */
  131218. forceDepthWrite: boolean;
  131219. /**
  131220. * Gets or set the number of active particles
  131221. */
  131222. get activeParticleCount(): number;
  131223. set activeParticleCount(value: number);
  131224. private _preWarmDone;
  131225. /**
  131226. * Is this system ready to be used/rendered
  131227. * @return true if the system is ready
  131228. */
  131229. isReady(): boolean;
  131230. /**
  131231. * Gets if the system has been started. (Note: this will still be true after stop is called)
  131232. * @returns True if it has been started, otherwise false.
  131233. */
  131234. isStarted(): boolean;
  131235. /**
  131236. * Starts the particle system and begins to emit
  131237. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  131238. */
  131239. start(delay?: number): void;
  131240. /**
  131241. * Stops the particle system.
  131242. */
  131243. stop(): void;
  131244. /**
  131245. * Remove all active particles
  131246. */
  131247. reset(): void;
  131248. /**
  131249. * Returns the string "GPUParticleSystem"
  131250. * @returns a string containing the class name
  131251. */
  131252. getClassName(): string;
  131253. private _colorGradientsTexture;
  131254. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  131255. /**
  131256. * Adds a new color gradient
  131257. * @param gradient defines the gradient to use (between 0 and 1)
  131258. * @param color1 defines the color to affect to the specified gradient
  131259. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  131260. * @returns the current particle system
  131261. */
  131262. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  131263. /**
  131264. * Remove a specific color gradient
  131265. * @param gradient defines the gradient to remove
  131266. * @returns the current particle system
  131267. */
  131268. removeColorGradient(gradient: number): GPUParticleSystem;
  131269. private _angularSpeedGradientsTexture;
  131270. private _sizeGradientsTexture;
  131271. private _velocityGradientsTexture;
  131272. private _limitVelocityGradientsTexture;
  131273. private _dragGradientsTexture;
  131274. private _addFactorGradient;
  131275. /**
  131276. * Adds a new size gradient
  131277. * @param gradient defines the gradient to use (between 0 and 1)
  131278. * @param factor defines the size factor to affect to the specified gradient
  131279. * @returns the current particle system
  131280. */
  131281. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  131282. /**
  131283. * Remove a specific size gradient
  131284. * @param gradient defines the gradient to remove
  131285. * @returns the current particle system
  131286. */
  131287. removeSizeGradient(gradient: number): GPUParticleSystem;
  131288. /**
  131289. * Adds a new angular speed gradient
  131290. * @param gradient defines the gradient to use (between 0 and 1)
  131291. * @param factor defines the angular speed to affect to the specified gradient
  131292. * @returns the current particle system
  131293. */
  131294. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  131295. /**
  131296. * Remove a specific angular speed gradient
  131297. * @param gradient defines the gradient to remove
  131298. * @returns the current particle system
  131299. */
  131300. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  131301. /**
  131302. * Adds a new velocity gradient
  131303. * @param gradient defines the gradient to use (between 0 and 1)
  131304. * @param factor defines the velocity to affect to the specified gradient
  131305. * @returns the current particle system
  131306. */
  131307. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131308. /**
  131309. * Remove a specific velocity gradient
  131310. * @param gradient defines the gradient to remove
  131311. * @returns the current particle system
  131312. */
  131313. removeVelocityGradient(gradient: number): GPUParticleSystem;
  131314. /**
  131315. * Adds a new limit velocity gradient
  131316. * @param gradient defines the gradient to use (between 0 and 1)
  131317. * @param factor defines the limit velocity value to affect to the specified gradient
  131318. * @returns the current particle system
  131319. */
  131320. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131321. /**
  131322. * Remove a specific limit velocity gradient
  131323. * @param gradient defines the gradient to remove
  131324. * @returns the current particle system
  131325. */
  131326. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  131327. /**
  131328. * Adds a new drag gradient
  131329. * @param gradient defines the gradient to use (between 0 and 1)
  131330. * @param factor defines the drag value to affect to the specified gradient
  131331. * @returns the current particle system
  131332. */
  131333. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  131334. /**
  131335. * Remove a specific drag gradient
  131336. * @param gradient defines the gradient to remove
  131337. * @returns the current particle system
  131338. */
  131339. removeDragGradient(gradient: number): GPUParticleSystem;
  131340. /**
  131341. * Not supported by GPUParticleSystem
  131342. * @param gradient defines the gradient to use (between 0 and 1)
  131343. * @param factor defines the emit rate value to affect to the specified gradient
  131344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131345. * @returns the current particle system
  131346. */
  131347. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131348. /**
  131349. * Not supported by GPUParticleSystem
  131350. * @param gradient defines the gradient to remove
  131351. * @returns the current particle system
  131352. */
  131353. removeEmitRateGradient(gradient: number): IParticleSystem;
  131354. /**
  131355. * Not supported by GPUParticleSystem
  131356. * @param gradient defines the gradient to use (between 0 and 1)
  131357. * @param factor defines the start size value to affect to the specified gradient
  131358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131359. * @returns the current particle system
  131360. */
  131361. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131362. /**
  131363. * Not supported by GPUParticleSystem
  131364. * @param gradient defines the gradient to remove
  131365. * @returns the current particle system
  131366. */
  131367. removeStartSizeGradient(gradient: number): IParticleSystem;
  131368. /**
  131369. * Not supported by GPUParticleSystem
  131370. * @param gradient defines the gradient to use (between 0 and 1)
  131371. * @param min defines the color remap minimal range
  131372. * @param max defines the color remap maximal range
  131373. * @returns the current particle system
  131374. */
  131375. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131376. /**
  131377. * Not supported by GPUParticleSystem
  131378. * @param gradient defines the gradient to remove
  131379. * @returns the current particle system
  131380. */
  131381. removeColorRemapGradient(): IParticleSystem;
  131382. /**
  131383. * Not supported by GPUParticleSystem
  131384. * @param gradient defines the gradient to use (between 0 and 1)
  131385. * @param min defines the alpha remap minimal range
  131386. * @param max defines the alpha remap maximal range
  131387. * @returns the current particle system
  131388. */
  131389. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131390. /**
  131391. * Not supported by GPUParticleSystem
  131392. * @param gradient defines the gradient to remove
  131393. * @returns the current particle system
  131394. */
  131395. removeAlphaRemapGradient(): IParticleSystem;
  131396. /**
  131397. * Not supported by GPUParticleSystem
  131398. * @param gradient defines the gradient to use (between 0 and 1)
  131399. * @param color defines the color to affect to the specified gradient
  131400. * @returns the current particle system
  131401. */
  131402. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  131403. /**
  131404. * Not supported by GPUParticleSystem
  131405. * @param gradient defines the gradient to remove
  131406. * @returns the current particle system
  131407. */
  131408. removeRampGradient(): IParticleSystem;
  131409. /**
  131410. * Not supported by GPUParticleSystem
  131411. * @returns the list of ramp gradients
  131412. */
  131413. getRampGradients(): Nullable<Array<Color3Gradient>>;
  131414. /**
  131415. * Not supported by GPUParticleSystem
  131416. * Gets or sets a boolean indicating that ramp gradients must be used
  131417. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  131418. */
  131419. get useRampGradients(): boolean;
  131420. set useRampGradients(value: boolean);
  131421. /**
  131422. * Not supported by GPUParticleSystem
  131423. * @param gradient defines the gradient to use (between 0 and 1)
  131424. * @param factor defines the life time factor to affect to the specified gradient
  131425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131426. * @returns the current particle system
  131427. */
  131428. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131429. /**
  131430. * Not supported by GPUParticleSystem
  131431. * @param gradient defines the gradient to remove
  131432. * @returns the current particle system
  131433. */
  131434. removeLifeTimeGradient(gradient: number): IParticleSystem;
  131435. /**
  131436. * Instantiates a GPU particle system.
  131437. * 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.
  131438. * @param name The name of the particle system
  131439. * @param options The options used to create the system
  131440. * @param scene The scene the particle system belongs to
  131441. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  131442. */
  131443. constructor(name: string, options: Partial<{
  131444. capacity: number;
  131445. randomTextureSize: number;
  131446. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  131447. protected _reset(): void;
  131448. private _createUpdateVAO;
  131449. private _createRenderVAO;
  131450. private _initialize;
  131451. /** @hidden */
  131452. _recreateUpdateEffect(): void;
  131453. /** @hidden */
  131454. _recreateRenderEffect(): void;
  131455. /**
  131456. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  131457. * @param preWarm defines if we are in the pre-warmimg phase
  131458. */
  131459. animate(preWarm?: boolean): void;
  131460. private _createFactorGradientTexture;
  131461. private _createSizeGradientTexture;
  131462. private _createAngularSpeedGradientTexture;
  131463. private _createVelocityGradientTexture;
  131464. private _createLimitVelocityGradientTexture;
  131465. private _createDragGradientTexture;
  131466. private _createColorGradientTexture;
  131467. /**
  131468. * Renders the particle system in its current state
  131469. * @param preWarm defines if the system should only update the particles but not render them
  131470. * @returns the current number of particles
  131471. */
  131472. render(preWarm?: boolean): number;
  131473. /**
  131474. * Rebuilds the particle system
  131475. */
  131476. rebuild(): void;
  131477. private _releaseBuffers;
  131478. private _releaseVAOs;
  131479. /**
  131480. * Disposes the particle system and free the associated resources
  131481. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  131482. */
  131483. dispose(disposeTexture?: boolean): void;
  131484. /**
  131485. * Clones the particle system.
  131486. * @param name The name of the cloned object
  131487. * @param newEmitter The new emitter to use
  131488. * @returns the cloned particle system
  131489. */
  131490. clone(name: string, newEmitter: any): GPUParticleSystem;
  131491. /**
  131492. * Serializes the particle system to a JSON object.
  131493. * @returns the JSON object
  131494. */
  131495. serialize(): any;
  131496. /**
  131497. * Parses a JSON object to create a GPU particle system.
  131498. * @param parsedParticleSystem The JSON object to parse
  131499. * @param scene The scene to create the particle system in
  131500. * @param rootUrl The root url to use to load external dependencies like texture
  131501. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  131502. * @returns the parsed GPU particle system
  131503. */
  131504. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  131505. }
  131506. }
  131507. declare module BABYLON {
  131508. /**
  131509. * Represents a set of particle systems working together to create a specific effect
  131510. */
  131511. export class ParticleSystemSet implements IDisposable {
  131512. /**
  131513. * Gets or sets base Assets URL
  131514. */
  131515. static BaseAssetsUrl: string;
  131516. private _emitterCreationOptions;
  131517. private _emitterNode;
  131518. /**
  131519. * Gets the particle system list
  131520. */
  131521. systems: IParticleSystem[];
  131522. /**
  131523. * Gets the emitter node used with this set
  131524. */
  131525. get emitterNode(): Nullable<TransformNode>;
  131526. /**
  131527. * Creates a new emitter mesh as a sphere
  131528. * @param options defines the options used to create the sphere
  131529. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  131530. * @param scene defines the hosting scene
  131531. */
  131532. setEmitterAsSphere(options: {
  131533. diameter: number;
  131534. segments: number;
  131535. color: Color3;
  131536. }, renderingGroupId: number, scene: Scene): void;
  131537. /**
  131538. * Starts all particle systems of the set
  131539. * @param emitter defines an optional mesh to use as emitter for the particle systems
  131540. */
  131541. start(emitter?: AbstractMesh): void;
  131542. /**
  131543. * Release all associated resources
  131544. */
  131545. dispose(): void;
  131546. /**
  131547. * Serialize the set into a JSON compatible object
  131548. * @returns a JSON compatible representation of the set
  131549. */
  131550. serialize(): any;
  131551. /**
  131552. * Parse a new ParticleSystemSet from a serialized source
  131553. * @param data defines a JSON compatible representation of the set
  131554. * @param scene defines the hosting scene
  131555. * @param gpu defines if we want GPU particles or CPU particles
  131556. * @returns a new ParticleSystemSet
  131557. */
  131558. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  131559. }
  131560. }
  131561. declare module BABYLON {
  131562. /**
  131563. * This class is made for on one-liner static method to help creating particle system set.
  131564. */
  131565. export class ParticleHelper {
  131566. /**
  131567. * Gets or sets base Assets URL
  131568. */
  131569. static BaseAssetsUrl: string;
  131570. /**
  131571. * Create a default particle system that you can tweak
  131572. * @param emitter defines the emitter to use
  131573. * @param capacity defines the system capacity (default is 500 particles)
  131574. * @param scene defines the hosting scene
  131575. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  131576. * @returns the new Particle system
  131577. */
  131578. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  131579. /**
  131580. * This is the main static method (one-liner) of this helper to create different particle systems
  131581. * @param type This string represents the type to the particle system to create
  131582. * @param scene The scene where the particle system should live
  131583. * @param gpu If the system will use gpu
  131584. * @returns the ParticleSystemSet created
  131585. */
  131586. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  131587. /**
  131588. * Static function used to export a particle system to a ParticleSystemSet variable.
  131589. * Please note that the emitter shape is not exported
  131590. * @param systems defines the particle systems to export
  131591. * @returns the created particle system set
  131592. */
  131593. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  131594. }
  131595. }
  131596. declare module BABYLON {
  131597. interface Engine {
  131598. /**
  131599. * Create an effect to use with particle systems.
  131600. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  131601. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  131602. * @param uniformsNames defines a list of attribute names
  131603. * @param samplers defines an array of string used to represent textures
  131604. * @param defines defines the string containing the defines to use to compile the shaders
  131605. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  131606. * @param onCompiled defines a function to call when the effect creation is successful
  131607. * @param onError defines a function to call when the effect creation has failed
  131608. * @returns the new Effect
  131609. */
  131610. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  131611. }
  131612. interface Mesh {
  131613. /**
  131614. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  131615. * @returns an array of IParticleSystem
  131616. */
  131617. getEmittedParticleSystems(): IParticleSystem[];
  131618. /**
  131619. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  131620. * @returns an array of IParticleSystem
  131621. */
  131622. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  131623. }
  131624. /**
  131625. * @hidden
  131626. */
  131627. export var _IDoNeedToBeInTheBuild: number;
  131628. }
  131629. declare module BABYLON {
  131630. /** Defines the 4 color options */
  131631. export enum PointColor {
  131632. /** color value */
  131633. Color = 2,
  131634. /** uv value */
  131635. UV = 1,
  131636. /** random value */
  131637. Random = 0,
  131638. /** stated value */
  131639. Stated = 3
  131640. }
  131641. /**
  131642. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  131643. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  131644. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  131645. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  131646. *
  131647. * Full documentation here : TO BE ENTERED
  131648. */
  131649. export class PointsCloudSystem implements IDisposable {
  131650. /**
  131651. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  131652. * Example : var p = SPS.particles[i];
  131653. */
  131654. particles: CloudPoint[];
  131655. /**
  131656. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  131657. */
  131658. nbParticles: number;
  131659. /**
  131660. * This a counter for your own usage. It's not set by any SPS functions.
  131661. */
  131662. counter: number;
  131663. /**
  131664. * The PCS name. This name is also given to the underlying mesh.
  131665. */
  131666. name: string;
  131667. /**
  131668. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  131669. */
  131670. mesh: Mesh;
  131671. /**
  131672. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  131673. * Please read :
  131674. */
  131675. vars: any;
  131676. /**
  131677. * @hidden
  131678. */
  131679. _size: number;
  131680. private _scene;
  131681. private _promises;
  131682. private _positions;
  131683. private _indices;
  131684. private _normals;
  131685. private _colors;
  131686. private _uvs;
  131687. private _indices32;
  131688. private _positions32;
  131689. private _colors32;
  131690. private _uvs32;
  131691. private _updatable;
  131692. private _isVisibilityBoxLocked;
  131693. private _alwaysVisible;
  131694. private _groups;
  131695. private _groupCounter;
  131696. private _computeParticleColor;
  131697. private _computeParticleTexture;
  131698. private _computeParticleRotation;
  131699. private _computeBoundingBox;
  131700. private _isReady;
  131701. /**
  131702. * Creates a PCS (Points Cloud System) object
  131703. * @param name (String) is the PCS name, this will be the underlying mesh name
  131704. * @param pointSize (number) is the size for each point
  131705. * @param scene (Scene) is the scene in which the PCS is added
  131706. * @param options defines the options of the PCS e.g.
  131707. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  131708. */
  131709. constructor(name: string, pointSize: number, scene: Scene, options?: {
  131710. updatable?: boolean;
  131711. });
  131712. /**
  131713. * Builds the PCS underlying mesh. Returns a standard Mesh.
  131714. * If no points were added to the PCS, the returned mesh is just a single point.
  131715. * @returns a promise for the created mesh
  131716. */
  131717. buildMeshAsync(): Promise<Mesh>;
  131718. /**
  131719. * @hidden
  131720. */
  131721. private _buildMesh;
  131722. private _addParticle;
  131723. private _randomUnitVector;
  131724. private _getColorIndicesForCoord;
  131725. private _setPointsColorOrUV;
  131726. private _colorFromTexture;
  131727. private _calculateDensity;
  131728. /**
  131729. * Adds points to the PCS in random positions within a unit sphere
  131730. * @param nb (positive integer) the number of particles to be created from this model
  131731. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  131732. * @returns the number of groups in the system
  131733. */
  131734. addPoints(nb: number, pointFunction?: any): number;
  131735. /**
  131736. * Adds points to the PCS from the surface of the model shape
  131737. * @param mesh is any Mesh object that will be used as a surface model for the points
  131738. * @param nb (positive integer) the number of particles to be created from this model
  131739. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131740. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131741. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131742. * @returns the number of groups in the system
  131743. */
  131744. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131745. /**
  131746. * Adds points to the PCS inside the model shape
  131747. * @param mesh is any Mesh object that will be used as a surface model for the points
  131748. * @param nb (positive integer) the number of particles to be created from this model
  131749. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131750. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131751. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131752. * @returns the number of groups in the system
  131753. */
  131754. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131755. /**
  131756. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  131757. * This method calls `updateParticle()` for each particle of the SPS.
  131758. * For an animated SPS, it is usually called within the render loop.
  131759. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  131760. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  131761. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  131762. * @returns the PCS.
  131763. */
  131764. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  131765. /**
  131766. * Disposes the PCS.
  131767. */
  131768. dispose(): void;
  131769. /**
  131770. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  131771. * doc :
  131772. * @returns the PCS.
  131773. */
  131774. refreshVisibleSize(): PointsCloudSystem;
  131775. /**
  131776. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  131777. * @param size the size (float) of the visibility box
  131778. * note : this doesn't lock the PCS mesh bounding box.
  131779. * doc :
  131780. */
  131781. setVisibilityBox(size: number): void;
  131782. /**
  131783. * Gets whether the PCS is always visible or not
  131784. * doc :
  131785. */
  131786. get isAlwaysVisible(): boolean;
  131787. /**
  131788. * Sets the PCS as always visible or not
  131789. * doc :
  131790. */
  131791. set isAlwaysVisible(val: boolean);
  131792. /**
  131793. * Tells to `setParticles()` to compute the particle rotations or not
  131794. * Default value : false. The PCS is faster when it's set to false
  131795. * Note : particle rotations are only applied to parent particles
  131796. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  131797. */
  131798. set computeParticleRotation(val: boolean);
  131799. /**
  131800. * Tells to `setParticles()` to compute the particle colors or not.
  131801. * Default value : true. The PCS is faster when it's set to false.
  131802. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131803. */
  131804. set computeParticleColor(val: boolean);
  131805. set computeParticleTexture(val: boolean);
  131806. /**
  131807. * Gets if `setParticles()` computes the particle colors or not.
  131808. * Default value : false. The PCS is faster when it's set to false.
  131809. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131810. */
  131811. get computeParticleColor(): boolean;
  131812. /**
  131813. * Gets if `setParticles()` computes the particle textures or not.
  131814. * Default value : false. The PCS is faster when it's set to false.
  131815. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  131816. */
  131817. get computeParticleTexture(): boolean;
  131818. /**
  131819. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  131820. */
  131821. set computeBoundingBox(val: boolean);
  131822. /**
  131823. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  131824. */
  131825. get computeBoundingBox(): boolean;
  131826. /**
  131827. * This function does nothing. It may be overwritten to set all the particle first values.
  131828. * The PCS doesn't call this function, you may have to call it by your own.
  131829. * doc :
  131830. */
  131831. initParticles(): void;
  131832. /**
  131833. * This function does nothing. It may be overwritten to recycle a particle
  131834. * The PCS doesn't call this function, you can to call it
  131835. * doc :
  131836. * @param particle The particle to recycle
  131837. * @returns the recycled particle
  131838. */
  131839. recycleParticle(particle: CloudPoint): CloudPoint;
  131840. /**
  131841. * Updates a particle : this function should be overwritten by the user.
  131842. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  131843. * doc :
  131844. * @example : just set a particle position or velocity and recycle conditions
  131845. * @param particle The particle to update
  131846. * @returns the updated particle
  131847. */
  131848. updateParticle(particle: CloudPoint): CloudPoint;
  131849. /**
  131850. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  131851. * This does nothing and may be overwritten by the user.
  131852. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  131853. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  131854. * @param update the boolean update value actually passed to setParticles()
  131855. */
  131856. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  131857. /**
  131858. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  131859. * This will be passed three parameters.
  131860. * This does nothing and may be overwritten by the user.
  131861. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  131862. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  131863. * @param update the boolean update value actually passed to setParticles()
  131864. */
  131865. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  131866. }
  131867. }
  131868. declare module BABYLON {
  131869. /**
  131870. * Represents one particle of a points cloud system.
  131871. */
  131872. export class CloudPoint {
  131873. /**
  131874. * particle global index
  131875. */
  131876. idx: number;
  131877. /**
  131878. * The color of the particle
  131879. */
  131880. color: Nullable<Color4>;
  131881. /**
  131882. * The world space position of the particle.
  131883. */
  131884. position: Vector3;
  131885. /**
  131886. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  131887. */
  131888. rotation: Vector3;
  131889. /**
  131890. * The world space rotation quaternion of the particle.
  131891. */
  131892. rotationQuaternion: Nullable<Quaternion>;
  131893. /**
  131894. * The uv of the particle.
  131895. */
  131896. uv: Nullable<Vector2>;
  131897. /**
  131898. * The current speed of the particle.
  131899. */
  131900. velocity: Vector3;
  131901. /**
  131902. * The pivot point in the particle local space.
  131903. */
  131904. pivot: Vector3;
  131905. /**
  131906. * Must the particle be translated from its pivot point in its local space ?
  131907. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  131908. * Default : false
  131909. */
  131910. translateFromPivot: boolean;
  131911. /**
  131912. * Index of this particle in the global "positions" array (Internal use)
  131913. * @hidden
  131914. */
  131915. _pos: number;
  131916. /**
  131917. * @hidden Index of this particle in the global "indices" array (Internal use)
  131918. */
  131919. _ind: number;
  131920. /**
  131921. * Group this particle belongs to
  131922. */
  131923. _group: PointsGroup;
  131924. /**
  131925. * Group id of this particle
  131926. */
  131927. groupId: number;
  131928. /**
  131929. * Index of the particle in its group id (Internal use)
  131930. */
  131931. idxInGroup: number;
  131932. /**
  131933. * @hidden Particle BoundingInfo object (Internal use)
  131934. */
  131935. _boundingInfo: BoundingInfo;
  131936. /**
  131937. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  131938. */
  131939. _pcs: PointsCloudSystem;
  131940. /**
  131941. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  131942. */
  131943. _stillInvisible: boolean;
  131944. /**
  131945. * @hidden Last computed particle rotation matrix
  131946. */
  131947. _rotationMatrix: number[];
  131948. /**
  131949. * Parent particle Id, if any.
  131950. * Default null.
  131951. */
  131952. parentId: Nullable<number>;
  131953. /**
  131954. * @hidden Internal global position in the PCS.
  131955. */
  131956. _globalPosition: Vector3;
  131957. /**
  131958. * Creates a Point Cloud object.
  131959. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  131960. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  131961. * @param group (PointsGroup) is the group the particle belongs to
  131962. * @param groupId (integer) is the group identifier in the PCS.
  131963. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  131964. * @param pcs defines the PCS it is associated to
  131965. */
  131966. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  131967. /**
  131968. * get point size
  131969. */
  131970. get size(): Vector3;
  131971. /**
  131972. * Set point size
  131973. */
  131974. set size(scale: Vector3);
  131975. /**
  131976. * Legacy support, changed quaternion to rotationQuaternion
  131977. */
  131978. get quaternion(): Nullable<Quaternion>;
  131979. /**
  131980. * Legacy support, changed quaternion to rotationQuaternion
  131981. */
  131982. set quaternion(q: Nullable<Quaternion>);
  131983. /**
  131984. * Returns a boolean. True if the particle intersects a mesh, else false
  131985. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  131986. * @param target is the object (point or mesh) what the intersection is computed against
  131987. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  131988. * @returns true if it intersects
  131989. */
  131990. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  131991. /**
  131992. * get the rotation matrix of the particle
  131993. * @hidden
  131994. */
  131995. getRotationMatrix(m: Matrix): void;
  131996. }
  131997. /**
  131998. * Represents a group of points in a points cloud system
  131999. * * PCS internal tool, don't use it manually.
  132000. */
  132001. export class PointsGroup {
  132002. /**
  132003. * The group id
  132004. * @hidden
  132005. */
  132006. groupID: number;
  132007. /**
  132008. * image data for group (internal use)
  132009. * @hidden
  132010. */
  132011. _groupImageData: Nullable<ArrayBufferView>;
  132012. /**
  132013. * Image Width (internal use)
  132014. * @hidden
  132015. */
  132016. _groupImgWidth: number;
  132017. /**
  132018. * Image Height (internal use)
  132019. * @hidden
  132020. */
  132021. _groupImgHeight: number;
  132022. /**
  132023. * Custom position function (internal use)
  132024. * @hidden
  132025. */
  132026. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  132027. /**
  132028. * density per facet for surface points
  132029. * @hidden
  132030. */
  132031. _groupDensity: number[];
  132032. /**
  132033. * Only when points are colored by texture carries pointer to texture list array
  132034. * @hidden
  132035. */
  132036. _textureNb: number;
  132037. /**
  132038. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  132039. * PCS internal tool, don't use it manually.
  132040. * @hidden
  132041. */
  132042. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  132043. }
  132044. }
  132045. declare module BABYLON {
  132046. interface Scene {
  132047. /** @hidden (Backing field) */
  132048. _physicsEngine: Nullable<IPhysicsEngine>;
  132049. /** @hidden */
  132050. _physicsTimeAccumulator: number;
  132051. /**
  132052. * Gets the current physics engine
  132053. * @returns a IPhysicsEngine or null if none attached
  132054. */
  132055. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  132056. /**
  132057. * Enables physics to the current scene
  132058. * @param gravity defines the scene's gravity for the physics engine
  132059. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  132060. * @return a boolean indicating if the physics engine was initialized
  132061. */
  132062. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  132063. /**
  132064. * Disables and disposes the physics engine associated with the scene
  132065. */
  132066. disablePhysicsEngine(): void;
  132067. /**
  132068. * Gets a boolean indicating if there is an active physics engine
  132069. * @returns a boolean indicating if there is an active physics engine
  132070. */
  132071. isPhysicsEnabled(): boolean;
  132072. /**
  132073. * Deletes a physics compound impostor
  132074. * @param compound defines the compound to delete
  132075. */
  132076. deleteCompoundImpostor(compound: any): void;
  132077. /**
  132078. * An event triggered when physic simulation is about to be run
  132079. */
  132080. onBeforePhysicsObservable: Observable<Scene>;
  132081. /**
  132082. * An event triggered when physic simulation has been done
  132083. */
  132084. onAfterPhysicsObservable: Observable<Scene>;
  132085. }
  132086. interface AbstractMesh {
  132087. /** @hidden */
  132088. _physicsImpostor: Nullable<PhysicsImpostor>;
  132089. /**
  132090. * Gets or sets impostor used for physic simulation
  132091. * @see http://doc.babylonjs.com/features/physics_engine
  132092. */
  132093. physicsImpostor: Nullable<PhysicsImpostor>;
  132094. /**
  132095. * Gets the current physics impostor
  132096. * @see http://doc.babylonjs.com/features/physics_engine
  132097. * @returns a physics impostor or null
  132098. */
  132099. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  132100. /** Apply a physic impulse to the mesh
  132101. * @param force defines the force to apply
  132102. * @param contactPoint defines where to apply the force
  132103. * @returns the current mesh
  132104. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  132105. */
  132106. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  132107. /**
  132108. * Creates a physic joint between two meshes
  132109. * @param otherMesh defines the other mesh to use
  132110. * @param pivot1 defines the pivot to use on this mesh
  132111. * @param pivot2 defines the pivot to use on the other mesh
  132112. * @param options defines additional options (can be plugin dependent)
  132113. * @returns the current mesh
  132114. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  132115. */
  132116. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  132117. /** @hidden */
  132118. _disposePhysicsObserver: Nullable<Observer<Node>>;
  132119. }
  132120. /**
  132121. * Defines the physics engine scene component responsible to manage a physics engine
  132122. */
  132123. export class PhysicsEngineSceneComponent implements ISceneComponent {
  132124. /**
  132125. * The component name helpful to identify the component in the list of scene components.
  132126. */
  132127. readonly name: string;
  132128. /**
  132129. * The scene the component belongs to.
  132130. */
  132131. scene: Scene;
  132132. /**
  132133. * Creates a new instance of the component for the given scene
  132134. * @param scene Defines the scene to register the component in
  132135. */
  132136. constructor(scene: Scene);
  132137. /**
  132138. * Registers the component in a given scene
  132139. */
  132140. register(): void;
  132141. /**
  132142. * Rebuilds the elements related to this component in case of
  132143. * context lost for instance.
  132144. */
  132145. rebuild(): void;
  132146. /**
  132147. * Disposes the component and the associated ressources
  132148. */
  132149. dispose(): void;
  132150. }
  132151. }
  132152. declare module BABYLON {
  132153. /**
  132154. * A helper for physics simulations
  132155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132156. */
  132157. export class PhysicsHelper {
  132158. private _scene;
  132159. private _physicsEngine;
  132160. /**
  132161. * Initializes the Physics helper
  132162. * @param scene Babylon.js scene
  132163. */
  132164. constructor(scene: Scene);
  132165. /**
  132166. * Applies a radial explosion impulse
  132167. * @param origin the origin of the explosion
  132168. * @param radiusOrEventOptions the radius or the options of radial explosion
  132169. * @param strength the explosion strength
  132170. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132171. * @returns A physics radial explosion event, or null
  132172. */
  132173. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132174. /**
  132175. * Applies a radial explosion force
  132176. * @param origin the origin of the explosion
  132177. * @param radiusOrEventOptions the radius or the options of radial explosion
  132178. * @param strength the explosion strength
  132179. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132180. * @returns A physics radial explosion event, or null
  132181. */
  132182. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132183. /**
  132184. * Creates a gravitational field
  132185. * @param origin the origin of the explosion
  132186. * @param radiusOrEventOptions the radius or the options of radial explosion
  132187. * @param strength the explosion strength
  132188. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132189. * @returns A physics gravitational field event, or null
  132190. */
  132191. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  132192. /**
  132193. * Creates a physics updraft event
  132194. * @param origin the origin of the updraft
  132195. * @param radiusOrEventOptions the radius or the options of the updraft
  132196. * @param strength the strength of the updraft
  132197. * @param height the height of the updraft
  132198. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  132199. * @returns A physics updraft event, or null
  132200. */
  132201. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  132202. /**
  132203. * Creates a physics vortex event
  132204. * @param origin the of the vortex
  132205. * @param radiusOrEventOptions the radius or the options of the vortex
  132206. * @param strength the strength of the vortex
  132207. * @param height the height of the vortex
  132208. * @returns a Physics vortex event, or null
  132209. * A physics vortex event or null
  132210. */
  132211. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  132212. }
  132213. /**
  132214. * Represents a physics radial explosion event
  132215. */
  132216. class PhysicsRadialExplosionEvent {
  132217. private _scene;
  132218. private _options;
  132219. private _sphere;
  132220. private _dataFetched;
  132221. /**
  132222. * Initializes a radial explosioin event
  132223. * @param _scene BabylonJS scene
  132224. * @param _options The options for the vortex event
  132225. */
  132226. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  132227. /**
  132228. * Returns the data related to the radial explosion event (sphere).
  132229. * @returns The radial explosion event data
  132230. */
  132231. getData(): PhysicsRadialExplosionEventData;
  132232. /**
  132233. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  132234. * @param impostor A physics imposter
  132235. * @param origin the origin of the explosion
  132236. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  132237. */
  132238. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  132239. /**
  132240. * Triggers affecterd impostors callbacks
  132241. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  132242. */
  132243. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  132244. /**
  132245. * Disposes the sphere.
  132246. * @param force Specifies if the sphere should be disposed by force
  132247. */
  132248. dispose(force?: boolean): void;
  132249. /*** Helpers ***/
  132250. private _prepareSphere;
  132251. private _intersectsWithSphere;
  132252. }
  132253. /**
  132254. * Represents a gravitational field event
  132255. */
  132256. class PhysicsGravitationalFieldEvent {
  132257. private _physicsHelper;
  132258. private _scene;
  132259. private _origin;
  132260. private _options;
  132261. private _tickCallback;
  132262. private _sphere;
  132263. private _dataFetched;
  132264. /**
  132265. * Initializes the physics gravitational field event
  132266. * @param _physicsHelper A physics helper
  132267. * @param _scene BabylonJS scene
  132268. * @param _origin The origin position of the gravitational field event
  132269. * @param _options The options for the vortex event
  132270. */
  132271. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  132272. /**
  132273. * Returns the data related to the gravitational field event (sphere).
  132274. * @returns A gravitational field event
  132275. */
  132276. getData(): PhysicsGravitationalFieldEventData;
  132277. /**
  132278. * Enables the gravitational field.
  132279. */
  132280. enable(): void;
  132281. /**
  132282. * Disables the gravitational field.
  132283. */
  132284. disable(): void;
  132285. /**
  132286. * Disposes the sphere.
  132287. * @param force The force to dispose from the gravitational field event
  132288. */
  132289. dispose(force?: boolean): void;
  132290. private _tick;
  132291. }
  132292. /**
  132293. * Represents a physics updraft event
  132294. */
  132295. class PhysicsUpdraftEvent {
  132296. private _scene;
  132297. private _origin;
  132298. private _options;
  132299. private _physicsEngine;
  132300. private _originTop;
  132301. private _originDirection;
  132302. private _tickCallback;
  132303. private _cylinder;
  132304. private _cylinderPosition;
  132305. private _dataFetched;
  132306. /**
  132307. * Initializes the physics updraft event
  132308. * @param _scene BabylonJS scene
  132309. * @param _origin The origin position of the updraft
  132310. * @param _options The options for the updraft event
  132311. */
  132312. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  132313. /**
  132314. * Returns the data related to the updraft event (cylinder).
  132315. * @returns A physics updraft event
  132316. */
  132317. getData(): PhysicsUpdraftEventData;
  132318. /**
  132319. * Enables the updraft.
  132320. */
  132321. enable(): void;
  132322. /**
  132323. * Disables the updraft.
  132324. */
  132325. disable(): void;
  132326. /**
  132327. * Disposes the cylinder.
  132328. * @param force Specifies if the updraft should be disposed by force
  132329. */
  132330. dispose(force?: boolean): void;
  132331. private getImpostorHitData;
  132332. private _tick;
  132333. /*** Helpers ***/
  132334. private _prepareCylinder;
  132335. private _intersectsWithCylinder;
  132336. }
  132337. /**
  132338. * Represents a physics vortex event
  132339. */
  132340. class PhysicsVortexEvent {
  132341. private _scene;
  132342. private _origin;
  132343. private _options;
  132344. private _physicsEngine;
  132345. private _originTop;
  132346. private _tickCallback;
  132347. private _cylinder;
  132348. private _cylinderPosition;
  132349. private _dataFetched;
  132350. /**
  132351. * Initializes the physics vortex event
  132352. * @param _scene The BabylonJS scene
  132353. * @param _origin The origin position of the vortex
  132354. * @param _options The options for the vortex event
  132355. */
  132356. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  132357. /**
  132358. * Returns the data related to the vortex event (cylinder).
  132359. * @returns The physics vortex event data
  132360. */
  132361. getData(): PhysicsVortexEventData;
  132362. /**
  132363. * Enables the vortex.
  132364. */
  132365. enable(): void;
  132366. /**
  132367. * Disables the cortex.
  132368. */
  132369. disable(): void;
  132370. /**
  132371. * Disposes the sphere.
  132372. * @param force
  132373. */
  132374. dispose(force?: boolean): void;
  132375. private getImpostorHitData;
  132376. private _tick;
  132377. /*** Helpers ***/
  132378. private _prepareCylinder;
  132379. private _intersectsWithCylinder;
  132380. }
  132381. /**
  132382. * Options fot the radial explosion event
  132383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132384. */
  132385. export class PhysicsRadialExplosionEventOptions {
  132386. /**
  132387. * The radius of the sphere for the radial explosion.
  132388. */
  132389. radius: number;
  132390. /**
  132391. * The strenth of the explosion.
  132392. */
  132393. strength: number;
  132394. /**
  132395. * The strenght of the force in correspondence to the distance of the affected object
  132396. */
  132397. falloff: PhysicsRadialImpulseFalloff;
  132398. /**
  132399. * Sphere options for the radial explosion.
  132400. */
  132401. sphere: {
  132402. segments: number;
  132403. diameter: number;
  132404. };
  132405. /**
  132406. * Sphere options for the radial explosion.
  132407. */
  132408. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  132409. }
  132410. /**
  132411. * Options fot the updraft event
  132412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132413. */
  132414. export class PhysicsUpdraftEventOptions {
  132415. /**
  132416. * The radius of the cylinder for the vortex
  132417. */
  132418. radius: number;
  132419. /**
  132420. * The strenth of the updraft.
  132421. */
  132422. strength: number;
  132423. /**
  132424. * The height of the cylinder for the updraft.
  132425. */
  132426. height: number;
  132427. /**
  132428. * The mode for the the updraft.
  132429. */
  132430. updraftMode: PhysicsUpdraftMode;
  132431. }
  132432. /**
  132433. * Options fot the vortex event
  132434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132435. */
  132436. export class PhysicsVortexEventOptions {
  132437. /**
  132438. * The radius of the cylinder for the vortex
  132439. */
  132440. radius: number;
  132441. /**
  132442. * The strenth of the vortex.
  132443. */
  132444. strength: number;
  132445. /**
  132446. * The height of the cylinder for the vortex.
  132447. */
  132448. height: number;
  132449. /**
  132450. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  132451. */
  132452. centripetalForceThreshold: number;
  132453. /**
  132454. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  132455. */
  132456. centripetalForceMultiplier: number;
  132457. /**
  132458. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  132459. */
  132460. centrifugalForceMultiplier: number;
  132461. /**
  132462. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  132463. */
  132464. updraftForceMultiplier: number;
  132465. }
  132466. /**
  132467. * The strenght of the force in correspondence to the distance of the affected object
  132468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132469. */
  132470. export enum PhysicsRadialImpulseFalloff {
  132471. /** Defines that impulse is constant in strength across it's whole radius */
  132472. Constant = 0,
  132473. /** Defines that impulse gets weaker if it's further from the origin */
  132474. Linear = 1
  132475. }
  132476. /**
  132477. * The strength of the force in correspondence to the distance of the affected object
  132478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132479. */
  132480. export enum PhysicsUpdraftMode {
  132481. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  132482. Center = 0,
  132483. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  132484. Perpendicular = 1
  132485. }
  132486. /**
  132487. * Interface for a physics hit data
  132488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132489. */
  132490. export interface PhysicsHitData {
  132491. /**
  132492. * The force applied at the contact point
  132493. */
  132494. force: Vector3;
  132495. /**
  132496. * The contact point
  132497. */
  132498. contactPoint: Vector3;
  132499. /**
  132500. * The distance from the origin to the contact point
  132501. */
  132502. distanceFromOrigin: number;
  132503. }
  132504. /**
  132505. * Interface for radial explosion event data
  132506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132507. */
  132508. export interface PhysicsRadialExplosionEventData {
  132509. /**
  132510. * A sphere used for the radial explosion event
  132511. */
  132512. sphere: Mesh;
  132513. }
  132514. /**
  132515. * Interface for gravitational field event data
  132516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132517. */
  132518. export interface PhysicsGravitationalFieldEventData {
  132519. /**
  132520. * A sphere mesh used for the gravitational field event
  132521. */
  132522. sphere: Mesh;
  132523. }
  132524. /**
  132525. * Interface for updraft event data
  132526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132527. */
  132528. export interface PhysicsUpdraftEventData {
  132529. /**
  132530. * A cylinder used for the updraft event
  132531. */
  132532. cylinder: Mesh;
  132533. }
  132534. /**
  132535. * Interface for vortex event data
  132536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132537. */
  132538. export interface PhysicsVortexEventData {
  132539. /**
  132540. * A cylinder used for the vortex event
  132541. */
  132542. cylinder: Mesh;
  132543. }
  132544. /**
  132545. * Interface for an affected physics impostor
  132546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132547. */
  132548. export interface PhysicsAffectedImpostorWithData {
  132549. /**
  132550. * The impostor affected by the effect
  132551. */
  132552. impostor: PhysicsImpostor;
  132553. /**
  132554. * The data about the hit/horce from the explosion
  132555. */
  132556. hitData: PhysicsHitData;
  132557. }
  132558. }
  132559. declare module BABYLON {
  132560. /** @hidden */
  132561. export var blackAndWhitePixelShader: {
  132562. name: string;
  132563. shader: string;
  132564. };
  132565. }
  132566. declare module BABYLON {
  132567. /**
  132568. * Post process used to render in black and white
  132569. */
  132570. export class BlackAndWhitePostProcess extends PostProcess {
  132571. /**
  132572. * Linear about to convert he result to black and white (default: 1)
  132573. */
  132574. degree: number;
  132575. /**
  132576. * Creates a black and white post process
  132577. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  132578. * @param name The name of the effect.
  132579. * @param options The required width/height ratio to downsize to before computing the render pass.
  132580. * @param camera The camera to apply the render pass to.
  132581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132582. * @param engine The engine which the post process will be applied. (default: current engine)
  132583. * @param reusable If the post process can be reused on the same frame. (default: false)
  132584. */
  132585. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132586. }
  132587. }
  132588. declare module BABYLON {
  132589. /**
  132590. * This represents a set of one or more post processes in Babylon.
  132591. * A post process can be used to apply a shader to a texture after it is rendered.
  132592. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132593. */
  132594. export class PostProcessRenderEffect {
  132595. private _postProcesses;
  132596. private _getPostProcesses;
  132597. private _singleInstance;
  132598. private _cameras;
  132599. private _indicesForCamera;
  132600. /**
  132601. * Name of the effect
  132602. * @hidden
  132603. */
  132604. _name: string;
  132605. /**
  132606. * Instantiates a post process render effect.
  132607. * A post process can be used to apply a shader to a texture after it is rendered.
  132608. * @param engine The engine the effect is tied to
  132609. * @param name The name of the effect
  132610. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  132611. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  132612. */
  132613. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  132614. /**
  132615. * Checks if all the post processes in the effect are supported.
  132616. */
  132617. get isSupported(): boolean;
  132618. /**
  132619. * Updates the current state of the effect
  132620. * @hidden
  132621. */
  132622. _update(): void;
  132623. /**
  132624. * Attaches the effect on cameras
  132625. * @param cameras The camera to attach to.
  132626. * @hidden
  132627. */
  132628. _attachCameras(cameras: Camera): void;
  132629. /**
  132630. * Attaches the effect on cameras
  132631. * @param cameras The camera to attach to.
  132632. * @hidden
  132633. */
  132634. _attachCameras(cameras: Camera[]): void;
  132635. /**
  132636. * Detaches the effect on cameras
  132637. * @param cameras The camera to detatch from.
  132638. * @hidden
  132639. */
  132640. _detachCameras(cameras: Camera): void;
  132641. /**
  132642. * Detatches the effect on cameras
  132643. * @param cameras The camera to detatch from.
  132644. * @hidden
  132645. */
  132646. _detachCameras(cameras: Camera[]): void;
  132647. /**
  132648. * Enables the effect on given cameras
  132649. * @param cameras The camera to enable.
  132650. * @hidden
  132651. */
  132652. _enable(cameras: Camera): void;
  132653. /**
  132654. * Enables the effect on given cameras
  132655. * @param cameras The camera to enable.
  132656. * @hidden
  132657. */
  132658. _enable(cameras: Nullable<Camera[]>): void;
  132659. /**
  132660. * Disables the effect on the given cameras
  132661. * @param cameras The camera to disable.
  132662. * @hidden
  132663. */
  132664. _disable(cameras: Camera): void;
  132665. /**
  132666. * Disables the effect on the given cameras
  132667. * @param cameras The camera to disable.
  132668. * @hidden
  132669. */
  132670. _disable(cameras: Nullable<Camera[]>): void;
  132671. /**
  132672. * Gets a list of the post processes contained in the effect.
  132673. * @param camera The camera to get the post processes on.
  132674. * @returns The list of the post processes in the effect.
  132675. */
  132676. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  132677. }
  132678. }
  132679. declare module BABYLON {
  132680. /** @hidden */
  132681. export var extractHighlightsPixelShader: {
  132682. name: string;
  132683. shader: string;
  132684. };
  132685. }
  132686. declare module BABYLON {
  132687. /**
  132688. * 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.
  132689. */
  132690. export class ExtractHighlightsPostProcess extends PostProcess {
  132691. /**
  132692. * The luminance threshold, pixels below this value will be set to black.
  132693. */
  132694. threshold: number;
  132695. /** @hidden */
  132696. _exposure: number;
  132697. /**
  132698. * Post process which has the input texture to be used when performing highlight extraction
  132699. * @hidden
  132700. */
  132701. _inputPostProcess: Nullable<PostProcess>;
  132702. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132703. }
  132704. }
  132705. declare module BABYLON {
  132706. /** @hidden */
  132707. export var bloomMergePixelShader: {
  132708. name: string;
  132709. shader: string;
  132710. };
  132711. }
  132712. declare module BABYLON {
  132713. /**
  132714. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  132715. */
  132716. export class BloomMergePostProcess extends PostProcess {
  132717. /** Weight of the bloom to be added to the original input. */
  132718. weight: number;
  132719. /**
  132720. * Creates a new instance of @see BloomMergePostProcess
  132721. * @param name The name of the effect.
  132722. * @param originalFromInput Post process which's input will be used for the merge.
  132723. * @param blurred Blurred highlights post process which's output will be used.
  132724. * @param weight Weight of the bloom to be added to the original input.
  132725. * @param options The required width/height ratio to downsize to before computing the render pass.
  132726. * @param camera The camera to apply the render pass to.
  132727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132728. * @param engine The engine which the post process will be applied. (default: current engine)
  132729. * @param reusable If the post process can be reused on the same frame. (default: false)
  132730. * @param textureType Type of textures used when performing the post process. (default: 0)
  132731. * @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)
  132732. */
  132733. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  132734. /** Weight of the bloom to be added to the original input. */
  132735. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132736. }
  132737. }
  132738. declare module BABYLON {
  132739. /**
  132740. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  132741. */
  132742. export class BloomEffect extends PostProcessRenderEffect {
  132743. private bloomScale;
  132744. /**
  132745. * @hidden Internal
  132746. */
  132747. _effects: Array<PostProcess>;
  132748. /**
  132749. * @hidden Internal
  132750. */
  132751. _downscale: ExtractHighlightsPostProcess;
  132752. private _blurX;
  132753. private _blurY;
  132754. private _merge;
  132755. /**
  132756. * The luminance threshold to find bright areas of the image to bloom.
  132757. */
  132758. get threshold(): number;
  132759. set threshold(value: number);
  132760. /**
  132761. * The strength of the bloom.
  132762. */
  132763. get weight(): number;
  132764. set weight(value: number);
  132765. /**
  132766. * Specifies the size of the bloom blur kernel, relative to the final output size
  132767. */
  132768. get kernel(): number;
  132769. set kernel(value: number);
  132770. /**
  132771. * Creates a new instance of @see BloomEffect
  132772. * @param scene The scene the effect belongs to.
  132773. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  132774. * @param bloomKernel The size of the kernel to be used when applying the blur.
  132775. * @param bloomWeight The the strength of bloom.
  132776. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  132777. * @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)
  132778. */
  132779. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  132780. /**
  132781. * Disposes each of the internal effects for a given camera.
  132782. * @param camera The camera to dispose the effect on.
  132783. */
  132784. disposeEffects(camera: Camera): void;
  132785. /**
  132786. * @hidden Internal
  132787. */
  132788. _updateEffects(): void;
  132789. /**
  132790. * Internal
  132791. * @returns if all the contained post processes are ready.
  132792. * @hidden
  132793. */
  132794. _isReady(): boolean;
  132795. }
  132796. }
  132797. declare module BABYLON {
  132798. /** @hidden */
  132799. export var chromaticAberrationPixelShader: {
  132800. name: string;
  132801. shader: string;
  132802. };
  132803. }
  132804. declare module BABYLON {
  132805. /**
  132806. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  132807. */
  132808. export class ChromaticAberrationPostProcess extends PostProcess {
  132809. /**
  132810. * The amount of seperation of rgb channels (default: 30)
  132811. */
  132812. aberrationAmount: number;
  132813. /**
  132814. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  132815. */
  132816. radialIntensity: number;
  132817. /**
  132818. * 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))
  132819. */
  132820. direction: Vector2;
  132821. /**
  132822. * 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))
  132823. */
  132824. centerPosition: Vector2;
  132825. /**
  132826. * Creates a new instance ChromaticAberrationPostProcess
  132827. * @param name The name of the effect.
  132828. * @param screenWidth The width of the screen to apply the effect on.
  132829. * @param screenHeight The height of the screen to apply the effect on.
  132830. * @param options The required width/height ratio to downsize to before computing the render pass.
  132831. * @param camera The camera to apply the render pass to.
  132832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132833. * @param engine The engine which the post process will be applied. (default: current engine)
  132834. * @param reusable If the post process can be reused on the same frame. (default: false)
  132835. * @param textureType Type of textures used when performing the post process. (default: 0)
  132836. * @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)
  132837. */
  132838. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132839. }
  132840. }
  132841. declare module BABYLON {
  132842. /** @hidden */
  132843. export var circleOfConfusionPixelShader: {
  132844. name: string;
  132845. shader: string;
  132846. };
  132847. }
  132848. declare module BABYLON {
  132849. /**
  132850. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  132851. */
  132852. export class CircleOfConfusionPostProcess extends PostProcess {
  132853. /**
  132854. * 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.
  132855. */
  132856. lensSize: number;
  132857. /**
  132858. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  132859. */
  132860. fStop: number;
  132861. /**
  132862. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  132863. */
  132864. focusDistance: number;
  132865. /**
  132866. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  132867. */
  132868. focalLength: number;
  132869. private _depthTexture;
  132870. /**
  132871. * Creates a new instance CircleOfConfusionPostProcess
  132872. * @param name The name of the effect.
  132873. * @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.
  132874. * @param options The required width/height ratio to downsize to before computing the render pass.
  132875. * @param camera The camera to apply the render pass to.
  132876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132877. * @param engine The engine which the post process will be applied. (default: current engine)
  132878. * @param reusable If the post process can be reused on the same frame. (default: false)
  132879. * @param textureType Type of textures used when performing the post process. (default: 0)
  132880. * @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)
  132881. */
  132882. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132883. /**
  132884. * 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.
  132885. */
  132886. set depthTexture(value: RenderTargetTexture);
  132887. }
  132888. }
  132889. declare module BABYLON {
  132890. /** @hidden */
  132891. export var colorCorrectionPixelShader: {
  132892. name: string;
  132893. shader: string;
  132894. };
  132895. }
  132896. declare module BABYLON {
  132897. /**
  132898. *
  132899. * This post-process allows the modification of rendered colors by using
  132900. * a 'look-up table' (LUT). This effect is also called Color Grading.
  132901. *
  132902. * The object needs to be provided an url to a texture containing the color
  132903. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  132904. * Use an image editing software to tweak the LUT to match your needs.
  132905. *
  132906. * For an example of a color LUT, see here:
  132907. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  132908. * For explanations on color grading, see here:
  132909. * @see http://udn.epicgames.com/Three/ColorGrading.html
  132910. *
  132911. */
  132912. export class ColorCorrectionPostProcess extends PostProcess {
  132913. private _colorTableTexture;
  132914. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132915. }
  132916. }
  132917. declare module BABYLON {
  132918. /** @hidden */
  132919. export var convolutionPixelShader: {
  132920. name: string;
  132921. shader: string;
  132922. };
  132923. }
  132924. declare module BABYLON {
  132925. /**
  132926. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  132927. * input texture to perform effects such as edge detection or sharpening
  132928. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  132929. */
  132930. export class ConvolutionPostProcess extends PostProcess {
  132931. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  132932. kernel: number[];
  132933. /**
  132934. * Creates a new instance ConvolutionPostProcess
  132935. * @param name The name of the effect.
  132936. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  132937. * @param options The required width/height ratio to downsize to before computing the render pass.
  132938. * @param camera The camera to apply the render pass to.
  132939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132940. * @param engine The engine which the post process will be applied. (default: current engine)
  132941. * @param reusable If the post process can be reused on the same frame. (default: false)
  132942. * @param textureType Type of textures used when performing the post process. (default: 0)
  132943. */
  132944. constructor(name: string,
  132945. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  132946. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  132947. /**
  132948. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132949. */
  132950. static EdgeDetect0Kernel: number[];
  132951. /**
  132952. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132953. */
  132954. static EdgeDetect1Kernel: number[];
  132955. /**
  132956. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132957. */
  132958. static EdgeDetect2Kernel: number[];
  132959. /**
  132960. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132961. */
  132962. static SharpenKernel: number[];
  132963. /**
  132964. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132965. */
  132966. static EmbossKernel: number[];
  132967. /**
  132968. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132969. */
  132970. static GaussianKernel: number[];
  132971. }
  132972. }
  132973. declare module BABYLON {
  132974. /**
  132975. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  132976. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  132977. * based on samples that have a large difference in distance than the center pixel.
  132978. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  132979. */
  132980. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  132981. direction: Vector2;
  132982. /**
  132983. * Creates a new instance CircleOfConfusionPostProcess
  132984. * @param name The name of the effect.
  132985. * @param scene The scene the effect belongs to.
  132986. * @param direction The direction the blur should be applied.
  132987. * @param kernel The size of the kernel used to blur.
  132988. * @param options The required width/height ratio to downsize to before computing the render pass.
  132989. * @param camera The camera to apply the render pass to.
  132990. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  132991. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  132992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132993. * @param engine The engine which the post process will be applied. (default: current engine)
  132994. * @param reusable If the post process can be reused on the same frame. (default: false)
  132995. * @param textureType Type of textures used when performing the post process. (default: 0)
  132996. * @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)
  132997. */
  132998. 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);
  132999. }
  133000. }
  133001. declare module BABYLON {
  133002. /** @hidden */
  133003. export var depthOfFieldMergePixelShader: {
  133004. name: string;
  133005. shader: string;
  133006. };
  133007. }
  133008. declare module BABYLON {
  133009. /**
  133010. * Options to be set when merging outputs from the default pipeline.
  133011. */
  133012. export class DepthOfFieldMergePostProcessOptions {
  133013. /**
  133014. * The original image to merge on top of
  133015. */
  133016. originalFromInput: PostProcess;
  133017. /**
  133018. * Parameters to perform the merge of the depth of field effect
  133019. */
  133020. depthOfField?: {
  133021. circleOfConfusion: PostProcess;
  133022. blurSteps: Array<PostProcess>;
  133023. };
  133024. /**
  133025. * Parameters to perform the merge of bloom effect
  133026. */
  133027. bloom?: {
  133028. blurred: PostProcess;
  133029. weight: number;
  133030. };
  133031. }
  133032. /**
  133033. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  133034. */
  133035. export class DepthOfFieldMergePostProcess extends PostProcess {
  133036. private blurSteps;
  133037. /**
  133038. * Creates a new instance of DepthOfFieldMergePostProcess
  133039. * @param name The name of the effect.
  133040. * @param originalFromInput Post process which's input will be used for the merge.
  133041. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  133042. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  133043. * @param options The required width/height ratio to downsize to before computing the render pass.
  133044. * @param camera The camera to apply the render pass to.
  133045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133046. * @param engine The engine which the post process will be applied. (default: current engine)
  133047. * @param reusable If the post process can be reused on the same frame. (default: false)
  133048. * @param textureType Type of textures used when performing the post process. (default: 0)
  133049. * @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)
  133050. */
  133051. 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);
  133052. /**
  133053. * Updates the effect with the current post process compile time values and recompiles the shader.
  133054. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  133055. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  133056. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  133057. * @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
  133058. * @param onCompiled Called when the shader has been compiled.
  133059. * @param onError Called if there is an error when compiling a shader.
  133060. */
  133061. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  133062. }
  133063. }
  133064. declare module BABYLON {
  133065. /**
  133066. * Specifies the level of max blur that should be applied when using the depth of field effect
  133067. */
  133068. export enum DepthOfFieldEffectBlurLevel {
  133069. /**
  133070. * Subtle blur
  133071. */
  133072. Low = 0,
  133073. /**
  133074. * Medium blur
  133075. */
  133076. Medium = 1,
  133077. /**
  133078. * Large blur
  133079. */
  133080. High = 2
  133081. }
  133082. /**
  133083. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  133084. */
  133085. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  133086. private _circleOfConfusion;
  133087. /**
  133088. * @hidden Internal, blurs from high to low
  133089. */
  133090. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  133091. private _depthOfFieldBlurY;
  133092. private _dofMerge;
  133093. /**
  133094. * @hidden Internal post processes in depth of field effect
  133095. */
  133096. _effects: Array<PostProcess>;
  133097. /**
  133098. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  133099. */
  133100. set focalLength(value: number);
  133101. get focalLength(): number;
  133102. /**
  133103. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133104. */
  133105. set fStop(value: number);
  133106. get fStop(): number;
  133107. /**
  133108. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133109. */
  133110. set focusDistance(value: number);
  133111. get focusDistance(): number;
  133112. /**
  133113. * 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.
  133114. */
  133115. set lensSize(value: number);
  133116. get lensSize(): number;
  133117. /**
  133118. * Creates a new instance DepthOfFieldEffect
  133119. * @param scene The scene the effect belongs to.
  133120. * @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.
  133121. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  133122. * @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)
  133123. */
  133124. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  133125. /**
  133126. * Get the current class name of the current effet
  133127. * @returns "DepthOfFieldEffect"
  133128. */
  133129. getClassName(): string;
  133130. /**
  133131. * 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.
  133132. */
  133133. set depthTexture(value: RenderTargetTexture);
  133134. /**
  133135. * Disposes each of the internal effects for a given camera.
  133136. * @param camera The camera to dispose the effect on.
  133137. */
  133138. disposeEffects(camera: Camera): void;
  133139. /**
  133140. * @hidden Internal
  133141. */
  133142. _updateEffects(): void;
  133143. /**
  133144. * Internal
  133145. * @returns if all the contained post processes are ready.
  133146. * @hidden
  133147. */
  133148. _isReady(): boolean;
  133149. }
  133150. }
  133151. declare module BABYLON {
  133152. /** @hidden */
  133153. export var displayPassPixelShader: {
  133154. name: string;
  133155. shader: string;
  133156. };
  133157. }
  133158. declare module BABYLON {
  133159. /**
  133160. * DisplayPassPostProcess which produces an output the same as it's input
  133161. */
  133162. export class DisplayPassPostProcess extends PostProcess {
  133163. /**
  133164. * Creates the DisplayPassPostProcess
  133165. * @param name The name of the effect.
  133166. * @param options The required width/height ratio to downsize to before computing the render pass.
  133167. * @param camera The camera to apply the render pass to.
  133168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133169. * @param engine The engine which the post process will be applied. (default: current engine)
  133170. * @param reusable If the post process can be reused on the same frame. (default: false)
  133171. */
  133172. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133173. }
  133174. }
  133175. declare module BABYLON {
  133176. /** @hidden */
  133177. export var filterPixelShader: {
  133178. name: string;
  133179. shader: string;
  133180. };
  133181. }
  133182. declare module BABYLON {
  133183. /**
  133184. * Applies a kernel filter to the image
  133185. */
  133186. export class FilterPostProcess extends PostProcess {
  133187. /** The matrix to be applied to the image */
  133188. kernelMatrix: Matrix;
  133189. /**
  133190. *
  133191. * @param name The name of the effect.
  133192. * @param kernelMatrix The matrix to be applied to the image
  133193. * @param options The required width/height ratio to downsize to before computing the render pass.
  133194. * @param camera The camera to apply the render pass to.
  133195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133196. * @param engine The engine which the post process will be applied. (default: current engine)
  133197. * @param reusable If the post process can be reused on the same frame. (default: false)
  133198. */
  133199. constructor(name: string,
  133200. /** The matrix to be applied to the image */
  133201. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133202. }
  133203. }
  133204. declare module BABYLON {
  133205. /** @hidden */
  133206. export var fxaaPixelShader: {
  133207. name: string;
  133208. shader: string;
  133209. };
  133210. }
  133211. declare module BABYLON {
  133212. /** @hidden */
  133213. export var fxaaVertexShader: {
  133214. name: string;
  133215. shader: string;
  133216. };
  133217. }
  133218. declare module BABYLON {
  133219. /**
  133220. * Fxaa post process
  133221. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  133222. */
  133223. export class FxaaPostProcess extends PostProcess {
  133224. /** @hidden */
  133225. texelWidth: number;
  133226. /** @hidden */
  133227. texelHeight: number;
  133228. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133229. private _getDefines;
  133230. }
  133231. }
  133232. declare module BABYLON {
  133233. /** @hidden */
  133234. export var grainPixelShader: {
  133235. name: string;
  133236. shader: string;
  133237. };
  133238. }
  133239. declare module BABYLON {
  133240. /**
  133241. * The GrainPostProcess adds noise to the image at mid luminance levels
  133242. */
  133243. export class GrainPostProcess extends PostProcess {
  133244. /**
  133245. * The intensity of the grain added (default: 30)
  133246. */
  133247. intensity: number;
  133248. /**
  133249. * If the grain should be randomized on every frame
  133250. */
  133251. animated: boolean;
  133252. /**
  133253. * Creates a new instance of @see GrainPostProcess
  133254. * @param name The name of the effect.
  133255. * @param options The required width/height ratio to downsize to before computing the render pass.
  133256. * @param camera The camera to apply the render pass to.
  133257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133258. * @param engine The engine which the post process will be applied. (default: current engine)
  133259. * @param reusable If the post process can be reused on the same frame. (default: false)
  133260. * @param textureType Type of textures used when performing the post process. (default: 0)
  133261. * @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)
  133262. */
  133263. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133264. }
  133265. }
  133266. declare module BABYLON {
  133267. /** @hidden */
  133268. export var highlightsPixelShader: {
  133269. name: string;
  133270. shader: string;
  133271. };
  133272. }
  133273. declare module BABYLON {
  133274. /**
  133275. * Extracts highlights from the image
  133276. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133277. */
  133278. export class HighlightsPostProcess extends PostProcess {
  133279. /**
  133280. * Extracts highlights from the image
  133281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133282. * @param name The name of the effect.
  133283. * @param options The required width/height ratio to downsize to before computing the render pass.
  133284. * @param camera The camera to apply the render pass to.
  133285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133286. * @param engine The engine which the post process will be applied. (default: current engine)
  133287. * @param reusable If the post process can be reused on the same frame. (default: false)
  133288. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  133289. */
  133290. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133291. }
  133292. }
  133293. declare module BABYLON {
  133294. /** @hidden */
  133295. export var mrtFragmentDeclaration: {
  133296. name: string;
  133297. shader: string;
  133298. };
  133299. }
  133300. declare module BABYLON {
  133301. /** @hidden */
  133302. export var geometryPixelShader: {
  133303. name: string;
  133304. shader: string;
  133305. };
  133306. }
  133307. declare module BABYLON {
  133308. /** @hidden */
  133309. export var geometryVertexShader: {
  133310. name: string;
  133311. shader: string;
  133312. };
  133313. }
  133314. declare module BABYLON {
  133315. /** @hidden */
  133316. interface ISavedTransformationMatrix {
  133317. world: Matrix;
  133318. viewProjection: Matrix;
  133319. }
  133320. /**
  133321. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  133322. */
  133323. export class GeometryBufferRenderer {
  133324. /**
  133325. * Constant used to retrieve the position texture index in the G-Buffer textures array
  133326. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  133327. */
  133328. static readonly POSITION_TEXTURE_TYPE: number;
  133329. /**
  133330. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  133331. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  133332. */
  133333. static readonly VELOCITY_TEXTURE_TYPE: number;
  133334. /**
  133335. * Dictionary used to store the previous transformation matrices of each rendered mesh
  133336. * in order to compute objects velocities when enableVelocity is set to "true"
  133337. * @hidden
  133338. */
  133339. _previousTransformationMatrices: {
  133340. [index: number]: ISavedTransformationMatrix;
  133341. };
  133342. /**
  133343. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  133344. * in order to compute objects velocities when enableVelocity is set to "true"
  133345. * @hidden
  133346. */
  133347. _previousBonesTransformationMatrices: {
  133348. [index: number]: Float32Array;
  133349. };
  133350. /**
  133351. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  133352. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  133353. */
  133354. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  133355. private _scene;
  133356. private _multiRenderTarget;
  133357. private _ratio;
  133358. private _enablePosition;
  133359. private _enableVelocity;
  133360. private _positionIndex;
  133361. private _velocityIndex;
  133362. protected _effect: Effect;
  133363. protected _cachedDefines: string;
  133364. /**
  133365. * Set the render list (meshes to be rendered) used in the G buffer.
  133366. */
  133367. set renderList(meshes: Mesh[]);
  133368. /**
  133369. * Gets wether or not G buffer are supported by the running hardware.
  133370. * This requires draw buffer supports
  133371. */
  133372. get isSupported(): boolean;
  133373. /**
  133374. * Returns the index of the given texture type in the G-Buffer textures array
  133375. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  133376. * @returns the index of the given texture type in the G-Buffer textures array
  133377. */
  133378. getTextureIndex(textureType: number): number;
  133379. /**
  133380. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  133381. */
  133382. get enablePosition(): boolean;
  133383. /**
  133384. * Sets whether or not objects positions are enabled for the G buffer.
  133385. */
  133386. set enablePosition(enable: boolean);
  133387. /**
  133388. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  133389. */
  133390. get enableVelocity(): boolean;
  133391. /**
  133392. * Sets wether or not objects velocities are enabled for the G buffer.
  133393. */
  133394. set enableVelocity(enable: boolean);
  133395. /**
  133396. * Gets the scene associated with the buffer.
  133397. */
  133398. get scene(): Scene;
  133399. /**
  133400. * Gets the ratio used by the buffer during its creation.
  133401. * How big is the buffer related to the main canvas.
  133402. */
  133403. get ratio(): number;
  133404. /** @hidden */
  133405. static _SceneComponentInitialization: (scene: Scene) => void;
  133406. /**
  133407. * Creates a new G Buffer for the scene
  133408. * @param scene The scene the buffer belongs to
  133409. * @param ratio How big is the buffer related to the main canvas.
  133410. */
  133411. constructor(scene: Scene, ratio?: number);
  133412. /**
  133413. * Checks wether everything is ready to render a submesh to the G buffer.
  133414. * @param subMesh the submesh to check readiness for
  133415. * @param useInstances is the mesh drawn using instance or not
  133416. * @returns true if ready otherwise false
  133417. */
  133418. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133419. /**
  133420. * Gets the current underlying G Buffer.
  133421. * @returns the buffer
  133422. */
  133423. getGBuffer(): MultiRenderTarget;
  133424. /**
  133425. * Gets the number of samples used to render the buffer (anti aliasing).
  133426. */
  133427. get samples(): number;
  133428. /**
  133429. * Sets the number of samples used to render the buffer (anti aliasing).
  133430. */
  133431. set samples(value: number);
  133432. /**
  133433. * Disposes the renderer and frees up associated resources.
  133434. */
  133435. dispose(): void;
  133436. protected _createRenderTargets(): void;
  133437. private _copyBonesTransformationMatrices;
  133438. }
  133439. }
  133440. declare module BABYLON {
  133441. interface Scene {
  133442. /** @hidden (Backing field) */
  133443. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133444. /**
  133445. * Gets or Sets the current geometry buffer associated to the scene.
  133446. */
  133447. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133448. /**
  133449. * Enables a GeometryBufferRender and associates it with the scene
  133450. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  133451. * @returns the GeometryBufferRenderer
  133452. */
  133453. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  133454. /**
  133455. * Disables the GeometryBufferRender associated with the scene
  133456. */
  133457. disableGeometryBufferRenderer(): void;
  133458. }
  133459. /**
  133460. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  133461. * in several rendering techniques.
  133462. */
  133463. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  133464. /**
  133465. * The component name helpful to identify the component in the list of scene components.
  133466. */
  133467. readonly name: string;
  133468. /**
  133469. * The scene the component belongs to.
  133470. */
  133471. scene: Scene;
  133472. /**
  133473. * Creates a new instance of the component for the given scene
  133474. * @param scene Defines the scene to register the component in
  133475. */
  133476. constructor(scene: Scene);
  133477. /**
  133478. * Registers the component in a given scene
  133479. */
  133480. register(): void;
  133481. /**
  133482. * Rebuilds the elements related to this component in case of
  133483. * context lost for instance.
  133484. */
  133485. rebuild(): void;
  133486. /**
  133487. * Disposes the component and the associated ressources
  133488. */
  133489. dispose(): void;
  133490. private _gatherRenderTargets;
  133491. }
  133492. }
  133493. declare module BABYLON {
  133494. /** @hidden */
  133495. export var motionBlurPixelShader: {
  133496. name: string;
  133497. shader: string;
  133498. };
  133499. }
  133500. declare module BABYLON {
  133501. /**
  133502. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  133503. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  133504. * As an example, all you have to do is to create the post-process:
  133505. * var mb = new BABYLON.MotionBlurPostProcess(
  133506. * 'mb', // The name of the effect.
  133507. * scene, // The scene containing the objects to blur according to their velocity.
  133508. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  133509. * camera // The camera to apply the render pass to.
  133510. * );
  133511. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  133512. */
  133513. export class MotionBlurPostProcess extends PostProcess {
  133514. /**
  133515. * Defines how much the image is blurred by the movement. Default value is equal to 1
  133516. */
  133517. motionStrength: number;
  133518. /**
  133519. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  133520. */
  133521. get motionBlurSamples(): number;
  133522. /**
  133523. * Sets the number of iterations to be used for motion blur quality
  133524. */
  133525. set motionBlurSamples(samples: number);
  133526. private _motionBlurSamples;
  133527. private _geometryBufferRenderer;
  133528. /**
  133529. * Creates a new instance MotionBlurPostProcess
  133530. * @param name The name of the effect.
  133531. * @param scene The scene containing the objects to blur according to their velocity.
  133532. * @param options The required width/height ratio to downsize to before computing the render pass.
  133533. * @param camera The camera to apply the render pass to.
  133534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133535. * @param engine The engine which the post process will be applied. (default: current engine)
  133536. * @param reusable If the post process can be reused on the same frame. (default: false)
  133537. * @param textureType Type of textures used when performing the post process. (default: 0)
  133538. * @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)
  133539. */
  133540. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133541. /**
  133542. * Excludes the given skinned mesh from computing bones velocities.
  133543. * 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.
  133544. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  133545. */
  133546. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133547. /**
  133548. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  133549. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  133550. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  133551. */
  133552. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133553. /**
  133554. * Disposes the post process.
  133555. * @param camera The camera to dispose the post process on.
  133556. */
  133557. dispose(camera?: Camera): void;
  133558. }
  133559. }
  133560. declare module BABYLON {
  133561. /** @hidden */
  133562. export var refractionPixelShader: {
  133563. name: string;
  133564. shader: string;
  133565. };
  133566. }
  133567. declare module BABYLON {
  133568. /**
  133569. * Post process which applies a refractin texture
  133570. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133571. */
  133572. export class RefractionPostProcess extends PostProcess {
  133573. /** the base color of the refraction (used to taint the rendering) */
  133574. color: Color3;
  133575. /** simulated refraction depth */
  133576. depth: number;
  133577. /** the coefficient of the base color (0 to remove base color tainting) */
  133578. colorLevel: number;
  133579. private _refTexture;
  133580. private _ownRefractionTexture;
  133581. /**
  133582. * Gets or sets the refraction texture
  133583. * Please note that you are responsible for disposing the texture if you set it manually
  133584. */
  133585. get refractionTexture(): Texture;
  133586. set refractionTexture(value: Texture);
  133587. /**
  133588. * Initializes the RefractionPostProcess
  133589. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133590. * @param name The name of the effect.
  133591. * @param refractionTextureUrl Url of the refraction texture to use
  133592. * @param color the base color of the refraction (used to taint the rendering)
  133593. * @param depth simulated refraction depth
  133594. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  133595. * @param camera The camera to apply the render pass to.
  133596. * @param options The required width/height ratio to downsize to before computing the render pass.
  133597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133598. * @param engine The engine which the post process will be applied. (default: current engine)
  133599. * @param reusable If the post process can be reused on the same frame. (default: false)
  133600. */
  133601. constructor(name: string, refractionTextureUrl: string,
  133602. /** the base color of the refraction (used to taint the rendering) */
  133603. color: Color3,
  133604. /** simulated refraction depth */
  133605. depth: number,
  133606. /** the coefficient of the base color (0 to remove base color tainting) */
  133607. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133608. /**
  133609. * Disposes of the post process
  133610. * @param camera Camera to dispose post process on
  133611. */
  133612. dispose(camera: Camera): void;
  133613. }
  133614. }
  133615. declare module BABYLON {
  133616. /** @hidden */
  133617. export var sharpenPixelShader: {
  133618. name: string;
  133619. shader: string;
  133620. };
  133621. }
  133622. declare module BABYLON {
  133623. /**
  133624. * The SharpenPostProcess applies a sharpen kernel to every pixel
  133625. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133626. */
  133627. export class SharpenPostProcess extends PostProcess {
  133628. /**
  133629. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  133630. */
  133631. colorAmount: number;
  133632. /**
  133633. * How much sharpness should be applied (default: 0.3)
  133634. */
  133635. edgeAmount: number;
  133636. /**
  133637. * Creates a new instance ConvolutionPostProcess
  133638. * @param name The name of the effect.
  133639. * @param options The required width/height ratio to downsize to before computing the render pass.
  133640. * @param camera The camera to apply the render pass to.
  133641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133642. * @param engine The engine which the post process will be applied. (default: current engine)
  133643. * @param reusable If the post process can be reused on the same frame. (default: false)
  133644. * @param textureType Type of textures used when performing the post process. (default: 0)
  133645. * @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)
  133646. */
  133647. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133648. }
  133649. }
  133650. declare module BABYLON {
  133651. /**
  133652. * PostProcessRenderPipeline
  133653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133654. */
  133655. export class PostProcessRenderPipeline {
  133656. private engine;
  133657. private _renderEffects;
  133658. private _renderEffectsForIsolatedPass;
  133659. /**
  133660. * List of inspectable custom properties (used by the Inspector)
  133661. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  133662. */
  133663. inspectableCustomProperties: IInspectable[];
  133664. /**
  133665. * @hidden
  133666. */
  133667. protected _cameras: Camera[];
  133668. /** @hidden */
  133669. _name: string;
  133670. /**
  133671. * Gets pipeline name
  133672. */
  133673. get name(): string;
  133674. /** Gets the list of attached cameras */
  133675. get cameras(): Camera[];
  133676. /**
  133677. * Initializes a PostProcessRenderPipeline
  133678. * @param engine engine to add the pipeline to
  133679. * @param name name of the pipeline
  133680. */
  133681. constructor(engine: Engine, name: string);
  133682. /**
  133683. * Gets the class name
  133684. * @returns "PostProcessRenderPipeline"
  133685. */
  133686. getClassName(): string;
  133687. /**
  133688. * If all the render effects in the pipeline are supported
  133689. */
  133690. get isSupported(): boolean;
  133691. /**
  133692. * Adds an effect to the pipeline
  133693. * @param renderEffect the effect to add
  133694. */
  133695. addEffect(renderEffect: PostProcessRenderEffect): void;
  133696. /** @hidden */
  133697. _rebuild(): void;
  133698. /** @hidden */
  133699. _enableEffect(renderEffectName: string, cameras: Camera): void;
  133700. /** @hidden */
  133701. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  133702. /** @hidden */
  133703. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133704. /** @hidden */
  133705. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133706. /** @hidden */
  133707. _attachCameras(cameras: Camera, unique: boolean): void;
  133708. /** @hidden */
  133709. _attachCameras(cameras: Camera[], unique: boolean): void;
  133710. /** @hidden */
  133711. _detachCameras(cameras: Camera): void;
  133712. /** @hidden */
  133713. _detachCameras(cameras: Nullable<Camera[]>): void;
  133714. /** @hidden */
  133715. _update(): void;
  133716. /** @hidden */
  133717. _reset(): void;
  133718. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  133719. /**
  133720. * Disposes of the pipeline
  133721. */
  133722. dispose(): void;
  133723. }
  133724. }
  133725. declare module BABYLON {
  133726. /**
  133727. * PostProcessRenderPipelineManager class
  133728. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133729. */
  133730. export class PostProcessRenderPipelineManager {
  133731. private _renderPipelines;
  133732. /**
  133733. * Initializes a PostProcessRenderPipelineManager
  133734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133735. */
  133736. constructor();
  133737. /**
  133738. * Gets the list of supported render pipelines
  133739. */
  133740. get supportedPipelines(): PostProcessRenderPipeline[];
  133741. /**
  133742. * Adds a pipeline to the manager
  133743. * @param renderPipeline The pipeline to add
  133744. */
  133745. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  133746. /**
  133747. * Attaches a camera to the pipeline
  133748. * @param renderPipelineName The name of the pipeline to attach to
  133749. * @param cameras the camera to attach
  133750. * @param unique if the camera can be attached multiple times to the pipeline
  133751. */
  133752. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  133753. /**
  133754. * Detaches a camera from the pipeline
  133755. * @param renderPipelineName The name of the pipeline to detach from
  133756. * @param cameras the camera to detach
  133757. */
  133758. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  133759. /**
  133760. * Enables an effect by name on a pipeline
  133761. * @param renderPipelineName the name of the pipeline to enable the effect in
  133762. * @param renderEffectName the name of the effect to enable
  133763. * @param cameras the cameras that the effect should be enabled on
  133764. */
  133765. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133766. /**
  133767. * Disables an effect by name on a pipeline
  133768. * @param renderPipelineName the name of the pipeline to disable the effect in
  133769. * @param renderEffectName the name of the effect to disable
  133770. * @param cameras the cameras that the effect should be disabled on
  133771. */
  133772. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133773. /**
  133774. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  133775. */
  133776. update(): void;
  133777. /** @hidden */
  133778. _rebuild(): void;
  133779. /**
  133780. * Disposes of the manager and pipelines
  133781. */
  133782. dispose(): void;
  133783. }
  133784. }
  133785. declare module BABYLON {
  133786. interface Scene {
  133787. /** @hidden (Backing field) */
  133788. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133789. /**
  133790. * Gets the postprocess render pipeline manager
  133791. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133792. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133793. */
  133794. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133795. }
  133796. /**
  133797. * Defines the Render Pipeline scene component responsible to rendering pipelines
  133798. */
  133799. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  133800. /**
  133801. * The component name helpfull to identify the component in the list of scene components.
  133802. */
  133803. readonly name: string;
  133804. /**
  133805. * The scene the component belongs to.
  133806. */
  133807. scene: Scene;
  133808. /**
  133809. * Creates a new instance of the component for the given scene
  133810. * @param scene Defines the scene to register the component in
  133811. */
  133812. constructor(scene: Scene);
  133813. /**
  133814. * Registers the component in a given scene
  133815. */
  133816. register(): void;
  133817. /**
  133818. * Rebuilds the elements related to this component in case of
  133819. * context lost for instance.
  133820. */
  133821. rebuild(): void;
  133822. /**
  133823. * Disposes the component and the associated ressources
  133824. */
  133825. dispose(): void;
  133826. private _gatherRenderTargets;
  133827. }
  133828. }
  133829. declare module BABYLON {
  133830. /**
  133831. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  133832. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133833. */
  133834. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  133835. private _scene;
  133836. private _camerasToBeAttached;
  133837. /**
  133838. * ID of the sharpen post process,
  133839. */
  133840. private readonly SharpenPostProcessId;
  133841. /**
  133842. * @ignore
  133843. * ID of the image processing post process;
  133844. */
  133845. readonly ImageProcessingPostProcessId: string;
  133846. /**
  133847. * @ignore
  133848. * ID of the Fast Approximate Anti-Aliasing post process;
  133849. */
  133850. readonly FxaaPostProcessId: string;
  133851. /**
  133852. * ID of the chromatic aberration post process,
  133853. */
  133854. private readonly ChromaticAberrationPostProcessId;
  133855. /**
  133856. * ID of the grain post process
  133857. */
  133858. private readonly GrainPostProcessId;
  133859. /**
  133860. * Sharpen post process which will apply a sharpen convolution to enhance edges
  133861. */
  133862. sharpen: SharpenPostProcess;
  133863. private _sharpenEffect;
  133864. private bloom;
  133865. /**
  133866. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  133867. */
  133868. depthOfField: DepthOfFieldEffect;
  133869. /**
  133870. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  133871. */
  133872. fxaa: FxaaPostProcess;
  133873. /**
  133874. * Image post processing pass used to perform operations such as tone mapping or color grading.
  133875. */
  133876. imageProcessing: ImageProcessingPostProcess;
  133877. /**
  133878. * Chromatic aberration post process which will shift rgb colors in the image
  133879. */
  133880. chromaticAberration: ChromaticAberrationPostProcess;
  133881. private _chromaticAberrationEffect;
  133882. /**
  133883. * Grain post process which add noise to the image
  133884. */
  133885. grain: GrainPostProcess;
  133886. private _grainEffect;
  133887. /**
  133888. * Glow post process which adds a glow to emissive areas of the image
  133889. */
  133890. private _glowLayer;
  133891. /**
  133892. * Animations which can be used to tweak settings over a period of time
  133893. */
  133894. animations: Animation[];
  133895. private _imageProcessingConfigurationObserver;
  133896. private _sharpenEnabled;
  133897. private _bloomEnabled;
  133898. private _depthOfFieldEnabled;
  133899. private _depthOfFieldBlurLevel;
  133900. private _fxaaEnabled;
  133901. private _imageProcessingEnabled;
  133902. private _defaultPipelineTextureType;
  133903. private _bloomScale;
  133904. private _chromaticAberrationEnabled;
  133905. private _grainEnabled;
  133906. private _buildAllowed;
  133907. /**
  133908. * Gets active scene
  133909. */
  133910. get scene(): Scene;
  133911. /**
  133912. * Enable or disable the sharpen process from the pipeline
  133913. */
  133914. set sharpenEnabled(enabled: boolean);
  133915. get sharpenEnabled(): boolean;
  133916. private _resizeObserver;
  133917. private _hardwareScaleLevel;
  133918. private _bloomKernel;
  133919. /**
  133920. * Specifies the size of the bloom blur kernel, relative to the final output size
  133921. */
  133922. get bloomKernel(): number;
  133923. set bloomKernel(value: number);
  133924. /**
  133925. * Specifies the weight of the bloom in the final rendering
  133926. */
  133927. private _bloomWeight;
  133928. /**
  133929. * Specifies the luma threshold for the area that will be blurred by the bloom
  133930. */
  133931. private _bloomThreshold;
  133932. private _hdr;
  133933. /**
  133934. * The strength of the bloom.
  133935. */
  133936. set bloomWeight(value: number);
  133937. get bloomWeight(): number;
  133938. /**
  133939. * The strength of the bloom.
  133940. */
  133941. set bloomThreshold(value: number);
  133942. get bloomThreshold(): number;
  133943. /**
  133944. * The scale of the bloom, lower value will provide better performance.
  133945. */
  133946. set bloomScale(value: number);
  133947. get bloomScale(): number;
  133948. /**
  133949. * Enable or disable the bloom from the pipeline
  133950. */
  133951. set bloomEnabled(enabled: boolean);
  133952. get bloomEnabled(): boolean;
  133953. private _rebuildBloom;
  133954. /**
  133955. * If the depth of field is enabled.
  133956. */
  133957. get depthOfFieldEnabled(): boolean;
  133958. set depthOfFieldEnabled(enabled: boolean);
  133959. /**
  133960. * Blur level of the depth of field effect. (Higher blur will effect performance)
  133961. */
  133962. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  133963. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  133964. /**
  133965. * If the anti aliasing is enabled.
  133966. */
  133967. set fxaaEnabled(enabled: boolean);
  133968. get fxaaEnabled(): boolean;
  133969. private _samples;
  133970. /**
  133971. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  133972. */
  133973. set samples(sampleCount: number);
  133974. get samples(): number;
  133975. /**
  133976. * If image processing is enabled.
  133977. */
  133978. set imageProcessingEnabled(enabled: boolean);
  133979. get imageProcessingEnabled(): boolean;
  133980. /**
  133981. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  133982. */
  133983. set glowLayerEnabled(enabled: boolean);
  133984. get glowLayerEnabled(): boolean;
  133985. /**
  133986. * Gets the glow layer (or null if not defined)
  133987. */
  133988. get glowLayer(): Nullable<GlowLayer>;
  133989. /**
  133990. * Enable or disable the chromaticAberration process from the pipeline
  133991. */
  133992. set chromaticAberrationEnabled(enabled: boolean);
  133993. get chromaticAberrationEnabled(): boolean;
  133994. /**
  133995. * Enable or disable the grain process from the pipeline
  133996. */
  133997. set grainEnabled(enabled: boolean);
  133998. get grainEnabled(): boolean;
  133999. /**
  134000. * @constructor
  134001. * @param name - The rendering pipeline name (default: "")
  134002. * @param hdr - If high dynamic range textures should be used (default: true)
  134003. * @param scene - The scene linked to this pipeline (default: the last created scene)
  134004. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  134005. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  134006. */
  134007. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  134008. /**
  134009. * Get the class name
  134010. * @returns "DefaultRenderingPipeline"
  134011. */
  134012. getClassName(): string;
  134013. /**
  134014. * Force the compilation of the entire pipeline.
  134015. */
  134016. prepare(): void;
  134017. private _hasCleared;
  134018. private _prevPostProcess;
  134019. private _prevPrevPostProcess;
  134020. private _setAutoClearAndTextureSharing;
  134021. private _depthOfFieldSceneObserver;
  134022. private _buildPipeline;
  134023. private _disposePostProcesses;
  134024. /**
  134025. * Adds a camera to the pipeline
  134026. * @param camera the camera to be added
  134027. */
  134028. addCamera(camera: Camera): void;
  134029. /**
  134030. * Removes a camera from the pipeline
  134031. * @param camera the camera to remove
  134032. */
  134033. removeCamera(camera: Camera): void;
  134034. /**
  134035. * Dispose of the pipeline and stop all post processes
  134036. */
  134037. dispose(): void;
  134038. /**
  134039. * Serialize the rendering pipeline (Used when exporting)
  134040. * @returns the serialized object
  134041. */
  134042. serialize(): any;
  134043. /**
  134044. * Parse the serialized pipeline
  134045. * @param source Source pipeline.
  134046. * @param scene The scene to load the pipeline to.
  134047. * @param rootUrl The URL of the serialized pipeline.
  134048. * @returns An instantiated pipeline from the serialized object.
  134049. */
  134050. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  134051. }
  134052. }
  134053. declare module BABYLON {
  134054. /** @hidden */
  134055. export var lensHighlightsPixelShader: {
  134056. name: string;
  134057. shader: string;
  134058. };
  134059. }
  134060. declare module BABYLON {
  134061. /** @hidden */
  134062. export var depthOfFieldPixelShader: {
  134063. name: string;
  134064. shader: string;
  134065. };
  134066. }
  134067. declare module BABYLON {
  134068. /**
  134069. * BABYLON.JS Chromatic Aberration GLSL Shader
  134070. * Author: Olivier Guyot
  134071. * Separates very slightly R, G and B colors on the edges of the screen
  134072. * Inspired by Francois Tarlier & Martins Upitis
  134073. */
  134074. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  134075. /**
  134076. * @ignore
  134077. * The chromatic aberration PostProcess id in the pipeline
  134078. */
  134079. LensChromaticAberrationEffect: string;
  134080. /**
  134081. * @ignore
  134082. * The highlights enhancing PostProcess id in the pipeline
  134083. */
  134084. HighlightsEnhancingEffect: string;
  134085. /**
  134086. * @ignore
  134087. * The depth-of-field PostProcess id in the pipeline
  134088. */
  134089. LensDepthOfFieldEffect: string;
  134090. private _scene;
  134091. private _depthTexture;
  134092. private _grainTexture;
  134093. private _chromaticAberrationPostProcess;
  134094. private _highlightsPostProcess;
  134095. private _depthOfFieldPostProcess;
  134096. private _edgeBlur;
  134097. private _grainAmount;
  134098. private _chromaticAberration;
  134099. private _distortion;
  134100. private _highlightsGain;
  134101. private _highlightsThreshold;
  134102. private _dofDistance;
  134103. private _dofAperture;
  134104. private _dofDarken;
  134105. private _dofPentagon;
  134106. private _blurNoise;
  134107. /**
  134108. * @constructor
  134109. *
  134110. * Effect parameters are as follow:
  134111. * {
  134112. * chromatic_aberration: number; // from 0 to x (1 for realism)
  134113. * edge_blur: number; // from 0 to x (1 for realism)
  134114. * distortion: number; // from 0 to x (1 for realism)
  134115. * grain_amount: number; // from 0 to 1
  134116. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  134117. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  134118. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  134119. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  134120. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  134121. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  134122. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  134123. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  134124. * }
  134125. * Note: if an effect parameter is unset, effect is disabled
  134126. *
  134127. * @param name The rendering pipeline name
  134128. * @param parameters - An object containing all parameters (see above)
  134129. * @param scene The scene linked to this pipeline
  134130. * @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)
  134131. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134132. */
  134133. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  134134. /**
  134135. * Get the class name
  134136. * @returns "LensRenderingPipeline"
  134137. */
  134138. getClassName(): string;
  134139. /**
  134140. * Gets associated scene
  134141. */
  134142. get scene(): Scene;
  134143. /**
  134144. * Gets or sets the edge blur
  134145. */
  134146. get edgeBlur(): number;
  134147. set edgeBlur(value: number);
  134148. /**
  134149. * Gets or sets the grain amount
  134150. */
  134151. get grainAmount(): number;
  134152. set grainAmount(value: number);
  134153. /**
  134154. * Gets or sets the chromatic aberration amount
  134155. */
  134156. get chromaticAberration(): number;
  134157. set chromaticAberration(value: number);
  134158. /**
  134159. * Gets or sets the depth of field aperture
  134160. */
  134161. get dofAperture(): number;
  134162. set dofAperture(value: number);
  134163. /**
  134164. * Gets or sets the edge distortion
  134165. */
  134166. get edgeDistortion(): number;
  134167. set edgeDistortion(value: number);
  134168. /**
  134169. * Gets or sets the depth of field distortion
  134170. */
  134171. get dofDistortion(): number;
  134172. set dofDistortion(value: number);
  134173. /**
  134174. * Gets or sets the darken out of focus amount
  134175. */
  134176. get darkenOutOfFocus(): number;
  134177. set darkenOutOfFocus(value: number);
  134178. /**
  134179. * Gets or sets a boolean indicating if blur noise is enabled
  134180. */
  134181. get blurNoise(): boolean;
  134182. set blurNoise(value: boolean);
  134183. /**
  134184. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  134185. */
  134186. get pentagonBokeh(): boolean;
  134187. set pentagonBokeh(value: boolean);
  134188. /**
  134189. * Gets or sets the highlight grain amount
  134190. */
  134191. get highlightsGain(): number;
  134192. set highlightsGain(value: number);
  134193. /**
  134194. * Gets or sets the highlight threshold
  134195. */
  134196. get highlightsThreshold(): number;
  134197. set highlightsThreshold(value: number);
  134198. /**
  134199. * Sets the amount of blur at the edges
  134200. * @param amount blur amount
  134201. */
  134202. setEdgeBlur(amount: number): void;
  134203. /**
  134204. * Sets edge blur to 0
  134205. */
  134206. disableEdgeBlur(): void;
  134207. /**
  134208. * Sets the amout of grain
  134209. * @param amount Amount of grain
  134210. */
  134211. setGrainAmount(amount: number): void;
  134212. /**
  134213. * Set grain amount to 0
  134214. */
  134215. disableGrain(): void;
  134216. /**
  134217. * Sets the chromatic aberration amount
  134218. * @param amount amount of chromatic aberration
  134219. */
  134220. setChromaticAberration(amount: number): void;
  134221. /**
  134222. * Sets chromatic aberration amount to 0
  134223. */
  134224. disableChromaticAberration(): void;
  134225. /**
  134226. * Sets the EdgeDistortion amount
  134227. * @param amount amount of EdgeDistortion
  134228. */
  134229. setEdgeDistortion(amount: number): void;
  134230. /**
  134231. * Sets edge distortion to 0
  134232. */
  134233. disableEdgeDistortion(): void;
  134234. /**
  134235. * Sets the FocusDistance amount
  134236. * @param amount amount of FocusDistance
  134237. */
  134238. setFocusDistance(amount: number): void;
  134239. /**
  134240. * Disables depth of field
  134241. */
  134242. disableDepthOfField(): void;
  134243. /**
  134244. * Sets the Aperture amount
  134245. * @param amount amount of Aperture
  134246. */
  134247. setAperture(amount: number): void;
  134248. /**
  134249. * Sets the DarkenOutOfFocus amount
  134250. * @param amount amount of DarkenOutOfFocus
  134251. */
  134252. setDarkenOutOfFocus(amount: number): void;
  134253. private _pentagonBokehIsEnabled;
  134254. /**
  134255. * Creates a pentagon bokeh effect
  134256. */
  134257. enablePentagonBokeh(): void;
  134258. /**
  134259. * Disables the pentagon bokeh effect
  134260. */
  134261. disablePentagonBokeh(): void;
  134262. /**
  134263. * Enables noise blur
  134264. */
  134265. enableNoiseBlur(): void;
  134266. /**
  134267. * Disables noise blur
  134268. */
  134269. disableNoiseBlur(): void;
  134270. /**
  134271. * Sets the HighlightsGain amount
  134272. * @param amount amount of HighlightsGain
  134273. */
  134274. setHighlightsGain(amount: number): void;
  134275. /**
  134276. * Sets the HighlightsThreshold amount
  134277. * @param amount amount of HighlightsThreshold
  134278. */
  134279. setHighlightsThreshold(amount: number): void;
  134280. /**
  134281. * Disables highlights
  134282. */
  134283. disableHighlights(): void;
  134284. /**
  134285. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  134286. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  134287. */
  134288. dispose(disableDepthRender?: boolean): void;
  134289. private _createChromaticAberrationPostProcess;
  134290. private _createHighlightsPostProcess;
  134291. private _createDepthOfFieldPostProcess;
  134292. private _createGrainTexture;
  134293. }
  134294. }
  134295. declare module BABYLON {
  134296. /** @hidden */
  134297. export var ssao2PixelShader: {
  134298. name: string;
  134299. shader: string;
  134300. };
  134301. }
  134302. declare module BABYLON {
  134303. /** @hidden */
  134304. export var ssaoCombinePixelShader: {
  134305. name: string;
  134306. shader: string;
  134307. };
  134308. }
  134309. declare module BABYLON {
  134310. /**
  134311. * Render pipeline to produce ssao effect
  134312. */
  134313. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  134314. /**
  134315. * @ignore
  134316. * The PassPostProcess id in the pipeline that contains the original scene color
  134317. */
  134318. SSAOOriginalSceneColorEffect: string;
  134319. /**
  134320. * @ignore
  134321. * The SSAO PostProcess id in the pipeline
  134322. */
  134323. SSAORenderEffect: string;
  134324. /**
  134325. * @ignore
  134326. * The horizontal blur PostProcess id in the pipeline
  134327. */
  134328. SSAOBlurHRenderEffect: string;
  134329. /**
  134330. * @ignore
  134331. * The vertical blur PostProcess id in the pipeline
  134332. */
  134333. SSAOBlurVRenderEffect: string;
  134334. /**
  134335. * @ignore
  134336. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134337. */
  134338. SSAOCombineRenderEffect: string;
  134339. /**
  134340. * The output strength of the SSAO post-process. Default value is 1.0.
  134341. */
  134342. totalStrength: number;
  134343. /**
  134344. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  134345. */
  134346. maxZ: number;
  134347. /**
  134348. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  134349. */
  134350. minZAspect: number;
  134351. private _samples;
  134352. /**
  134353. * Number of samples used for the SSAO calculations. Default value is 8
  134354. */
  134355. set samples(n: number);
  134356. get samples(): number;
  134357. private _textureSamples;
  134358. /**
  134359. * Number of samples to use for antialiasing
  134360. */
  134361. set textureSamples(n: number);
  134362. get textureSamples(): number;
  134363. /**
  134364. * Ratio object used for SSAO ratio and blur ratio
  134365. */
  134366. private _ratio;
  134367. /**
  134368. * Dynamically generated sphere sampler.
  134369. */
  134370. private _sampleSphere;
  134371. /**
  134372. * Blur filter offsets
  134373. */
  134374. private _samplerOffsets;
  134375. private _expensiveBlur;
  134376. /**
  134377. * If bilateral blur should be used
  134378. */
  134379. set expensiveBlur(b: boolean);
  134380. get expensiveBlur(): boolean;
  134381. /**
  134382. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  134383. */
  134384. radius: number;
  134385. /**
  134386. * The base color of the SSAO post-process
  134387. * The final result is "base + ssao" between [0, 1]
  134388. */
  134389. base: number;
  134390. /**
  134391. * Support test.
  134392. */
  134393. static get IsSupported(): boolean;
  134394. private _scene;
  134395. private _depthTexture;
  134396. private _normalTexture;
  134397. private _randomTexture;
  134398. private _originalColorPostProcess;
  134399. private _ssaoPostProcess;
  134400. private _blurHPostProcess;
  134401. private _blurVPostProcess;
  134402. private _ssaoCombinePostProcess;
  134403. /**
  134404. * Gets active scene
  134405. */
  134406. get scene(): Scene;
  134407. /**
  134408. * @constructor
  134409. * @param name The rendering pipeline name
  134410. * @param scene The scene linked to this pipeline
  134411. * @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 }
  134412. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134413. */
  134414. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134415. /**
  134416. * Get the class name
  134417. * @returns "SSAO2RenderingPipeline"
  134418. */
  134419. getClassName(): string;
  134420. /**
  134421. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134422. */
  134423. dispose(disableGeometryBufferRenderer?: boolean): void;
  134424. private _createBlurPostProcess;
  134425. /** @hidden */
  134426. _rebuild(): void;
  134427. private _bits;
  134428. private _radicalInverse_VdC;
  134429. private _hammersley;
  134430. private _hemisphereSample_uniform;
  134431. private _generateHemisphere;
  134432. private _createSSAOPostProcess;
  134433. private _createSSAOCombinePostProcess;
  134434. private _createRandomTexture;
  134435. /**
  134436. * Serialize the rendering pipeline (Used when exporting)
  134437. * @returns the serialized object
  134438. */
  134439. serialize(): any;
  134440. /**
  134441. * Parse the serialized pipeline
  134442. * @param source Source pipeline.
  134443. * @param scene The scene to load the pipeline to.
  134444. * @param rootUrl The URL of the serialized pipeline.
  134445. * @returns An instantiated pipeline from the serialized object.
  134446. */
  134447. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  134448. }
  134449. }
  134450. declare module BABYLON {
  134451. /** @hidden */
  134452. export var ssaoPixelShader: {
  134453. name: string;
  134454. shader: string;
  134455. };
  134456. }
  134457. declare module BABYLON {
  134458. /**
  134459. * Render pipeline to produce ssao effect
  134460. */
  134461. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  134462. /**
  134463. * @ignore
  134464. * The PassPostProcess id in the pipeline that contains the original scene color
  134465. */
  134466. SSAOOriginalSceneColorEffect: string;
  134467. /**
  134468. * @ignore
  134469. * The SSAO PostProcess id in the pipeline
  134470. */
  134471. SSAORenderEffect: string;
  134472. /**
  134473. * @ignore
  134474. * The horizontal blur PostProcess id in the pipeline
  134475. */
  134476. SSAOBlurHRenderEffect: string;
  134477. /**
  134478. * @ignore
  134479. * The vertical blur PostProcess id in the pipeline
  134480. */
  134481. SSAOBlurVRenderEffect: string;
  134482. /**
  134483. * @ignore
  134484. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134485. */
  134486. SSAOCombineRenderEffect: string;
  134487. /**
  134488. * The output strength of the SSAO post-process. Default value is 1.0.
  134489. */
  134490. totalStrength: number;
  134491. /**
  134492. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  134493. */
  134494. radius: number;
  134495. /**
  134496. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  134497. * Must not be equal to fallOff and superior to fallOff.
  134498. * Default value is 0.0075
  134499. */
  134500. area: number;
  134501. /**
  134502. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  134503. * Must not be equal to area and inferior to area.
  134504. * Default value is 0.000001
  134505. */
  134506. fallOff: number;
  134507. /**
  134508. * The base color of the SSAO post-process
  134509. * The final result is "base + ssao" between [0, 1]
  134510. */
  134511. base: number;
  134512. private _scene;
  134513. private _depthTexture;
  134514. private _randomTexture;
  134515. private _originalColorPostProcess;
  134516. private _ssaoPostProcess;
  134517. private _blurHPostProcess;
  134518. private _blurVPostProcess;
  134519. private _ssaoCombinePostProcess;
  134520. private _firstUpdate;
  134521. /**
  134522. * Gets active scene
  134523. */
  134524. get scene(): Scene;
  134525. /**
  134526. * @constructor
  134527. * @param name - The rendering pipeline name
  134528. * @param scene - The scene linked to this pipeline
  134529. * @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 }
  134530. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  134531. */
  134532. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134533. /**
  134534. * Get the class name
  134535. * @returns "SSAORenderingPipeline"
  134536. */
  134537. getClassName(): string;
  134538. /**
  134539. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134540. */
  134541. dispose(disableDepthRender?: boolean): void;
  134542. private _createBlurPostProcess;
  134543. /** @hidden */
  134544. _rebuild(): void;
  134545. private _createSSAOPostProcess;
  134546. private _createSSAOCombinePostProcess;
  134547. private _createRandomTexture;
  134548. }
  134549. }
  134550. declare module BABYLON {
  134551. /** @hidden */
  134552. export var standardPixelShader: {
  134553. name: string;
  134554. shader: string;
  134555. };
  134556. }
  134557. declare module BABYLON {
  134558. /**
  134559. * Standard rendering pipeline
  134560. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134561. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  134562. */
  134563. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  134564. /**
  134565. * Public members
  134566. */
  134567. /**
  134568. * Post-process which contains the original scene color before the pipeline applies all the effects
  134569. */
  134570. originalPostProcess: Nullable<PostProcess>;
  134571. /**
  134572. * Post-process used to down scale an image x4
  134573. */
  134574. downSampleX4PostProcess: Nullable<PostProcess>;
  134575. /**
  134576. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  134577. */
  134578. brightPassPostProcess: Nullable<PostProcess>;
  134579. /**
  134580. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  134581. */
  134582. blurHPostProcesses: PostProcess[];
  134583. /**
  134584. * Post-process array storing all the vertical blur post-processes used by the pipeline
  134585. */
  134586. blurVPostProcesses: PostProcess[];
  134587. /**
  134588. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  134589. */
  134590. textureAdderPostProcess: Nullable<PostProcess>;
  134591. /**
  134592. * Post-process used to create volumetric lighting effect
  134593. */
  134594. volumetricLightPostProcess: Nullable<PostProcess>;
  134595. /**
  134596. * Post-process used to smooth the previous volumetric light post-process on the X axis
  134597. */
  134598. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  134599. /**
  134600. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  134601. */
  134602. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  134603. /**
  134604. * Post-process used to merge the volumetric light effect and the real scene color
  134605. */
  134606. volumetricLightMergePostProces: Nullable<PostProcess>;
  134607. /**
  134608. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  134609. */
  134610. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  134611. /**
  134612. * Base post-process used to calculate the average luminance of the final image for HDR
  134613. */
  134614. luminancePostProcess: Nullable<PostProcess>;
  134615. /**
  134616. * Post-processes used to create down sample post-processes in order to get
  134617. * the average luminance of the final image for HDR
  134618. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  134619. */
  134620. luminanceDownSamplePostProcesses: PostProcess[];
  134621. /**
  134622. * Post-process used to create a HDR effect (light adaptation)
  134623. */
  134624. hdrPostProcess: Nullable<PostProcess>;
  134625. /**
  134626. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  134627. */
  134628. textureAdderFinalPostProcess: Nullable<PostProcess>;
  134629. /**
  134630. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  134631. */
  134632. lensFlareFinalPostProcess: Nullable<PostProcess>;
  134633. /**
  134634. * Post-process used to merge the final HDR post-process and the real scene color
  134635. */
  134636. hdrFinalPostProcess: Nullable<PostProcess>;
  134637. /**
  134638. * Post-process used to create a lens flare effect
  134639. */
  134640. lensFlarePostProcess: Nullable<PostProcess>;
  134641. /**
  134642. * Post-process that merges the result of the lens flare post-process and the real scene color
  134643. */
  134644. lensFlareComposePostProcess: Nullable<PostProcess>;
  134645. /**
  134646. * Post-process used to create a motion blur effect
  134647. */
  134648. motionBlurPostProcess: Nullable<PostProcess>;
  134649. /**
  134650. * Post-process used to create a depth of field effect
  134651. */
  134652. depthOfFieldPostProcess: Nullable<PostProcess>;
  134653. /**
  134654. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134655. */
  134656. fxaaPostProcess: Nullable<FxaaPostProcess>;
  134657. /**
  134658. * Represents the brightness threshold in order to configure the illuminated surfaces
  134659. */
  134660. brightThreshold: number;
  134661. /**
  134662. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  134663. */
  134664. blurWidth: number;
  134665. /**
  134666. * Sets if the blur for highlighted surfaces must be only horizontal
  134667. */
  134668. horizontalBlur: boolean;
  134669. /**
  134670. * Gets the overall exposure used by the pipeline
  134671. */
  134672. get exposure(): number;
  134673. /**
  134674. * Sets the overall exposure used by the pipeline
  134675. */
  134676. set exposure(value: number);
  134677. /**
  134678. * Texture used typically to simulate "dirty" on camera lens
  134679. */
  134680. lensTexture: Nullable<Texture>;
  134681. /**
  134682. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  134683. */
  134684. volumetricLightCoefficient: number;
  134685. /**
  134686. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  134687. */
  134688. volumetricLightPower: number;
  134689. /**
  134690. * Used the set the blur intensity to smooth the volumetric lights
  134691. */
  134692. volumetricLightBlurScale: number;
  134693. /**
  134694. * Light (spot or directional) used to generate the volumetric lights rays
  134695. * The source light must have a shadow generate so the pipeline can get its
  134696. * depth map
  134697. */
  134698. sourceLight: Nullable<SpotLight | DirectionalLight>;
  134699. /**
  134700. * For eye adaptation, represents the minimum luminance the eye can see
  134701. */
  134702. hdrMinimumLuminance: number;
  134703. /**
  134704. * For eye adaptation, represents the decrease luminance speed
  134705. */
  134706. hdrDecreaseRate: number;
  134707. /**
  134708. * For eye adaptation, represents the increase luminance speed
  134709. */
  134710. hdrIncreaseRate: number;
  134711. /**
  134712. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134713. */
  134714. get hdrAutoExposure(): boolean;
  134715. /**
  134716. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134717. */
  134718. set hdrAutoExposure(value: boolean);
  134719. /**
  134720. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  134721. */
  134722. lensColorTexture: Nullable<Texture>;
  134723. /**
  134724. * The overall strengh for the lens flare effect
  134725. */
  134726. lensFlareStrength: number;
  134727. /**
  134728. * Dispersion coefficient for lens flare ghosts
  134729. */
  134730. lensFlareGhostDispersal: number;
  134731. /**
  134732. * Main lens flare halo width
  134733. */
  134734. lensFlareHaloWidth: number;
  134735. /**
  134736. * Based on the lens distortion effect, defines how much the lens flare result
  134737. * is distorted
  134738. */
  134739. lensFlareDistortionStrength: number;
  134740. /**
  134741. * Configures the blur intensity used for for lens flare (halo)
  134742. */
  134743. lensFlareBlurWidth: number;
  134744. /**
  134745. * Lens star texture must be used to simulate rays on the flares and is available
  134746. * in the documentation
  134747. */
  134748. lensStarTexture: Nullable<Texture>;
  134749. /**
  134750. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  134751. * flare effect by taking account of the dirt texture
  134752. */
  134753. lensFlareDirtTexture: Nullable<Texture>;
  134754. /**
  134755. * Represents the focal length for the depth of field effect
  134756. */
  134757. depthOfFieldDistance: number;
  134758. /**
  134759. * Represents the blur intensity for the blurred part of the depth of field effect
  134760. */
  134761. depthOfFieldBlurWidth: number;
  134762. /**
  134763. * Gets how much the image is blurred by the movement while using the motion blur post-process
  134764. */
  134765. get motionStrength(): number;
  134766. /**
  134767. * Sets how much the image is blurred by the movement while using the motion blur post-process
  134768. */
  134769. set motionStrength(strength: number);
  134770. /**
  134771. * Gets wether or not the motion blur post-process is object based or screen based.
  134772. */
  134773. get objectBasedMotionBlur(): boolean;
  134774. /**
  134775. * Sets wether or not the motion blur post-process should be object based or screen based
  134776. */
  134777. set objectBasedMotionBlur(value: boolean);
  134778. /**
  134779. * List of animations for the pipeline (IAnimatable implementation)
  134780. */
  134781. animations: Animation[];
  134782. /**
  134783. * Private members
  134784. */
  134785. private _scene;
  134786. private _currentDepthOfFieldSource;
  134787. private _basePostProcess;
  134788. private _fixedExposure;
  134789. private _currentExposure;
  134790. private _hdrAutoExposure;
  134791. private _hdrCurrentLuminance;
  134792. private _motionStrength;
  134793. private _isObjectBasedMotionBlur;
  134794. private _floatTextureType;
  134795. private _camerasToBeAttached;
  134796. private _ratio;
  134797. private _bloomEnabled;
  134798. private _depthOfFieldEnabled;
  134799. private _vlsEnabled;
  134800. private _lensFlareEnabled;
  134801. private _hdrEnabled;
  134802. private _motionBlurEnabled;
  134803. private _fxaaEnabled;
  134804. private _motionBlurSamples;
  134805. private _volumetricLightStepsCount;
  134806. private _samples;
  134807. /**
  134808. * @ignore
  134809. * Specifies if the bloom pipeline is enabled
  134810. */
  134811. get BloomEnabled(): boolean;
  134812. set BloomEnabled(enabled: boolean);
  134813. /**
  134814. * @ignore
  134815. * Specifies if the depth of field pipeline is enabed
  134816. */
  134817. get DepthOfFieldEnabled(): boolean;
  134818. set DepthOfFieldEnabled(enabled: boolean);
  134819. /**
  134820. * @ignore
  134821. * Specifies if the lens flare pipeline is enabed
  134822. */
  134823. get LensFlareEnabled(): boolean;
  134824. set LensFlareEnabled(enabled: boolean);
  134825. /**
  134826. * @ignore
  134827. * Specifies if the HDR pipeline is enabled
  134828. */
  134829. get HDREnabled(): boolean;
  134830. set HDREnabled(enabled: boolean);
  134831. /**
  134832. * @ignore
  134833. * Specifies if the volumetric lights scattering effect is enabled
  134834. */
  134835. get VLSEnabled(): boolean;
  134836. set VLSEnabled(enabled: boolean);
  134837. /**
  134838. * @ignore
  134839. * Specifies if the motion blur effect is enabled
  134840. */
  134841. get MotionBlurEnabled(): boolean;
  134842. set MotionBlurEnabled(enabled: boolean);
  134843. /**
  134844. * Specifies if anti-aliasing is enabled
  134845. */
  134846. get fxaaEnabled(): boolean;
  134847. set fxaaEnabled(enabled: boolean);
  134848. /**
  134849. * Specifies the number of steps used to calculate the volumetric lights
  134850. * Typically in interval [50, 200]
  134851. */
  134852. get volumetricLightStepsCount(): number;
  134853. set volumetricLightStepsCount(count: number);
  134854. /**
  134855. * Specifies the number of samples used for the motion blur effect
  134856. * Typically in interval [16, 64]
  134857. */
  134858. get motionBlurSamples(): number;
  134859. set motionBlurSamples(samples: number);
  134860. /**
  134861. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  134862. */
  134863. get samples(): number;
  134864. set samples(sampleCount: number);
  134865. /**
  134866. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134867. * @constructor
  134868. * @param name The rendering pipeline name
  134869. * @param scene The scene linked to this pipeline
  134870. * @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)
  134871. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  134872. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134873. */
  134874. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  134875. private _buildPipeline;
  134876. private _createDownSampleX4PostProcess;
  134877. private _createBrightPassPostProcess;
  134878. private _createBlurPostProcesses;
  134879. private _createTextureAdderPostProcess;
  134880. private _createVolumetricLightPostProcess;
  134881. private _createLuminancePostProcesses;
  134882. private _createHdrPostProcess;
  134883. private _createLensFlarePostProcess;
  134884. private _createDepthOfFieldPostProcess;
  134885. private _createMotionBlurPostProcess;
  134886. private _getDepthTexture;
  134887. private _disposePostProcesses;
  134888. /**
  134889. * Dispose of the pipeline and stop all post processes
  134890. */
  134891. dispose(): void;
  134892. /**
  134893. * Serialize the rendering pipeline (Used when exporting)
  134894. * @returns the serialized object
  134895. */
  134896. serialize(): any;
  134897. /**
  134898. * Parse the serialized pipeline
  134899. * @param source Source pipeline.
  134900. * @param scene The scene to load the pipeline to.
  134901. * @param rootUrl The URL of the serialized pipeline.
  134902. * @returns An instantiated pipeline from the serialized object.
  134903. */
  134904. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  134905. /**
  134906. * Luminance steps
  134907. */
  134908. static LuminanceSteps: number;
  134909. }
  134910. }
  134911. declare module BABYLON {
  134912. /** @hidden */
  134913. export var tonemapPixelShader: {
  134914. name: string;
  134915. shader: string;
  134916. };
  134917. }
  134918. declare module BABYLON {
  134919. /** Defines operator used for tonemapping */
  134920. export enum TonemappingOperator {
  134921. /** Hable */
  134922. Hable = 0,
  134923. /** Reinhard */
  134924. Reinhard = 1,
  134925. /** HejiDawson */
  134926. HejiDawson = 2,
  134927. /** Photographic */
  134928. Photographic = 3
  134929. }
  134930. /**
  134931. * Defines a post process to apply tone mapping
  134932. */
  134933. export class TonemapPostProcess extends PostProcess {
  134934. private _operator;
  134935. /** Defines the required exposure adjustement */
  134936. exposureAdjustment: number;
  134937. /**
  134938. * Creates a new TonemapPostProcess
  134939. * @param name defines the name of the postprocess
  134940. * @param _operator defines the operator to use
  134941. * @param exposureAdjustment defines the required exposure adjustement
  134942. * @param camera defines the camera to use (can be null)
  134943. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  134944. * @param engine defines the hosting engine (can be ignore if camera is set)
  134945. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  134946. */
  134947. constructor(name: string, _operator: TonemappingOperator,
  134948. /** Defines the required exposure adjustement */
  134949. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  134950. }
  134951. }
  134952. declare module BABYLON {
  134953. /** @hidden */
  134954. export var depthVertexShader: {
  134955. name: string;
  134956. shader: string;
  134957. };
  134958. }
  134959. declare module BABYLON {
  134960. /** @hidden */
  134961. export var volumetricLightScatteringPixelShader: {
  134962. name: string;
  134963. shader: string;
  134964. };
  134965. }
  134966. declare module BABYLON {
  134967. /** @hidden */
  134968. export var volumetricLightScatteringPassVertexShader: {
  134969. name: string;
  134970. shader: string;
  134971. };
  134972. }
  134973. declare module BABYLON {
  134974. /** @hidden */
  134975. export var volumetricLightScatteringPassPixelShader: {
  134976. name: string;
  134977. shader: string;
  134978. };
  134979. }
  134980. declare module BABYLON {
  134981. /**
  134982. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  134983. */
  134984. export class VolumetricLightScatteringPostProcess extends PostProcess {
  134985. private _volumetricLightScatteringPass;
  134986. private _volumetricLightScatteringRTT;
  134987. private _viewPort;
  134988. private _screenCoordinates;
  134989. private _cachedDefines;
  134990. /**
  134991. * If not undefined, the mesh position is computed from the attached node position
  134992. */
  134993. attachedNode: {
  134994. position: Vector3;
  134995. };
  134996. /**
  134997. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  134998. */
  134999. customMeshPosition: Vector3;
  135000. /**
  135001. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  135002. */
  135003. useCustomMeshPosition: boolean;
  135004. /**
  135005. * If the post-process should inverse the light scattering direction
  135006. */
  135007. invert: boolean;
  135008. /**
  135009. * The internal mesh used by the post-process
  135010. */
  135011. mesh: Mesh;
  135012. /**
  135013. * @hidden
  135014. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  135015. */
  135016. get useDiffuseColor(): boolean;
  135017. set useDiffuseColor(useDiffuseColor: boolean);
  135018. /**
  135019. * Array containing the excluded meshes not rendered in the internal pass
  135020. */
  135021. excludedMeshes: AbstractMesh[];
  135022. /**
  135023. * Controls the overall intensity of the post-process
  135024. */
  135025. exposure: number;
  135026. /**
  135027. * Dissipates each sample's contribution in range [0, 1]
  135028. */
  135029. decay: number;
  135030. /**
  135031. * Controls the overall intensity of each sample
  135032. */
  135033. weight: number;
  135034. /**
  135035. * Controls the density of each sample
  135036. */
  135037. density: number;
  135038. /**
  135039. * @constructor
  135040. * @param name The post-process name
  135041. * @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)
  135042. * @param camera The camera that the post-process will be attached to
  135043. * @param mesh The mesh used to create the light scattering
  135044. * @param samples The post-process quality, default 100
  135045. * @param samplingModeThe post-process filtering mode
  135046. * @param engine The babylon engine
  135047. * @param reusable If the post-process is reusable
  135048. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  135049. */
  135050. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  135051. /**
  135052. * Returns the string "VolumetricLightScatteringPostProcess"
  135053. * @returns "VolumetricLightScatteringPostProcess"
  135054. */
  135055. getClassName(): string;
  135056. private _isReady;
  135057. /**
  135058. * Sets the new light position for light scattering effect
  135059. * @param position The new custom light position
  135060. */
  135061. setCustomMeshPosition(position: Vector3): void;
  135062. /**
  135063. * Returns the light position for light scattering effect
  135064. * @return Vector3 The custom light position
  135065. */
  135066. getCustomMeshPosition(): Vector3;
  135067. /**
  135068. * Disposes the internal assets and detaches the post-process from the camera
  135069. */
  135070. dispose(camera: Camera): void;
  135071. /**
  135072. * Returns the render target texture used by the post-process
  135073. * @return the render target texture used by the post-process
  135074. */
  135075. getPass(): RenderTargetTexture;
  135076. private _meshExcluded;
  135077. private _createPass;
  135078. private _updateMeshScreenCoordinates;
  135079. /**
  135080. * Creates a default mesh for the Volumeric Light Scattering post-process
  135081. * @param name The mesh name
  135082. * @param scene The scene where to create the mesh
  135083. * @return the default mesh
  135084. */
  135085. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  135086. }
  135087. }
  135088. declare module BABYLON {
  135089. interface Scene {
  135090. /** @hidden (Backing field) */
  135091. _boundingBoxRenderer: BoundingBoxRenderer;
  135092. /** @hidden (Backing field) */
  135093. _forceShowBoundingBoxes: boolean;
  135094. /**
  135095. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  135096. */
  135097. forceShowBoundingBoxes: boolean;
  135098. /**
  135099. * Gets the bounding box renderer associated with the scene
  135100. * @returns a BoundingBoxRenderer
  135101. */
  135102. getBoundingBoxRenderer(): BoundingBoxRenderer;
  135103. }
  135104. interface AbstractMesh {
  135105. /** @hidden (Backing field) */
  135106. _showBoundingBox: boolean;
  135107. /**
  135108. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  135109. */
  135110. showBoundingBox: boolean;
  135111. }
  135112. /**
  135113. * Component responsible of rendering the bounding box of the meshes in a scene.
  135114. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  135115. */
  135116. export class BoundingBoxRenderer implements ISceneComponent {
  135117. /**
  135118. * The component name helpfull to identify the component in the list of scene components.
  135119. */
  135120. readonly name: string;
  135121. /**
  135122. * The scene the component belongs to.
  135123. */
  135124. scene: Scene;
  135125. /**
  135126. * Color of the bounding box lines placed in front of an object
  135127. */
  135128. frontColor: Color3;
  135129. /**
  135130. * Color of the bounding box lines placed behind an object
  135131. */
  135132. backColor: Color3;
  135133. /**
  135134. * Defines if the renderer should show the back lines or not
  135135. */
  135136. showBackLines: boolean;
  135137. /**
  135138. * @hidden
  135139. */
  135140. renderList: SmartArray<BoundingBox>;
  135141. private _colorShader;
  135142. private _vertexBuffers;
  135143. private _indexBuffer;
  135144. private _fillIndexBuffer;
  135145. private _fillIndexData;
  135146. /**
  135147. * Instantiates a new bounding box renderer in a scene.
  135148. * @param scene the scene the renderer renders in
  135149. */
  135150. constructor(scene: Scene);
  135151. /**
  135152. * Registers the component in a given scene
  135153. */
  135154. register(): void;
  135155. private _evaluateSubMesh;
  135156. private _activeMesh;
  135157. private _prepareRessources;
  135158. private _createIndexBuffer;
  135159. /**
  135160. * Rebuilds the elements related to this component in case of
  135161. * context lost for instance.
  135162. */
  135163. rebuild(): void;
  135164. /**
  135165. * @hidden
  135166. */
  135167. reset(): void;
  135168. /**
  135169. * Render the bounding boxes of a specific rendering group
  135170. * @param renderingGroupId defines the rendering group to render
  135171. */
  135172. render(renderingGroupId: number): void;
  135173. /**
  135174. * In case of occlusion queries, we can render the occlusion bounding box through this method
  135175. * @param mesh Define the mesh to render the occlusion bounding box for
  135176. */
  135177. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  135178. /**
  135179. * Dispose and release the resources attached to this renderer.
  135180. */
  135181. dispose(): void;
  135182. }
  135183. }
  135184. declare module BABYLON {
  135185. /** @hidden */
  135186. export var depthPixelShader: {
  135187. name: string;
  135188. shader: string;
  135189. };
  135190. }
  135191. declare module BABYLON {
  135192. /**
  135193. * This represents a depth renderer in Babylon.
  135194. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135195. */
  135196. export class DepthRenderer {
  135197. private _scene;
  135198. private _depthMap;
  135199. private _effect;
  135200. private readonly _storeNonLinearDepth;
  135201. private readonly _clearColor;
  135202. /** Get if the depth renderer is using packed depth or not */
  135203. readonly isPacked: boolean;
  135204. private _cachedDefines;
  135205. private _camera;
  135206. /**
  135207. * Specifiess that the depth renderer will only be used within
  135208. * the camera it is created for.
  135209. * This can help forcing its rendering during the camera processing.
  135210. */
  135211. useOnlyInActiveCamera: boolean;
  135212. /** @hidden */
  135213. static _SceneComponentInitialization: (scene: Scene) => void;
  135214. /**
  135215. * Instantiates a depth renderer
  135216. * @param scene The scene the renderer belongs to
  135217. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135218. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135219. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135220. */
  135221. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135222. /**
  135223. * Creates the depth rendering effect and checks if the effect is ready.
  135224. * @param subMesh The submesh to be used to render the depth map of
  135225. * @param useInstances If multiple world instances should be used
  135226. * @returns if the depth renderer is ready to render the depth map
  135227. */
  135228. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135229. /**
  135230. * Gets the texture which the depth map will be written to.
  135231. * @returns The depth map texture
  135232. */
  135233. getDepthMap(): RenderTargetTexture;
  135234. /**
  135235. * Disposes of the depth renderer.
  135236. */
  135237. dispose(): void;
  135238. }
  135239. }
  135240. declare module BABYLON {
  135241. interface Scene {
  135242. /** @hidden (Backing field) */
  135243. _depthRenderer: {
  135244. [id: string]: DepthRenderer;
  135245. };
  135246. /**
  135247. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  135248. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  135249. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135250. * @returns the created depth renderer
  135251. */
  135252. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  135253. /**
  135254. * Disables a depth renderer for a given camera
  135255. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  135256. */
  135257. disableDepthRenderer(camera?: Nullable<Camera>): void;
  135258. }
  135259. /**
  135260. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  135261. * in several rendering techniques.
  135262. */
  135263. export class DepthRendererSceneComponent implements ISceneComponent {
  135264. /**
  135265. * The component name helpfull to identify the component in the list of scene components.
  135266. */
  135267. readonly name: string;
  135268. /**
  135269. * The scene the component belongs to.
  135270. */
  135271. scene: Scene;
  135272. /**
  135273. * Creates a new instance of the component for the given scene
  135274. * @param scene Defines the scene to register the component in
  135275. */
  135276. constructor(scene: Scene);
  135277. /**
  135278. * Registers the component in a given scene
  135279. */
  135280. register(): void;
  135281. /**
  135282. * Rebuilds the elements related to this component in case of
  135283. * context lost for instance.
  135284. */
  135285. rebuild(): void;
  135286. /**
  135287. * Disposes the component and the associated ressources
  135288. */
  135289. dispose(): void;
  135290. private _gatherRenderTargets;
  135291. private _gatherActiveCameraRenderTargets;
  135292. }
  135293. }
  135294. declare module BABYLON {
  135295. /** @hidden */
  135296. export var outlinePixelShader: {
  135297. name: string;
  135298. shader: string;
  135299. };
  135300. }
  135301. declare module BABYLON {
  135302. /** @hidden */
  135303. export var outlineVertexShader: {
  135304. name: string;
  135305. shader: string;
  135306. };
  135307. }
  135308. declare module BABYLON {
  135309. interface Scene {
  135310. /** @hidden */
  135311. _outlineRenderer: OutlineRenderer;
  135312. /**
  135313. * Gets the outline renderer associated with the scene
  135314. * @returns a OutlineRenderer
  135315. */
  135316. getOutlineRenderer(): OutlineRenderer;
  135317. }
  135318. interface AbstractMesh {
  135319. /** @hidden (Backing field) */
  135320. _renderOutline: boolean;
  135321. /**
  135322. * Gets or sets a boolean indicating if the outline must be rendered as well
  135323. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  135324. */
  135325. renderOutline: boolean;
  135326. /** @hidden (Backing field) */
  135327. _renderOverlay: boolean;
  135328. /**
  135329. * Gets or sets a boolean indicating if the overlay must be rendered as well
  135330. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  135331. */
  135332. renderOverlay: boolean;
  135333. }
  135334. /**
  135335. * This class is responsible to draw bothe outline/overlay of meshes.
  135336. * It should not be used directly but through the available method on mesh.
  135337. */
  135338. export class OutlineRenderer implements ISceneComponent {
  135339. /**
  135340. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  135341. */
  135342. private static _StencilReference;
  135343. /**
  135344. * The name of the component. Each component must have a unique name.
  135345. */
  135346. name: string;
  135347. /**
  135348. * The scene the component belongs to.
  135349. */
  135350. scene: Scene;
  135351. /**
  135352. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  135353. */
  135354. zOffset: number;
  135355. private _engine;
  135356. private _effect;
  135357. private _cachedDefines;
  135358. private _savedDepthWrite;
  135359. /**
  135360. * Instantiates a new outline renderer. (There could be only one per scene).
  135361. * @param scene Defines the scene it belongs to
  135362. */
  135363. constructor(scene: Scene);
  135364. /**
  135365. * Register the component to one instance of a scene.
  135366. */
  135367. register(): void;
  135368. /**
  135369. * Rebuilds the elements related to this component in case of
  135370. * context lost for instance.
  135371. */
  135372. rebuild(): void;
  135373. /**
  135374. * Disposes the component and the associated ressources.
  135375. */
  135376. dispose(): void;
  135377. /**
  135378. * Renders the outline in the canvas.
  135379. * @param subMesh Defines the sumesh to render
  135380. * @param batch Defines the batch of meshes in case of instances
  135381. * @param useOverlay Defines if the rendering is for the overlay or the outline
  135382. */
  135383. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  135384. /**
  135385. * Returns whether or not the outline renderer is ready for a given submesh.
  135386. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  135387. * @param subMesh Defines the submesh to check readyness for
  135388. * @param useInstances Defines wheter wee are trying to render instances or not
  135389. * @returns true if ready otherwise false
  135390. */
  135391. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135392. private _beforeRenderingMesh;
  135393. private _afterRenderingMesh;
  135394. }
  135395. }
  135396. declare module BABYLON {
  135397. /**
  135398. * Defines the basic options interface of a Sprite Frame Source Size.
  135399. */
  135400. export interface ISpriteJSONSpriteSourceSize {
  135401. /**
  135402. * number of the original width of the Frame
  135403. */
  135404. w: number;
  135405. /**
  135406. * number of the original height of the Frame
  135407. */
  135408. h: number;
  135409. }
  135410. /**
  135411. * Defines the basic options interface of a Sprite Frame Data.
  135412. */
  135413. export interface ISpriteJSONSpriteFrameData {
  135414. /**
  135415. * number of the x offset of the Frame
  135416. */
  135417. x: number;
  135418. /**
  135419. * number of the y offset of the Frame
  135420. */
  135421. y: number;
  135422. /**
  135423. * number of the width of the Frame
  135424. */
  135425. w: number;
  135426. /**
  135427. * number of the height of the Frame
  135428. */
  135429. h: number;
  135430. }
  135431. /**
  135432. * Defines the basic options interface of a JSON Sprite.
  135433. */
  135434. export interface ISpriteJSONSprite {
  135435. /**
  135436. * string name of the Frame
  135437. */
  135438. filename: string;
  135439. /**
  135440. * ISpriteJSONSpriteFrame basic object of the frame data
  135441. */
  135442. frame: ISpriteJSONSpriteFrameData;
  135443. /**
  135444. * boolean to flag is the frame was rotated.
  135445. */
  135446. rotated: boolean;
  135447. /**
  135448. * boolean to flag is the frame was trimmed.
  135449. */
  135450. trimmed: boolean;
  135451. /**
  135452. * ISpriteJSONSpriteFrame basic object of the source data
  135453. */
  135454. spriteSourceSize: ISpriteJSONSpriteFrameData;
  135455. /**
  135456. * ISpriteJSONSpriteFrame basic object of the source data
  135457. */
  135458. sourceSize: ISpriteJSONSpriteSourceSize;
  135459. }
  135460. /**
  135461. * Defines the basic options interface of a JSON atlas.
  135462. */
  135463. export interface ISpriteJSONAtlas {
  135464. /**
  135465. * Array of objects that contain the frame data.
  135466. */
  135467. frames: Array<ISpriteJSONSprite>;
  135468. /**
  135469. * object basic object containing the sprite meta data.
  135470. */
  135471. meta?: object;
  135472. }
  135473. }
  135474. declare module BABYLON {
  135475. /** @hidden */
  135476. export var spriteMapPixelShader: {
  135477. name: string;
  135478. shader: string;
  135479. };
  135480. }
  135481. declare module BABYLON {
  135482. /** @hidden */
  135483. export var spriteMapVertexShader: {
  135484. name: string;
  135485. shader: string;
  135486. };
  135487. }
  135488. declare module BABYLON {
  135489. /**
  135490. * Defines the basic options interface of a SpriteMap
  135491. */
  135492. export interface ISpriteMapOptions {
  135493. /**
  135494. * Vector2 of the number of cells in the grid.
  135495. */
  135496. stageSize?: Vector2;
  135497. /**
  135498. * Vector2 of the size of the output plane in World Units.
  135499. */
  135500. outputSize?: Vector2;
  135501. /**
  135502. * Vector3 of the position of the output plane in World Units.
  135503. */
  135504. outputPosition?: Vector3;
  135505. /**
  135506. * Vector3 of the rotation of the output plane.
  135507. */
  135508. outputRotation?: Vector3;
  135509. /**
  135510. * number of layers that the system will reserve in resources.
  135511. */
  135512. layerCount?: number;
  135513. /**
  135514. * number of max animation frames a single cell will reserve in resources.
  135515. */
  135516. maxAnimationFrames?: number;
  135517. /**
  135518. * number cell index of the base tile when the system compiles.
  135519. */
  135520. baseTile?: number;
  135521. /**
  135522. * boolean flip the sprite after its been repositioned by the framing data.
  135523. */
  135524. flipU?: boolean;
  135525. /**
  135526. * Vector3 scalar of the global RGB values of the SpriteMap.
  135527. */
  135528. colorMultiply?: Vector3;
  135529. }
  135530. /**
  135531. * Defines the IDisposable interface in order to be cleanable from resources.
  135532. */
  135533. export interface ISpriteMap extends IDisposable {
  135534. /**
  135535. * String name of the SpriteMap.
  135536. */
  135537. name: string;
  135538. /**
  135539. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  135540. */
  135541. atlasJSON: ISpriteJSONAtlas;
  135542. /**
  135543. * Texture of the SpriteMap.
  135544. */
  135545. spriteSheet: Texture;
  135546. /**
  135547. * The parameters to initialize the SpriteMap with.
  135548. */
  135549. options: ISpriteMapOptions;
  135550. }
  135551. /**
  135552. * Class used to manage a grid restricted sprite deployment on an Output plane.
  135553. */
  135554. export class SpriteMap implements ISpriteMap {
  135555. /** The Name of the spriteMap */
  135556. name: string;
  135557. /** The JSON file with the frame and meta data */
  135558. atlasJSON: ISpriteJSONAtlas;
  135559. /** The systems Sprite Sheet Texture */
  135560. spriteSheet: Texture;
  135561. /** Arguments passed with the Constructor */
  135562. options: ISpriteMapOptions;
  135563. /** Public Sprite Storage array, parsed from atlasJSON */
  135564. sprites: Array<ISpriteJSONSprite>;
  135565. /** Returns the Number of Sprites in the System */
  135566. get spriteCount(): number;
  135567. /** Returns the Position of Output Plane*/
  135568. get position(): Vector3;
  135569. /** Returns the Position of Output Plane*/
  135570. set position(v: Vector3);
  135571. /** Returns the Rotation of Output Plane*/
  135572. get rotation(): Vector3;
  135573. /** Returns the Rotation of Output Plane*/
  135574. set rotation(v: Vector3);
  135575. /** Sets the AnimationMap*/
  135576. get animationMap(): RawTexture;
  135577. /** Sets the AnimationMap*/
  135578. set animationMap(v: RawTexture);
  135579. /** Scene that the SpriteMap was created in */
  135580. private _scene;
  135581. /** Texture Buffer of Float32 that holds tile frame data*/
  135582. private _frameMap;
  135583. /** Texture Buffers of Float32 that holds tileMap data*/
  135584. private _tileMaps;
  135585. /** Texture Buffer of Float32 that holds Animation Data*/
  135586. private _animationMap;
  135587. /** Custom ShaderMaterial Central to the System*/
  135588. private _material;
  135589. /** Custom ShaderMaterial Central to the System*/
  135590. private _output;
  135591. /** Systems Time Ticker*/
  135592. private _time;
  135593. /**
  135594. * Creates a new SpriteMap
  135595. * @param name defines the SpriteMaps Name
  135596. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  135597. * @param spriteSheet is the Texture that the Sprites are on.
  135598. * @param options a basic deployment configuration
  135599. * @param scene The Scene that the map is deployed on
  135600. */
  135601. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  135602. /**
  135603. * Returns tileID location
  135604. * @returns Vector2 the cell position ID
  135605. */
  135606. getTileID(): Vector2;
  135607. /**
  135608. * Gets the UV location of the mouse over the SpriteMap.
  135609. * @returns Vector2 the UV position of the mouse interaction
  135610. */
  135611. getMousePosition(): Vector2;
  135612. /**
  135613. * Creates the "frame" texture Buffer
  135614. * -------------------------------------
  135615. * Structure of frames
  135616. * "filename": "Falling-Water-2.png",
  135617. * "frame": {"x":69,"y":103,"w":24,"h":32},
  135618. * "rotated": true,
  135619. * "trimmed": true,
  135620. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  135621. * "sourceSize": {"w":32,"h":32}
  135622. * @returns RawTexture of the frameMap
  135623. */
  135624. private _createFrameBuffer;
  135625. /**
  135626. * Creates the tileMap texture Buffer
  135627. * @param buffer normally and array of numbers, or a false to generate from scratch
  135628. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  135629. * @returns RawTexture of the tileMap
  135630. */
  135631. private _createTileBuffer;
  135632. /**
  135633. * Modifies the data of the tileMaps
  135634. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  135635. * @param pos is the iVector2 Coordinates of the Tile
  135636. * @param tile The SpriteIndex of the new Tile
  135637. */
  135638. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  135639. /**
  135640. * Creates the animationMap texture Buffer
  135641. * @param buffer normally and array of numbers, or a false to generate from scratch
  135642. * @returns RawTexture of the animationMap
  135643. */
  135644. private _createTileAnimationBuffer;
  135645. /**
  135646. * Modifies the data of the animationMap
  135647. * @param cellID is the Index of the Sprite
  135648. * @param _frame is the target Animation frame
  135649. * @param toCell is the Target Index of the next frame of the animation
  135650. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  135651. * @param speed is a global scalar of the time variable on the map.
  135652. */
  135653. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  135654. /**
  135655. * Exports the .tilemaps file
  135656. */
  135657. saveTileMaps(): void;
  135658. /**
  135659. * Imports the .tilemaps file
  135660. * @param url of the .tilemaps file
  135661. */
  135662. loadTileMaps(url: string): void;
  135663. /**
  135664. * Release associated resources
  135665. */
  135666. dispose(): void;
  135667. }
  135668. }
  135669. declare module BABYLON {
  135670. /**
  135671. * Class used to manage multiple sprites of different sizes on the same spritesheet
  135672. * @see http://doc.babylonjs.com/babylon101/sprites
  135673. */
  135674. export class SpritePackedManager extends SpriteManager {
  135675. /** defines the packed manager's name */
  135676. name: string;
  135677. /**
  135678. * Creates a new sprite manager from a packed sprite sheet
  135679. * @param name defines the manager's name
  135680. * @param imgUrl defines the sprite sheet url
  135681. * @param capacity defines the maximum allowed number of sprites
  135682. * @param scene defines the hosting scene
  135683. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  135684. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  135685. * @param samplingMode defines the smapling mode to use with spritesheet
  135686. * @param fromPacked set to true; do not alter
  135687. */
  135688. constructor(
  135689. /** defines the packed manager's name */
  135690. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  135691. }
  135692. }
  135693. declare module BABYLON {
  135694. /**
  135695. * Defines the list of states available for a task inside a AssetsManager
  135696. */
  135697. export enum AssetTaskState {
  135698. /**
  135699. * Initialization
  135700. */
  135701. INIT = 0,
  135702. /**
  135703. * Running
  135704. */
  135705. RUNNING = 1,
  135706. /**
  135707. * Done
  135708. */
  135709. DONE = 2,
  135710. /**
  135711. * Error
  135712. */
  135713. ERROR = 3
  135714. }
  135715. /**
  135716. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  135717. */
  135718. export abstract class AbstractAssetTask {
  135719. /**
  135720. * Task name
  135721. */ name: string;
  135722. /**
  135723. * Callback called when the task is successful
  135724. */
  135725. onSuccess: (task: any) => void;
  135726. /**
  135727. * Callback called when the task is not successful
  135728. */
  135729. onError: (task: any, message?: string, exception?: any) => void;
  135730. /**
  135731. * Creates a new AssetsManager
  135732. * @param name defines the name of the task
  135733. */
  135734. constructor(
  135735. /**
  135736. * Task name
  135737. */ name: string);
  135738. private _isCompleted;
  135739. private _taskState;
  135740. private _errorObject;
  135741. /**
  135742. * Get if the task is completed
  135743. */
  135744. get isCompleted(): boolean;
  135745. /**
  135746. * Gets the current state of the task
  135747. */
  135748. get taskState(): AssetTaskState;
  135749. /**
  135750. * Gets the current error object (if task is in error)
  135751. */
  135752. get errorObject(): {
  135753. message?: string;
  135754. exception?: any;
  135755. };
  135756. /**
  135757. * Internal only
  135758. * @hidden
  135759. */
  135760. _setErrorObject(message?: string, exception?: any): void;
  135761. /**
  135762. * Execute the current task
  135763. * @param scene defines the scene where you want your assets to be loaded
  135764. * @param onSuccess is a callback called when the task is successfully executed
  135765. * @param onError is a callback called if an error occurs
  135766. */
  135767. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135768. /**
  135769. * Execute the current task
  135770. * @param scene defines the scene where you want your assets to be loaded
  135771. * @param onSuccess is a callback called when the task is successfully executed
  135772. * @param onError is a callback called if an error occurs
  135773. */
  135774. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135775. /**
  135776. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  135777. * This can be used with failed tasks that have the reason for failure fixed.
  135778. */
  135779. reset(): void;
  135780. private onErrorCallback;
  135781. private onDoneCallback;
  135782. }
  135783. /**
  135784. * Define the interface used by progress events raised during assets loading
  135785. */
  135786. export interface IAssetsProgressEvent {
  135787. /**
  135788. * Defines the number of remaining tasks to process
  135789. */
  135790. remainingCount: number;
  135791. /**
  135792. * Defines the total number of tasks
  135793. */
  135794. totalCount: number;
  135795. /**
  135796. * Defines the task that was just processed
  135797. */
  135798. task: AbstractAssetTask;
  135799. }
  135800. /**
  135801. * Class used to share progress information about assets loading
  135802. */
  135803. export class AssetsProgressEvent implements IAssetsProgressEvent {
  135804. /**
  135805. * Defines the number of remaining tasks to process
  135806. */
  135807. remainingCount: number;
  135808. /**
  135809. * Defines the total number of tasks
  135810. */
  135811. totalCount: number;
  135812. /**
  135813. * Defines the task that was just processed
  135814. */
  135815. task: AbstractAssetTask;
  135816. /**
  135817. * Creates a AssetsProgressEvent
  135818. * @param remainingCount defines the number of remaining tasks to process
  135819. * @param totalCount defines the total number of tasks
  135820. * @param task defines the task that was just processed
  135821. */
  135822. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  135823. }
  135824. /**
  135825. * Define a task used by AssetsManager to load meshes
  135826. */
  135827. export class MeshAssetTask extends AbstractAssetTask {
  135828. /**
  135829. * Defines the name of the task
  135830. */
  135831. name: string;
  135832. /**
  135833. * Defines the list of mesh's names you want to load
  135834. */
  135835. meshesNames: any;
  135836. /**
  135837. * Defines the root url to use as a base to load your meshes and associated resources
  135838. */
  135839. rootUrl: string;
  135840. /**
  135841. * Defines the filename of the scene to load from
  135842. */
  135843. sceneFilename: string;
  135844. /**
  135845. * Gets the list of loaded meshes
  135846. */
  135847. loadedMeshes: Array<AbstractMesh>;
  135848. /**
  135849. * Gets the list of loaded particle systems
  135850. */
  135851. loadedParticleSystems: Array<IParticleSystem>;
  135852. /**
  135853. * Gets the list of loaded skeletons
  135854. */
  135855. loadedSkeletons: Array<Skeleton>;
  135856. /**
  135857. * Gets the list of loaded animation groups
  135858. */
  135859. loadedAnimationGroups: Array<AnimationGroup>;
  135860. /**
  135861. * Callback called when the task is successful
  135862. */
  135863. onSuccess: (task: MeshAssetTask) => void;
  135864. /**
  135865. * Callback called when the task is successful
  135866. */
  135867. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  135868. /**
  135869. * Creates a new MeshAssetTask
  135870. * @param name defines the name of the task
  135871. * @param meshesNames defines the list of mesh's names you want to load
  135872. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  135873. * @param sceneFilename defines the filename of the scene to load from
  135874. */
  135875. constructor(
  135876. /**
  135877. * Defines the name of the task
  135878. */
  135879. name: string,
  135880. /**
  135881. * Defines the list of mesh's names you want to load
  135882. */
  135883. meshesNames: any,
  135884. /**
  135885. * Defines the root url to use as a base to load your meshes and associated resources
  135886. */
  135887. rootUrl: string,
  135888. /**
  135889. * Defines the filename of the scene to load from
  135890. */
  135891. sceneFilename: string);
  135892. /**
  135893. * Execute the current task
  135894. * @param scene defines the scene where you want your assets to be loaded
  135895. * @param onSuccess is a callback called when the task is successfully executed
  135896. * @param onError is a callback called if an error occurs
  135897. */
  135898. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135899. }
  135900. /**
  135901. * Define a task used by AssetsManager to load text content
  135902. */
  135903. export class TextFileAssetTask extends AbstractAssetTask {
  135904. /**
  135905. * Defines the name of the task
  135906. */
  135907. name: string;
  135908. /**
  135909. * Defines the location of the file to load
  135910. */
  135911. url: string;
  135912. /**
  135913. * Gets the loaded text string
  135914. */
  135915. text: string;
  135916. /**
  135917. * Callback called when the task is successful
  135918. */
  135919. onSuccess: (task: TextFileAssetTask) => void;
  135920. /**
  135921. * Callback called when the task is successful
  135922. */
  135923. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  135924. /**
  135925. * Creates a new TextFileAssetTask object
  135926. * @param name defines the name of the task
  135927. * @param url defines the location of the file to load
  135928. */
  135929. constructor(
  135930. /**
  135931. * Defines the name of the task
  135932. */
  135933. name: string,
  135934. /**
  135935. * Defines the location of the file to load
  135936. */
  135937. url: string);
  135938. /**
  135939. * Execute the current task
  135940. * @param scene defines the scene where you want your assets to be loaded
  135941. * @param onSuccess is a callback called when the task is successfully executed
  135942. * @param onError is a callback called if an error occurs
  135943. */
  135944. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135945. }
  135946. /**
  135947. * Define a task used by AssetsManager to load binary data
  135948. */
  135949. export class BinaryFileAssetTask extends AbstractAssetTask {
  135950. /**
  135951. * Defines the name of the task
  135952. */
  135953. name: string;
  135954. /**
  135955. * Defines the location of the file to load
  135956. */
  135957. url: string;
  135958. /**
  135959. * Gets the lodaded data (as an array buffer)
  135960. */
  135961. data: ArrayBuffer;
  135962. /**
  135963. * Callback called when the task is successful
  135964. */
  135965. onSuccess: (task: BinaryFileAssetTask) => void;
  135966. /**
  135967. * Callback called when the task is successful
  135968. */
  135969. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  135970. /**
  135971. * Creates a new BinaryFileAssetTask object
  135972. * @param name defines the name of the new task
  135973. * @param url defines the location of the file to load
  135974. */
  135975. constructor(
  135976. /**
  135977. * Defines the name of the task
  135978. */
  135979. name: string,
  135980. /**
  135981. * Defines the location of the file to load
  135982. */
  135983. url: string);
  135984. /**
  135985. * Execute the current task
  135986. * @param scene defines the scene where you want your assets to be loaded
  135987. * @param onSuccess is a callback called when the task is successfully executed
  135988. * @param onError is a callback called if an error occurs
  135989. */
  135990. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135991. }
  135992. /**
  135993. * Define a task used by AssetsManager to load images
  135994. */
  135995. export class ImageAssetTask extends AbstractAssetTask {
  135996. /**
  135997. * Defines the name of the task
  135998. */
  135999. name: string;
  136000. /**
  136001. * Defines the location of the image to load
  136002. */
  136003. url: string;
  136004. /**
  136005. * Gets the loaded images
  136006. */
  136007. image: HTMLImageElement;
  136008. /**
  136009. * Callback called when the task is successful
  136010. */
  136011. onSuccess: (task: ImageAssetTask) => void;
  136012. /**
  136013. * Callback called when the task is successful
  136014. */
  136015. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  136016. /**
  136017. * Creates a new ImageAssetTask
  136018. * @param name defines the name of the task
  136019. * @param url defines the location of the image to load
  136020. */
  136021. constructor(
  136022. /**
  136023. * Defines the name of the task
  136024. */
  136025. name: string,
  136026. /**
  136027. * Defines the location of the image to load
  136028. */
  136029. url: string);
  136030. /**
  136031. * Execute the current task
  136032. * @param scene defines the scene where you want your assets to be loaded
  136033. * @param onSuccess is a callback called when the task is successfully executed
  136034. * @param onError is a callback called if an error occurs
  136035. */
  136036. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136037. }
  136038. /**
  136039. * Defines the interface used by texture loading tasks
  136040. */
  136041. export interface ITextureAssetTask<TEX extends BaseTexture> {
  136042. /**
  136043. * Gets the loaded texture
  136044. */
  136045. texture: TEX;
  136046. }
  136047. /**
  136048. * Define a task used by AssetsManager to load 2D textures
  136049. */
  136050. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  136051. /**
  136052. * Defines the name of the task
  136053. */
  136054. name: string;
  136055. /**
  136056. * Defines the location of the file to load
  136057. */
  136058. url: string;
  136059. /**
  136060. * Defines if mipmap should not be generated (default is false)
  136061. */
  136062. noMipmap?: boolean | undefined;
  136063. /**
  136064. * Defines if texture must be inverted on Y axis (default is false)
  136065. */
  136066. invertY?: boolean | undefined;
  136067. /**
  136068. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136069. */
  136070. samplingMode: number;
  136071. /**
  136072. * Gets the loaded texture
  136073. */
  136074. texture: Texture;
  136075. /**
  136076. * Callback called when the task is successful
  136077. */
  136078. onSuccess: (task: TextureAssetTask) => void;
  136079. /**
  136080. * Callback called when the task is successful
  136081. */
  136082. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  136083. /**
  136084. * Creates a new TextureAssetTask object
  136085. * @param name defines the name of the task
  136086. * @param url defines the location of the file to load
  136087. * @param noMipmap defines if mipmap should not be generated (default is false)
  136088. * @param invertY defines if texture must be inverted on Y axis (default is false)
  136089. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136090. */
  136091. constructor(
  136092. /**
  136093. * Defines the name of the task
  136094. */
  136095. name: string,
  136096. /**
  136097. * Defines the location of the file to load
  136098. */
  136099. url: string,
  136100. /**
  136101. * Defines if mipmap should not be generated (default is false)
  136102. */
  136103. noMipmap?: boolean | undefined,
  136104. /**
  136105. * Defines if texture must be inverted on Y axis (default is false)
  136106. */
  136107. invertY?: boolean | undefined,
  136108. /**
  136109. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136110. */
  136111. samplingMode?: number);
  136112. /**
  136113. * Execute the current task
  136114. * @param scene defines the scene where you want your assets to be loaded
  136115. * @param onSuccess is a callback called when the task is successfully executed
  136116. * @param onError is a callback called if an error occurs
  136117. */
  136118. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136119. }
  136120. /**
  136121. * Define a task used by AssetsManager to load cube textures
  136122. */
  136123. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  136124. /**
  136125. * Defines the name of the task
  136126. */
  136127. name: string;
  136128. /**
  136129. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136130. */
  136131. url: string;
  136132. /**
  136133. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136134. */
  136135. extensions?: string[] | undefined;
  136136. /**
  136137. * Defines if mipmaps should not be generated (default is false)
  136138. */
  136139. noMipmap?: boolean | undefined;
  136140. /**
  136141. * Defines the explicit list of files (undefined by default)
  136142. */
  136143. files?: string[] | undefined;
  136144. /**
  136145. * Gets the loaded texture
  136146. */
  136147. texture: CubeTexture;
  136148. /**
  136149. * Callback called when the task is successful
  136150. */
  136151. onSuccess: (task: CubeTextureAssetTask) => void;
  136152. /**
  136153. * Callback called when the task is successful
  136154. */
  136155. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  136156. /**
  136157. * Creates a new CubeTextureAssetTask
  136158. * @param name defines the name of the task
  136159. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136160. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136161. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136162. * @param files defines the explicit list of files (undefined by default)
  136163. */
  136164. constructor(
  136165. /**
  136166. * Defines the name of the task
  136167. */
  136168. name: string,
  136169. /**
  136170. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136171. */
  136172. url: string,
  136173. /**
  136174. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136175. */
  136176. extensions?: string[] | undefined,
  136177. /**
  136178. * Defines if mipmaps should not be generated (default is false)
  136179. */
  136180. noMipmap?: boolean | undefined,
  136181. /**
  136182. * Defines the explicit list of files (undefined by default)
  136183. */
  136184. files?: string[] | undefined);
  136185. /**
  136186. * Execute the current task
  136187. * @param scene defines the scene where you want your assets to be loaded
  136188. * @param onSuccess is a callback called when the task is successfully executed
  136189. * @param onError is a callback called if an error occurs
  136190. */
  136191. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136192. }
  136193. /**
  136194. * Define a task used by AssetsManager to load HDR cube textures
  136195. */
  136196. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  136197. /**
  136198. * Defines the name of the task
  136199. */
  136200. name: string;
  136201. /**
  136202. * Defines the location of the file to load
  136203. */
  136204. url: string;
  136205. /**
  136206. * Defines the desired size (the more it increases the longer the generation will be)
  136207. */
  136208. size: number;
  136209. /**
  136210. * Defines if mipmaps should not be generated (default is false)
  136211. */
  136212. noMipmap: boolean;
  136213. /**
  136214. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136215. */
  136216. generateHarmonics: boolean;
  136217. /**
  136218. * 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)
  136219. */
  136220. gammaSpace: boolean;
  136221. /**
  136222. * Internal Use Only
  136223. */
  136224. reserved: boolean;
  136225. /**
  136226. * Gets the loaded texture
  136227. */
  136228. texture: HDRCubeTexture;
  136229. /**
  136230. * Callback called when the task is successful
  136231. */
  136232. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  136233. /**
  136234. * Callback called when the task is successful
  136235. */
  136236. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  136237. /**
  136238. * Creates a new HDRCubeTextureAssetTask object
  136239. * @param name defines the name of the task
  136240. * @param url defines the location of the file to load
  136241. * @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.
  136242. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136243. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136244. * @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)
  136245. * @param reserved Internal use only
  136246. */
  136247. constructor(
  136248. /**
  136249. * Defines the name of the task
  136250. */
  136251. name: string,
  136252. /**
  136253. * Defines the location of the file to load
  136254. */
  136255. url: string,
  136256. /**
  136257. * Defines the desired size (the more it increases the longer the generation will be)
  136258. */
  136259. size: number,
  136260. /**
  136261. * Defines if mipmaps should not be generated (default is false)
  136262. */
  136263. noMipmap?: boolean,
  136264. /**
  136265. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136266. */
  136267. generateHarmonics?: boolean,
  136268. /**
  136269. * 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)
  136270. */
  136271. gammaSpace?: boolean,
  136272. /**
  136273. * Internal Use Only
  136274. */
  136275. reserved?: boolean);
  136276. /**
  136277. * Execute the current task
  136278. * @param scene defines the scene where you want your assets to be loaded
  136279. * @param onSuccess is a callback called when the task is successfully executed
  136280. * @param onError is a callback called if an error occurs
  136281. */
  136282. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136283. }
  136284. /**
  136285. * Define a task used by AssetsManager to load Equirectangular cube textures
  136286. */
  136287. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  136288. /**
  136289. * Defines the name of the task
  136290. */
  136291. name: string;
  136292. /**
  136293. * Defines the location of the file to load
  136294. */
  136295. url: string;
  136296. /**
  136297. * Defines the desired size (the more it increases the longer the generation will be)
  136298. */
  136299. size: number;
  136300. /**
  136301. * Defines if mipmaps should not be generated (default is false)
  136302. */
  136303. noMipmap: boolean;
  136304. /**
  136305. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136306. * but the standard material would require them in Gamma space) (default is true)
  136307. */
  136308. gammaSpace: boolean;
  136309. /**
  136310. * Gets the loaded texture
  136311. */
  136312. texture: EquiRectangularCubeTexture;
  136313. /**
  136314. * Callback called when the task is successful
  136315. */
  136316. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  136317. /**
  136318. * Callback called when the task is successful
  136319. */
  136320. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  136321. /**
  136322. * Creates a new EquiRectangularCubeTextureAssetTask object
  136323. * @param name defines the name of the task
  136324. * @param url defines the location of the file to load
  136325. * @param size defines the desired size (the more it increases the longer the generation will be)
  136326. * If the size is omitted this implies you are using a preprocessed cubemap.
  136327. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136328. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  136329. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  136330. * (default is true)
  136331. */
  136332. constructor(
  136333. /**
  136334. * Defines the name of the task
  136335. */
  136336. name: string,
  136337. /**
  136338. * Defines the location of the file to load
  136339. */
  136340. url: string,
  136341. /**
  136342. * Defines the desired size (the more it increases the longer the generation will be)
  136343. */
  136344. size: number,
  136345. /**
  136346. * Defines if mipmaps should not be generated (default is false)
  136347. */
  136348. noMipmap?: boolean,
  136349. /**
  136350. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136351. * but the standard material would require them in Gamma space) (default is true)
  136352. */
  136353. gammaSpace?: boolean);
  136354. /**
  136355. * Execute the current task
  136356. * @param scene defines the scene where you want your assets to be loaded
  136357. * @param onSuccess is a callback called when the task is successfully executed
  136358. * @param onError is a callback called if an error occurs
  136359. */
  136360. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136361. }
  136362. /**
  136363. * This class can be used to easily import assets into a scene
  136364. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  136365. */
  136366. export class AssetsManager {
  136367. private _scene;
  136368. private _isLoading;
  136369. protected _tasks: AbstractAssetTask[];
  136370. protected _waitingTasksCount: number;
  136371. protected _totalTasksCount: number;
  136372. /**
  136373. * Callback called when all tasks are processed
  136374. */
  136375. onFinish: (tasks: AbstractAssetTask[]) => void;
  136376. /**
  136377. * Callback called when a task is successful
  136378. */
  136379. onTaskSuccess: (task: AbstractAssetTask) => void;
  136380. /**
  136381. * Callback called when a task had an error
  136382. */
  136383. onTaskError: (task: AbstractAssetTask) => void;
  136384. /**
  136385. * Callback called when a task is done (whatever the result is)
  136386. */
  136387. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  136388. /**
  136389. * Observable called when all tasks are processed
  136390. */
  136391. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  136392. /**
  136393. * Observable called when a task had an error
  136394. */
  136395. onTaskErrorObservable: Observable<AbstractAssetTask>;
  136396. /**
  136397. * Observable called when all tasks were executed
  136398. */
  136399. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  136400. /**
  136401. * Observable called when a task is done (whatever the result is)
  136402. */
  136403. onProgressObservable: Observable<IAssetsProgressEvent>;
  136404. /**
  136405. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  136406. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  136407. */
  136408. useDefaultLoadingScreen: boolean;
  136409. /**
  136410. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  136411. * when all assets have been downloaded.
  136412. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  136413. */
  136414. autoHideLoadingUI: boolean;
  136415. /**
  136416. * Creates a new AssetsManager
  136417. * @param scene defines the scene to work on
  136418. */
  136419. constructor(scene: Scene);
  136420. /**
  136421. * Add a MeshAssetTask to the list of active tasks
  136422. * @param taskName defines the name of the new task
  136423. * @param meshesNames defines the name of meshes to load
  136424. * @param rootUrl defines the root url to use to locate files
  136425. * @param sceneFilename defines the filename of the scene file
  136426. * @returns a new MeshAssetTask object
  136427. */
  136428. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  136429. /**
  136430. * Add a TextFileAssetTask to the list of active tasks
  136431. * @param taskName defines the name of the new task
  136432. * @param url defines the url of the file to load
  136433. * @returns a new TextFileAssetTask object
  136434. */
  136435. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  136436. /**
  136437. * Add a BinaryFileAssetTask to the list of active tasks
  136438. * @param taskName defines the name of the new task
  136439. * @param url defines the url of the file to load
  136440. * @returns a new BinaryFileAssetTask object
  136441. */
  136442. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  136443. /**
  136444. * Add a ImageAssetTask to the list of active tasks
  136445. * @param taskName defines the name of the new task
  136446. * @param url defines the url of the file to load
  136447. * @returns a new ImageAssetTask object
  136448. */
  136449. addImageTask(taskName: string, url: string): ImageAssetTask;
  136450. /**
  136451. * Add a TextureAssetTask to the list of active tasks
  136452. * @param taskName defines the name of the new task
  136453. * @param url defines the url of the file to load
  136454. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136455. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  136456. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  136457. * @returns a new TextureAssetTask object
  136458. */
  136459. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  136460. /**
  136461. * Add a CubeTextureAssetTask to the list of active tasks
  136462. * @param taskName defines the name of the new task
  136463. * @param url defines the url of the file to load
  136464. * @param extensions defines the extension to use to load the cube map (can be null)
  136465. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136466. * @param files defines the list of files to load (can be null)
  136467. * @returns a new CubeTextureAssetTask object
  136468. */
  136469. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  136470. /**
  136471. *
  136472. * Add a HDRCubeTextureAssetTask to the list of active tasks
  136473. * @param taskName defines the name of the new task
  136474. * @param url defines the url of the file to load
  136475. * @param size defines the size you want for the cubemap (can be null)
  136476. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136477. * @param generateHarmonics defines if you want to automatically generate (true by default)
  136478. * @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)
  136479. * @param reserved Internal use only
  136480. * @returns a new HDRCubeTextureAssetTask object
  136481. */
  136482. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  136483. /**
  136484. *
  136485. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  136486. * @param taskName defines the name of the new task
  136487. * @param url defines the url of the file to load
  136488. * @param size defines the size you want for the cubemap (can be null)
  136489. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136490. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136491. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136492. * @returns a new EquiRectangularCubeTextureAssetTask object
  136493. */
  136494. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  136495. /**
  136496. * Remove a task from the assets manager.
  136497. * @param task the task to remove
  136498. */
  136499. removeTask(task: AbstractAssetTask): void;
  136500. private _decreaseWaitingTasksCount;
  136501. private _runTask;
  136502. /**
  136503. * Reset the AssetsManager and remove all tasks
  136504. * @return the current instance of the AssetsManager
  136505. */
  136506. reset(): AssetsManager;
  136507. /**
  136508. * Start the loading process
  136509. * @return the current instance of the AssetsManager
  136510. */
  136511. load(): AssetsManager;
  136512. /**
  136513. * Start the loading process as an async operation
  136514. * @return a promise returning the list of failed tasks
  136515. */
  136516. loadAsync(): Promise<void>;
  136517. }
  136518. }
  136519. declare module BABYLON {
  136520. /**
  136521. * Wrapper class for promise with external resolve and reject.
  136522. */
  136523. export class Deferred<T> {
  136524. /**
  136525. * The promise associated with this deferred object.
  136526. */
  136527. readonly promise: Promise<T>;
  136528. private _resolve;
  136529. private _reject;
  136530. /**
  136531. * The resolve method of the promise associated with this deferred object.
  136532. */
  136533. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  136534. /**
  136535. * The reject method of the promise associated with this deferred object.
  136536. */
  136537. get reject(): (reason?: any) => void;
  136538. /**
  136539. * Constructor for this deferred object.
  136540. */
  136541. constructor();
  136542. }
  136543. }
  136544. declare module BABYLON {
  136545. /**
  136546. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  136547. */
  136548. export class MeshExploder {
  136549. private _centerMesh;
  136550. private _meshes;
  136551. private _meshesOrigins;
  136552. private _toCenterVectors;
  136553. private _scaledDirection;
  136554. private _newPosition;
  136555. private _centerPosition;
  136556. /**
  136557. * Explodes meshes from a center mesh.
  136558. * @param meshes The meshes to explode.
  136559. * @param centerMesh The mesh to be center of explosion.
  136560. */
  136561. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  136562. private _setCenterMesh;
  136563. /**
  136564. * Get class name
  136565. * @returns "MeshExploder"
  136566. */
  136567. getClassName(): string;
  136568. /**
  136569. * "Exploded meshes"
  136570. * @returns Array of meshes with the centerMesh at index 0.
  136571. */
  136572. getMeshes(): Array<Mesh>;
  136573. /**
  136574. * Explodes meshes giving a specific direction
  136575. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  136576. */
  136577. explode(direction?: number): void;
  136578. }
  136579. }
  136580. declare module BABYLON {
  136581. /**
  136582. * Class used to help managing file picking and drag'n'drop
  136583. */
  136584. export class FilesInput {
  136585. /**
  136586. * List of files ready to be loaded
  136587. */
  136588. static get FilesToLoad(): {
  136589. [key: string]: File;
  136590. };
  136591. /**
  136592. * Callback called when a file is processed
  136593. */
  136594. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  136595. private _engine;
  136596. private _currentScene;
  136597. private _sceneLoadedCallback;
  136598. private _progressCallback;
  136599. private _additionalRenderLoopLogicCallback;
  136600. private _textureLoadingCallback;
  136601. private _startingProcessingFilesCallback;
  136602. private _onReloadCallback;
  136603. private _errorCallback;
  136604. private _elementToMonitor;
  136605. private _sceneFileToLoad;
  136606. private _filesToLoad;
  136607. /**
  136608. * Creates a new FilesInput
  136609. * @param engine defines the rendering engine
  136610. * @param scene defines the hosting scene
  136611. * @param sceneLoadedCallback callback called when scene is loaded
  136612. * @param progressCallback callback called to track progress
  136613. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  136614. * @param textureLoadingCallback callback called when a texture is loading
  136615. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  136616. * @param onReloadCallback callback called when a reload is requested
  136617. * @param errorCallback callback call if an error occurs
  136618. */
  136619. 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);
  136620. private _dragEnterHandler;
  136621. private _dragOverHandler;
  136622. private _dropHandler;
  136623. /**
  136624. * Calls this function to listen to drag'n'drop events on a specific DOM element
  136625. * @param elementToMonitor defines the DOM element to track
  136626. */
  136627. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  136628. /**
  136629. * Release all associated resources
  136630. */
  136631. dispose(): void;
  136632. private renderFunction;
  136633. private drag;
  136634. private drop;
  136635. private _traverseFolder;
  136636. private _processFiles;
  136637. /**
  136638. * Load files from a drop event
  136639. * @param event defines the drop event to use as source
  136640. */
  136641. loadFiles(event: any): void;
  136642. private _processReload;
  136643. /**
  136644. * Reload the current scene from the loaded files
  136645. */
  136646. reload(): void;
  136647. }
  136648. }
  136649. declare module BABYLON {
  136650. /**
  136651. * Defines the root class used to create scene optimization to use with SceneOptimizer
  136652. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136653. */
  136654. export class SceneOptimization {
  136655. /**
  136656. * Defines the priority of this optimization (0 by default which means first in the list)
  136657. */
  136658. priority: number;
  136659. /**
  136660. * Gets a string describing the action executed by the current optimization
  136661. * @returns description string
  136662. */
  136663. getDescription(): string;
  136664. /**
  136665. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136666. * @param scene defines the current scene where to apply this optimization
  136667. * @param optimizer defines the current optimizer
  136668. * @returns true if everything that can be done was applied
  136669. */
  136670. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136671. /**
  136672. * Creates the SceneOptimization object
  136673. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136674. * @param desc defines the description associated with the optimization
  136675. */
  136676. constructor(
  136677. /**
  136678. * Defines the priority of this optimization (0 by default which means first in the list)
  136679. */
  136680. priority?: number);
  136681. }
  136682. /**
  136683. * Defines an optimization used to reduce the size of render target textures
  136684. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136685. */
  136686. export class TextureOptimization extends SceneOptimization {
  136687. /**
  136688. * Defines the priority of this optimization (0 by default which means first in the list)
  136689. */
  136690. priority: number;
  136691. /**
  136692. * 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
  136693. */
  136694. maximumSize: number;
  136695. /**
  136696. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136697. */
  136698. step: number;
  136699. /**
  136700. * Gets a string describing the action executed by the current optimization
  136701. * @returns description string
  136702. */
  136703. getDescription(): string;
  136704. /**
  136705. * Creates the TextureOptimization object
  136706. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136707. * @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
  136708. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136709. */
  136710. constructor(
  136711. /**
  136712. * Defines the priority of this optimization (0 by default which means first in the list)
  136713. */
  136714. priority?: number,
  136715. /**
  136716. * 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
  136717. */
  136718. maximumSize?: number,
  136719. /**
  136720. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136721. */
  136722. step?: number);
  136723. /**
  136724. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136725. * @param scene defines the current scene where to apply this optimization
  136726. * @param optimizer defines the current optimizer
  136727. * @returns true if everything that can be done was applied
  136728. */
  136729. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136730. }
  136731. /**
  136732. * Defines an optimization used to increase or decrease the rendering resolution
  136733. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136734. */
  136735. export class HardwareScalingOptimization extends SceneOptimization {
  136736. /**
  136737. * Defines the priority of this optimization (0 by default which means first in the list)
  136738. */
  136739. priority: number;
  136740. /**
  136741. * Defines the maximum scale to use (2 by default)
  136742. */
  136743. maximumScale: number;
  136744. /**
  136745. * Defines the step to use between two passes (0.5 by default)
  136746. */
  136747. step: number;
  136748. private _currentScale;
  136749. private _directionOffset;
  136750. /**
  136751. * Gets a string describing the action executed by the current optimization
  136752. * @return description string
  136753. */
  136754. getDescription(): string;
  136755. /**
  136756. * Creates the HardwareScalingOptimization object
  136757. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136758. * @param maximumScale defines the maximum scale to use (2 by default)
  136759. * @param step defines the step to use between two passes (0.5 by default)
  136760. */
  136761. constructor(
  136762. /**
  136763. * Defines the priority of this optimization (0 by default which means first in the list)
  136764. */
  136765. priority?: number,
  136766. /**
  136767. * Defines the maximum scale to use (2 by default)
  136768. */
  136769. maximumScale?: number,
  136770. /**
  136771. * Defines the step to use between two passes (0.5 by default)
  136772. */
  136773. step?: number);
  136774. /**
  136775. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136776. * @param scene defines the current scene where to apply this optimization
  136777. * @param optimizer defines the current optimizer
  136778. * @returns true if everything that can be done was applied
  136779. */
  136780. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136781. }
  136782. /**
  136783. * Defines an optimization used to remove shadows
  136784. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136785. */
  136786. export class ShadowsOptimization extends SceneOptimization {
  136787. /**
  136788. * Gets a string describing the action executed by the current optimization
  136789. * @return description string
  136790. */
  136791. getDescription(): string;
  136792. /**
  136793. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136794. * @param scene defines the current scene where to apply this optimization
  136795. * @param optimizer defines the current optimizer
  136796. * @returns true if everything that can be done was applied
  136797. */
  136798. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136799. }
  136800. /**
  136801. * Defines an optimization used to turn post-processes off
  136802. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136803. */
  136804. export class PostProcessesOptimization extends SceneOptimization {
  136805. /**
  136806. * Gets a string describing the action executed by the current optimization
  136807. * @return description string
  136808. */
  136809. getDescription(): string;
  136810. /**
  136811. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136812. * @param scene defines the current scene where to apply this optimization
  136813. * @param optimizer defines the current optimizer
  136814. * @returns true if everything that can be done was applied
  136815. */
  136816. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136817. }
  136818. /**
  136819. * Defines an optimization used to turn lens flares off
  136820. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136821. */
  136822. export class LensFlaresOptimization extends SceneOptimization {
  136823. /**
  136824. * Gets a string describing the action executed by the current optimization
  136825. * @return description string
  136826. */
  136827. getDescription(): string;
  136828. /**
  136829. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136830. * @param scene defines the current scene where to apply this optimization
  136831. * @param optimizer defines the current optimizer
  136832. * @returns true if everything that can be done was applied
  136833. */
  136834. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136835. }
  136836. /**
  136837. * Defines an optimization based on user defined callback.
  136838. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136839. */
  136840. export class CustomOptimization extends SceneOptimization {
  136841. /**
  136842. * Callback called to apply the custom optimization.
  136843. */
  136844. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  136845. /**
  136846. * Callback called to get custom description
  136847. */
  136848. onGetDescription: () => string;
  136849. /**
  136850. * Gets a string describing the action executed by the current optimization
  136851. * @returns description string
  136852. */
  136853. getDescription(): string;
  136854. /**
  136855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136856. * @param scene defines the current scene where to apply this optimization
  136857. * @param optimizer defines the current optimizer
  136858. * @returns true if everything that can be done was applied
  136859. */
  136860. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136861. }
  136862. /**
  136863. * Defines an optimization used to turn particles off
  136864. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136865. */
  136866. export class ParticlesOptimization extends SceneOptimization {
  136867. /**
  136868. * Gets a string describing the action executed by the current optimization
  136869. * @return description string
  136870. */
  136871. getDescription(): string;
  136872. /**
  136873. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136874. * @param scene defines the current scene where to apply this optimization
  136875. * @param optimizer defines the current optimizer
  136876. * @returns true if everything that can be done was applied
  136877. */
  136878. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136879. }
  136880. /**
  136881. * Defines an optimization used to turn render targets off
  136882. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136883. */
  136884. export class RenderTargetsOptimization extends SceneOptimization {
  136885. /**
  136886. * Gets a string describing the action executed by the current optimization
  136887. * @return description string
  136888. */
  136889. getDescription(): string;
  136890. /**
  136891. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136892. * @param scene defines the current scene where to apply this optimization
  136893. * @param optimizer defines the current optimizer
  136894. * @returns true if everything that can be done was applied
  136895. */
  136896. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136897. }
  136898. /**
  136899. * Defines an optimization used to merge meshes with compatible materials
  136900. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136901. */
  136902. export class MergeMeshesOptimization extends SceneOptimization {
  136903. private static _UpdateSelectionTree;
  136904. /**
  136905. * Gets or sets a boolean which defines if optimization octree has to be updated
  136906. */
  136907. static get UpdateSelectionTree(): boolean;
  136908. /**
  136909. * Gets or sets a boolean which defines if optimization octree has to be updated
  136910. */
  136911. static set UpdateSelectionTree(value: boolean);
  136912. /**
  136913. * Gets a string describing the action executed by the current optimization
  136914. * @return description string
  136915. */
  136916. getDescription(): string;
  136917. private _canBeMerged;
  136918. /**
  136919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136920. * @param scene defines the current scene where to apply this optimization
  136921. * @param optimizer defines the current optimizer
  136922. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  136923. * @returns true if everything that can be done was applied
  136924. */
  136925. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  136926. }
  136927. /**
  136928. * Defines a list of options used by SceneOptimizer
  136929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136930. */
  136931. export class SceneOptimizerOptions {
  136932. /**
  136933. * Defines the target frame rate to reach (60 by default)
  136934. */
  136935. targetFrameRate: number;
  136936. /**
  136937. * Defines the interval between two checkes (2000ms by default)
  136938. */
  136939. trackerDuration: number;
  136940. /**
  136941. * Gets the list of optimizations to apply
  136942. */
  136943. optimizations: SceneOptimization[];
  136944. /**
  136945. * Creates a new list of options used by SceneOptimizer
  136946. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  136947. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  136948. */
  136949. constructor(
  136950. /**
  136951. * Defines the target frame rate to reach (60 by default)
  136952. */
  136953. targetFrameRate?: number,
  136954. /**
  136955. * Defines the interval between two checkes (2000ms by default)
  136956. */
  136957. trackerDuration?: number);
  136958. /**
  136959. * Add a new optimization
  136960. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  136961. * @returns the current SceneOptimizerOptions
  136962. */
  136963. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  136964. /**
  136965. * Add a new custom optimization
  136966. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  136967. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  136968. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136969. * @returns the current SceneOptimizerOptions
  136970. */
  136971. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  136972. /**
  136973. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  136974. * @param targetFrameRate defines the target frame rate (60 by default)
  136975. * @returns a SceneOptimizerOptions object
  136976. */
  136977. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  136978. /**
  136979. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  136980. * @param targetFrameRate defines the target frame rate (60 by default)
  136981. * @returns a SceneOptimizerOptions object
  136982. */
  136983. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  136984. /**
  136985. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  136986. * @param targetFrameRate defines the target frame rate (60 by default)
  136987. * @returns a SceneOptimizerOptions object
  136988. */
  136989. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  136990. }
  136991. /**
  136992. * Class used to run optimizations in order to reach a target frame rate
  136993. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136994. */
  136995. export class SceneOptimizer implements IDisposable {
  136996. private _isRunning;
  136997. private _options;
  136998. private _scene;
  136999. private _currentPriorityLevel;
  137000. private _targetFrameRate;
  137001. private _trackerDuration;
  137002. private _currentFrameRate;
  137003. private _sceneDisposeObserver;
  137004. private _improvementMode;
  137005. /**
  137006. * Defines an observable called when the optimizer reaches the target frame rate
  137007. */
  137008. onSuccessObservable: Observable<SceneOptimizer>;
  137009. /**
  137010. * Defines an observable called when the optimizer enables an optimization
  137011. */
  137012. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  137013. /**
  137014. * Defines an observable called when the optimizer is not able to reach the target frame rate
  137015. */
  137016. onFailureObservable: Observable<SceneOptimizer>;
  137017. /**
  137018. * Gets a boolean indicating if the optimizer is in improvement mode
  137019. */
  137020. get isInImprovementMode(): boolean;
  137021. /**
  137022. * Gets the current priority level (0 at start)
  137023. */
  137024. get currentPriorityLevel(): number;
  137025. /**
  137026. * Gets the current frame rate checked by the SceneOptimizer
  137027. */
  137028. get currentFrameRate(): number;
  137029. /**
  137030. * Gets or sets the current target frame rate (60 by default)
  137031. */
  137032. get targetFrameRate(): number;
  137033. /**
  137034. * Gets or sets the current target frame rate (60 by default)
  137035. */
  137036. set targetFrameRate(value: number);
  137037. /**
  137038. * Gets or sets the current interval between two checks (every 2000ms by default)
  137039. */
  137040. get trackerDuration(): number;
  137041. /**
  137042. * Gets or sets the current interval between two checks (every 2000ms by default)
  137043. */
  137044. set trackerDuration(value: number);
  137045. /**
  137046. * Gets the list of active optimizations
  137047. */
  137048. get optimizations(): SceneOptimization[];
  137049. /**
  137050. * Creates a new SceneOptimizer
  137051. * @param scene defines the scene to work on
  137052. * @param options defines the options to use with the SceneOptimizer
  137053. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  137054. * @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)
  137055. */
  137056. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  137057. /**
  137058. * Stops the current optimizer
  137059. */
  137060. stop(): void;
  137061. /**
  137062. * Reset the optimizer to initial step (current priority level = 0)
  137063. */
  137064. reset(): void;
  137065. /**
  137066. * Start the optimizer. By default it will try to reach a specific framerate
  137067. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  137068. */
  137069. start(): void;
  137070. private _checkCurrentState;
  137071. /**
  137072. * Release all resources
  137073. */
  137074. dispose(): void;
  137075. /**
  137076. * Helper function to create a SceneOptimizer with one single line of code
  137077. * @param scene defines the scene to work on
  137078. * @param options defines the options to use with the SceneOptimizer
  137079. * @param onSuccess defines a callback to call on success
  137080. * @param onFailure defines a callback to call on failure
  137081. * @returns the new SceneOptimizer object
  137082. */
  137083. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  137084. }
  137085. }
  137086. declare module BABYLON {
  137087. /**
  137088. * Class used to serialize a scene into a string
  137089. */
  137090. export class SceneSerializer {
  137091. /**
  137092. * Clear cache used by a previous serialization
  137093. */
  137094. static ClearCache(): void;
  137095. /**
  137096. * Serialize a scene into a JSON compatible object
  137097. * @param scene defines the scene to serialize
  137098. * @returns a JSON compatible object
  137099. */
  137100. static Serialize(scene: Scene): any;
  137101. /**
  137102. * Serialize a mesh into a JSON compatible object
  137103. * @param toSerialize defines the mesh to serialize
  137104. * @param withParents defines if parents must be serialized as well
  137105. * @param withChildren defines if children must be serialized as well
  137106. * @returns a JSON compatible object
  137107. */
  137108. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  137109. }
  137110. }
  137111. declare module BABYLON {
  137112. /**
  137113. * Class used to host texture specific utilities
  137114. */
  137115. export class TextureTools {
  137116. /**
  137117. * Uses the GPU to create a copy texture rescaled at a given size
  137118. * @param texture Texture to copy from
  137119. * @param width defines the desired width
  137120. * @param height defines the desired height
  137121. * @param useBilinearMode defines if bilinear mode has to be used
  137122. * @return the generated texture
  137123. */
  137124. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  137125. }
  137126. }
  137127. declare module BABYLON {
  137128. /**
  137129. * This represents the different options available for the video capture.
  137130. */
  137131. export interface VideoRecorderOptions {
  137132. /** Defines the mime type of the video. */
  137133. mimeType: string;
  137134. /** Defines the FPS the video should be recorded at. */
  137135. fps: number;
  137136. /** Defines the chunk size for the recording data. */
  137137. recordChunckSize: number;
  137138. /** The audio tracks to attach to the recording. */
  137139. audioTracks?: MediaStreamTrack[];
  137140. }
  137141. /**
  137142. * This can help with recording videos from BabylonJS.
  137143. * This is based on the available WebRTC functionalities of the browser.
  137144. *
  137145. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  137146. */
  137147. export class VideoRecorder {
  137148. private static readonly _defaultOptions;
  137149. /**
  137150. * Returns whether or not the VideoRecorder is available in your browser.
  137151. * @param engine Defines the Babylon Engine.
  137152. * @returns true if supported otherwise false.
  137153. */
  137154. static IsSupported(engine: Engine): boolean;
  137155. private readonly _options;
  137156. private _canvas;
  137157. private _mediaRecorder;
  137158. private _recordedChunks;
  137159. private _fileName;
  137160. private _resolve;
  137161. private _reject;
  137162. /**
  137163. * True when a recording is already in progress.
  137164. */
  137165. get isRecording(): boolean;
  137166. /**
  137167. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  137168. * @param engine Defines the BabylonJS Engine you wish to record.
  137169. * @param options Defines options that can be used to customize the capture.
  137170. */
  137171. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  137172. /**
  137173. * Stops the current recording before the default capture timeout passed in the startRecording function.
  137174. */
  137175. stopRecording(): void;
  137176. /**
  137177. * Starts recording the canvas for a max duration specified in parameters.
  137178. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  137179. * If null no automatic download will start and you can rely on the promise to get the data back.
  137180. * @param maxDuration Defines the maximum recording time in seconds.
  137181. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  137182. * @return A promise callback at the end of the recording with the video data in Blob.
  137183. */
  137184. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  137185. /**
  137186. * Releases internal resources used during the recording.
  137187. */
  137188. dispose(): void;
  137189. private _handleDataAvailable;
  137190. private _handleError;
  137191. private _handleStop;
  137192. }
  137193. }
  137194. declare module BABYLON {
  137195. /**
  137196. * Class containing a set of static utilities functions for screenshots
  137197. */
  137198. export class ScreenshotTools {
  137199. /**
  137200. * Captures a screenshot of the current rendering
  137201. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137202. * @param engine defines the rendering engine
  137203. * @param camera defines the source camera
  137204. * @param size This parameter can be set to a single number or to an object with the
  137205. * following (optional) properties: precision, width, height. If a single number is passed,
  137206. * it will be used for both width and height. If an object is passed, the screenshot size
  137207. * will be derived from the parameters. The precision property is a multiplier allowing
  137208. * rendering at a higher or lower resolution
  137209. * @param successCallback defines the callback receives a single parameter which contains the
  137210. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137211. * src parameter of an <img> to display it
  137212. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137213. * Check your browser for supported MIME types
  137214. */
  137215. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  137216. /**
  137217. * Captures a screenshot of the current rendering
  137218. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137219. * @param engine defines the rendering engine
  137220. * @param camera defines the source camera
  137221. * @param size This parameter can be set to a single number or to an object with the
  137222. * following (optional) properties: precision, width, height. If a single number is passed,
  137223. * it will be used for both width and height. If an object is passed, the screenshot size
  137224. * will be derived from the parameters. The precision property is a multiplier allowing
  137225. * rendering at a higher or lower resolution
  137226. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137227. * Check your browser for supported MIME types
  137228. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137229. * to the src parameter of an <img> to display it
  137230. */
  137231. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  137232. /**
  137233. * Generates an image screenshot from the specified camera.
  137234. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137235. * @param engine The engine to use for rendering
  137236. * @param camera The camera to use for rendering
  137237. * @param size This parameter can be set to a single number or to an object with the
  137238. * following (optional) properties: precision, width, height. If a single number is passed,
  137239. * it will be used for both width and height. If an object is passed, the screenshot size
  137240. * will be derived from the parameters. The precision property is a multiplier allowing
  137241. * rendering at a higher or lower resolution
  137242. * @param successCallback The callback receives a single parameter which contains the
  137243. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137244. * src parameter of an <img> to display it
  137245. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137246. * Check your browser for supported MIME types
  137247. * @param samples Texture samples (default: 1)
  137248. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137249. * @param fileName A name for for the downloaded file.
  137250. */
  137251. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  137252. /**
  137253. * Generates an image screenshot from the specified camera.
  137254. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137255. * @param engine The engine to use for rendering
  137256. * @param camera The camera to use for rendering
  137257. * @param size This parameter can be set to a single number or to an object with the
  137258. * following (optional) properties: precision, width, height. If a single number is passed,
  137259. * it will be used for both width and height. If an object is passed, the screenshot size
  137260. * will be derived from the parameters. The precision property is a multiplier allowing
  137261. * rendering at a higher or lower resolution
  137262. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137263. * Check your browser for supported MIME types
  137264. * @param samples Texture samples (default: 1)
  137265. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137266. * @param fileName A name for for the downloaded file.
  137267. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137268. * to the src parameter of an <img> to display it
  137269. */
  137270. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  137271. /**
  137272. * Gets height and width for screenshot size
  137273. * @private
  137274. */
  137275. private static _getScreenshotSize;
  137276. }
  137277. }
  137278. declare module BABYLON {
  137279. /**
  137280. * Interface for a data buffer
  137281. */
  137282. export interface IDataBuffer {
  137283. /**
  137284. * Reads bytes from the data buffer.
  137285. * @param byteOffset The byte offset to read
  137286. * @param byteLength The byte length to read
  137287. * @returns A promise that resolves when the bytes are read
  137288. */
  137289. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  137290. /**
  137291. * The byte length of the buffer.
  137292. */
  137293. readonly byteLength: number;
  137294. }
  137295. /**
  137296. * Utility class for reading from a data buffer
  137297. */
  137298. export class DataReader {
  137299. /**
  137300. * The data buffer associated with this data reader.
  137301. */
  137302. readonly buffer: IDataBuffer;
  137303. /**
  137304. * The current byte offset from the beginning of the data buffer.
  137305. */
  137306. byteOffset: number;
  137307. private _dataView;
  137308. private _dataByteOffset;
  137309. /**
  137310. * Constructor
  137311. * @param buffer The buffer to read
  137312. */
  137313. constructor(buffer: IDataBuffer);
  137314. /**
  137315. * Loads the given byte length.
  137316. * @param byteLength The byte length to load
  137317. * @returns A promise that resolves when the load is complete
  137318. */
  137319. loadAsync(byteLength: number): Promise<void>;
  137320. /**
  137321. * Read a unsigned 32-bit integer from the currently loaded data range.
  137322. * @returns The 32-bit integer read
  137323. */
  137324. readUint32(): number;
  137325. /**
  137326. * Read a byte array from the currently loaded data range.
  137327. * @param byteLength The byte length to read
  137328. * @returns The byte array read
  137329. */
  137330. readUint8Array(byteLength: number): Uint8Array;
  137331. /**
  137332. * Read a string from the currently loaded data range.
  137333. * @param byteLength The byte length to read
  137334. * @returns The string read
  137335. */
  137336. readString(byteLength: number): string;
  137337. /**
  137338. * Skips the given byte length the currently loaded data range.
  137339. * @param byteLength The byte length to skip
  137340. */
  137341. skipBytes(byteLength: number): void;
  137342. }
  137343. }
  137344. declare module BABYLON {
  137345. /**
  137346. * A cursor which tracks a point on a path
  137347. */
  137348. export class PathCursor {
  137349. private path;
  137350. /**
  137351. * Stores path cursor callbacks for when an onchange event is triggered
  137352. */
  137353. private _onchange;
  137354. /**
  137355. * The value of the path cursor
  137356. */
  137357. value: number;
  137358. /**
  137359. * The animation array of the path cursor
  137360. */
  137361. animations: Animation[];
  137362. /**
  137363. * Initializes the path cursor
  137364. * @param path The path to track
  137365. */
  137366. constructor(path: Path2);
  137367. /**
  137368. * Gets the cursor point on the path
  137369. * @returns A point on the path cursor at the cursor location
  137370. */
  137371. getPoint(): Vector3;
  137372. /**
  137373. * Moves the cursor ahead by the step amount
  137374. * @param step The amount to move the cursor forward
  137375. * @returns This path cursor
  137376. */
  137377. moveAhead(step?: number): PathCursor;
  137378. /**
  137379. * Moves the cursor behind by the step amount
  137380. * @param step The amount to move the cursor back
  137381. * @returns This path cursor
  137382. */
  137383. moveBack(step?: number): PathCursor;
  137384. /**
  137385. * Moves the cursor by the step amount
  137386. * If the step amount is greater than one, an exception is thrown
  137387. * @param step The amount to move the cursor
  137388. * @returns This path cursor
  137389. */
  137390. move(step: number): PathCursor;
  137391. /**
  137392. * Ensures that the value is limited between zero and one
  137393. * @returns This path cursor
  137394. */
  137395. private ensureLimits;
  137396. /**
  137397. * Runs onchange callbacks on change (used by the animation engine)
  137398. * @returns This path cursor
  137399. */
  137400. private raiseOnChange;
  137401. /**
  137402. * Executes a function on change
  137403. * @param f A path cursor onchange callback
  137404. * @returns This path cursor
  137405. */
  137406. onchange(f: (cursor: PathCursor) => void): PathCursor;
  137407. }
  137408. }
  137409. declare module BABYLON {
  137410. /** @hidden */
  137411. export var blurPixelShader: {
  137412. name: string;
  137413. shader: string;
  137414. };
  137415. }
  137416. declare module BABYLON {
  137417. /** @hidden */
  137418. export var pointCloudVertexDeclaration: {
  137419. name: string;
  137420. shader: string;
  137421. };
  137422. }
  137423. // Mixins
  137424. interface Window {
  137425. mozIndexedDB: IDBFactory;
  137426. webkitIndexedDB: IDBFactory;
  137427. msIndexedDB: IDBFactory;
  137428. webkitURL: typeof URL;
  137429. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  137430. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  137431. WebGLRenderingContext: WebGLRenderingContext;
  137432. MSGesture: MSGesture;
  137433. CANNON: any;
  137434. AudioContext: AudioContext;
  137435. webkitAudioContext: AudioContext;
  137436. PointerEvent: any;
  137437. Math: Math;
  137438. Uint8Array: Uint8ArrayConstructor;
  137439. Float32Array: Float32ArrayConstructor;
  137440. mozURL: typeof URL;
  137441. msURL: typeof URL;
  137442. VRFrameData: any; // WebVR, from specs 1.1
  137443. DracoDecoderModule: any;
  137444. setImmediate(handler: (...args: any[]) => void): number;
  137445. }
  137446. interface HTMLCanvasElement {
  137447. requestPointerLock(): void;
  137448. msRequestPointerLock?(): void;
  137449. mozRequestPointerLock?(): void;
  137450. webkitRequestPointerLock?(): void;
  137451. /** Track wether a record is in progress */
  137452. isRecording: boolean;
  137453. /** Capture Stream method defined by some browsers */
  137454. captureStream(fps?: number): MediaStream;
  137455. }
  137456. interface CanvasRenderingContext2D {
  137457. msImageSmoothingEnabled: boolean;
  137458. }
  137459. interface MouseEvent {
  137460. mozMovementX: number;
  137461. mozMovementY: number;
  137462. webkitMovementX: number;
  137463. webkitMovementY: number;
  137464. msMovementX: number;
  137465. msMovementY: number;
  137466. }
  137467. interface Navigator {
  137468. mozGetVRDevices: (any: any) => any;
  137469. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137470. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137471. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137472. webkitGetGamepads(): Gamepad[];
  137473. msGetGamepads(): Gamepad[];
  137474. webkitGamepads(): Gamepad[];
  137475. }
  137476. interface HTMLVideoElement {
  137477. mozSrcObject: any;
  137478. }
  137479. interface Math {
  137480. fround(x: number): number;
  137481. imul(a: number, b: number): number;
  137482. }
  137483. interface WebGLRenderingContext {
  137484. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  137485. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  137486. vertexAttribDivisor(index: number, divisor: number): void;
  137487. createVertexArray(): any;
  137488. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  137489. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  137490. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  137491. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  137492. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  137493. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  137494. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  137495. // Queries
  137496. createQuery(): WebGLQuery;
  137497. deleteQuery(query: WebGLQuery): void;
  137498. beginQuery(target: number, query: WebGLQuery): void;
  137499. endQuery(target: number): void;
  137500. getQueryParameter(query: WebGLQuery, pname: number): any;
  137501. getQuery(target: number, pname: number): any;
  137502. MAX_SAMPLES: number;
  137503. RGBA8: number;
  137504. READ_FRAMEBUFFER: number;
  137505. DRAW_FRAMEBUFFER: number;
  137506. UNIFORM_BUFFER: number;
  137507. HALF_FLOAT_OES: number;
  137508. RGBA16F: number;
  137509. RGBA32F: number;
  137510. R32F: number;
  137511. RG32F: number;
  137512. RGB32F: number;
  137513. R16F: number;
  137514. RG16F: number;
  137515. RGB16F: number;
  137516. RED: number;
  137517. RG: number;
  137518. R8: number;
  137519. RG8: number;
  137520. UNSIGNED_INT_24_8: number;
  137521. DEPTH24_STENCIL8: number;
  137522. MIN: number;
  137523. MAX: number;
  137524. /* Multiple Render Targets */
  137525. drawBuffers(buffers: number[]): void;
  137526. readBuffer(src: number): void;
  137527. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  137528. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  137529. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  137530. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  137531. // Occlusion Query
  137532. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  137533. ANY_SAMPLES_PASSED: number;
  137534. QUERY_RESULT_AVAILABLE: number;
  137535. QUERY_RESULT: number;
  137536. }
  137537. interface WebGLProgram {
  137538. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  137539. }
  137540. interface EXT_disjoint_timer_query {
  137541. QUERY_COUNTER_BITS_EXT: number;
  137542. TIME_ELAPSED_EXT: number;
  137543. TIMESTAMP_EXT: number;
  137544. GPU_DISJOINT_EXT: number;
  137545. QUERY_RESULT_EXT: number;
  137546. QUERY_RESULT_AVAILABLE_EXT: number;
  137547. queryCounterEXT(query: WebGLQuery, target: number): void;
  137548. createQueryEXT(): WebGLQuery;
  137549. beginQueryEXT(target: number, query: WebGLQuery): void;
  137550. endQueryEXT(target: number): void;
  137551. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  137552. deleteQueryEXT(query: WebGLQuery): void;
  137553. }
  137554. interface WebGLUniformLocation {
  137555. _currentState: any;
  137556. }
  137557. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  137558. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  137559. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  137560. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137561. interface WebGLRenderingContext {
  137562. readonly RASTERIZER_DISCARD: number;
  137563. readonly DEPTH_COMPONENT24: number;
  137564. readonly TEXTURE_3D: number;
  137565. readonly TEXTURE_2D_ARRAY: number;
  137566. readonly TEXTURE_COMPARE_FUNC: number;
  137567. readonly TEXTURE_COMPARE_MODE: number;
  137568. readonly COMPARE_REF_TO_TEXTURE: number;
  137569. readonly TEXTURE_WRAP_R: number;
  137570. readonly HALF_FLOAT: number;
  137571. readonly RGB8: number;
  137572. readonly RED_INTEGER: number;
  137573. readonly RG_INTEGER: number;
  137574. readonly RGB_INTEGER: number;
  137575. readonly RGBA_INTEGER: number;
  137576. readonly R8_SNORM: number;
  137577. readonly RG8_SNORM: number;
  137578. readonly RGB8_SNORM: number;
  137579. readonly RGBA8_SNORM: number;
  137580. readonly R8I: number;
  137581. readonly RG8I: number;
  137582. readonly RGB8I: number;
  137583. readonly RGBA8I: number;
  137584. readonly R8UI: number;
  137585. readonly RG8UI: number;
  137586. readonly RGB8UI: number;
  137587. readonly RGBA8UI: number;
  137588. readonly R16I: number;
  137589. readonly RG16I: number;
  137590. readonly RGB16I: number;
  137591. readonly RGBA16I: number;
  137592. readonly R16UI: number;
  137593. readonly RG16UI: number;
  137594. readonly RGB16UI: number;
  137595. readonly RGBA16UI: number;
  137596. readonly R32I: number;
  137597. readonly RG32I: number;
  137598. readonly RGB32I: number;
  137599. readonly RGBA32I: number;
  137600. readonly R32UI: number;
  137601. readonly RG32UI: number;
  137602. readonly RGB32UI: number;
  137603. readonly RGBA32UI: number;
  137604. readonly RGB10_A2UI: number;
  137605. readonly R11F_G11F_B10F: number;
  137606. readonly RGB9_E5: number;
  137607. readonly RGB10_A2: number;
  137608. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  137609. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  137610. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  137611. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  137612. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  137613. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  137614. 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;
  137615. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  137616. readonly TRANSFORM_FEEDBACK: number;
  137617. readonly INTERLEAVED_ATTRIBS: number;
  137618. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  137619. createTransformFeedback(): WebGLTransformFeedback;
  137620. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  137621. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  137622. beginTransformFeedback(primitiveMode: number): void;
  137623. endTransformFeedback(): void;
  137624. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  137625. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137626. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137627. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137628. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  137629. }
  137630. interface ImageBitmap {
  137631. readonly width: number;
  137632. readonly height: number;
  137633. close(): void;
  137634. }
  137635. interface WebGLQuery extends WebGLObject {
  137636. }
  137637. declare var WebGLQuery: {
  137638. prototype: WebGLQuery;
  137639. new(): WebGLQuery;
  137640. };
  137641. interface WebGLSampler extends WebGLObject {
  137642. }
  137643. declare var WebGLSampler: {
  137644. prototype: WebGLSampler;
  137645. new(): WebGLSampler;
  137646. };
  137647. interface WebGLSync extends WebGLObject {
  137648. }
  137649. declare var WebGLSync: {
  137650. prototype: WebGLSync;
  137651. new(): WebGLSync;
  137652. };
  137653. interface WebGLTransformFeedback extends WebGLObject {
  137654. }
  137655. declare var WebGLTransformFeedback: {
  137656. prototype: WebGLTransformFeedback;
  137657. new(): WebGLTransformFeedback;
  137658. };
  137659. interface WebGLVertexArrayObject extends WebGLObject {
  137660. }
  137661. declare var WebGLVertexArrayObject: {
  137662. prototype: WebGLVertexArrayObject;
  137663. new(): WebGLVertexArrayObject;
  137664. };
  137665. // Type definitions for WebVR API
  137666. // Project: https://w3c.github.io/webvr/
  137667. // Definitions by: six a <https://github.com/lostfictions>
  137668. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137669. interface VRDisplay extends EventTarget {
  137670. /**
  137671. * Dictionary of capabilities describing the VRDisplay.
  137672. */
  137673. readonly capabilities: VRDisplayCapabilities;
  137674. /**
  137675. * z-depth defining the far plane of the eye view frustum
  137676. * enables mapping of values in the render target depth
  137677. * attachment to scene coordinates. Initially set to 10000.0.
  137678. */
  137679. depthFar: number;
  137680. /**
  137681. * z-depth defining the near plane of the eye view frustum
  137682. * enables mapping of values in the render target depth
  137683. * attachment to scene coordinates. Initially set to 0.01.
  137684. */
  137685. depthNear: number;
  137686. /**
  137687. * An identifier for this distinct VRDisplay. Used as an
  137688. * association point in the Gamepad API.
  137689. */
  137690. readonly displayId: number;
  137691. /**
  137692. * A display name, a user-readable name identifying it.
  137693. */
  137694. readonly displayName: string;
  137695. readonly isConnected: boolean;
  137696. readonly isPresenting: boolean;
  137697. /**
  137698. * If this VRDisplay supports room-scale experiences, the optional
  137699. * stage attribute contains details on the room-scale parameters.
  137700. */
  137701. readonly stageParameters: VRStageParameters | null;
  137702. /**
  137703. * Passing the value returned by `requestAnimationFrame` to
  137704. * `cancelAnimationFrame` will unregister the callback.
  137705. * @param handle Define the hanle of the request to cancel
  137706. */
  137707. cancelAnimationFrame(handle: number): void;
  137708. /**
  137709. * Stops presenting to the VRDisplay.
  137710. * @returns a promise to know when it stopped
  137711. */
  137712. exitPresent(): Promise<void>;
  137713. /**
  137714. * Return the current VREyeParameters for the given eye.
  137715. * @param whichEye Define the eye we want the parameter for
  137716. * @returns the eye parameters
  137717. */
  137718. getEyeParameters(whichEye: string): VREyeParameters;
  137719. /**
  137720. * Populates the passed VRFrameData with the information required to render
  137721. * the current frame.
  137722. * @param frameData Define the data structure to populate
  137723. * @returns true if ok otherwise false
  137724. */
  137725. getFrameData(frameData: VRFrameData): boolean;
  137726. /**
  137727. * Get the layers currently being presented.
  137728. * @returns the list of VR layers
  137729. */
  137730. getLayers(): VRLayer[];
  137731. /**
  137732. * Return a VRPose containing the future predicted pose of the VRDisplay
  137733. * when the current frame will be presented. The value returned will not
  137734. * change until JavaScript has returned control to the browser.
  137735. *
  137736. * The VRPose will contain the position, orientation, velocity,
  137737. * and acceleration of each of these properties.
  137738. * @returns the pose object
  137739. */
  137740. getPose(): VRPose;
  137741. /**
  137742. * Return the current instantaneous pose of the VRDisplay, with no
  137743. * prediction applied.
  137744. * @returns the current instantaneous pose
  137745. */
  137746. getImmediatePose(): VRPose;
  137747. /**
  137748. * The callback passed to `requestAnimationFrame` will be called
  137749. * any time a new frame should be rendered. When the VRDisplay is
  137750. * presenting the callback will be called at the native refresh
  137751. * rate of the HMD. When not presenting this function acts
  137752. * identically to how window.requestAnimationFrame acts. Content should
  137753. * make no assumptions of frame rate or vsync behavior as the HMD runs
  137754. * asynchronously from other displays and at differing refresh rates.
  137755. * @param callback Define the eaction to run next frame
  137756. * @returns the request handle it
  137757. */
  137758. requestAnimationFrame(callback: FrameRequestCallback): number;
  137759. /**
  137760. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  137761. * Repeat calls while already presenting will update the VRLayers being displayed.
  137762. * @param layers Define the list of layer to present
  137763. * @returns a promise to know when the request has been fulfilled
  137764. */
  137765. requestPresent(layers: VRLayer[]): Promise<void>;
  137766. /**
  137767. * Reset the pose for this display, treating its current position and
  137768. * orientation as the "origin/zero" values. VRPose.position,
  137769. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  137770. * updated when calling resetPose(). This should be called in only
  137771. * sitting-space experiences.
  137772. */
  137773. resetPose(): void;
  137774. /**
  137775. * The VRLayer provided to the VRDisplay will be captured and presented
  137776. * in the HMD. Calling this function has the same effect on the source
  137777. * canvas as any other operation that uses its source image, and canvases
  137778. * created without preserveDrawingBuffer set to true will be cleared.
  137779. * @param pose Define the pose to submit
  137780. */
  137781. submitFrame(pose?: VRPose): void;
  137782. }
  137783. declare var VRDisplay: {
  137784. prototype: VRDisplay;
  137785. new(): VRDisplay;
  137786. };
  137787. interface VRLayer {
  137788. leftBounds?: number[] | Float32Array | null;
  137789. rightBounds?: number[] | Float32Array | null;
  137790. source?: HTMLCanvasElement | null;
  137791. }
  137792. interface VRDisplayCapabilities {
  137793. readonly canPresent: boolean;
  137794. readonly hasExternalDisplay: boolean;
  137795. readonly hasOrientation: boolean;
  137796. readonly hasPosition: boolean;
  137797. readonly maxLayers: number;
  137798. }
  137799. interface VREyeParameters {
  137800. /** @deprecated */
  137801. readonly fieldOfView: VRFieldOfView;
  137802. readonly offset: Float32Array;
  137803. readonly renderHeight: number;
  137804. readonly renderWidth: number;
  137805. }
  137806. interface VRFieldOfView {
  137807. readonly downDegrees: number;
  137808. readonly leftDegrees: number;
  137809. readonly rightDegrees: number;
  137810. readonly upDegrees: number;
  137811. }
  137812. interface VRFrameData {
  137813. readonly leftProjectionMatrix: Float32Array;
  137814. readonly leftViewMatrix: Float32Array;
  137815. readonly pose: VRPose;
  137816. readonly rightProjectionMatrix: Float32Array;
  137817. readonly rightViewMatrix: Float32Array;
  137818. readonly timestamp: number;
  137819. }
  137820. interface VRPose {
  137821. readonly angularAcceleration: Float32Array | null;
  137822. readonly angularVelocity: Float32Array | null;
  137823. readonly linearAcceleration: Float32Array | null;
  137824. readonly linearVelocity: Float32Array | null;
  137825. readonly orientation: Float32Array | null;
  137826. readonly position: Float32Array | null;
  137827. readonly timestamp: number;
  137828. }
  137829. interface VRStageParameters {
  137830. sittingToStandingTransform?: Float32Array;
  137831. sizeX?: number;
  137832. sizeY?: number;
  137833. }
  137834. interface Navigator {
  137835. getVRDisplays(): Promise<VRDisplay[]>;
  137836. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  137837. }
  137838. interface Window {
  137839. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  137840. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  137841. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  137842. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137843. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137844. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  137845. }
  137846. interface Gamepad {
  137847. readonly displayId: number;
  137848. }
  137849. type XRSessionMode =
  137850. | "inline"
  137851. | "immersive-vr"
  137852. | "immersive-ar";
  137853. type XRReferenceSpaceType =
  137854. | "viewer"
  137855. | "local"
  137856. | "local-floor"
  137857. | "bounded-floor"
  137858. | "unbounded";
  137859. type XREnvironmentBlendMode =
  137860. | "opaque"
  137861. | "additive"
  137862. | "alpha-blend";
  137863. type XRVisibilityState =
  137864. | "visible"
  137865. | "visible-blurred"
  137866. | "hidden";
  137867. type XRHandedness =
  137868. | "none"
  137869. | "left"
  137870. | "right";
  137871. type XRTargetRayMode =
  137872. | "gaze"
  137873. | "tracked-pointer"
  137874. | "screen";
  137875. type XREye =
  137876. | "none"
  137877. | "left"
  137878. | "right";
  137879. interface XRSpace extends EventTarget {
  137880. }
  137881. interface XRRenderState {
  137882. depthNear?: number;
  137883. depthFar?: number;
  137884. inlineVerticalFieldOfView?: number;
  137885. baseLayer?: XRWebGLLayer;
  137886. }
  137887. interface XRInputSource {
  137888. handedness: XRHandedness;
  137889. targetRayMode: XRTargetRayMode;
  137890. targetRaySpace: XRSpace;
  137891. gripSpace: XRSpace | undefined;
  137892. gamepad: Gamepad | undefined;
  137893. profiles: Array<string>;
  137894. }
  137895. interface XRSession extends XRAnchorCreator {
  137896. addEventListener: Function;
  137897. removeEventListener: Function;
  137898. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  137899. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  137900. requestAnimationFrame: Function;
  137901. end(): Promise<void>;
  137902. renderState: XRRenderState;
  137903. inputSources: Array<XRInputSource>;
  137904. // AR hit test
  137905. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  137906. updateWorldTrackingState(options: {
  137907. planeDetectionState?: { enabled: boolean; }
  137908. }): void;
  137909. }
  137910. interface XRReferenceSpace extends XRSpace {
  137911. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  137912. onreset: any;
  137913. }
  137914. type XRPlaneSet = Set<XRPlane>;
  137915. type XRAnchorSet = Set<XRAnchor>;
  137916. interface XRFrame {
  137917. session: XRSession;
  137918. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  137919. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  137920. // Anchors
  137921. trackedAnchors?: XRAnchorSet;
  137922. // Planes
  137923. worldInformation: {
  137924. detectedPlanes?: XRPlaneSet;
  137925. };
  137926. }
  137927. interface XRViewerPose extends XRPose {
  137928. views: Array<XRView>;
  137929. }
  137930. interface XRPose {
  137931. transform: XRRigidTransform;
  137932. emulatedPosition: boolean;
  137933. }
  137934. interface XRWebGLLayerOptions {
  137935. antialias?: boolean;
  137936. depth?: boolean;
  137937. stencil?: boolean;
  137938. alpha?: boolean;
  137939. multiview?: boolean;
  137940. framebufferScaleFactor?: number;
  137941. }
  137942. declare var XRWebGLLayer: {
  137943. prototype: XRWebGLLayer;
  137944. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  137945. };
  137946. interface XRWebGLLayer {
  137947. framebuffer: WebGLFramebuffer;
  137948. framebufferWidth: number;
  137949. framebufferHeight: number;
  137950. getViewport: Function;
  137951. }
  137952. declare class XRRigidTransform {
  137953. constructor(matrix: Float32Array);
  137954. position: DOMPointReadOnly;
  137955. orientation: DOMPointReadOnly;
  137956. matrix: Float32Array;
  137957. inverse: XRRigidTransform;
  137958. }
  137959. interface XRView {
  137960. eye: XREye;
  137961. projectionMatrix: Float32Array;
  137962. transform: XRRigidTransform;
  137963. }
  137964. interface XRInputSourceChangeEvent {
  137965. session: XRSession;
  137966. removed: Array<XRInputSource>;
  137967. added: Array<XRInputSource>;
  137968. }
  137969. interface XRInputSourceEvent extends Event {
  137970. readonly frame: XRFrame;
  137971. readonly inputSource: XRInputSource;
  137972. }
  137973. // Experimental(er) features
  137974. declare class XRRay {
  137975. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  137976. origin: DOMPointReadOnly;
  137977. direction: DOMPointReadOnly;
  137978. matrix: Float32Array;
  137979. }
  137980. interface XRHitResult {
  137981. hitMatrix: Float32Array;
  137982. }
  137983. interface XRAnchor {
  137984. // remove?
  137985. id?: string;
  137986. anchorSpace: XRSpace;
  137987. lastChangedTime: number;
  137988. detach(): void;
  137989. }
  137990. interface XRPlane extends XRAnchorCreator {
  137991. orientation: "Horizontal" | "Vertical";
  137992. planeSpace: XRSpace;
  137993. polygon: Array<DOMPointReadOnly>;
  137994. lastChangedTime: number;
  137995. }
  137996. interface XRAnchorCreator {
  137997. // AR Anchors
  137998. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  137999. }